inst/examples/http-functions-crul.R

# Auto-Generated by `apipkgen` package:
# See apipkgen docs for help

xGET <- function(url, query = list(), ...) {
  xVERB("GET", url, query = query, ...)
}

xPOST <- function(url, ..., body = NULL, encode = "json") {
  body <- ct(body)
  xVERB("POST", url, ..., body = body, encode = encode)
}

xPUT <- function(url, ...) {
  xVERB("PUT", url, ...)
}

xPATCH <- function(url, ...) {
  xVERB("PATCH", url, ...)
}

xDELETE <- function(url, ...) {
  xVERB("DELETE", url, ...)
}

xVERB <- function(verb, url, query = list(), body = list(),
  encode = NULL, ...) {

  conn <- crul::HttpClient$new(url, opts = list(...))
  res <- conn$verb(verb, query = query, body = body, encode = encode)
  res$raise_for_status()
  res$parse("UTF-8")
}
ropenscilabs/apipkgen documentation built on Sept. 3, 2020, 5:30 a.m.