forked from loafle/openapi-generator-original
[R] improve code format (#12387)
* better code format for r client * more code format improvement
This commit is contained in:
parent
621f87b5e6
commit
7b08aa408d
@ -6,11 +6,11 @@
|
||||
#' @field response The raw response from the endpoint.
|
||||
#' @export
|
||||
ApiResponse <- R6::R6Class(
|
||||
'ApiResponse',
|
||||
"ApiResponse",
|
||||
public = list(
|
||||
content = NULL,
|
||||
response = NULL,
|
||||
initialize = function(content, response){
|
||||
initialize = function(content, response) {
|
||||
self$content <- content
|
||||
self$response <- response
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
#' @title {{baseName}} operations
|
||||
#' @description {{importPath}}
|
||||
#' @format An \code{R6Class} generator object
|
||||
#' @field apiClient Handles the client-server communication.
|
||||
#' @field api_client Handles the client-server communication.
|
||||
#'
|
||||
#' @section Methods:
|
||||
{{! Adding the below changes for generating documentation for the api methods. }}
|
||||
@ -97,17 +97,17 @@
|
||||
{{#isBasic}}
|
||||
#' #Configure HTTP basic authorization: {{{name}}}
|
||||
#' # provide your username in the user-serial format
|
||||
#' api.instance$apiClient$username <- '<user-serial>';
|
||||
#' api.instance$api_client$username <- '<user-serial>';
|
||||
#' # provide your api key generated using the developer portal
|
||||
#' api.instance$apiClient$password <- '<api_key>';
|
||||
#' api.instance$api_client$password <- '<api_key>';
|
||||
{{/isBasic}}
|
||||
{{#isApiKey}}
|
||||
#' #Configure API key authorization: {{{name}}}
|
||||
#' api.instance$apiClient$apiKeys['{{{keyParamName}}}'] <- 'TODO_YOUR_API_KEY';
|
||||
#' api.instance$api_client$api_keys['{{{keyParamName}}}'] <- 'TODO_YOUR_API_KEY';
|
||||
{{/isApiKey}}
|
||||
{{#isOAuth}}
|
||||
#' # Configure OAuth2 access token for authorization: {{{name}}}
|
||||
#' api.instance$apiClient$accessToken <- 'TODO_YOUR_ACCESS_TOKEN';
|
||||
#' api.instance$api_client$access_token <- 'TODO_YOUR_ACCESS_TOKEN';
|
||||
{{/isOAuth}}
|
||||
{{/authMethods}}
|
||||
{{/hasAuthMethods}}
|
||||
@ -147,36 +147,36 @@
|
||||
{{/useRlangExceptionHandling}}
|
||||
#' @export
|
||||
{{classname}} <- R6::R6Class(
|
||||
'{{classname}}',
|
||||
"{{classname}}",
|
||||
public = list(
|
||||
apiClient = NULL,
|
||||
initialize = function(apiClient){
|
||||
if (!missing(apiClient)) {
|
||||
self$apiClient <- apiClient
|
||||
api_client = NULL,
|
||||
initialize = function(api_client) {
|
||||
if (!missing(api_client)) {
|
||||
self$api_client <- api_client
|
||||
}
|
||||
else {
|
||||
self$apiClient <- ApiClient$new()
|
||||
self$api_client <- ApiClient$new()
|
||||
}
|
||||
},
|
||||
{{#operation}}
|
||||
{{{operationId}}} = function({{#requiredParams}}{{paramName}}, {{/requiredParams}}{{#optionalParams}}{{paramName}}={{^defaultValue}}NULL{{/defaultValue}}{{{defaultValue}}}, {{/optionalParams}}{{#returnType}}data_file=NULL, {{/returnType}}...){
|
||||
apiResponse <- self${{{operationId}}}WithHttpInfo({{#allParams}}{{paramName}}, {{/allParams}}{{#returnType}}data_file=data_file, {{/returnType}}...)
|
||||
resp <- apiResponse$response
|
||||
{{{operationId}}} = function({{#requiredParams}}{{paramName}}, {{/requiredParams}}{{#optionalParams}}{{paramName}}={{^defaultValue}}NULL{{/defaultValue}}{{{defaultValue}}}, {{/optionalParams}}{{#returnType}}data_file=NULL, {{/returnType}}...) {
|
||||
api_response <- self${{{operationId}}}WithHttpInfo({{#allParams}}{{paramName}}, {{/allParams}}{{#returnType}}data_file = data_file, {{/returnType}}...)
|
||||
resp <- api_response$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
api_response$content
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
api_response
|
||||
}
|
||||
},
|
||||
|
||||
{{{operationId}}}WithHttpInfo = function({{#requiredParams}}{{paramName}}, {{/requiredParams}}{{#optionalParams}}{{paramName}}={{^defaultValue}}NULL{{/defaultValue}}{{{defaultValue}}}, {{/optionalParams}}{{#returnType}}data_file=NULL, {{/returnType}}...){
|
||||
{{{operationId}}}WithHttpInfo = function({{#requiredParams}}{{paramName}}, {{/requiredParams}}{{#optionalParams}}{{paramName}}={{^defaultValue}}NULL{{/defaultValue}}{{{defaultValue}}}, {{/optionalParams}}{{#returnType}}data_file = NULL, {{/returnType}}...) {
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
query_params <- list()
|
||||
header_params <- c()
|
||||
|
||||
{{#requiredParams}}
|
||||
if (missing(`{{paramName}}`)) {
|
||||
@ -189,14 +189,14 @@
|
||||
}
|
||||
|
||||
{{/requiredParams}}
|
||||
{{#headerParams}}
|
||||
headerParams['{{baseName}}'] <- `{{paramName}}`
|
||||
{{#header_params}}
|
||||
header_params["{{baseName}}"] <- `{{paramName}}`
|
||||
|
||||
{{/headerParams}}
|
||||
{{#queryParams}}
|
||||
queryParams['{{baseName}}'] <- {{paramName}}
|
||||
{{/header_params}}
|
||||
{{#query_params}}
|
||||
query_params["{{baseName}}"] <- {{paramName}}
|
||||
|
||||
{{/queryParams}}
|
||||
{{/query_params}}
|
||||
{{#hasFormParams}}
|
||||
body <- list(
|
||||
{{#formParams}}
|
||||
@ -214,8 +214,8 @@
|
||||
{{#bodyParams}}
|
||||
if (!missing(`{{paramName}}`)) {
|
||||
{{#isArray}}
|
||||
body.items = paste(unlist(lapply({{paramName}}, function(param){param$toJSONString()})), collapse = ",")
|
||||
body <- paste0('[', body.items, ']')
|
||||
body.items = paste(unlist(lapply({{paramName}}, function(param) {param$toJSONString()})), collapse = ",")
|
||||
body <- paste0("[", body.items, "]")
|
||||
{{/isArray}}
|
||||
{{^isArray}}
|
||||
body <- `{{paramName}}`$toJSONString()
|
||||
@ -231,11 +231,11 @@
|
||||
body <- NULL
|
||||
{{/hasFormParams}}
|
||||
{{/hasBodyParam}}
|
||||
urlPath <- "{{path}}"
|
||||
url_path <- "{{path}}"
|
||||
{{#hasPathParams}}
|
||||
{{#pathParams}}
|
||||
if (!missing(`{{paramName}}`)) {
|
||||
urlPath <- gsub(paste0("\\{", "{{baseName}}", "\\}"), URLencode(as.character(`{{paramName}}`), reserved = TRUE), urlPath)
|
||||
url_path <- gsub(paste0("\\{", "{{baseName}}", "\\}"), URLencode(as.character(`{{paramName}}`), reserved = TRUE), url_path)
|
||||
}
|
||||
|
||||
{{/pathParams}}
|
||||
@ -244,32 +244,32 @@
|
||||
{{#isBasic}}
|
||||
{{#isBasicBasic}}
|
||||
# HTTP basic auth
|
||||
headerParams['Authorization'] <- paste("Basic", base64enc::base64encode(charToRaw(paste(self$apiClient$username, self$apiClient$password, sep=":"))))
|
||||
header_params["Authorization"] <- paste("Basic", base64enc::base64encode(charToRaw(paste(self$api_client$username, self$api_client$password, sep = ":"))))
|
||||
{{/isBasicBasic}}
|
||||
{{/isBasic}}
|
||||
{{#isApiKey}}
|
||||
# API key authentication
|
||||
{{#isKeyInHeader}}
|
||||
if ("{{{keyParamName}}}" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["{{{keyParamName}}}"]) > 0) {
|
||||
headerParams['{{keyParamName}}'] <- paste(unlist(self$apiClient$apiKeys["{{keyParamName}}"]), collapse='')
|
||||
if ("{{{keyParamName}}}" %in% names(self$api_client$api_keys) && nchar(self$api_client$api_keys["{{{keyParamName}}}"]) > 0) {
|
||||
header_params["{{keyParamName}}"] <- paste(unlist(self$api_client$api_keys["{{keyParamName}}"]), collapse = "")
|
||||
}
|
||||
{{/isKeyInHeader}}
|
||||
{{#isKeyInQuery}}
|
||||
if ("{{{keyParamName}}}" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["{{{keyParamName}}}"]) > 0) {
|
||||
queryParams['{{keyParamName}}'] <- paste(unlist(self$apiClient$apiKeys["{{keyParamName}}"]), collapse='')
|
||||
if ("{{{keyParamName}}}" %in% names(self$api_client$api_keys) && nchar(self$api_client$api_keys["{{{keyParamName}}}"]) > 0) {
|
||||
query_params["{{keyParamName}}"] <- paste(unlist(self$api_client$api_keys["{{keyParamName}}"]), collapse = "")
|
||||
}
|
||||
{{/isKeyInQuery}}
|
||||
{{/isApiKey}}
|
||||
{{#isOAuth}}
|
||||
# OAuth token
|
||||
headerParams['Authorization'] <- paste("Bearer", self$apiClient$accessToken, sep=" ")
|
||||
header_params["Authorization"] <- paste("Bearer", self$api_client$access_token, sep = " ")
|
||||
{{/isOAuth}}
|
||||
{{/authMethods}}
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path),
|
||||
method = "{{httpMethod}}",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
query_params = query_params,
|
||||
header_params = header_params,
|
||||
body = body,
|
||||
...)
|
||||
|
||||
@ -292,9 +292,9 @@
|
||||
write(httr::content(resp, "text", encoding = "UTF-8", simplifyVector = FALSE), data_file)
|
||||
}
|
||||
|
||||
deserializedRespObj <- tryCatch(
|
||||
self$apiClient$deserialize(resp, "{{returnType}}", loadNamespace("{{packageName}}")),
|
||||
error = function(e){
|
||||
deserialized_resp_obj <- tryCatch(
|
||||
self$api_client$deserialize(resp, "{{returnType}}", loadNamespace("{{packageName}}")),
|
||||
error = function(e) {
|
||||
{{#useDefaultExceptionHandling}}
|
||||
stop("Failed to deserialize response")
|
||||
{{/useDefaultExceptionHandling}}
|
||||
@ -303,7 +303,7 @@
|
||||
{{/useRlangExceptionHandling}}
|
||||
}
|
||||
)
|
||||
ApiResponse$new(deserializedRespObj, resp)
|
||||
ApiResponse$new(deserialized_resp_obj, resp)
|
||||
{{/isPrimitiveType}}
|
||||
{{/returnType}}
|
||||
{{^returnType}}
|
||||
@ -312,31 +312,31 @@
|
||||
{{/returnType}}
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
{{#returnExceptionOnFailure}}
|
||||
errorMsg <- toString(content(resp))
|
||||
if(errorMsg == ""){
|
||||
errorMsg <- paste("Server returned " , httr::status_code(resp) , " response status code.")
|
||||
error_msg <- toString(content(resp))
|
||||
if(error_msg == "") {
|
||||
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
|
||||
}
|
||||
{{#useDefaultExceptionHandling}}
|
||||
stop(errorMsg)
|
||||
stop(error_msg)
|
||||
{{/useDefaultExceptionHandling}}
|
||||
{{#useRlangExceptionHandling}}
|
||||
rlang::abort(message = errorMsg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||
{{/useRlangExceptionHandling}}
|
||||
{{/returnExceptionOnFailure}}
|
||||
{{^returnExceptionOnFailure}}
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
ApiResponse$new(paste("Server returned ", httr::status_code(resp), " response status code."), resp)
|
||||
{{/returnExceptionOnFailure}}
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
{{#returnExceptionOnFailure}}
|
||||
errorMsg <- toString(content(resp))
|
||||
if(errorMsg == ""){
|
||||
errorMsg <- "Api client exception encountered."
|
||||
error_msg <- toString(content(resp))
|
||||
if(error_msg == "") {
|
||||
error_msg <- "Api client exception encountered."
|
||||
}
|
||||
{{#useDefaultExceptionHandling}}
|
||||
stop(errorMsg)
|
||||
stop(error_msg)
|
||||
{{/useDefaultExceptionHandling}}
|
||||
{{#useRlangExceptionHandling}}
|
||||
rlang::abort(message = errorMsg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||
{{/useRlangExceptionHandling}}
|
||||
{{/returnExceptionOnFailure}}
|
||||
{{^returnExceptionOnFailure}}
|
||||
@ -344,15 +344,15 @@
|
||||
{{/returnExceptionOnFailure}}
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
{{#returnExceptionOnFailure}}
|
||||
errorMsg <- toString(content(resp))
|
||||
if(errorMsg == ""){
|
||||
errorMsg <- "Api server exception encountered."
|
||||
error_msg <- toString(content(resp))
|
||||
if(error_msg == "") {
|
||||
error_msg <- "Api server exception encountered."
|
||||
}
|
||||
{{#useDefaultExceptionHandling}}
|
||||
stop(errorMsg)
|
||||
stop(error_msg)
|
||||
{{/useDefaultExceptionHandling}}
|
||||
{{#useRlangExceptionHandling}}
|
||||
rlang::abort(message = errorMsg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||
{{/useRlangExceptionHandling}}
|
||||
{{/returnExceptionOnFailure}}
|
||||
{{^returnExceptionOnFailure}}
|
||||
|
@ -16,52 +16,55 @@
|
||||
#' @title ApiClient
|
||||
#' @description ApiClient Class
|
||||
#' @format An \code{R6Class} generator object
|
||||
#' @field basePath Base url
|
||||
#' @field userAgent Default user agent
|
||||
#' @field defaultHeaders
|
||||
#' @field base_path Base url
|
||||
#' @field user_agent Default user agent
|
||||
#' @field default_headers
|
||||
#' @field username Username for HTTP basic authentication
|
||||
#' @field password Password for HTTP basic authentication
|
||||
#' @field apiKeys
|
||||
#' @field accessToken
|
||||
#' @field api_keys
|
||||
#' @field access_token
|
||||
#' @field timeout Default timeout in seconds
|
||||
#' @field retryStatusCodes vector of status codes to retry
|
||||
#' @field maxRetryAttempts maximum number of retries for the status codes
|
||||
#' @field retry_status_codes vector of status codes to retry
|
||||
#' @field max_retry_attempts maximum number of retries for the status codes
|
||||
#' @importFrom httr add_headers accept timeout content
|
||||
{{#useRlangExceptionHandling}}
|
||||
#' @importFrom rlang abort
|
||||
{{/useRlangExceptionHandling}}
|
||||
#' @export
|
||||
ApiClient <- R6::R6Class(
|
||||
'ApiClient',
|
||||
"ApiClient",
|
||||
public = list(
|
||||
# base path of all requests
|
||||
basePath = "{{{basePath}}}",
|
||||
base_path = "{{{basePath}}}",
|
||||
# user agent in the HTTP request
|
||||
userAgent = "{{{httpUserAgent}}}{{^httpUserAgent}}OpenAPI-Generator/{{{packageVersion}}}/r{{/httpUserAgent}}",
|
||||
user_agent = "{{{httpUserAgent}}}{{^httpUserAgent}}OpenAPI-Generator/{{{packageVersion}}}/r{{/httpUserAgent}}",
|
||||
# default headers in the HTTP request
|
||||
defaultHeaders = NULL,
|
||||
default_headers = NULL,
|
||||
# username (HTTP basic authentication)
|
||||
username = NULL,
|
||||
# password (HTTP basic authentication)
|
||||
password = NULL,
|
||||
# API keys
|
||||
apiKeys = NULL,
|
||||
api_keys = NULL,
|
||||
# Access token
|
||||
accessToken = NULL,
|
||||
access_token = NULL,
|
||||
# Time Out (seconds)
|
||||
timeout = NULL,
|
||||
# Vector of status codes to retry
|
||||
retryStatusCodes=NULL,
|
||||
retry_status_codes = NULL,
|
||||
# Maximum number of retry attempts for the retry status codes
|
||||
maxRetryAttempts = NULL,
|
||||
max_retry_attempts = NULL,
|
||||
# constructor
|
||||
initialize = function(basePath=NULL, userAgent=NULL, defaultHeaders=NULL, username=NULL, password=NULL, apiKeys=NULL, accessToken=NULL, timeout=NULL, retryStatusCodes=NULL, maxRetryAttempts=NULL){
|
||||
if (!is.null(basePath)) {
|
||||
self$basePath <- basePath
|
||||
initialize = function(base_path=NULL, user_agent=NULL, default_headers=NULL,
|
||||
username=NULL, password=NULL, api_keys=NULL,
|
||||
access_token=NULL, timeout=NULL,
|
||||
retry_status_codes=NULL, max_retry_attempts=NULL) {
|
||||
if (!is.null(base_path)) {
|
||||
self$base_path <- base_path
|
||||
}
|
||||
|
||||
if (!is.null(defaultHeaders)) {
|
||||
self$defaultHeaders <- defaultHeaders
|
||||
if (!is.null(default_headers)) {
|
||||
self$default_headers <- default_headers
|
||||
}
|
||||
|
||||
if (!is.null(username)) {
|
||||
@ -72,49 +75,49 @@ ApiClient <- R6::R6Class(
|
||||
self$password <- password
|
||||
}
|
||||
|
||||
if (!is.null(accessToken)) {
|
||||
self$accessToken <- accessToken
|
||||
if (!is.null(access_token)) {
|
||||
self$access_token <- access_token
|
||||
}
|
||||
|
||||
if (!is.null(apiKeys)) {
|
||||
self$apiKeys <- apiKeys
|
||||
if (!is.null(api_keys)) {
|
||||
self$api_keys <- api_keys
|
||||
} else {
|
||||
self$apiKeys <- list()
|
||||
self$api_keys <- list()
|
||||
}
|
||||
|
||||
if (!is.null(userAgent)) {
|
||||
self$`userAgent` <- userAgent
|
||||
if (!is.null(user_agent)) {
|
||||
self$`user_agent` <- user_agent
|
||||
}
|
||||
|
||||
if (!is.null(timeout)) {
|
||||
self$timeout <- timeout
|
||||
}
|
||||
|
||||
if (!is.null(retryStatusCodes)) {
|
||||
self$retryStatusCodes <- retryStatusCodes
|
||||
if (!is.null(retry_status_codes)) {
|
||||
self$retry_status_codes <- retry_status_codes
|
||||
}
|
||||
|
||||
if (!is.null(maxRetryAttempts)) {
|
||||
self$maxRetryAttempts <- maxRetryAttempts
|
||||
if (!is.null(max_retry_attempts)) {
|
||||
self$max_retry_attempts <- max_retry_attempts
|
||||
}
|
||||
},
|
||||
|
||||
CallApi = function(url, method, queryParams, headerParams, body, ...){
|
||||
CallApi = function(url, method, query_params, header_params, body, ...) {
|
||||
|
||||
resp <- self$Execute(url, method, queryParams, headerParams, body, ...)
|
||||
statusCode <- httr::status_code(resp)
|
||||
resp <- self$Execute(url, method, query_params, header_params, body, ...)
|
||||
status_code <- httr::status_code(resp)
|
||||
|
||||
if (is.null(self$maxRetryAttempts)) {
|
||||
self$maxRetryAttempts = 3
|
||||
if (is.null(self$max_retry_attempts)) {
|
||||
self$max_retry_attempts <- 3
|
||||
}
|
||||
|
||||
if (!is.null(self$retryStatusCodes)) {
|
||||
if (!is.null(self$retry_status_codes)) {
|
||||
|
||||
for (i in 1 : self$maxRetryAttempts) {
|
||||
if (statusCode %in% self$retryStatusCodes) {
|
||||
for (i in 1 : self$max_retry_attempts) {
|
||||
if (status_code %in% self$retry_status_codes) {
|
||||
Sys.sleep((2 ^ i) + stats::runif(n = 1, min = 0, max = 1))
|
||||
resp <- self$Execute(url, method, queryParams, headerParams, body, ...)
|
||||
statusCode <- httr::status_code(resp)
|
||||
resp <- self$Execute(url, method, query_params, header_params, body, ...)
|
||||
status_code <- httr::status_code(resp)
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
@ -124,78 +127,78 @@ ApiClient <- R6::R6Class(
|
||||
resp
|
||||
},
|
||||
|
||||
Execute = function(url, method, queryParams, headerParams, body, ...){
|
||||
headers <- httr::add_headers(c(headerParams, self$defaultHeaders))
|
||||
Execute = function(url, method, query_params, header_params, body, ...) {
|
||||
headers <- httr::add_headers(c(header_params, self$default_headers))
|
||||
|
||||
{{! Adding timeout that can be set at the apiClient object level}}
|
||||
httpTimeout <- NULL
|
||||
http_timeout <- NULL
|
||||
if (!is.null(self$timeout)) {
|
||||
httpTimeout <- httr::timeout(self$timeout)
|
||||
http_timeout <- httr::timeout(self$timeout)
|
||||
}
|
||||
|
||||
if (method == "GET") {
|
||||
httr::GET(url, query = queryParams, headers, httpTimeout, httr::user_agent(self$`userAgent`), ...)
|
||||
httr::GET(url, query = query_params, headers, http_timeout, httr::user_agent(self$`user_agent`), ...)
|
||||
} else if (method == "POST") {
|
||||
httr::POST(url, query = queryParams, headers, body = body, httr::content_type("application/json"), httpTimeout, httr::user_agent(self$`userAgent`), ...)
|
||||
httr::POST(url, query = query_params, headers, body = body, httr::content_type("application/json"), http_timeout, httr::user_agent(self$`user_agent`), ...)
|
||||
} else if (method == "PUT") {
|
||||
httr::PUT(url, query = queryParams, headers, body = body, httr::content_type("application/json"), httpTimeout, httpTimeout, httr::user_agent(self$`userAgent`), ...)
|
||||
httr::PUT(url, query = query_params, headers, body = body, httr::content_type("application/json"), http_timeout, http_timeout, httr::user_agent(self$`user_agent`), ...)
|
||||
} else if (method == "PATCH") {
|
||||
httr::PATCH(url, query = queryParams, headers, body = body, httr::content_type("application/json"), httpTimeout, httpTimeout, httr::user_agent(self$`userAgent`), ...)
|
||||
httr::PATCH(url, query = query_params, headers, body = body, httr::content_type("application/json"), http_timeout, http_timeout, httr::user_agent(self$`user_agent`), ...)
|
||||
} else if (method == "HEAD") {
|
||||
httr::HEAD(url, query = queryParams, headers, httpTimeout, httpTimeout, httr::user_agent(self$`userAgent`), ...)
|
||||
httr::HEAD(url, query = query_params, headers, http_timeout, http_timeout, httr::user_agent(self$`user_agent`), ...)
|
||||
} else if (method == "DELETE") {
|
||||
httr::DELETE(url, query = queryParams, headers, httpTimeout, httpTimeout, httr::user_agent(self$`userAgent`), ...)
|
||||
httr::DELETE(url, query = query_params, headers, http_timeout, http_timeout, httr::user_agent(self$`user_agent`), ...)
|
||||
} else {
|
||||
errMsg <- "Http method must be `GET`, `HEAD`, `OPTIONS`, `POST`, `PATCH`, `PUT` or `DELETE`."
|
||||
err_msg <- "Http method must be `GET`, `HEAD`, `OPTIONS`, `POST`, `PATCH`, `PUT` or `DELETE`."
|
||||
{{#useDefaultExceptionHandling}}
|
||||
stop(errMsg)
|
||||
stop(err_msg)
|
||||
{{/useDefaultExceptionHandling}}
|
||||
{{#useRlangExceptionHandling}}
|
||||
rlang::abort(message = errMsg, .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = errMsg))
|
||||
rlang::abort(message = err_msg, .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = err_msg))
|
||||
{{/useRlangExceptionHandling}}
|
||||
}
|
||||
},
|
||||
|
||||
# Deserialize the content of api response to the given type.
|
||||
deserialize = function(resp, returnType, pkgEnv) {
|
||||
respObj <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
|
||||
self$deserializeObj(respObj, returnType, pkgEnv)
|
||||
deserialize = function(resp, return_type, pkg_env) {
|
||||
resp_obj <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
|
||||
self$deserializeObj(resp_obj, return_type, pkg_env)
|
||||
},
|
||||
|
||||
|
||||
# Deserialize the response from jsonlite object based on the given type
|
||||
# by handling complex and nested types by iterating recursively
|
||||
# Example returnTypes will be like "array[integer]", "map(Pet)", "array[map(Tag)]", etc.,
|
||||
# Example return_types will be like "array[integer]", "map(Pet)", "array[map(Tag)]", etc.,
|
||||
|
||||
deserializeObj = function(obj, returnType, pkgEnv) {
|
||||
returnObj <- NULL
|
||||
primitiveTypes <- c("character", "numeric", "integer", "logical", "complex")
|
||||
deserializeObj = function(obj, return_type, pkg_env) {
|
||||
return_obj <- NULL
|
||||
primitive_types <- c("character", "numeric", "integer", "logical", "complex")
|
||||
|
||||
# To handle the "map" type
|
||||
if (startsWith(returnType, "map(")) {
|
||||
innerReturnType <- regmatches(returnType, regexec(pattern = "map\\((.*)\\)", returnType))[[1]][2]
|
||||
returnObj <- lapply(names(obj), function(name) {
|
||||
self$deserializeObj(obj[[name]], innerReturnType, pkgEnv)
|
||||
if (startsWith(return_type, "map(")) {
|
||||
inner_return_type <- regmatches(return_type, regexec(pattern = "map\\((.*)\\)", return_type))[[1]][2]
|
||||
return_obj <- lapply(names(obj), function(name) {
|
||||
self$deserializeObj(obj[[name]], inner_return_type, pkg_env)
|
||||
})
|
||||
names(returnObj) <- names(obj)
|
||||
names(return_obj) <- names(obj)
|
||||
}
|
||||
|
||||
# To handle the "array" type
|
||||
else if (startsWith(returnType, "array[")) {
|
||||
innerReturnType <- regmatches(returnType, regexec(pattern = "array\\[(.*)\\]", returnType))[[1]][2]
|
||||
if (c(innerReturnType) %in% primitiveTypes) {
|
||||
returnObj <- vector("list", length = length(obj))
|
||||
else if (startsWith(return_type, "array[")) {
|
||||
inner_return_type <- regmatches(return_type, regexec(pattern = "array\\[(.*)\\]", return_type))[[1]][2]
|
||||
if (c(inner_return_type) %in% primitive_types) {
|
||||
return_obj <- vector("list", length = length(obj))
|
||||
if (length(obj) > 0) {
|
||||
for (row in 1:length(obj)) {
|
||||
returnObj[[row]] <- self$deserializeObj(obj[row], innerReturnType, pkgEnv)
|
||||
return_obj[[row]] <- self$deserializeObj(obj[row], inner_return_type, pkg_env)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(!is.null(nrow(obj))){
|
||||
returnObj <- vector("list", length = nrow(obj))
|
||||
if (!is.null(nrow(obj))) {
|
||||
return_obj <- vector("list", length = nrow(obj))
|
||||
if (nrow(obj) > 0) {
|
||||
for (row in 1:nrow(obj)) {
|
||||
returnObj[[row]] <- self$deserializeObj(obj[row, , drop = FALSE], innerReturnType, pkgEnv)
|
||||
return_obj[[row]] <- self$deserializeObj(obj[row, , drop = FALSE], inner_return_type, pkg_env)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -203,19 +206,19 @@ ApiClient <- R6::R6Class(
|
||||
}
|
||||
|
||||
# To handle model objects which are not array or map containers. Ex:"Pet"
|
||||
else if (exists(returnType, pkgEnv) && !(c(returnType) %in% primitiveTypes)) {
|
||||
returnType <- get(returnType, envir = as.environment(pkgEnv))
|
||||
returnObj <- returnType$new()
|
||||
returnObj$fromJSON(
|
||||
else if (exists(return_type, pkg_env) && !(c(return_type) %in% primitive_types)) {
|
||||
return_type <- get(return_type, envir = as.environment(pkg_env))
|
||||
return_obj <- return_type$new()
|
||||
return_obj$fromJSON(
|
||||
jsonlite::toJSON(obj, digits = NA, auto_unbox = TRUE)
|
||||
)
|
||||
}
|
||||
|
||||
# To handle primitive type
|
||||
else {
|
||||
returnObj <- obj
|
||||
return_obj <- obj
|
||||
}
|
||||
returnObj
|
||||
return_obj
|
||||
}
|
||||
)
|
||||
)
|
||||
|
@ -3,10 +3,10 @@
|
||||
|
||||
context("Test {{{classname}}}")
|
||||
|
||||
api.instance <- {{{classname}}}$new()
|
||||
|
||||
api_instance <- {{{classname}}}$new()
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
|
||||
test_that("{{{operationId}}}", {
|
||||
# tests for {{operationId}}
|
||||
# base path: {{{basePath}}}
|
||||
@ -24,6 +24,5 @@ test_that("{{{operationId}}}", {
|
||||
# uncomment below to test the operation
|
||||
#expect_equal(result, "EXPECTED_RESULT")
|
||||
})
|
||||
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
|
@ -8,9 +8,9 @@ context("Test {{{classname}}}")
|
||||
{{#vars}}
|
||||
{{#-first}}
|
||||
|
||||
model.instance <- {{{classname}}}$new()
|
||||
|
||||
model_instance <- {{{classname}}}$new()
|
||||
{{/-first}}
|
||||
|
||||
test_that("{{{name}}}", {
|
||||
# tests for the property `{{{name}}}` ({{dataType}})
|
||||
{{#description}}
|
||||
@ -20,7 +20,6 @@ test_that("{{{name}}}", {
|
||||
# uncomment below to test the property
|
||||
#expect_equal(model.instance$`{{{name}}}`, "EXPECTED_RESULT")
|
||||
})
|
||||
|
||||
{{/vars}}
|
||||
{{/isEnum}}
|
||||
{{/model}}
|
||||
|
@ -6,6 +6,10 @@
|
||||
# {{{.}}}
|
||||
#
|
||||
{{/appDescription}}
|
||||
# {{#version}}The version of the OpenAPI document: {{{.}}}{{/version}}
|
||||
# {{#infoEmail}}Contact: {{{.}}}{{/infoEmail}}
|
||||
{{#version}}
|
||||
# The version of the OpenAPI document: {{{.}}}
|
||||
{{/version}}
|
||||
{{#infoEmail}}
|
||||
# Contact: {{{.}}}
|
||||
{{/infoEmail}}
|
||||
# Generated by: https://openapi-generator.tech
|
||||
|
@ -3,7 +3,6 @@
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
#
|
||||
# The version of the OpenAPI document: 1.0.0
|
||||
#
|
||||
# Generated by: https://openapi-generator.tech
|
||||
|
||||
|
||||
@ -23,49 +22,52 @@
|
||||
#' @title ApiClient
|
||||
#' @description ApiClient Class
|
||||
#' @format An \code{R6Class} generator object
|
||||
#' @field basePath Base url
|
||||
#' @field userAgent Default user agent
|
||||
#' @field defaultHeaders
|
||||
#' @field base_path Base url
|
||||
#' @field user_agent Default user agent
|
||||
#' @field default_headers
|
||||
#' @field username Username for HTTP basic authentication
|
||||
#' @field password Password for HTTP basic authentication
|
||||
#' @field apiKeys
|
||||
#' @field accessToken
|
||||
#' @field api_keys
|
||||
#' @field access_token
|
||||
#' @field timeout Default timeout in seconds
|
||||
#' @field retryStatusCodes vector of status codes to retry
|
||||
#' @field maxRetryAttempts maximum number of retries for the status codes
|
||||
#' @field retry_status_codes vector of status codes to retry
|
||||
#' @field max_retry_attempts maximum number of retries for the status codes
|
||||
#' @importFrom httr add_headers accept timeout content
|
||||
#' @export
|
||||
ApiClient <- R6::R6Class(
|
||||
'ApiClient',
|
||||
"ApiClient",
|
||||
public = list(
|
||||
# base path of all requests
|
||||
basePath = "http://petstore.swagger.io/v2",
|
||||
base_path = "http://petstore.swagger.io/v2",
|
||||
# user agent in the HTTP request
|
||||
userAgent = "PetstoreAgent",
|
||||
user_agent = "PetstoreAgent",
|
||||
# default headers in the HTTP request
|
||||
defaultHeaders = NULL,
|
||||
default_headers = NULL,
|
||||
# username (HTTP basic authentication)
|
||||
username = NULL,
|
||||
# password (HTTP basic authentication)
|
||||
password = NULL,
|
||||
# API keys
|
||||
apiKeys = NULL,
|
||||
api_keys = NULL,
|
||||
# Access token
|
||||
accessToken = NULL,
|
||||
access_token = NULL,
|
||||
# Time Out (seconds)
|
||||
timeout = NULL,
|
||||
# Vector of status codes to retry
|
||||
retryStatusCodes=NULL,
|
||||
retry_status_codes = NULL,
|
||||
# Maximum number of retry attempts for the retry status codes
|
||||
maxRetryAttempts = NULL,
|
||||
max_retry_attempts = NULL,
|
||||
# constructor
|
||||
initialize = function(basePath=NULL, userAgent=NULL, defaultHeaders=NULL, username=NULL, password=NULL, apiKeys=NULL, accessToken=NULL, timeout=NULL, retryStatusCodes=NULL, maxRetryAttempts=NULL){
|
||||
if (!is.null(basePath)) {
|
||||
self$basePath <- basePath
|
||||
initialize = function(base_path=NULL, user_agent=NULL, default_headers=NULL,
|
||||
username=NULL, password=NULL, api_keys=NULL,
|
||||
access_token=NULL, timeout=NULL,
|
||||
retry_status_codes=NULL, max_retry_attempts=NULL) {
|
||||
if (!is.null(base_path)) {
|
||||
self$base_path <- base_path
|
||||
}
|
||||
|
||||
if (!is.null(defaultHeaders)) {
|
||||
self$defaultHeaders <- defaultHeaders
|
||||
if (!is.null(default_headers)) {
|
||||
self$default_headers <- default_headers
|
||||
}
|
||||
|
||||
if (!is.null(username)) {
|
||||
@ -76,49 +78,49 @@ ApiClient <- R6::R6Class(
|
||||
self$password <- password
|
||||
}
|
||||
|
||||
if (!is.null(accessToken)) {
|
||||
self$accessToken <- accessToken
|
||||
if (!is.null(access_token)) {
|
||||
self$access_token <- access_token
|
||||
}
|
||||
|
||||
if (!is.null(apiKeys)) {
|
||||
self$apiKeys <- apiKeys
|
||||
if (!is.null(api_keys)) {
|
||||
self$api_keys <- api_keys
|
||||
} else {
|
||||
self$apiKeys <- list()
|
||||
self$api_keys <- list()
|
||||
}
|
||||
|
||||
if (!is.null(userAgent)) {
|
||||
self$`userAgent` <- userAgent
|
||||
if (!is.null(user_agent)) {
|
||||
self$`user_agent` <- user_agent
|
||||
}
|
||||
|
||||
if (!is.null(timeout)) {
|
||||
self$timeout <- timeout
|
||||
}
|
||||
|
||||
if (!is.null(retryStatusCodes)) {
|
||||
self$retryStatusCodes <- retryStatusCodes
|
||||
if (!is.null(retry_status_codes)) {
|
||||
self$retry_status_codes <- retry_status_codes
|
||||
}
|
||||
|
||||
if (!is.null(maxRetryAttempts)) {
|
||||
self$maxRetryAttempts <- maxRetryAttempts
|
||||
if (!is.null(max_retry_attempts)) {
|
||||
self$max_retry_attempts <- max_retry_attempts
|
||||
}
|
||||
},
|
||||
|
||||
CallApi = function(url, method, queryParams, headerParams, body, ...){
|
||||
CallApi = function(url, method, query_params, header_params, body, ...) {
|
||||
|
||||
resp <- self$Execute(url, method, queryParams, headerParams, body, ...)
|
||||
statusCode <- httr::status_code(resp)
|
||||
resp <- self$Execute(url, method, query_params, header_params, body, ...)
|
||||
status_code <- httr::status_code(resp)
|
||||
|
||||
if (is.null(self$maxRetryAttempts)) {
|
||||
self$maxRetryAttempts = 3
|
||||
if (is.null(self$max_retry_attempts)) {
|
||||
self$max_retry_attempts <- 3
|
||||
}
|
||||
|
||||
if (!is.null(self$retryStatusCodes)) {
|
||||
if (!is.null(self$retry_status_codes)) {
|
||||
|
||||
for (i in 1 : self$maxRetryAttempts) {
|
||||
if (statusCode %in% self$retryStatusCodes) {
|
||||
for (i in 1 : self$max_retry_attempts) {
|
||||
if (status_code %in% self$retry_status_codes) {
|
||||
Sys.sleep((2 ^ i) + stats::runif(n = 1, min = 0, max = 1))
|
||||
resp <- self$Execute(url, method, queryParams, headerParams, body, ...)
|
||||
statusCode <- httr::status_code(resp)
|
||||
resp <- self$Execute(url, method, query_params, header_params, body, ...)
|
||||
status_code <- httr::status_code(resp)
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
@ -128,72 +130,72 @@ ApiClient <- R6::R6Class(
|
||||
resp
|
||||
},
|
||||
|
||||
Execute = function(url, method, queryParams, headerParams, body, ...){
|
||||
headers <- httr::add_headers(c(headerParams, self$defaultHeaders))
|
||||
Execute = function(url, method, query_params, header_params, body, ...) {
|
||||
headers <- httr::add_headers(c(header_params, self$default_headers))
|
||||
|
||||
httpTimeout <- NULL
|
||||
http_timeout <- NULL
|
||||
if (!is.null(self$timeout)) {
|
||||
httpTimeout <- httr::timeout(self$timeout)
|
||||
http_timeout <- httr::timeout(self$timeout)
|
||||
}
|
||||
|
||||
if (method == "GET") {
|
||||
httr::GET(url, query = queryParams, headers, httpTimeout, httr::user_agent(self$`userAgent`), ...)
|
||||
httr::GET(url, query = query_params, headers, http_timeout, httr::user_agent(self$`user_agent`), ...)
|
||||
} else if (method == "POST") {
|
||||
httr::POST(url, query = queryParams, headers, body = body, httr::content_type("application/json"), httpTimeout, httr::user_agent(self$`userAgent`), ...)
|
||||
httr::POST(url, query = query_params, headers, body = body, httr::content_type("application/json"), http_timeout, httr::user_agent(self$`user_agent`), ...)
|
||||
} else if (method == "PUT") {
|
||||
httr::PUT(url, query = queryParams, headers, body = body, httr::content_type("application/json"), httpTimeout, httpTimeout, httr::user_agent(self$`userAgent`), ...)
|
||||
httr::PUT(url, query = query_params, headers, body = body, httr::content_type("application/json"), http_timeout, http_timeout, httr::user_agent(self$`user_agent`), ...)
|
||||
} else if (method == "PATCH") {
|
||||
httr::PATCH(url, query = queryParams, headers, body = body, httr::content_type("application/json"), httpTimeout, httpTimeout, httr::user_agent(self$`userAgent`), ...)
|
||||
httr::PATCH(url, query = query_params, headers, body = body, httr::content_type("application/json"), http_timeout, http_timeout, httr::user_agent(self$`user_agent`), ...)
|
||||
} else if (method == "HEAD") {
|
||||
httr::HEAD(url, query = queryParams, headers, httpTimeout, httpTimeout, httr::user_agent(self$`userAgent`), ...)
|
||||
httr::HEAD(url, query = query_params, headers, http_timeout, http_timeout, httr::user_agent(self$`user_agent`), ...)
|
||||
} else if (method == "DELETE") {
|
||||
httr::DELETE(url, query = queryParams, headers, httpTimeout, httpTimeout, httr::user_agent(self$`userAgent`), ...)
|
||||
httr::DELETE(url, query = query_params, headers, http_timeout, http_timeout, httr::user_agent(self$`user_agent`), ...)
|
||||
} else {
|
||||
errMsg <- "Http method must be `GET`, `HEAD`, `OPTIONS`, `POST`, `PATCH`, `PUT` or `DELETE`."
|
||||
stop(errMsg)
|
||||
err_msg <- "Http method must be `GET`, `HEAD`, `OPTIONS`, `POST`, `PATCH`, `PUT` or `DELETE`."
|
||||
stop(err_msg)
|
||||
}
|
||||
},
|
||||
|
||||
# Deserialize the content of api response to the given type.
|
||||
deserialize = function(resp, returnType, pkgEnv) {
|
||||
respObj <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
|
||||
self$deserializeObj(respObj, returnType, pkgEnv)
|
||||
deserialize = function(resp, return_type, pkg_env) {
|
||||
resp_obj <- jsonlite::fromJSON(httr::content(resp, "text", encoding = "UTF-8"))
|
||||
self$deserializeObj(resp_obj, return_type, pkg_env)
|
||||
},
|
||||
|
||||
|
||||
# Deserialize the response from jsonlite object based on the given type
|
||||
# by handling complex and nested types by iterating recursively
|
||||
# Example returnTypes will be like "array[integer]", "map(Pet)", "array[map(Tag)]", etc.,
|
||||
# Example return_types will be like "array[integer]", "map(Pet)", "array[map(Tag)]", etc.,
|
||||
|
||||
deserializeObj = function(obj, returnType, pkgEnv) {
|
||||
returnObj <- NULL
|
||||
primitiveTypes <- c("character", "numeric", "integer", "logical", "complex")
|
||||
deserializeObj = function(obj, return_type, pkg_env) {
|
||||
return_obj <- NULL
|
||||
primitive_types <- c("character", "numeric", "integer", "logical", "complex")
|
||||
|
||||
# To handle the "map" type
|
||||
if (startsWith(returnType, "map(")) {
|
||||
innerReturnType <- regmatches(returnType, regexec(pattern = "map\\((.*)\\)", returnType))[[1]][2]
|
||||
returnObj <- lapply(names(obj), function(name) {
|
||||
self$deserializeObj(obj[[name]], innerReturnType, pkgEnv)
|
||||
if (startsWith(return_type, "map(")) {
|
||||
inner_return_type <- regmatches(return_type, regexec(pattern = "map\\((.*)\\)", return_type))[[1]][2]
|
||||
return_obj <- lapply(names(obj), function(name) {
|
||||
self$deserializeObj(obj[[name]], inner_return_type, pkg_env)
|
||||
})
|
||||
names(returnObj) <- names(obj)
|
||||
names(return_obj) <- names(obj)
|
||||
}
|
||||
|
||||
# To handle the "array" type
|
||||
else if (startsWith(returnType, "array[")) {
|
||||
innerReturnType <- regmatches(returnType, regexec(pattern = "array\\[(.*)\\]", returnType))[[1]][2]
|
||||
if (c(innerReturnType) %in% primitiveTypes) {
|
||||
returnObj <- vector("list", length = length(obj))
|
||||
else if (startsWith(return_type, "array[")) {
|
||||
inner_return_type <- regmatches(return_type, regexec(pattern = "array\\[(.*)\\]", return_type))[[1]][2]
|
||||
if (c(inner_return_type) %in% primitive_types) {
|
||||
return_obj <- vector("list", length = length(obj))
|
||||
if (length(obj) > 0) {
|
||||
for (row in 1:length(obj)) {
|
||||
returnObj[[row]] <- self$deserializeObj(obj[row], innerReturnType, pkgEnv)
|
||||
return_obj[[row]] <- self$deserializeObj(obj[row], inner_return_type, pkg_env)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(!is.null(nrow(obj))){
|
||||
returnObj <- vector("list", length = nrow(obj))
|
||||
if (!is.null(nrow(obj))) {
|
||||
return_obj <- vector("list", length = nrow(obj))
|
||||
if (nrow(obj) > 0) {
|
||||
for (row in 1:nrow(obj)) {
|
||||
returnObj[[row]] <- self$deserializeObj(obj[row, , drop = FALSE], innerReturnType, pkgEnv)
|
||||
return_obj[[row]] <- self$deserializeObj(obj[row, , drop = FALSE], inner_return_type, pkg_env)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -201,19 +203,19 @@ ApiClient <- R6::R6Class(
|
||||
}
|
||||
|
||||
# To handle model objects which are not array or map containers. Ex:"Pet"
|
||||
else if (exists(returnType, pkgEnv) && !(c(returnType) %in% primitiveTypes)) {
|
||||
returnType <- get(returnType, envir = as.environment(pkgEnv))
|
||||
returnObj <- returnType$new()
|
||||
returnObj$fromJSON(
|
||||
else if (exists(return_type, pkg_env) && !(c(return_type) %in% primitive_types)) {
|
||||
return_type <- get(return_type, envir = as.environment(pkg_env))
|
||||
return_obj <- return_type$new()
|
||||
return_obj$fromJSON(
|
||||
jsonlite::toJSON(obj, digits = NA, auto_unbox = TRUE)
|
||||
)
|
||||
}
|
||||
|
||||
# To handle primitive type
|
||||
else {
|
||||
returnObj <- obj
|
||||
return_obj <- obj
|
||||
}
|
||||
returnObj
|
||||
return_obj
|
||||
}
|
||||
)
|
||||
)
|
||||
|
@ -6,11 +6,11 @@
|
||||
#' @field response The raw response from the endpoint.
|
||||
#' @export
|
||||
ApiResponse <- R6::R6Class(
|
||||
'ApiResponse',
|
||||
"ApiResponse",
|
||||
public = list(
|
||||
content = NULL,
|
||||
response = NULL,
|
||||
initialize = function(content, response){
|
||||
initialize = function(content, response) {
|
||||
self$content <- content
|
||||
self$response <- response
|
||||
}
|
||||
|
@ -3,7 +3,6 @@
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
#
|
||||
# The version of the OpenAPI document: 1.0.0
|
||||
#
|
||||
# Generated by: https://openapi-generator.tech
|
||||
|
||||
#' @docType class
|
||||
|
@ -3,14 +3,13 @@
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
#
|
||||
# The version of the OpenAPI document: 1.0.0
|
||||
#
|
||||
# Generated by: https://openapi-generator.tech
|
||||
|
||||
#' @docType class
|
||||
#' @title Fake operations
|
||||
#' @description petstore.Fake
|
||||
#' @format An \code{R6Class} generator object
|
||||
#' @field apiClient Handles the client-server communication.
|
||||
#' @field api_client Handles the client-server communication.
|
||||
#'
|
||||
#' @section Methods:
|
||||
#' \describe{
|
||||
@ -54,51 +53,47 @@
|
||||
#' @importFrom base64enc base64encode
|
||||
#' @export
|
||||
FakeApi <- R6::R6Class(
|
||||
'FakeApi',
|
||||
"FakeApi",
|
||||
public = list(
|
||||
apiClient = NULL,
|
||||
initialize = function(apiClient){
|
||||
if (!missing(apiClient)) {
|
||||
self$apiClient <- apiClient
|
||||
api_client = NULL,
|
||||
initialize = function(api_client) {
|
||||
if (!missing(api_client)) {
|
||||
self$api_client <- api_client
|
||||
}
|
||||
else {
|
||||
self$apiClient <- ApiClient$new()
|
||||
self$api_client <- ApiClient$new()
|
||||
}
|
||||
},
|
||||
FakeDataFile = function(dummy, var_data_file=NULL, data_file=NULL, ...){
|
||||
apiResponse <- self$FakeDataFileWithHttpInfo(dummy, var_data_file, data_file=data_file, ...)
|
||||
resp <- apiResponse$response
|
||||
FakeDataFile = function(dummy, var_data_file=NULL, data_file=NULL, ...) {
|
||||
api_response <- self$FakeDataFileWithHttpInfo(dummy, var_data_file, data_file = data_file, ...)
|
||||
resp <- api_response$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
api_response$content
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
api_response
|
||||
}
|
||||
},
|
||||
|
||||
FakeDataFileWithHttpInfo = function(dummy, var_data_file=NULL, data_file=NULL, ...){
|
||||
FakeDataFileWithHttpInfo = function(dummy, var_data_file=NULL, data_file = NULL, ...) {
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
query_params <- list()
|
||||
header_params <- c()
|
||||
|
||||
if (missing(`dummy`)) {
|
||||
stop("Missing required parameter `dummy`.")
|
||||
}
|
||||
|
||||
headerParams['dummy'] <- `dummy`
|
||||
|
||||
headerParams['data_file'] <- `var_data_file`
|
||||
|
||||
body <- NULL
|
||||
urlPath <- "/fake/data_file"
|
||||
url_path <- "/fake/data_file"
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path),
|
||||
method = "GET",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
query_params = query_params,
|
||||
header_params = header_params,
|
||||
body = body,
|
||||
...)
|
||||
|
||||
@ -108,15 +103,15 @@ FakeApi <- R6::R6Class(
|
||||
write(httr::content(resp, "text", encoding = "UTF-8", simplifyVector = FALSE), data_file)
|
||||
}
|
||||
|
||||
deserializedRespObj <- tryCatch(
|
||||
self$apiClient$deserialize(resp, "User", loadNamespace("petstore")),
|
||||
error = function(e){
|
||||
deserialized_resp_obj <- tryCatch(
|
||||
self$api_client$deserialize(resp, "User", loadNamespace("petstore")),
|
||||
error = function(e) {
|
||||
stop("Failed to deserialize response")
|
||||
}
|
||||
)
|
||||
ApiResponse$new(deserializedRespObj, resp)
|
||||
ApiResponse$new(deserialized_resp_obj, resp)
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
ApiResponse$new(paste("Server returned ", httr::status_code(resp), " response status code."), resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
|
@ -3,7 +3,6 @@
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
#
|
||||
# The version of the OpenAPI document: 1.0.0
|
||||
#
|
||||
# Generated by: https://openapi-generator.tech
|
||||
|
||||
#' @docType class
|
||||
|
@ -3,7 +3,6 @@
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
#
|
||||
# The version of the OpenAPI document: 1.0.0
|
||||
#
|
||||
# Generated by: https://openapi-generator.tech
|
||||
|
||||
#' @docType class
|
||||
|
@ -3,7 +3,6 @@
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
#
|
||||
# The version of the OpenAPI document: 1.0.0
|
||||
#
|
||||
# Generated by: https://openapi-generator.tech
|
||||
|
||||
#' @docType class
|
||||
|
@ -3,14 +3,13 @@
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
#
|
||||
# The version of the OpenAPI document: 1.0.0
|
||||
#
|
||||
# Generated by: https://openapi-generator.tech
|
||||
|
||||
#' @docType class
|
||||
#' @title Pet operations
|
||||
#' @description petstore.Pet
|
||||
#' @format An \code{R6Class} generator object
|
||||
#' @field apiClient Handles the client-server communication.
|
||||
#' @field api_client Handles the client-server communication.
|
||||
#'
|
||||
#' @section Methods:
|
||||
#' \describe{
|
||||
@ -223,7 +222,7 @@
|
||||
#' api.instance <- PetApi$new()
|
||||
#'
|
||||
#' # Configure OAuth2 access token for authorization: petstore_auth
|
||||
#' api.instance$apiClient$accessToken <- 'TODO_YOUR_ACCESS_TOKEN';
|
||||
#' api.instance$api_client$access_token <- 'TODO_YOUR_ACCESS_TOKEN';
|
||||
#'
|
||||
#' result <- api.instance$AddPet(var.pet)
|
||||
#'
|
||||
@ -238,7 +237,7 @@
|
||||
#' api.instance <- PetApi$new()
|
||||
#'
|
||||
#' # Configure OAuth2 access token for authorization: petstore_auth
|
||||
#' api.instance$apiClient$accessToken <- 'TODO_YOUR_ACCESS_TOKEN';
|
||||
#' api.instance$api_client$access_token <- 'TODO_YOUR_ACCESS_TOKEN';
|
||||
#'
|
||||
#' result <- api.instance$DeletePet(var.pet_id, api_key=var.api_key)
|
||||
#'
|
||||
@ -252,7 +251,7 @@
|
||||
#' api.instance <- PetApi$new()
|
||||
#'
|
||||
#' # Configure OAuth2 access token for authorization: petstore_auth
|
||||
#' api.instance$apiClient$accessToken <- 'TODO_YOUR_ACCESS_TOKEN';
|
||||
#' api.instance$api_client$access_token <- 'TODO_YOUR_ACCESS_TOKEN';
|
||||
#'
|
||||
#' result <- api.instance$FindPetsByStatus(var.status)
|
||||
#'
|
||||
@ -266,7 +265,7 @@
|
||||
#' api.instance <- PetApi$new()
|
||||
#'
|
||||
#' # Configure OAuth2 access token for authorization: petstore_auth
|
||||
#' api.instance$apiClient$accessToken <- 'TODO_YOUR_ACCESS_TOKEN';
|
||||
#' api.instance$api_client$access_token <- 'TODO_YOUR_ACCESS_TOKEN';
|
||||
#'
|
||||
#' result <- api.instance$FindPetsByTags(var.tags)
|
||||
#'
|
||||
@ -280,7 +279,7 @@
|
||||
#' api.instance <- PetApi$new()
|
||||
#'
|
||||
#' #Configure API key authorization: api_key
|
||||
#' api.instance$apiClient$apiKeys['api_key'] <- 'TODO_YOUR_API_KEY';
|
||||
#' api.instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY';
|
||||
#'
|
||||
#' result <- api.instance$GetPetById(var.pet_id)
|
||||
#'
|
||||
@ -294,7 +293,7 @@
|
||||
#' api.instance <- PetApi$new()
|
||||
#'
|
||||
#' # Configure OAuth2 access token for authorization: petstore_auth
|
||||
#' api.instance$apiClient$accessToken <- 'TODO_YOUR_ACCESS_TOKEN';
|
||||
#' api.instance$api_client$access_token <- 'TODO_YOUR_ACCESS_TOKEN';
|
||||
#'
|
||||
#' result <- api.instance$UpdatePet(var.pet)
|
||||
#'
|
||||
@ -310,7 +309,7 @@
|
||||
#' api.instance <- PetApi$new()
|
||||
#'
|
||||
#' # Configure OAuth2 access token for authorization: petstore_auth
|
||||
#' api.instance$apiClient$accessToken <- 'TODO_YOUR_ACCESS_TOKEN';
|
||||
#' api.instance$api_client$access_token <- 'TODO_YOUR_ACCESS_TOKEN';
|
||||
#'
|
||||
#' result <- api.instance$UpdatePetWithForm(var.pet_id, name=var.name, status=var.status)
|
||||
#'
|
||||
@ -326,7 +325,7 @@
|
||||
#' api.instance <- PetApi$new()
|
||||
#'
|
||||
#' # Configure OAuth2 access token for authorization: petstore_auth
|
||||
#' api.instance$apiClient$accessToken <- 'TODO_YOUR_ACCESS_TOKEN';
|
||||
#' api.instance$api_client$access_token <- 'TODO_YOUR_ACCESS_TOKEN';
|
||||
#'
|
||||
#' result <- api.instance$UploadFile(var.pet_id, additional_metadata=var.additional_metadata, file=var.file)
|
||||
#'
|
||||
@ -336,35 +335,35 @@
|
||||
#' @importFrom base64enc base64encode
|
||||
#' @export
|
||||
PetApi <- R6::R6Class(
|
||||
'PetApi',
|
||||
"PetApi",
|
||||
public = list(
|
||||
apiClient = NULL,
|
||||
initialize = function(apiClient){
|
||||
if (!missing(apiClient)) {
|
||||
self$apiClient <- apiClient
|
||||
api_client = NULL,
|
||||
initialize = function(api_client) {
|
||||
if (!missing(api_client)) {
|
||||
self$api_client <- api_client
|
||||
}
|
||||
else {
|
||||
self$apiClient <- ApiClient$new()
|
||||
self$api_client <- ApiClient$new()
|
||||
}
|
||||
},
|
||||
AddPet = function(pet, data_file=NULL, ...){
|
||||
apiResponse <- self$AddPetWithHttpInfo(pet, data_file=data_file, ...)
|
||||
resp <- apiResponse$response
|
||||
AddPet = function(pet, data_file=NULL, ...) {
|
||||
api_response <- self$AddPetWithHttpInfo(pet, data_file = data_file, ...)
|
||||
resp <- api_response$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
api_response$content
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
api_response
|
||||
}
|
||||
},
|
||||
|
||||
AddPetWithHttpInfo = function(pet, data_file=NULL, ...){
|
||||
AddPetWithHttpInfo = function(pet, data_file = NULL, ...) {
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
query_params <- list()
|
||||
header_params <- c()
|
||||
|
||||
if (missing(`pet`)) {
|
||||
stop("Missing required parameter `pet`.")
|
||||
@ -376,14 +375,14 @@ PetApi <- R6::R6Class(
|
||||
body <- NULL
|
||||
}
|
||||
|
||||
urlPath <- "/pet"
|
||||
url_path <- "/pet"
|
||||
# OAuth token
|
||||
headerParams['Authorization'] <- paste("Bearer", self$apiClient$accessToken, sep=" ")
|
||||
header_params["Authorization"] <- paste("Bearer", self$api_client$access_token, sep = " ")
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path),
|
||||
method = "POST",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
query_params = query_params,
|
||||
header_params = header_params,
|
||||
body = body,
|
||||
...)
|
||||
|
||||
@ -393,106 +392,102 @@ PetApi <- R6::R6Class(
|
||||
write(httr::content(resp, "text", encoding = "UTF-8", simplifyVector = FALSE), data_file)
|
||||
}
|
||||
|
||||
deserializedRespObj <- tryCatch(
|
||||
self$apiClient$deserialize(resp, "Pet", loadNamespace("petstore")),
|
||||
error = function(e){
|
||||
deserialized_resp_obj <- tryCatch(
|
||||
self$api_client$deserialize(resp, "Pet", loadNamespace("petstore")),
|
||||
error = function(e) {
|
||||
stop("Failed to deserialize response")
|
||||
}
|
||||
)
|
||||
ApiResponse$new(deserializedRespObj, resp)
|
||||
ApiResponse$new(deserialized_resp_obj, resp)
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
ApiResponse$new(paste("Server returned ", httr::status_code(resp), " response status code."), resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
},
|
||||
DeletePet = function(pet_id, api_key=NULL, ...){
|
||||
apiResponse <- self$DeletePetWithHttpInfo(pet_id, api_key, ...)
|
||||
resp <- apiResponse$response
|
||||
DeletePet = function(pet_id, api_key=NULL, ...) {
|
||||
api_response <- self$DeletePetWithHttpInfo(pet_id, api_key, ...)
|
||||
resp <- api_response$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
api_response$content
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
api_response
|
||||
}
|
||||
},
|
||||
|
||||
DeletePetWithHttpInfo = function(pet_id, api_key=NULL, ...){
|
||||
DeletePetWithHttpInfo = function(pet_id, api_key=NULL, ...) {
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
query_params <- list()
|
||||
header_params <- c()
|
||||
|
||||
if (missing(`pet_id`)) {
|
||||
stop("Missing required parameter `pet_id`.")
|
||||
}
|
||||
|
||||
headerParams['api_key'] <- `api_key`
|
||||
|
||||
body <- NULL
|
||||
urlPath <- "/pet/{petId}"
|
||||
url_path <- "/pet/{petId}"
|
||||
if (!missing(`pet_id`)) {
|
||||
urlPath <- gsub(paste0("\\{", "petId", "\\}"), URLencode(as.character(`pet_id`), reserved = TRUE), urlPath)
|
||||
url_path <- gsub(paste0("\\{", "petId", "\\}"), URLencode(as.character(`pet_id`), reserved = TRUE), url_path)
|
||||
}
|
||||
|
||||
# OAuth token
|
||||
headerParams['Authorization'] <- paste("Bearer", self$apiClient$accessToken, sep=" ")
|
||||
header_params["Authorization"] <- paste("Bearer", self$api_client$access_token, sep = " ")
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path),
|
||||
method = "DELETE",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
query_params = query_params,
|
||||
header_params = header_params,
|
||||
body = body,
|
||||
...)
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
ApiResponse$new(NULL, resp)
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
ApiResponse$new(paste("Server returned ", httr::status_code(resp), " response status code."), resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
},
|
||||
FindPetsByStatus = function(status, data_file=NULL, ...){
|
||||
apiResponse <- self$FindPetsByStatusWithHttpInfo(status, data_file=data_file, ...)
|
||||
resp <- apiResponse$response
|
||||
FindPetsByStatus = function(status, data_file=NULL, ...) {
|
||||
api_response <- self$FindPetsByStatusWithHttpInfo(status, data_file = data_file, ...)
|
||||
resp <- api_response$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
api_response$content
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
api_response
|
||||
}
|
||||
},
|
||||
|
||||
FindPetsByStatusWithHttpInfo = function(status, data_file=NULL, ...){
|
||||
FindPetsByStatusWithHttpInfo = function(status, data_file = NULL, ...) {
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
query_params <- list()
|
||||
header_params <- c()
|
||||
|
||||
if (missing(`status`)) {
|
||||
stop("Missing required parameter `status`.")
|
||||
}
|
||||
|
||||
queryParams['status'] <- status
|
||||
|
||||
body <- NULL
|
||||
urlPath <- "/pet/findByStatus"
|
||||
url_path <- "/pet/findByStatus"
|
||||
# OAuth token
|
||||
headerParams['Authorization'] <- paste("Bearer", self$apiClient$accessToken, sep=" ")
|
||||
header_params["Authorization"] <- paste("Bearer", self$api_client$access_token, sep = " ")
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path),
|
||||
method = "GET",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
query_params = query_params,
|
||||
header_params = header_params,
|
||||
body = body,
|
||||
...)
|
||||
|
||||
@ -502,55 +497,53 @@ PetApi <- R6::R6Class(
|
||||
write(httr::content(resp, "text", encoding = "UTF-8", simplifyVector = FALSE), data_file)
|
||||
}
|
||||
|
||||
deserializedRespObj <- tryCatch(
|
||||
self$apiClient$deserialize(resp, "array[Pet]", loadNamespace("petstore")),
|
||||
error = function(e){
|
||||
deserialized_resp_obj <- tryCatch(
|
||||
self$api_client$deserialize(resp, "array[Pet]", loadNamespace("petstore")),
|
||||
error = function(e) {
|
||||
stop("Failed to deserialize response")
|
||||
}
|
||||
)
|
||||
ApiResponse$new(deserializedRespObj, resp)
|
||||
ApiResponse$new(deserialized_resp_obj, resp)
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
ApiResponse$new(paste("Server returned ", httr::status_code(resp), " response status code."), resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
},
|
||||
FindPetsByTags = function(tags, data_file=NULL, ...){
|
||||
apiResponse <- self$FindPetsByTagsWithHttpInfo(tags, data_file=data_file, ...)
|
||||
resp <- apiResponse$response
|
||||
FindPetsByTags = function(tags, data_file=NULL, ...) {
|
||||
api_response <- self$FindPetsByTagsWithHttpInfo(tags, data_file = data_file, ...)
|
||||
resp <- api_response$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
api_response$content
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
api_response
|
||||
}
|
||||
},
|
||||
|
||||
FindPetsByTagsWithHttpInfo = function(tags, data_file=NULL, ...){
|
||||
FindPetsByTagsWithHttpInfo = function(tags, data_file = NULL, ...) {
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
query_params <- list()
|
||||
header_params <- c()
|
||||
|
||||
if (missing(`tags`)) {
|
||||
stop("Missing required parameter `tags`.")
|
||||
}
|
||||
|
||||
queryParams['tags'] <- tags
|
||||
|
||||
body <- NULL
|
||||
urlPath <- "/pet/findByTags"
|
||||
url_path <- "/pet/findByTags"
|
||||
# OAuth token
|
||||
headerParams['Authorization'] <- paste("Bearer", self$apiClient$accessToken, sep=" ")
|
||||
header_params["Authorization"] <- paste("Bearer", self$api_client$access_token, sep = " ")
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path),
|
||||
method = "GET",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
query_params = query_params,
|
||||
header_params = header_params,
|
||||
body = body,
|
||||
...)
|
||||
|
||||
@ -560,59 +553,59 @@ PetApi <- R6::R6Class(
|
||||
write(httr::content(resp, "text", encoding = "UTF-8", simplifyVector = FALSE), data_file)
|
||||
}
|
||||
|
||||
deserializedRespObj <- tryCatch(
|
||||
self$apiClient$deserialize(resp, "array[Pet]", loadNamespace("petstore")),
|
||||
error = function(e){
|
||||
deserialized_resp_obj <- tryCatch(
|
||||
self$api_client$deserialize(resp, "array[Pet]", loadNamespace("petstore")),
|
||||
error = function(e) {
|
||||
stop("Failed to deserialize response")
|
||||
}
|
||||
)
|
||||
ApiResponse$new(deserializedRespObj, resp)
|
||||
ApiResponse$new(deserialized_resp_obj, resp)
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
ApiResponse$new(paste("Server returned ", httr::status_code(resp), " response status code."), resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
},
|
||||
GetPetById = function(pet_id, data_file=NULL, ...){
|
||||
apiResponse <- self$GetPetByIdWithHttpInfo(pet_id, data_file=data_file, ...)
|
||||
resp <- apiResponse$response
|
||||
GetPetById = function(pet_id, data_file=NULL, ...) {
|
||||
api_response <- self$GetPetByIdWithHttpInfo(pet_id, data_file = data_file, ...)
|
||||
resp <- api_response$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
api_response$content
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
api_response
|
||||
}
|
||||
},
|
||||
|
||||
GetPetByIdWithHttpInfo = function(pet_id, data_file=NULL, ...){
|
||||
GetPetByIdWithHttpInfo = function(pet_id, data_file = NULL, ...) {
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
query_params <- list()
|
||||
header_params <- c()
|
||||
|
||||
if (missing(`pet_id`)) {
|
||||
stop("Missing required parameter `pet_id`.")
|
||||
}
|
||||
|
||||
body <- NULL
|
||||
urlPath <- "/pet/{petId}"
|
||||
url_path <- "/pet/{petId}"
|
||||
if (!missing(`pet_id`)) {
|
||||
urlPath <- gsub(paste0("\\{", "petId", "\\}"), URLencode(as.character(`pet_id`), reserved = TRUE), urlPath)
|
||||
url_path <- gsub(paste0("\\{", "petId", "\\}"), URLencode(as.character(`pet_id`), reserved = TRUE), url_path)
|
||||
}
|
||||
|
||||
# API key authentication
|
||||
if ("api_key" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["api_key"]) > 0) {
|
||||
headerParams['api_key'] <- paste(unlist(self$apiClient$apiKeys["api_key"]), collapse='')
|
||||
if ("api_key" %in% names(self$api_client$api_keys) && nchar(self$api_client$api_keys["api_key"]) > 0) {
|
||||
header_params["api_key"] <- paste(unlist(self$api_client$api_keys["api_key"]), collapse = "")
|
||||
}
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path),
|
||||
method = "GET",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
query_params = query_params,
|
||||
header_params = header_params,
|
||||
body = body,
|
||||
...)
|
||||
|
||||
@ -622,39 +615,39 @@ PetApi <- R6::R6Class(
|
||||
write(httr::content(resp, "text", encoding = "UTF-8", simplifyVector = FALSE), data_file)
|
||||
}
|
||||
|
||||
deserializedRespObj <- tryCatch(
|
||||
self$apiClient$deserialize(resp, "Pet", loadNamespace("petstore")),
|
||||
error = function(e){
|
||||
deserialized_resp_obj <- tryCatch(
|
||||
self$api_client$deserialize(resp, "Pet", loadNamespace("petstore")),
|
||||
error = function(e) {
|
||||
stop("Failed to deserialize response")
|
||||
}
|
||||
)
|
||||
ApiResponse$new(deserializedRespObj, resp)
|
||||
ApiResponse$new(deserialized_resp_obj, resp)
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
ApiResponse$new(paste("Server returned ", httr::status_code(resp), " response status code."), resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
},
|
||||
UpdatePet = function(pet, data_file=NULL, ...){
|
||||
apiResponse <- self$UpdatePetWithHttpInfo(pet, data_file=data_file, ...)
|
||||
resp <- apiResponse$response
|
||||
UpdatePet = function(pet, data_file=NULL, ...) {
|
||||
api_response <- self$UpdatePetWithHttpInfo(pet, data_file = data_file, ...)
|
||||
resp <- api_response$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
api_response$content
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
api_response
|
||||
}
|
||||
},
|
||||
|
||||
UpdatePetWithHttpInfo = function(pet, data_file=NULL, ...){
|
||||
UpdatePetWithHttpInfo = function(pet, data_file = NULL, ...) {
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
query_params <- list()
|
||||
header_params <- c()
|
||||
|
||||
if (missing(`pet`)) {
|
||||
stop("Missing required parameter `pet`.")
|
||||
@ -666,14 +659,14 @@ PetApi <- R6::R6Class(
|
||||
body <- NULL
|
||||
}
|
||||
|
||||
urlPath <- "/pet"
|
||||
url_path <- "/pet"
|
||||
# OAuth token
|
||||
headerParams['Authorization'] <- paste("Bearer", self$apiClient$accessToken, sep=" ")
|
||||
header_params["Authorization"] <- paste("Bearer", self$api_client$access_token, sep = " ")
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path),
|
||||
method = "PUT",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
query_params = query_params,
|
||||
header_params = header_params,
|
||||
body = body,
|
||||
...)
|
||||
|
||||
@ -683,39 +676,39 @@ PetApi <- R6::R6Class(
|
||||
write(httr::content(resp, "text", encoding = "UTF-8", simplifyVector = FALSE), data_file)
|
||||
}
|
||||
|
||||
deserializedRespObj <- tryCatch(
|
||||
self$apiClient$deserialize(resp, "Pet", loadNamespace("petstore")),
|
||||
error = function(e){
|
||||
deserialized_resp_obj <- tryCatch(
|
||||
self$api_client$deserialize(resp, "Pet", loadNamespace("petstore")),
|
||||
error = function(e) {
|
||||
stop("Failed to deserialize response")
|
||||
}
|
||||
)
|
||||
ApiResponse$new(deserializedRespObj, resp)
|
||||
ApiResponse$new(deserialized_resp_obj, resp)
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
ApiResponse$new(paste("Server returned ", httr::status_code(resp), " response status code."), resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
},
|
||||
UpdatePetWithForm = function(pet_id, name=NULL, status=NULL, ...){
|
||||
apiResponse <- self$UpdatePetWithFormWithHttpInfo(pet_id, name, status, ...)
|
||||
resp <- apiResponse$response
|
||||
UpdatePetWithForm = function(pet_id, name=NULL, status=NULL, ...) {
|
||||
api_response <- self$UpdatePetWithFormWithHttpInfo(pet_id, name, status, ...)
|
||||
resp <- api_response$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
api_response$content
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
api_response
|
||||
}
|
||||
},
|
||||
|
||||
UpdatePetWithFormWithHttpInfo = function(pet_id, name=NULL, status=NULL, ...){
|
||||
UpdatePetWithFormWithHttpInfo = function(pet_id, name=NULL, status=NULL, ...) {
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
query_params <- list()
|
||||
header_params <- c()
|
||||
|
||||
if (missing(`pet_id`)) {
|
||||
stop("Missing required parameter `pet_id`.")
|
||||
@ -726,49 +719,49 @@ PetApi <- R6::R6Class(
|
||||
"status" = status
|
||||
)
|
||||
|
||||
urlPath <- "/pet/{petId}"
|
||||
url_path <- "/pet/{petId}"
|
||||
if (!missing(`pet_id`)) {
|
||||
urlPath <- gsub(paste0("\\{", "petId", "\\}"), URLencode(as.character(`pet_id`), reserved = TRUE), urlPath)
|
||||
url_path <- gsub(paste0("\\{", "petId", "\\}"), URLencode(as.character(`pet_id`), reserved = TRUE), url_path)
|
||||
}
|
||||
|
||||
# OAuth token
|
||||
headerParams['Authorization'] <- paste("Bearer", self$apiClient$accessToken, sep=" ")
|
||||
header_params["Authorization"] <- paste("Bearer", self$api_client$access_token, sep = " ")
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path),
|
||||
method = "POST",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
query_params = query_params,
|
||||
header_params = header_params,
|
||||
body = body,
|
||||
...)
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
ApiResponse$new(NULL, resp)
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
ApiResponse$new(paste("Server returned ", httr::status_code(resp), " response status code."), resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
},
|
||||
UploadFile = function(pet_id, additional_metadata=NULL, file=NULL, data_file=NULL, ...){
|
||||
apiResponse <- self$UploadFileWithHttpInfo(pet_id, additional_metadata, file, data_file=data_file, ...)
|
||||
resp <- apiResponse$response
|
||||
UploadFile = function(pet_id, additional_metadata=NULL, file=NULL, data_file=NULL, ...) {
|
||||
api_response <- self$UploadFileWithHttpInfo(pet_id, additional_metadata, file, data_file = data_file, ...)
|
||||
resp <- api_response$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
api_response$content
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
api_response
|
||||
}
|
||||
},
|
||||
|
||||
UploadFileWithHttpInfo = function(pet_id, additional_metadata=NULL, file=NULL, data_file=NULL, ...){
|
||||
UploadFileWithHttpInfo = function(pet_id, additional_metadata=NULL, file=NULL, data_file = NULL, ...) {
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
query_params <- list()
|
||||
header_params <- c()
|
||||
|
||||
if (missing(`pet_id`)) {
|
||||
stop("Missing required parameter `pet_id`.")
|
||||
@ -779,18 +772,18 @@ PetApi <- R6::R6Class(
|
||||
"file" = httr::upload_file(file)
|
||||
)
|
||||
|
||||
urlPath <- "/pet/{petId}/uploadImage"
|
||||
url_path <- "/pet/{petId}/uploadImage"
|
||||
if (!missing(`pet_id`)) {
|
||||
urlPath <- gsub(paste0("\\{", "petId", "\\}"), URLencode(as.character(`pet_id`), reserved = TRUE), urlPath)
|
||||
url_path <- gsub(paste0("\\{", "petId", "\\}"), URLencode(as.character(`pet_id`), reserved = TRUE), url_path)
|
||||
}
|
||||
|
||||
# OAuth token
|
||||
headerParams['Authorization'] <- paste("Bearer", self$apiClient$accessToken, sep=" ")
|
||||
header_params["Authorization"] <- paste("Bearer", self$api_client$access_token, sep = " ")
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path),
|
||||
method = "POST",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
query_params = query_params,
|
||||
header_params = header_params,
|
||||
body = body,
|
||||
...)
|
||||
|
||||
@ -800,15 +793,15 @@ PetApi <- R6::R6Class(
|
||||
write(httr::content(resp, "text", encoding = "UTF-8", simplifyVector = FALSE), data_file)
|
||||
}
|
||||
|
||||
deserializedRespObj <- tryCatch(
|
||||
self$apiClient$deserialize(resp, "ModelApiResponse", loadNamespace("petstore")),
|
||||
error = function(e){
|
||||
deserialized_resp_obj <- tryCatch(
|
||||
self$api_client$deserialize(resp, "ModelApiResponse", loadNamespace("petstore")),
|
||||
error = function(e) {
|
||||
stop("Failed to deserialize response")
|
||||
}
|
||||
)
|
||||
ApiResponse$new(deserializedRespObj, resp)
|
||||
ApiResponse$new(deserialized_resp_obj, resp)
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
ApiResponse$new(paste("Server returned ", httr::status_code(resp), " response status code."), resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
|
@ -3,14 +3,13 @@
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
#
|
||||
# The version of the OpenAPI document: 1.0.0
|
||||
#
|
||||
# Generated by: https://openapi-generator.tech
|
||||
|
||||
#' @docType class
|
||||
#' @title Store operations
|
||||
#' @description petstore.Store
|
||||
#' @format An \code{R6Class} generator object
|
||||
#' @field apiClient Handles the client-server communication.
|
||||
#' @field api_client Handles the client-server communication.
|
||||
#'
|
||||
#' @section Methods:
|
||||
#' \describe{
|
||||
@ -131,7 +130,7 @@
|
||||
#' api.instance <- StoreApi$new()
|
||||
#'
|
||||
#' #Configure API key authorization: api_key
|
||||
#' api.instance$apiClient$apiKeys['api_key'] <- 'TODO_YOUR_API_KEY';
|
||||
#' api.instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY';
|
||||
#'
|
||||
#' result <- api.instance$GetInventory()
|
||||
#'
|
||||
@ -163,94 +162,94 @@
|
||||
#' @importFrom base64enc base64encode
|
||||
#' @export
|
||||
StoreApi <- R6::R6Class(
|
||||
'StoreApi',
|
||||
"StoreApi",
|
||||
public = list(
|
||||
apiClient = NULL,
|
||||
initialize = function(apiClient){
|
||||
if (!missing(apiClient)) {
|
||||
self$apiClient <- apiClient
|
||||
api_client = NULL,
|
||||
initialize = function(api_client) {
|
||||
if (!missing(api_client)) {
|
||||
self$api_client <- api_client
|
||||
}
|
||||
else {
|
||||
self$apiClient <- ApiClient$new()
|
||||
self$api_client <- ApiClient$new()
|
||||
}
|
||||
},
|
||||
DeleteOrder = function(order_id, ...){
|
||||
apiResponse <- self$DeleteOrderWithHttpInfo(order_id, ...)
|
||||
resp <- apiResponse$response
|
||||
DeleteOrder = function(order_id, ...) {
|
||||
api_response <- self$DeleteOrderWithHttpInfo(order_id, ...)
|
||||
resp <- api_response$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
api_response$content
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
api_response
|
||||
}
|
||||
},
|
||||
|
||||
DeleteOrderWithHttpInfo = function(order_id, ...){
|
||||
DeleteOrderWithHttpInfo = function(order_id, ...) {
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
query_params <- list()
|
||||
header_params <- c()
|
||||
|
||||
if (missing(`order_id`)) {
|
||||
stop("Missing required parameter `order_id`.")
|
||||
}
|
||||
|
||||
body <- NULL
|
||||
urlPath <- "/store/order/{orderId}"
|
||||
url_path <- "/store/order/{orderId}"
|
||||
if (!missing(`order_id`)) {
|
||||
urlPath <- gsub(paste0("\\{", "orderId", "\\}"), URLencode(as.character(`order_id`), reserved = TRUE), urlPath)
|
||||
url_path <- gsub(paste0("\\{", "orderId", "\\}"), URLencode(as.character(`order_id`), reserved = TRUE), url_path)
|
||||
}
|
||||
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path),
|
||||
method = "DELETE",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
query_params = query_params,
|
||||
header_params = header_params,
|
||||
body = body,
|
||||
...)
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
ApiResponse$new(NULL, resp)
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
ApiResponse$new(paste("Server returned ", httr::status_code(resp), " response status code."), resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
},
|
||||
GetInventory = function(data_file=NULL, ...){
|
||||
apiResponse <- self$GetInventoryWithHttpInfo(data_file=data_file, ...)
|
||||
resp <- apiResponse$response
|
||||
GetInventory = function(data_file=NULL, ...) {
|
||||
api_response <- self$GetInventoryWithHttpInfo(data_file = data_file, ...)
|
||||
resp <- api_response$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
api_response$content
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
api_response
|
||||
}
|
||||
},
|
||||
|
||||
GetInventoryWithHttpInfo = function(data_file=NULL, ...){
|
||||
GetInventoryWithHttpInfo = function(data_file = NULL, ...) {
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
query_params <- list()
|
||||
header_params <- c()
|
||||
|
||||
body <- NULL
|
||||
urlPath <- "/store/inventory"
|
||||
url_path <- "/store/inventory"
|
||||
# API key authentication
|
||||
if ("api_key" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["api_key"]) > 0) {
|
||||
headerParams['api_key'] <- paste(unlist(self$apiClient$apiKeys["api_key"]), collapse='')
|
||||
if ("api_key" %in% names(self$api_client$api_keys) && nchar(self$api_client$api_keys["api_key"]) > 0) {
|
||||
header_params["api_key"] <- paste(unlist(self$api_client$api_keys["api_key"]), collapse = "")
|
||||
}
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path),
|
||||
method = "GET",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
query_params = query_params,
|
||||
header_params = header_params,
|
||||
body = body,
|
||||
...)
|
||||
|
||||
@ -260,55 +259,55 @@ StoreApi <- R6::R6Class(
|
||||
write(httr::content(resp, "text", encoding = "UTF-8", simplifyVector = FALSE), data_file)
|
||||
}
|
||||
|
||||
deserializedRespObj <- tryCatch(
|
||||
self$apiClient$deserialize(resp, "map(integer)", loadNamespace("petstore")),
|
||||
error = function(e){
|
||||
deserialized_resp_obj <- tryCatch(
|
||||
self$api_client$deserialize(resp, "map(integer)", loadNamespace("petstore")),
|
||||
error = function(e) {
|
||||
stop("Failed to deserialize response")
|
||||
}
|
||||
)
|
||||
ApiResponse$new(deserializedRespObj, resp)
|
||||
ApiResponse$new(deserialized_resp_obj, resp)
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
ApiResponse$new(paste("Server returned ", httr::status_code(resp), " response status code."), resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
},
|
||||
GetOrderById = function(order_id, data_file=NULL, ...){
|
||||
apiResponse <- self$GetOrderByIdWithHttpInfo(order_id, data_file=data_file, ...)
|
||||
resp <- apiResponse$response
|
||||
GetOrderById = function(order_id, data_file=NULL, ...) {
|
||||
api_response <- self$GetOrderByIdWithHttpInfo(order_id, data_file = data_file, ...)
|
||||
resp <- api_response$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
api_response$content
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
api_response
|
||||
}
|
||||
},
|
||||
|
||||
GetOrderByIdWithHttpInfo = function(order_id, data_file=NULL, ...){
|
||||
GetOrderByIdWithHttpInfo = function(order_id, data_file = NULL, ...) {
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
query_params <- list()
|
||||
header_params <- c()
|
||||
|
||||
if (missing(`order_id`)) {
|
||||
stop("Missing required parameter `order_id`.")
|
||||
}
|
||||
|
||||
body <- NULL
|
||||
urlPath <- "/store/order/{orderId}"
|
||||
url_path <- "/store/order/{orderId}"
|
||||
if (!missing(`order_id`)) {
|
||||
urlPath <- gsub(paste0("\\{", "orderId", "\\}"), URLencode(as.character(`order_id`), reserved = TRUE), urlPath)
|
||||
url_path <- gsub(paste0("\\{", "orderId", "\\}"), URLencode(as.character(`order_id`), reserved = TRUE), url_path)
|
||||
}
|
||||
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path),
|
||||
method = "GET",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
query_params = query_params,
|
||||
header_params = header_params,
|
||||
body = body,
|
||||
...)
|
||||
|
||||
@ -318,39 +317,39 @@ StoreApi <- R6::R6Class(
|
||||
write(httr::content(resp, "text", encoding = "UTF-8", simplifyVector = FALSE), data_file)
|
||||
}
|
||||
|
||||
deserializedRespObj <- tryCatch(
|
||||
self$apiClient$deserialize(resp, "Order", loadNamespace("petstore")),
|
||||
error = function(e){
|
||||
deserialized_resp_obj <- tryCatch(
|
||||
self$api_client$deserialize(resp, "Order", loadNamespace("petstore")),
|
||||
error = function(e) {
|
||||
stop("Failed to deserialize response")
|
||||
}
|
||||
)
|
||||
ApiResponse$new(deserializedRespObj, resp)
|
||||
ApiResponse$new(deserialized_resp_obj, resp)
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
ApiResponse$new(paste("Server returned ", httr::status_code(resp), " response status code."), resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
},
|
||||
PlaceOrder = function(order, data_file=NULL, ...){
|
||||
apiResponse <- self$PlaceOrderWithHttpInfo(order, data_file=data_file, ...)
|
||||
resp <- apiResponse$response
|
||||
PlaceOrder = function(order, data_file=NULL, ...) {
|
||||
api_response <- self$PlaceOrderWithHttpInfo(order, data_file = data_file, ...)
|
||||
resp <- api_response$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
api_response$content
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
api_response
|
||||
}
|
||||
},
|
||||
|
||||
PlaceOrderWithHttpInfo = function(order, data_file=NULL, ...){
|
||||
PlaceOrderWithHttpInfo = function(order, data_file = NULL, ...) {
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
query_params <- list()
|
||||
header_params <- c()
|
||||
|
||||
if (missing(`order`)) {
|
||||
stop("Missing required parameter `order`.")
|
||||
@ -362,12 +361,12 @@ StoreApi <- R6::R6Class(
|
||||
body <- NULL
|
||||
}
|
||||
|
||||
urlPath <- "/store/order"
|
||||
url_path <- "/store/order"
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path),
|
||||
method = "POST",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
query_params = query_params,
|
||||
header_params = header_params,
|
||||
body = body,
|
||||
...)
|
||||
|
||||
@ -377,15 +376,15 @@ StoreApi <- R6::R6Class(
|
||||
write(httr::content(resp, "text", encoding = "UTF-8", simplifyVector = FALSE), data_file)
|
||||
}
|
||||
|
||||
deserializedRespObj <- tryCatch(
|
||||
self$apiClient$deserialize(resp, "Order", loadNamespace("petstore")),
|
||||
error = function(e){
|
||||
deserialized_resp_obj <- tryCatch(
|
||||
self$api_client$deserialize(resp, "Order", loadNamespace("petstore")),
|
||||
error = function(e) {
|
||||
stop("Failed to deserialize response")
|
||||
}
|
||||
)
|
||||
ApiResponse$new(deserializedRespObj, resp)
|
||||
ApiResponse$new(deserialized_resp_obj, resp)
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
ApiResponse$new(paste("Server returned ", httr::status_code(resp), " response status code."), resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
|
@ -3,7 +3,6 @@
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
#
|
||||
# The version of the OpenAPI document: 1.0.0
|
||||
#
|
||||
# Generated by: https://openapi-generator.tech
|
||||
|
||||
#' @docType class
|
||||
|
@ -3,7 +3,6 @@
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
#
|
||||
# The version of the OpenAPI document: 1.0.0
|
||||
#
|
||||
# Generated by: https://openapi-generator.tech
|
||||
|
||||
#' @docType class
|
||||
|
@ -3,14 +3,13 @@
|
||||
# This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
#
|
||||
# The version of the OpenAPI document: 1.0.0
|
||||
#
|
||||
# Generated by: https://openapi-generator.tech
|
||||
|
||||
#' @docType class
|
||||
#' @title User operations
|
||||
#' @description petstore.User
|
||||
#' @format An \code{R6Class} generator object
|
||||
#' @field apiClient Handles the client-server communication.
|
||||
#' @field api_client Handles the client-server communication.
|
||||
#'
|
||||
#' @section Methods:
|
||||
#' \describe{
|
||||
@ -196,7 +195,7 @@
|
||||
#' api.instance <- UserApi$new()
|
||||
#'
|
||||
#' #Configure API key authorization: api_key
|
||||
#' api.instance$apiClient$apiKeys['api_key'] <- 'TODO_YOUR_API_KEY';
|
||||
#' api.instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY';
|
||||
#'
|
||||
#' result <- api.instance$CreateUser(var.user)
|
||||
#'
|
||||
@ -210,7 +209,7 @@
|
||||
#' api.instance <- UserApi$new()
|
||||
#'
|
||||
#' #Configure API key authorization: api_key
|
||||
#' api.instance$apiClient$apiKeys['api_key'] <- 'TODO_YOUR_API_KEY';
|
||||
#' api.instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY';
|
||||
#'
|
||||
#' result <- api.instance$CreateUsersWithArrayInput(var.user)
|
||||
#'
|
||||
@ -224,7 +223,7 @@
|
||||
#' api.instance <- UserApi$new()
|
||||
#'
|
||||
#' #Configure API key authorization: api_key
|
||||
#' api.instance$apiClient$apiKeys['api_key'] <- 'TODO_YOUR_API_KEY';
|
||||
#' api.instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY';
|
||||
#'
|
||||
#' result <- api.instance$CreateUsersWithListInput(var.user)
|
||||
#'
|
||||
@ -238,7 +237,7 @@
|
||||
#' api.instance <- UserApi$new()
|
||||
#'
|
||||
#' #Configure API key authorization: api_key
|
||||
#' api.instance$apiClient$apiKeys['api_key'] <- 'TODO_YOUR_API_KEY';
|
||||
#' api.instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY';
|
||||
#'
|
||||
#' result <- api.instance$DeleteUser(var.username)
|
||||
#'
|
||||
@ -274,7 +273,7 @@
|
||||
#' api.instance <- UserApi$new()
|
||||
#'
|
||||
#' #Configure API key authorization: api_key
|
||||
#' api.instance$apiClient$apiKeys['api_key'] <- 'TODO_YOUR_API_KEY';
|
||||
#' api.instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY';
|
||||
#'
|
||||
#' result <- api.instance$LogoutUser()
|
||||
#'
|
||||
@ -289,7 +288,7 @@
|
||||
#' api.instance <- UserApi$new()
|
||||
#'
|
||||
#' #Configure API key authorization: api_key
|
||||
#' api.instance$apiClient$apiKeys['api_key'] <- 'TODO_YOUR_API_KEY';
|
||||
#' api.instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY';
|
||||
#'
|
||||
#' result <- api.instance$UpdateUser(var.username, var.user)
|
||||
#'
|
||||
@ -299,35 +298,35 @@
|
||||
#' @importFrom base64enc base64encode
|
||||
#' @export
|
||||
UserApi <- R6::R6Class(
|
||||
'UserApi',
|
||||
"UserApi",
|
||||
public = list(
|
||||
apiClient = NULL,
|
||||
initialize = function(apiClient){
|
||||
if (!missing(apiClient)) {
|
||||
self$apiClient <- apiClient
|
||||
api_client = NULL,
|
||||
initialize = function(api_client) {
|
||||
if (!missing(api_client)) {
|
||||
self$api_client <- api_client
|
||||
}
|
||||
else {
|
||||
self$apiClient <- ApiClient$new()
|
||||
self$api_client <- ApiClient$new()
|
||||
}
|
||||
},
|
||||
CreateUser = function(user, ...){
|
||||
apiResponse <- self$CreateUserWithHttpInfo(user, ...)
|
||||
resp <- apiResponse$response
|
||||
CreateUser = function(user, ...) {
|
||||
api_response <- self$CreateUserWithHttpInfo(user, ...)
|
||||
resp <- api_response$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
api_response$content
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
api_response
|
||||
}
|
||||
},
|
||||
|
||||
CreateUserWithHttpInfo = function(user, ...){
|
||||
CreateUserWithHttpInfo = function(user, ...) {
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
query_params <- list()
|
||||
header_params <- c()
|
||||
|
||||
if (missing(`user`)) {
|
||||
stop("Missing required parameter `user`.")
|
||||
@ -339,220 +338,220 @@ UserApi <- R6::R6Class(
|
||||
body <- NULL
|
||||
}
|
||||
|
||||
urlPath <- "/user"
|
||||
url_path <- "/user"
|
||||
# API key authentication
|
||||
if ("api_key" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["api_key"]) > 0) {
|
||||
headerParams['api_key'] <- paste(unlist(self$apiClient$apiKeys["api_key"]), collapse='')
|
||||
if ("api_key" %in% names(self$api_client$api_keys) && nchar(self$api_client$api_keys["api_key"]) > 0) {
|
||||
header_params["api_key"] <- paste(unlist(self$api_client$api_keys["api_key"]), collapse = "")
|
||||
}
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path),
|
||||
method = "POST",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
query_params = query_params,
|
||||
header_params = header_params,
|
||||
body = body,
|
||||
...)
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
ApiResponse$new(NULL, resp)
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
ApiResponse$new(paste("Server returned ", httr::status_code(resp), " response status code."), resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
},
|
||||
CreateUsersWithArrayInput = function(user, ...){
|
||||
apiResponse <- self$CreateUsersWithArrayInputWithHttpInfo(user, ...)
|
||||
resp <- apiResponse$response
|
||||
CreateUsersWithArrayInput = function(user, ...) {
|
||||
api_response <- self$CreateUsersWithArrayInputWithHttpInfo(user, ...)
|
||||
resp <- api_response$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
api_response$content
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
api_response
|
||||
}
|
||||
},
|
||||
|
||||
CreateUsersWithArrayInputWithHttpInfo = function(user, ...){
|
||||
CreateUsersWithArrayInputWithHttpInfo = function(user, ...) {
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
query_params <- list()
|
||||
header_params <- c()
|
||||
|
||||
if (missing(`user`)) {
|
||||
stop("Missing required parameter `user`.")
|
||||
}
|
||||
|
||||
if (!missing(`user`)) {
|
||||
body.items = paste(unlist(lapply(user, function(param){param$toJSONString()})), collapse = ",")
|
||||
body <- paste0('[', body.items, ']')
|
||||
body.items = paste(unlist(lapply(user, function(param) {param$toJSONString()})), collapse = ",")
|
||||
body <- paste0("[", body.items, "]")
|
||||
} else {
|
||||
body <- NULL
|
||||
}
|
||||
|
||||
urlPath <- "/user/createWithArray"
|
||||
url_path <- "/user/createWithArray"
|
||||
# API key authentication
|
||||
if ("api_key" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["api_key"]) > 0) {
|
||||
headerParams['api_key'] <- paste(unlist(self$apiClient$apiKeys["api_key"]), collapse='')
|
||||
if ("api_key" %in% names(self$api_client$api_keys) && nchar(self$api_client$api_keys["api_key"]) > 0) {
|
||||
header_params["api_key"] <- paste(unlist(self$api_client$api_keys["api_key"]), collapse = "")
|
||||
}
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path),
|
||||
method = "POST",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
query_params = query_params,
|
||||
header_params = header_params,
|
||||
body = body,
|
||||
...)
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
ApiResponse$new(NULL, resp)
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
ApiResponse$new(paste("Server returned ", httr::status_code(resp), " response status code."), resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
},
|
||||
CreateUsersWithListInput = function(user, ...){
|
||||
apiResponse <- self$CreateUsersWithListInputWithHttpInfo(user, ...)
|
||||
resp <- apiResponse$response
|
||||
CreateUsersWithListInput = function(user, ...) {
|
||||
api_response <- self$CreateUsersWithListInputWithHttpInfo(user, ...)
|
||||
resp <- api_response$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
api_response$content
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
api_response
|
||||
}
|
||||
},
|
||||
|
||||
CreateUsersWithListInputWithHttpInfo = function(user, ...){
|
||||
CreateUsersWithListInputWithHttpInfo = function(user, ...) {
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
query_params <- list()
|
||||
header_params <- c()
|
||||
|
||||
if (missing(`user`)) {
|
||||
stop("Missing required parameter `user`.")
|
||||
}
|
||||
|
||||
if (!missing(`user`)) {
|
||||
body.items = paste(unlist(lapply(user, function(param){param$toJSONString()})), collapse = ",")
|
||||
body <- paste0('[', body.items, ']')
|
||||
body.items = paste(unlist(lapply(user, function(param) {param$toJSONString()})), collapse = ",")
|
||||
body <- paste0("[", body.items, "]")
|
||||
} else {
|
||||
body <- NULL
|
||||
}
|
||||
|
||||
urlPath <- "/user/createWithList"
|
||||
url_path <- "/user/createWithList"
|
||||
# API key authentication
|
||||
if ("api_key" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["api_key"]) > 0) {
|
||||
headerParams['api_key'] <- paste(unlist(self$apiClient$apiKeys["api_key"]), collapse='')
|
||||
if ("api_key" %in% names(self$api_client$api_keys) && nchar(self$api_client$api_keys["api_key"]) > 0) {
|
||||
header_params["api_key"] <- paste(unlist(self$api_client$api_keys["api_key"]), collapse = "")
|
||||
}
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path),
|
||||
method = "POST",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
query_params = query_params,
|
||||
header_params = header_params,
|
||||
body = body,
|
||||
...)
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
ApiResponse$new(NULL, resp)
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
ApiResponse$new(paste("Server returned ", httr::status_code(resp), " response status code."), resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
},
|
||||
DeleteUser = function(username, ...){
|
||||
apiResponse <- self$DeleteUserWithHttpInfo(username, ...)
|
||||
resp <- apiResponse$response
|
||||
DeleteUser = function(username, ...) {
|
||||
api_response <- self$DeleteUserWithHttpInfo(username, ...)
|
||||
resp <- api_response$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
api_response$content
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
api_response
|
||||
}
|
||||
},
|
||||
|
||||
DeleteUserWithHttpInfo = function(username, ...){
|
||||
DeleteUserWithHttpInfo = function(username, ...) {
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
query_params <- list()
|
||||
header_params <- c()
|
||||
|
||||
if (missing(`username`)) {
|
||||
stop("Missing required parameter `username`.")
|
||||
}
|
||||
|
||||
body <- NULL
|
||||
urlPath <- "/user/{username}"
|
||||
url_path <- "/user/{username}"
|
||||
if (!missing(`username`)) {
|
||||
urlPath <- gsub(paste0("\\{", "username", "\\}"), URLencode(as.character(`username`), reserved = TRUE), urlPath)
|
||||
url_path <- gsub(paste0("\\{", "username", "\\}"), URLencode(as.character(`username`), reserved = TRUE), url_path)
|
||||
}
|
||||
|
||||
# API key authentication
|
||||
if ("api_key" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["api_key"]) > 0) {
|
||||
headerParams['api_key'] <- paste(unlist(self$apiClient$apiKeys["api_key"]), collapse='')
|
||||
if ("api_key" %in% names(self$api_client$api_keys) && nchar(self$api_client$api_keys["api_key"]) > 0) {
|
||||
header_params["api_key"] <- paste(unlist(self$api_client$api_keys["api_key"]), collapse = "")
|
||||
}
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path),
|
||||
method = "DELETE",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
query_params = query_params,
|
||||
header_params = header_params,
|
||||
body = body,
|
||||
...)
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
ApiResponse$new(NULL, resp)
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
ApiResponse$new(paste("Server returned ", httr::status_code(resp), " response status code."), resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
},
|
||||
GetUserByName = function(username, data_file=NULL, ...){
|
||||
apiResponse <- self$GetUserByNameWithHttpInfo(username, data_file=data_file, ...)
|
||||
resp <- apiResponse$response
|
||||
GetUserByName = function(username, data_file=NULL, ...) {
|
||||
api_response <- self$GetUserByNameWithHttpInfo(username, data_file = data_file, ...)
|
||||
resp <- api_response$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
api_response$content
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
api_response
|
||||
}
|
||||
},
|
||||
|
||||
GetUserByNameWithHttpInfo = function(username, data_file=NULL, ...){
|
||||
GetUserByNameWithHttpInfo = function(username, data_file = NULL, ...) {
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
query_params <- list()
|
||||
header_params <- c()
|
||||
|
||||
if (missing(`username`)) {
|
||||
stop("Missing required parameter `username`.")
|
||||
}
|
||||
|
||||
body <- NULL
|
||||
urlPath <- "/user/{username}"
|
||||
url_path <- "/user/{username}"
|
||||
if (!missing(`username`)) {
|
||||
urlPath <- gsub(paste0("\\{", "username", "\\}"), URLencode(as.character(`username`), reserved = TRUE), urlPath)
|
||||
url_path <- gsub(paste0("\\{", "username", "\\}"), URLencode(as.character(`username`), reserved = TRUE), url_path)
|
||||
}
|
||||
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path),
|
||||
method = "GET",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
query_params = query_params,
|
||||
header_params = header_params,
|
||||
body = body,
|
||||
...)
|
||||
|
||||
@ -562,39 +561,39 @@ UserApi <- R6::R6Class(
|
||||
write(httr::content(resp, "text", encoding = "UTF-8", simplifyVector = FALSE), data_file)
|
||||
}
|
||||
|
||||
deserializedRespObj <- tryCatch(
|
||||
self$apiClient$deserialize(resp, "User", loadNamespace("petstore")),
|
||||
error = function(e){
|
||||
deserialized_resp_obj <- tryCatch(
|
||||
self$api_client$deserialize(resp, "User", loadNamespace("petstore")),
|
||||
error = function(e) {
|
||||
stop("Failed to deserialize response")
|
||||
}
|
||||
)
|
||||
ApiResponse$new(deserializedRespObj, resp)
|
||||
ApiResponse$new(deserialized_resp_obj, resp)
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
ApiResponse$new(paste("Server returned ", httr::status_code(resp), " response status code."), resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
},
|
||||
LoginUser = function(username, password, data_file=NULL, ...){
|
||||
apiResponse <- self$LoginUserWithHttpInfo(username, password, data_file=data_file, ...)
|
||||
resp <- apiResponse$response
|
||||
LoginUser = function(username, password, data_file=NULL, ...) {
|
||||
api_response <- self$LoginUserWithHttpInfo(username, password, data_file = data_file, ...)
|
||||
resp <- api_response$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
api_response$content
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
api_response
|
||||
}
|
||||
},
|
||||
|
||||
LoginUserWithHttpInfo = function(username, password, data_file=NULL, ...){
|
||||
LoginUserWithHttpInfo = function(username, password, data_file = NULL, ...) {
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
query_params <- list()
|
||||
header_params <- c()
|
||||
|
||||
if (missing(`username`)) {
|
||||
stop("Missing required parameter `username`.")
|
||||
@ -604,17 +603,13 @@ UserApi <- R6::R6Class(
|
||||
stop("Missing required parameter `password`.")
|
||||
}
|
||||
|
||||
queryParams['username'] <- username
|
||||
|
||||
queryParams['password'] <- password
|
||||
|
||||
body <- NULL
|
||||
urlPath <- "/user/login"
|
||||
url_path <- "/user/login"
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path),
|
||||
method = "GET",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
query_params = query_params,
|
||||
header_params = header_params,
|
||||
body = body,
|
||||
...)
|
||||
|
||||
@ -624,82 +619,82 @@ UserApi <- R6::R6Class(
|
||||
write(httr::content(resp, "text", encoding = "UTF-8", simplifyVector = FALSE), data_file)
|
||||
}
|
||||
|
||||
deserializedRespObj <- tryCatch(
|
||||
self$apiClient$deserialize(resp, "character", loadNamespace("petstore")),
|
||||
error = function(e){
|
||||
deserialized_resp_obj <- tryCatch(
|
||||
self$api_client$deserialize(resp, "character", loadNamespace("petstore")),
|
||||
error = function(e) {
|
||||
stop("Failed to deserialize response")
|
||||
}
|
||||
)
|
||||
ApiResponse$new(deserializedRespObj, resp)
|
||||
ApiResponse$new(deserialized_resp_obj, resp)
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
ApiResponse$new(paste("Server returned ", httr::status_code(resp), " response status code."), resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
},
|
||||
LogoutUser = function(...){
|
||||
apiResponse <- self$LogoutUserWithHttpInfo(...)
|
||||
resp <- apiResponse$response
|
||||
LogoutUser = function(...) {
|
||||
api_response <- self$LogoutUserWithHttpInfo(...)
|
||||
resp <- api_response$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
api_response$content
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
api_response
|
||||
}
|
||||
},
|
||||
|
||||
LogoutUserWithHttpInfo = function(...){
|
||||
LogoutUserWithHttpInfo = function(...) {
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
query_params <- list()
|
||||
header_params <- c()
|
||||
|
||||
body <- NULL
|
||||
urlPath <- "/user/logout"
|
||||
url_path <- "/user/logout"
|
||||
# API key authentication
|
||||
if ("api_key" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["api_key"]) > 0) {
|
||||
headerParams['api_key'] <- paste(unlist(self$apiClient$apiKeys["api_key"]), collapse='')
|
||||
if ("api_key" %in% names(self$api_client$api_keys) && nchar(self$api_client$api_keys["api_key"]) > 0) {
|
||||
header_params["api_key"] <- paste(unlist(self$api_client$api_keys["api_key"]), collapse = "")
|
||||
}
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path),
|
||||
method = "GET",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
query_params = query_params,
|
||||
header_params = header_params,
|
||||
body = body,
|
||||
...)
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
ApiResponse$new(NULL, resp)
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
ApiResponse$new(paste("Server returned ", httr::status_code(resp), " response status code."), resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
ApiResponse$new("API server error", resp)
|
||||
}
|
||||
},
|
||||
UpdateUser = function(username, user, ...){
|
||||
apiResponse <- self$UpdateUserWithHttpInfo(username, user, ...)
|
||||
resp <- apiResponse$response
|
||||
UpdateUser = function(username, user, ...) {
|
||||
api_response <- self$UpdateUserWithHttpInfo(username, user, ...)
|
||||
resp <- api_response$response
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
apiResponse$content
|
||||
api_response$content
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
apiResponse
|
||||
api_response
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
apiResponse
|
||||
api_response
|
||||
}
|
||||
},
|
||||
|
||||
UpdateUserWithHttpInfo = function(username, user, ...){
|
||||
UpdateUserWithHttpInfo = function(username, user, ...) {
|
||||
args <- list(...)
|
||||
queryParams <- list()
|
||||
headerParams <- c()
|
||||
query_params <- list()
|
||||
header_params <- c()
|
||||
|
||||
if (missing(`username`)) {
|
||||
stop("Missing required parameter `username`.")
|
||||
@ -715,27 +710,27 @@ UserApi <- R6::R6Class(
|
||||
body <- NULL
|
||||
}
|
||||
|
||||
urlPath <- "/user/{username}"
|
||||
url_path <- "/user/{username}"
|
||||
if (!missing(`username`)) {
|
||||
urlPath <- gsub(paste0("\\{", "username", "\\}"), URLencode(as.character(`username`), reserved = TRUE), urlPath)
|
||||
url_path <- gsub(paste0("\\{", "username", "\\}"), URLencode(as.character(`username`), reserved = TRUE), url_path)
|
||||
}
|
||||
|
||||
# API key authentication
|
||||
if ("api_key" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["api_key"]) > 0) {
|
||||
headerParams['api_key'] <- paste(unlist(self$apiClient$apiKeys["api_key"]), collapse='')
|
||||
if ("api_key" %in% names(self$api_client$api_keys) && nchar(self$api_client$api_keys["api_key"]) > 0) {
|
||||
header_params["api_key"] <- paste(unlist(self$api_client$api_keys["api_key"]), collapse = "")
|
||||
}
|
||||
|
||||
resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
|
||||
resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, url_path),
|
||||
method = "PUT",
|
||||
queryParams = queryParams,
|
||||
headerParams = headerParams,
|
||||
query_params = query_params,
|
||||
header_params = header_params,
|
||||
body = body,
|
||||
...)
|
||||
|
||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||
ApiResponse$new(NULL, resp)
|
||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
||||
ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
|
||||
ApiResponse$new(paste("Server returned ", httr::status_code(resp), " response status code."), resp)
|
||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||
ApiResponse$new("API client error", resp)
|
||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||
|
@ -1,19 +1,19 @@
|
||||
context("basic functionality")
|
||||
petApi <- PetApi$new()
|
||||
petId <- 123321
|
||||
pet_api <- PetApi$new()
|
||||
pet_id <- 123321
|
||||
pet <- Pet$new("name_test",
|
||||
photoUrls = list("photo_test", "second test"),
|
||||
category = Category$new(id=450, name="test_cat"),
|
||||
id = petId,
|
||||
category = Category$new(id = 450, name = "test_cat"),
|
||||
id = pet_id,
|
||||
tags = list(
|
||||
Tag$new(id=123, name="tag_test"), Tag$new(id=456, name="unknown")
|
||||
Tag$new(id = 123, name = "tag_test"), Tag$new(id = 456, name = "unknown")
|
||||
),
|
||||
status = "available"
|
||||
)
|
||||
result <- petApi$AddPet(pet)
|
||||
result <- pet_api$AddPet(pet)
|
||||
|
||||
test_that("AddPet", {
|
||||
expect_equal(petId, 123321)
|
||||
expect_equal(pet_id, 123321)
|
||||
#expect_equal(result, NULL)
|
||||
})
|
||||
|
||||
@ -21,7 +21,7 @@ test_that("Test toJSON toJSON fromJSON fromJSONString", {
|
||||
pet0 <- Pet$new()
|
||||
jsonpet <- pet0$toJSON()
|
||||
pet2 <- pet0$fromJSON(
|
||||
jsonlite::toJSON(jsonpet, auto_unbox=TRUE)
|
||||
jsonlite::toJSON(jsonpet, auto_unbox = TRUE)
|
||||
)
|
||||
expect_equal(pet0, pet2)
|
||||
jsonpet <- pet0$toJSONString()
|
||||
@ -38,16 +38,16 @@ test_that("Test toJSON toJSON fromJSON fromJSONString", {
|
||||
|
||||
pet1 <- Pet$new("name_test",
|
||||
list("photo_test", "second test"),
|
||||
category = Category$new(id=450, name="test_cat"),
|
||||
id = petId,
|
||||
category = Category$new(id = 450, name = "test_cat"),
|
||||
id = pet_id,
|
||||
tags = list(
|
||||
Tag$new(id=123, name="tag_test"), Tag$new(id=456, name="unknown")
|
||||
Tag$new(id = 123, name = "tag_test"), Tag$new(id = 456, name = "unknown")
|
||||
),
|
||||
status = "available"
|
||||
)
|
||||
jsonpet <- pet1$toJSON()
|
||||
pet2 <- pet1$fromJSON(
|
||||
jsonlite::toJSON(jsonpet, auto_unbox=TRUE)
|
||||
jsonlite::toJSON(jsonpet, auto_unbox = TRUE)
|
||||
)
|
||||
expect_equal(pet1, pet2)
|
||||
|
||||
@ -65,38 +65,38 @@ test_that("Test toJSON toJSON fromJSON fromJSONString", {
|
||||
})
|
||||
|
||||
test_that("Test Category", {
|
||||
c1 <- Category$new(id=450, name="test_cat")
|
||||
c1 <- Category$new(id = 450, name = "test_cat")
|
||||
c2 <- Category$new()
|
||||
c2$fromJSON(jsonlite::toJSON(c1$toJSON(), auto_unbox=TRUE))
|
||||
c2$fromJSON(jsonlite::toJSON(c1$toJSON(), auto_unbox = TRUE))
|
||||
expect_equal(c1, c2)
|
||||
c2$fromJSONString(c1$toJSONString())
|
||||
expect_equal(c1, c2)
|
||||
})
|
||||
|
||||
test_that("GetPetById", {
|
||||
response <- petApi$GetPetById(petId)
|
||||
expect_equal(response$id, petId)
|
||||
response <- pet_api$GetPetById(pet_id)
|
||||
expect_equal(response$id, pet_id)
|
||||
expect_equal(response$name, "name_test")
|
||||
expect_equal(
|
||||
response$photoUrls,
|
||||
list("photo_test", "second test")
|
||||
)
|
||||
expect_equal(response$status, "available")
|
||||
expect_equal(response$category, Category$new(id=450, name="test_cat"))
|
||||
expect_equal(response$category, Category$new(id = 450, name = "test_cat"))
|
||||
|
||||
expect_equal(pet$tags, response$tags)
|
||||
expect_equal(
|
||||
response$tags,
|
||||
list(Tag$new(id=123, name="tag_test"), Tag$new(id=456, name="unknown"))
|
||||
list(Tag$new(id = 123, name = "tag_test"), Tag$new(id = 456, name = "unknown"))
|
||||
)
|
||||
})
|
||||
|
||||
test_that("GetPetById with data_file", {
|
||||
# test to ensure json is saved to the file `get_pet_by_id.json`
|
||||
petResponse <- petApi$GetPetById(petId, data_file="get_pet_by_id.json")
|
||||
pet_response <- pet_api$GetPetById(pet_id, data_file = "get_pet_by_id.json")
|
||||
response <- read_json("get_pet_by_id.json")
|
||||
expect_true(!is.null(response))
|
||||
expect_equal(response$id, petId)
|
||||
expect_equal(response$id, pet_id)
|
||||
expect_equal(response$name, "name_test")
|
||||
})
|
||||
|
||||
@ -105,9 +105,9 @@ test_that("GetPetById with data_file", {
|
||||
# pet <- Pet$new(pet.id, NULL, "name_test2",
|
||||
# list("photo_test2", "second test2"),
|
||||
# NULL, NULL)
|
||||
# result <-petApi$AddPet(pet)
|
||||
# result <-pet_api$AddPet(pet)
|
||||
#
|
||||
# response <- petApi$GetPetById(pet.id)
|
||||
# response <- pet_api$GetPetById(pet.id)
|
||||
#
|
||||
# expect_equal(response$id, pet.id)
|
||||
# expect_equal(response$name, "name_test2")
|
||||
@ -118,6 +118,6 @@ test_that("GetPetById with data_file", {
|
||||
#})
|
||||
|
||||
#test_that("updatePetWithForm", {
|
||||
# response <- petApi$updatePetWithForm(petId, "test", "sold")
|
||||
# response <- pet_api$updatePetWithForm(pet_id, "test", "sold")
|
||||
# expect_equal(response, "Pet updated")
|
||||
#})
|
||||
|
Loading…
x
Reference in New Issue
Block a user