Skip to content

Commit

Permalink
Merge pull request #17 from amanyiraho/minor-update-0-2-0
Browse files Browse the repository at this point in the history
Minor update 0 2 0
  • Loading branch information
amanyiraho authored Nov 10, 2024
2 parents a43e256 + ee78bc7 commit baee4d3
Show file tree
Hide file tree
Showing 11 changed files with 106 additions and 64 deletions.
3 changes: 0 additions & 3 deletions CRAN-SUBMISSION

This file was deleted.

2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: dhis2r
Title: Client for the 'DHIS2' Web API
Version: 0.1.1
Version: 0.2.1
Authors@R: c(
person("Robinson", "Amanyiraho", , "amanyiraho@gmail.com", role = c("cre", "aut", "cph"),
comment = c(ORCID = "0000-0002-7747-1367"))
Expand Down
21 changes: 17 additions & 4 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
# dhis2r 0.2.1

## Bug fix

* Updated the vignette to use the `username` and `password` instead of `PAT` since the public server is regularly updated


# dhis2r 0.2.0

## Improvements
## New features

* In `Dhis2r$new()` now includes `api_token = NULL` for authentication via personal access token option(@Brar, #12).

* New `dhis2_connection$get_any_analytic()` to GET long DHIS2 resources.

* Functions now print out the resource link being queried

* Add authentication via personal access token @Brar
## Minor improvements and fixes

* Added `get_any_analytic()` to cater for long DHIS2 favorites
* Updated the public server URL in examples and vignettes to "https://play.im.dhis2.org/stable-2-40-5"

# dhis2r 0.1.1

* Fix R CMD check failures on CRAN
* Fix R CMD check failures on CRAN.

* Added a NEWS.md file to track changes to the package.
11 changes: 6 additions & 5 deletions R/connect.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
#' @export
#'
#' @examples
#' \dontrun{
#' # Load dhis2r
#' library(dhis2r)
#' # connect to the DHIS2 instance
#' dhis2_play_connection <- Dhis2r$new(base_url = "https://play.dhis2.org/",
#' username = "admin", password = "district",api_version = "2.39.0.1")
#' dhis2_play_connection <- Dhis2r$new(base_url = "https://play.im.dhis2.org/stable-2-40-5",
#' username = "admin",
#' password = "district")
#'
#' # get all the available resources
#' dhis2_play_connection$get_metadata()
Expand All @@ -35,8 +37,7 @@
#' period = "LAST_12_MONTHS",
#' output_scheme = "NAME")
#'
#' }

#'

Dhis2r <- R6::R6Class(

Expand Down
29 changes: 20 additions & 9 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ There are over 2 million R users, some of whom periodically analyse data from DH

## Installation

You can install the development version of dhis2r from [GitHub](https://github.com/) with:
You can install the stable version of dhis2r from CRAN with:

``` r
install.packages("dhis2r")
```

You can install also the development version of dhis2r from [GitHub](https://github.com/) with:

``` r
# install.packages("devtools")
Expand All @@ -56,30 +62,35 @@ devtools::install_github("amanyiraho/dhis2r")

### How to connect to a DHIS2?

Users must be authenticated to access a specific DHIS2 instance before connecting to it.
Users must be authenticated to access a specific DHIS2 instance before connecting to it. You can use

1. `username` and `password`

2. Personal Access Token (PAT)

#### 1. Using `username` and `password`
The easiest way to connect to a DHIS2 instance using dhis2r is to use the `username` and `password` of the DHIS2 user.


``` r
library(dhis2r)
dhis2_play_connection <- Dhis2r$new(base_url = "https://play.dhis2.org/",
dhis2_play_connection <- Dhis2r$new(base_url = "https://play.im.dhis2.org/stable-2-40-5",
username = "admin",
password = "district",
api_version = "2.39.0.1",
api_version_position = "before")
password = "district")
```

Alternatively you can generate a [personal access token](https://docs.dhis2.org/en/develop/using-the-api/dhis-core-version-master/introduction.html#webapi_pat_authentication) and use that to connect.
#### 2. Using Personal Access Token (PAT)


Alternatively you can generate a [personal access token](https://docs.dhis2.org/en/develop/using-the-api/dhis-core-version-master/introduction.html#webapi_pat_authentication) and use that to connect.

``` r
library(dhis2r)

# Replace the value of api_token with the token you have generated

dhis2_play_connection <- Dhis2r$new(base_url = "https://play.dhis2.org/",
api_token = "d2pat_5xVA12xyUbWNedQxy4ohH77WlxRGVvZZ1151814092")
dhis2_play_connection <- Dhis2r$new(base_url = "https://play.im.dhis2.org/stable-2-40-5",
api_token = "d2pat_2EkxmqdxtwAGDGe1hXzpWEixYdvHGRw71587176066")
```


Expand Down
28 changes: 20 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ billion people.

## Installation

You can install the development version of dhis2r from
You can install the stable version of dhis2r from CRAN with:

``` r
install.packages("dhis2r")
```

You can install also the development version of dhis2r from
[GitHub](https://github.com/) with:

``` r
Expand All @@ -59,20 +65,26 @@ devtools::install_github("amanyiraho/dhis2r")
### How to connect to a DHIS2?

Users must be authenticated to access a specific DHIS2 instance before
connecting to it.
connecting to it. You can use

1. `username` and `password`

2. Personal Access Token (PAT)

#### 1. Using `username` and `password`

The easiest way to connect to a DHIS2 instance using dhis2r is to use
the `username` and `password` of the DHIS2 user.

``` r
library(dhis2r)
dhis2_play_connection <- Dhis2r$new(base_url = "https://play.dhis2.org/",
dhis2_play_connection <- Dhis2r$new(base_url = "https://play.im.dhis2.org/stable-2-40-5",
username = "admin",
password = "district",
api_version = "2.39.0.1",
api_version_position = "before")
password = "district")
```

#### 2. Using Personal Access Token (PAT)

Alternatively you can generate a [personal access
token](https://docs.dhis2.org/en/develop/using-the-api/dhis-core-version-master/introduction.html#webapi_pat_authentication)
and use that to connect.
Expand All @@ -82,8 +94,8 @@ library(dhis2r)

# Replace the value of api_token with the token you have generated

dhis2_play_connection <- Dhis2r$new(base_url = "https://play.dhis2.org/",
api_token = "d2pat_5xVA12xyUbWNedQxy4ohH77WlxRGVvZZ1151814092")
dhis2_play_connection <- Dhis2r$new(base_url = "https://play.im.dhis2.org/stable-2-40-5",
api_token = "d2pat_2EkxmqdxtwAGDGe1hXzpWEixYdvHGRw71587176066")
```

`Dhis2r$new()` returns a `Dhis2r` R6 class which represents a DHIS2
Expand Down
6 changes: 5 additions & 1 deletion _pkgdown.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
url: http://www.amanyiraho.com/dhis2r/
url: https://dhis2r.amanyiraho.com/
template:
bootstrap: 5
news:
releases:
- text: "dhis2r 0.2.0"
href: https://www.amanyiraho.com/blog/dhis2r-0-2-0/
14 changes: 5 additions & 9 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
## Resubmission
This is a resubmission. In this version I have:

* Include LazyData: true in DESCRIPTION

* included in Sys.setenv(TZ = "Africa/Kampala") .Rprofile
This is a resubmission. In this version I have:

* Updated the test that depended on dynamic data
* Updated the vignette to username and password instead of PAT since the public server is regularly updated

* Commented out code that used dynamic data in README and vignette

* I have tested the package on GITHUB actions and all past using these OSs
- {os: macos-latest, r: 'release'}
Expand All @@ -16,10 +12,10 @@ This is a resubmission. In this version I have:
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}



## R CMD check results
There were no ERRORs, WARNINGs or NOTEs

0 errors | 0 warnings | 0 notes

## Downstream dependencies

There are currently no downstream dependencies for this package
10 changes: 6 additions & 4 deletions man/Dhis2r.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 16 additions & 16 deletions renv.lock
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
},
"askpass": {
"Package": "askpass",
"Version": "1.2.0",
"Version": "1.2.1",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"sys"
],
"Hash": "cad6cf7f1d5f6e906700b9d3e718c796"
"Hash": "c39f4155b3ceb1a9a2799d700fbd4b6a"
},
"attempt": {
"Package": "attempt",
Expand All @@ -41,24 +41,24 @@
},
"cli": {
"Package": "cli",
"Version": "3.6.2",
"Version": "3.6.3",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"R",
"utils"
],
"Hash": "1216ac65ac55ec0058a6f75d7ca0fd52"
"Hash": "b21916dd77a27642b447374a5d30ecf3"
},
"curl": {
"Package": "curl",
"Version": "5.2.0",
"Version": "5.2.3",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"R"
],
"Hash": "ce88d13c0b10fe88a37d9c59dba2d7f9"
"Hash": "d91263322a58af798f6cf3b13fd56dde"
},
"dplyr": {
"Package": "dplyr",
Expand Down Expand Up @@ -108,14 +108,14 @@
},
"glue": {
"Package": "glue",
"Version": "1.7.0",
"Version": "1.8.0",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"R",
"methods"
],
"Hash": "e0b3a53876554bd45879e596cdb10a52"
"Hash": "5899f1eaa825580172bb56c08266f37c"
},
"httr2": {
"Package": "httr2",
Expand Down Expand Up @@ -163,13 +163,13 @@
},
"openssl": {
"Package": "openssl",
"Version": "2.1.1",
"Version": "2.2.2",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"askpass"
],
"Hash": "2a0dc8c6adfb6f032e4d4af82d258ab5"
"Hash": "d413e0fef796c9401a4419485f709ca1"
},
"pillar": {
"Package": "pillar",
Expand Down Expand Up @@ -220,21 +220,21 @@
},
"rlang": {
"Package": "rlang",
"Version": "1.1.3",
"Version": "1.1.4",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"R",
"utils"
],
"Hash": "42548638fae05fd9a9b5f3f437fbbbe2"
"Hash": "3eec01f8b1dee337674b2e34ab1f9bc1"
},
"sys": {
"Package": "sys",
"Version": "3.4.2",
"Version": "3.4.3",
"Source": "Repository",
"Repository": "CRAN",
"Hash": "3a1be13d68d47a8cd0bfd74739ca1555"
"Hash": "de342ebfebdbf40477d0758d05426646"
},
"tibble": {
"Package": "tibble",
Expand Down Expand Up @@ -297,15 +297,15 @@
},
"withr": {
"Package": "withr",
"Version": "3.0.0",
"Version": "3.0.2",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"R",
"grDevices",
"graphics"
],
"Hash": "d31b6c62c10dcf11ec530ca6b0dd5d35"
"Hash": "cc2d62c76458d425210d1eb1478b30b4"
}
}
}
14 changes: 10 additions & 4 deletions vignettes/dhis2r.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,19 @@ library(dhis2r)

Connect to the DHIS2 instance using `Dhis2r$new()`

In this vignette I used a Personal Access Token (PAT) as a more secure alternative to HTTP Basic Authentication, and should be your preferred choice when creating a new app/script etc.

```{r}
dhis2_play_connection <- Dhis2r$new(base_url = "https://play.im.dhis2.org/stable-2-40-5",
username = "admin",
password = "district"
# api_version = "2.41.1",
# api_version_position = "after"
)
password = "district")
```



``` r
dhis2_play_connection <- Dhis2r$new(base_url = "https://play.im.dhis2.org/stable-2-40-5",
api_token = "d2pat_2EkxmqdxtwAGDGe1hXzpWEixYdvHGRw71587176066")
```


Expand Down

0 comments on commit baee4d3

Please sign in to comment.