diff --git a/DESCRIPTION b/DESCRIPTION index fcfd3ff..3c2704d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -37,6 +37,6 @@ VignetteBuilder: Config/testthat/edition: 3 Encoding: UTF-8 LazyData: true -RoxygenNote: 7.3.1 +RoxygenNote: 7.3.2 X-schema.org-isPartOf: http://ropengov.org/ X-schema.org-keywords: ropengov diff --git a/R/ok.R b/R/ok.R index 02d5324..b38a388 100644 --- a/R/ok.R +++ b/R/ok.R @@ -17,14 +17,16 @@ #' o311_api("Bonn") #' o311_ok() #' -#' # check if Helsinki API is reachable - fails +#' o311_api("Helsinki, FI") +#' o311_ok() +#' +#' # check if Savonlinna API is reachable - should fail #' o311_add_endpoint( -#' name = "Helsinki", -#' root = "asiointi.hel.fi/palautews/rest/v1/" +#' name = "Savonlinna, FI", +#' root = "https://savonlinna.asiointi.fi/eFeedback/api/georeport/v2" #' ) #' -#' o311_api("Helsinki") -#' o311_ok() +#' o311_api("Savonlinna, FI") #' #' # return error message #' try(o311_ok(error = TRUE)) diff --git a/inst/endpoints.json b/inst/endpoints.json index 98c2e68..b409353 100644 --- a/inst/endpoints.json +++ b/inst/endpoints.json @@ -189,6 +189,13 @@ "json": true, "dialect": "Mark-a-Spot" }, + { + "name": "Helsinki, FI", + "root": "https://palautteet.hel.fi/public-api/open311-public-service/v1/", + "key": false, + "pagination": false, + "json": true + }, { "name": "Turku, FI", "root": "https://opaskartta.turku.fi/efeedback/api/georeport/6aika/", diff --git a/man/o311_endpoints.Rd b/man/o311_endpoints.Rd index a228b76..986d924 100644 --- a/man/o311_endpoints.Rd +++ b/man/o311_endpoints.Rd @@ -84,7 +84,10 @@ state of the endpoints list. installation directory. This list contains a limited number of endpoints that were proven to work at the time of package development. It does not include newer/smaller/less known endpoints or test APIs. These can be -manually added using \code{o311_add_endpoint}. +manually added using \code{o311_add_endpoint}. If an API is down and it +is unknown whether it will be up again or not, its \code{questioning} value +is set to \code{TRUE}. If they will not go up again, they are removed upon +the next release. } \note{ This function uses \code{\link[tools]{R_user_dir}} to persistently store diff --git a/man/o311_ok.Rd b/man/o311_ok.Rd index 5f4349b..1f2deb3 100644 --- a/man/o311_ok.Rd +++ b/man/o311_ok.Rd @@ -27,14 +27,16 @@ and returns a valid requests response. o311_api("Bonn") o311_ok() -# check if Helsinki API is reachable - fails +o311_api("Helsinki, FI") +o311_ok() + +# check if Savonlinna API is reachable - should fail o311_add_endpoint( - name = "Helsinki", - root = "asiointi.hel.fi/palautews/rest/v1/" + name = "Savonlinna, FI", + root = "https://savonlinna.asiointi.fi/eFeedback/api/georeport/v2" ) -o311_api("Helsinki") -o311_ok() +o311_api("Savonlinna, FI") # return error message try(o311_ok(error = TRUE)) diff --git a/vignettes/r311.Rmd b/vignettes/r311.Rmd index 068164c..1c427c5 100644 --- a/vignettes/r311.Rmd +++ b/vignettes/r311.Rmd @@ -55,8 +55,14 @@ incomplete or outdated. `r311` offers an updated and modifiable endpoint list that defines a number of open311 implementations that are defined for use in the package. The list can be read using `o311_endpoints`. +Load the package: -``` r +```{r, eval=FALSE} +library(r311) +``` + + +```{r, eval=FALSE} o311_endpoints() #> # A tibble: 69 × 12 #> name root docs jurisdiction key pagination limit json dialect deprecated deprecated_reason deprecated_url @@ -83,7 +89,7 @@ The following code adds the open311 test server of Mecklenburg-Vorpommern, Germany. -``` r +```{r, eval=FALSE} o311_add_endpoint( name = "MV Test", root = "https://klarschiff-mv.sis-schwerin.de/backoffice/citysdk/", @@ -95,7 +101,7 @@ Retrieving the endpoints list again confirms that you successfully added a new row to the endpoints dataframe. -``` r +```{r, eval=FALSE} nrow(o311_endpoints()) #> [1] 70 ``` @@ -105,8 +111,7 @@ This function matches an API using endpoint name and jurisdiction ID and attaches it to the active session. Query functions automatically detect the attached API. - -``` r +```{r, eval=FALSE} o311_api("MV Test") ``` @@ -114,7 +119,7 @@ After attaching an API, `o311_ok` confirms that the selected endpoint is able to handle request queries. -``` r +```{r, eval=FALSE} o311_ok() #> [1] TRUE ``` @@ -135,7 +140,7 @@ use `o311_services`, which returns a list of Rostock's administrative services. -``` r +```{r, eval=FALSE} o311_services() #> # A tibble: 183 × 8 #> service_code service_name description metadata type keywords group group_id @@ -159,7 +164,7 @@ o311_services() To get data about civic issues in the city area, run `o311_requests`. -``` r +```{r, eval=FALSE} o311_requests() #> Simple feature collection with 52 features and 15 fields #> Geometry type: POINT @@ -190,7 +195,7 @@ by all endpoints. Using the `service_code` parameter with one of the previously returned service codes, only complaints about broken traffic lights are returned. -``` r +```{r, eval=FALSE} o311_requests(service_code = "3") #> Simple feature collection with 6 features and 15 fields #> Geometry type: POINT @@ -214,7 +219,7 @@ Similarly, using a `service_request_id` from the output, you can retrieve a single service request from the API. -``` r +```{r, eval=FALSE} o311_request("250") #> Simple feature collection with 1 feature and 15 fields #> Geometry type: POINT @@ -241,7 +246,7 @@ retrieves data from the first two pages, resulting in a tibble with 200 service requests. -``` r +```{r, eval=FALSE} o311_api("Cologne") o311_request_all(max_pages = 2) #> Simple feature collection with 200 features and 11 fields @@ -278,7 +283,7 @@ usually be found in the respective documentation (e.g. on GitHub for The following query returns the last 50 requests tagged with the "idea" keyword. -``` r +```{r, eval=FALSE} o311_api("Rostock, DE") tickets <- o311_requests(keyword = "idea", max_requests = 50) tickets @@ -310,7 +315,7 @@ example, we query just the count of total requests using the `just_count` parameter. The result is a 1×1 tibble containing a count value. -``` r +```{r, eval=FALSE} o311_requests(just_count = TRUE) #> # A tibble: 1 × 1 #> value @@ -322,7 +327,7 @@ The CitySDK extensions also offers additional URL paths which can be queried using the generic `o311_query` function. -``` r +```{r, eval=FALSE} poly <- o311_query("areas") plot(poly$grenze) plot(tickets$geometry, add = TRUE, pch = 16) @@ -339,7 +344,7 @@ user directory as returned by `tools::R_user_dir("r311")`. To reset the database, run -``` r +```{r, eval=FALSE} o311_reset_endpoints() ```