Commit 82eb0047 authored by Jean-Marie Lepioufle's avatar Jean-Marie Lepioufle
Browse files

swagger generated client api

parent 449e9a03
......@@ -3,13 +3,16 @@ Type: Package
Version: 0.0.2
Authors@R: c(person("Jean-Marie", "Lepioufle", , "jml@nilu.no", role=c("aut","cre")))
Title: eipar
Description: Extracting air quality timeseries from the Irish Environmental Protection Agency.
The irish EPA API provides free access to Irish air quality timeseries.
Description: Extracting air quality timeseries from the Irish Environmental
Protection Agency. The irish EPA API provides free access to Irish air quality
timeseries. (generated by Swagger Codegen https://github.com/swagger-api/
swagger-codegen).
Depends:
R (>= 3.2.0)
Imports:
ecapi
Remotes: git::git@git.nilu.no:rextapi/ecapi.git
jsonlite,
httr,
R6
Suggests:
knitr
License: GPL-3
......
# Generated by roxygen2: do not edit by hand
S3method(print,eipar)
export(eipar)
export(ApiClient)
export(AqMeasurement)
export(AqMeasurementApi)
export(Element)
export(Response)
importFrom(R6,R6Class)
importFrom(jsonlite,fromJSON)
importFrom(jsonlite,toJSON)
# Air Quality Open Data API
#
# Air Quality Open Data API
#
# OpenAPI spec version: 1.0
#
# Generated by: https://github.com/swagger-api/swagger-codegen.git
#' ApiClient Class
#'
#' Generic API client for Swagger client library builds.
#' Swagger generic API client. This client handles the client-
#' server communication, and is invariant across implementations. Specifics of
#' the methods and models for each application are generated from the Swagger
#' templates.
#'
#' NOTE: This class is auto generated by the swagger code generator program.
#' Ref: https://github.com/swagger-api/swagger-codegen
#' Do not edit the class manually.
#'
#' @export
ApiClient <- R6::R6Class(
'ApiClient',
public = list(
basePath = "http://air-tst.epa.ie/api/v1",
configuration = NULL,
userAgent = NULL,
defaultHeaders = NULL,
initialize = function(basePath, configuration, defaultHeaders){
if (!missing(basePath)) {
self$basePath <- basePath
}
if (!missing(configuration)) {
self$configuration <- configuration
}
if (!missing(defaultHeaders)) {
self$defaultHeaders <- defaultHeaders
}
self$`userAgent` <- 'Swagger-Codegen/1.0.0/r'
},
callApi = function(url, method, queryParams, headerParams, body, ...){
headers <- httr::add_headers(headerParams)
if (method == "GET") {
httr::GET(url, queryParams, headers, ...)
}
else if (method == "POST") {
httr::POST(url, queryParams, headers, body = body, ...)
}
else if (method == "PUT") {
httr::PUT(url, queryParams, headers, body = body, ...)
}
else if (method == "PATCH") {
httr::PATCH(url, queryParams, headers, body = body, ...)
}
else if (method == "HEAD") {
httr::HEAD(url, queryParams, headers, ...)
}
else if (method == "DELETE") {
httr::DELETE(url, queryParams, headers, ...)
}
else {
stop("http method must be `GET`, `HEAD`, `OPTIONS`, `POST`, `PATCH`, `PUT` or `DELETE`.")
}
}
)
)
\ No newline at end of file
# Air Quality Open Data API
#
# Air Quality Open Data API
#
# OpenAPI spec version: 1.0
#
# Generated by: https://github.com/swagger-api/swagger-codegen.git
#' AqMeasurement Class
#'
#' @field measurementtype
#' @field samplingpoint
#' @field pollutantname
#' @field measurementunit
#' @field raw_reading_measurement_time
#' @field _id
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
AqMeasurement <- R6::R6Class(
'AqMeasurement',
public = list(
`measurementtype` = NULL,
`samplingpoint` = NULL,
`pollutantname` = NULL,
`measurementunit` = NULL,
`raw_reading_measurement_time` = NULL,
`_id` = NULL,
initialize = function(`measurementtype`, `samplingpoint`, `pollutantname`, `measurementunit`, `raw_reading_measurement_time`, `_id`){
if (!missing(`measurementtype`)) {
stopifnot(is.character(`measurementtype`), length(`measurementtype`) == 1)
self$`measurementtype` <- `measurementtype`
}
if (!missing(`samplingpoint`)) {
stopifnot(is.character(`samplingpoint`), length(`samplingpoint`) == 1)
self$`samplingpoint` <- `samplingpoint`
}
if (!missing(`pollutantname`)) {
stopifnot(is.character(`pollutantname`), length(`pollutantname`) == 1)
self$`pollutantname` <- `pollutantname`
}
if (!missing(`measurementunit`)) {
stopifnot(is.character(`measurementunit`), length(`measurementunit`) == 1)
self$`measurementunit` <- `measurementunit`
}
if (!missing(`raw_reading_measurement_time`)) {
stopifnot(is.character(`raw_reading_measurement_time`), length(`raw_reading_measurement_time`) == 1)
self$`raw_reading_measurement_time` <- `raw_reading_measurement_time`
}
if (!missing(`_id`)) {
stopifnot(is.character(`_id`), length(`_id`) == 1)
self$`_id` <- `_id`
}
},
toJSON = function() {
AqMeasurementObject <- list()
if (!is.null(self$`measurementtype`)) {
AqMeasurementObject[['measurementtype']] <- self$`measurementtype`
}
if (!is.null(self$`samplingpoint`)) {
AqMeasurementObject[['samplingpoint']] <- self$`samplingpoint`
}
if (!is.null(self$`pollutantname`)) {
AqMeasurementObject[['pollutantname']] <- self$`pollutantname`
}
if (!is.null(self$`measurementunit`)) {
AqMeasurementObject[['measurementunit']] <- self$`measurementunit`
}
if (!is.null(self$`raw_reading_measurement_time`)) {
AqMeasurementObject[['raw_reading_measurement_time']] <- self$`raw_reading_measurement_time`
}
if (!is.null(self$`_id`)) {
AqMeasurementObject[['_id']] <- self$`_id`
}
AqMeasurementObject
},
fromJSON = function(AqMeasurementJson) {
AqMeasurementObject <- jsonlite::fromJSON(AqMeasurementJson)
if (!is.null(AqMeasurementObject$`measurementtype`)) {
self$`measurementtype` <- AqMeasurementObject$`measurementtype`
}
if (!is.null(AqMeasurementObject$`samplingpoint`)) {
self$`samplingpoint` <- AqMeasurementObject$`samplingpoint`
}
if (!is.null(AqMeasurementObject$`pollutantname`)) {
self$`pollutantname` <- AqMeasurementObject$`pollutantname`
}
if (!is.null(AqMeasurementObject$`measurementunit`)) {
self$`measurementunit` <- AqMeasurementObject$`measurementunit`
}
if (!is.null(AqMeasurementObject$`raw_reading_measurement_time`)) {
self$`raw_reading_measurement_time` <- AqMeasurementObject$`raw_reading_measurement_time`
}
if (!is.null(AqMeasurementObject$`_id`)) {
self$`_id` <- AqMeasurementObject$`_id`
}
},
toJSONString = function() {
sprintf(
'{
"measurementtype": %s,
"samplingpoint": %s,
"pollutantname": %s,
"measurementunit": %s,
"raw_reading_measurement_time": %s,
"_id": %s
}',
self$`measurementtype`,
self$`samplingpoint`,
self$`pollutantname`,
self$`measurementunit`,
self$`raw_reading_measurement_time`,
self$`_id`
)
},
fromJSONString = function(AqMeasurementJson) {
AqMeasurementObject <- jsonlite::fromJSON(AqMeasurementJson)
self$`measurementtype` <- AqMeasurementObject$`measurementtype`
self$`samplingpoint` <- AqMeasurementObject$`samplingpoint`
self$`pollutantname` <- AqMeasurementObject$`pollutantname`
self$`measurementunit` <- AqMeasurementObject$`measurementunit`
self$`raw_reading_measurement_time` <- AqMeasurementObject$`raw_reading_measurement_time`
self$`_id` <- AqMeasurementObject$`_id`
}
)
)
# Air Quality Open Data API
#
# Air Quality Open Data API
#
# OpenAPI spec version: 1.0
#
# Generated by: https://github.com/swagger-api/swagger-codegen.git
#' @title AqMeasurement operations
#' @description eipar .AqMeasurement
#'
#' @field path Stores url path of the request.
#' @field apiClient Handles the client-server communication.
#' @field userAgent Set the user agent of the request.
#'
#' @importFrom R6 R6Class
#'
#' @section Methods:
#' \describe{
#'
#' aq_measurements_aq_measurement_id_get Retrieves a Aq_measurement document
#'
#'
#' aq_measurements_get Retrieves one or more aq_measurements
#'
#' }
#'
#' @export
AqMeasurementApi <- R6::R6Class(
'AqMeasurementApi',
public = list(
userAgent = "Swagger-Codegen/1.0.0/r",
apiClient = NULL,
initialize = function(apiClient){
if (!missing(apiClient)) {
self$apiClient <- apiClient
}
else {
self$apiClient <- ApiClient$new()
}
},
aq_measurements_aq_measurement_id_get = function(aq_measurement_id, ...){
args <- list(...)
queryParams <- list()
headerParams <- character()
urlPath <- "/aq_measurements/{aq_measurementId}"
if (!missing(`aq_measurement_id`)) {
urlPath <- gsub(paste0("\\{", "aq_measurementId", "\\}"), `aq_measurement_id`, urlPath)
}
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
method = "GET",
queryParams = queryParams,
headerParams = headerParams,
body = body,
...)
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
returnObject <- AqMeasurement$new()
result <- returnObject$fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
Response$new(returnObject, resp)
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
Response$new("API client error", resp)
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
Response$new("API server error", resp)
}
},
aq_measurements_get = function(...){
args <- list(...)
queryParams <- list()
headerParams <- character()
urlPath <- "/aq_measurements"
resp <- self$apiClient$callApi(url = paste0(self$apiClient$basePath, urlPath),
method = "GET",
queryParams = queryParams,
headerParams = headerParams,
body = body,
...)
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
returnObject <- AqMeasurement$new()
result <- returnObject$fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
Response$new(returnObject, resp)
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
Response$new("API client error", resp)
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
Response$new("API server error", resp)
}
}
)
)
#' Element Class
#'
#' Element Class
#' @export
Element <- R6::R6Class(
'Element',
public = list(
id = NULL,
name = NULL,
initialize = function(id,name){
if (!missing(id)) {
stopifnot(is.numeric(id), length(id) == 1)
self$id <- id
}
if (!missing(name)) {
stopifnot(is.character(name), length(name) == 1)
self$name <- name
}
},
toJSON = function() {
sprintf('{"id":%d,"name":"%s"}', self$id, self$name)
}
)
)
\ No newline at end of file
#' Response Class
#'
#' Response Class
#' @export
Response <- R6::R6Class(
'Response',
public = list(
content = NULL,
response = NULL,
initialize = function(content, response){
self$content <- content
self$response <- response
}
)
)
\ No newline at end of file
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ApiClient.r
\docType{data}
\name{ApiClient}
\alias{ApiClient}
\title{ApiClient Class}
\format{An object of class \code{R6ClassGenerator} of length 24.}
\usage{
ApiClient
}
\description{
Generic API client for Swagger client library builds.
Swagger generic API client. This client handles the client-
server communication, and is invariant across implementations. Specifics of
the methods and models for each application are generated from the Swagger
templates.
}
\details{
NOTE: This class is auto generated by the swagger code generator program.
Ref: https://github.com/swagger-api/swagger-codegen
Do not edit the class manually.
}
\keyword{datasets}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/AqMeasurement.r
\docType{data}
\name{AqMeasurement}
\alias{AqMeasurement}
\title{AqMeasurement Class}
\format{An object of class \code{R6ClassGenerator} of length 24.}
\usage{
AqMeasurement
}
\description{
AqMeasurement Class
}
\section{Fields}{
\describe{
\item{\code{measurementtype}}{}
\item{\code{samplingpoint}}{}
\item{\code{pollutantname}}{}
\item{\code{measurementunit}}{}
\item{\code{raw_reading_measurement_time}}{}
\item{\code{_id}}{}
}}
\keyword{datasets}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/AqMeasurementApi.r
\docType{data}
\name{AqMeasurementApi}
\alias{AqMeasurementApi}
\title{AqMeasurement operations}
\format{An object of class \code{R6ClassGenerator} of length 24.}
\usage{
AqMeasurementApi
}
\description{
eipar .AqMeasurement
}
\section{Fields}{
\describe{
\item{\code{path}}{Stores url path of the request.}
\item{\code{apiClient}}{Handles the client-server communication.}
\item{\code{userAgent}}{Set the user agent of the request.}
}}
\section{Methods}{
\describe{
aq_measurements_aq_measurement_id_get Retrieves a Aq_measurement document
aq_measurements_get Retrieves one or more aq_measurements
}
}
\keyword{datasets}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/Element.r
\docType{data}
\name{Element}
\alias{Element}
\title{Element Class}
\format{An object of class \code{R6ClassGenerator} of length 24.}
\usage{
Element
}
\description{
Element Class
}
\keyword{datasets}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/Response.r
\docType{data}
\name{Response}
\alias{Response}
\title{Response Class}
\format{An object of class \code{R6ClassGenerator} of length 24.}
\usage{
Response
}
\description{
Response Class
}
\keyword{datasets}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/eipar.R
\name{eipar}
\alias{eipar}
\title{eipar}
\usage{
eipar()
}
\description{
eipar
}
\examples{
\dontrun{
eipar()
}
}
\keyword{eipar}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment