R/http-helpers.R

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

xGET <- function(url, ...) {
  content.list <- jsonlite::fromJSON(xVERB("GET", url, ...), flatten = TRUE, simplifyDataFrame = FALSE)
  if(content.list$status != "success") stop("Error performing the GET request to Sensibo API.")
  return(content.list$result)
}

xPOST <- function(url, ..., body = NULL, encode = "json") {
  body <- ct(body)
  content.list <- jsonlite::fromJSON(xVERB("POST", url, ..., body = body, encode = encode), flatten = TRUE, simplifyDataFrame = FALSE)
  if(content.list$status != "success") stop("Error performing the POST request to Sensibo API.")
  return(content.list$result)
}

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

xVERB <- function(verb, url, ...) {
  res <- httr::VERB(verb, url, ...)
  httr::stop_for_status(res)
  httr::content(res, as = "text", encoding = "UTF-8")
}

Try the sensibo.sky package in your browser

Any scripts or data that you put into this service are public.

sensibo.sky documentation built on June 24, 2019, 5:03 p.m.