-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement an api parameter to choose the scope of the application
- Loading branch information
Showing
10 changed files
with
122 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Package: apinsee | ||
Title: Manage Access to Insee APIs | ||
Version: 0.0.0.9031 | ||
Version: 0.0.0.9040 | ||
Authors@R: c( | ||
person("Romain", "Lesur", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0002-0721-5595")), | ||
person() | ||
|
@@ -17,6 +17,7 @@ RoxygenNote: 6.1.1 | |
Collate: | ||
'endpoint.R' | ||
'utils.R' | ||
'scope.R' | ||
'token.R' | ||
'insee_auth.R' | ||
'zzz.R' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#' Addresses of the Insee APIs | ||
#' | ||
#' Cette fonction renvoie les adresses des API de l'Insee. | ||
#' | ||
#' @param api Un vecteur de chaînes de caractères dont chaque élément comprend | ||
#' le nom d'une API. La correspondance partielle est acceptée. | ||
#' @inheritParams insee_endpoint | ||
#' @inheritSection insee_endpoint Utilisation interne à l'Insee | ||
#' | ||
#' @return Un vecteur de chaînes de caractères comprenant les adresses des API | ||
#' de l'Insee. | ||
#' @keywords internal | ||
#' @export | ||
#' | ||
#' @examples | ||
#' insee_scopes() | ||
#' insee_scopes("Sirene") | ||
#' insee_scopes("Nomenclatures") | ||
#' insee_scopes(c("Sirene", "Nomenclatures")) | ||
insee_scopes <- function( | ||
api = c("Sirene V3", "Nomenclatures v1"), | ||
insee_url = getOption("apinsee.url") | ||
) { | ||
api <- match.arg(api, several.ok = TRUE) | ||
|
||
paths <- list( | ||
`Nomenclatures v1` = list( | ||
c("metadonnees", "nomenclatures", "v1") | ||
), | ||
`Sirene V3` = list( | ||
c("entreprises", "sirene", "V3"), | ||
c("entreprises", "sirene") | ||
) | ||
) | ||
|
||
modify_insee_url <- function(path) { | ||
vapply(path, function(x) httr::modify_url(url = insee_url, path = x), character(1)) | ||
} | ||
|
||
urls <- lapply(paths, modify_insee_url) | ||
|
||
unlist(urls[api], use.names = FALSE) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.