-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathget_event_subscription_schema.R
43 lines (43 loc) · 1.28 KB
/
get_event_subscription_schema.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#' Get event subscription schema
#'
#' @param env (character) Repository environment. Can be: "production",
#' "staging", or "development".
#'
#' @return (xml_document) Schema for event subscription creation request
#' entities.
#'
#' See the
#' \href{https://CRAN.R-project.org/package=xml2}{xml2} library
#' for more on working with XML.
#'
#' @family Event Notifications
#'
#' @export
#'
#' @examples
#' \dontrun{
#'
#' # Get schema
#' schema <- get_event_subscription_schema()
#' schema
#' #> {xml_document}
#' #> <schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
#' #> [1] <xs:element name="subscription">\n <xs:complexType>\n <xs: ...
#'
#' # Show schema structure
#' xml2::xml_structure(schema)
#' #> <schema [xmlns:xs]>
#' #> <element [name]>
#' #> <complexType>
#' #> <all>
#' #> <element [name, type, minOccurs, maxOccurs]>
#' #> <element [name, type, minOccurs, maxOccurs]>
#' #> <attribute [name, type, use, fixed]>
#' }
get_event_subscription_schema <- function(env = "production") {
url <- paste0(base_url(env), "/package/event/eml/schema")
resp <- httr::GET(url, set_user_agent(), handle = httr::handle(""))
res <- httr::content(resp, as = "text", encoding = "UTF-8")
httr::stop_for_status(resp, res)
return(xml2::read_xml(res))
}