forked from loafle/openapi-generator-original
Update R auto-generated doc (#12488)
* update r doc, tests * add new files
This commit is contained in:
parent
05d49d9107
commit
f0ea10f239
@ -5,3 +5,6 @@ templateDir: modules/openapi-generator/src/main/resources/r
|
|||||||
httpUserAgent: PetstoreAgent
|
httpUserAgent: PetstoreAgent
|
||||||
additionalProperties:
|
additionalProperties:
|
||||||
packageName: petstore
|
packageName: petstore
|
||||||
|
exceptionPackage: rlang
|
||||||
|
useRlangExceptionHandling: true
|
||||||
|
returnExceptionOnFailure: true
|
||||||
|
@ -22,53 +22,53 @@ Method | HTTP request | Description
|
|||||||
library({{{packageName}}})
|
library({{{packageName}}})
|
||||||
|
|
||||||
{{#allParams}}
|
{{#allParams}}
|
||||||
var.{{{paramName}}} <- {{{vendorExtensions.x-r-example}}} # {{{dataType}}} | {{{description}}}
|
var_{{{paramName}}} <- {{{vendorExtensions.x-r-example}}} # {{{dataType}}} | {{{description}}}
|
||||||
{{/allParams}}
|
{{/allParams}}
|
||||||
|
|
||||||
{{#summary}}
|
{{#summary}}
|
||||||
#{{{.}}}
|
#{{{.}}}
|
||||||
{{/summary}}
|
{{/summary}}
|
||||||
api.instance <- {{{classname}}}$new()
|
api_instance <- {{{classname}}}$new()
|
||||||
{{#hasAuthMethods}}
|
{{#hasAuthMethods}}
|
||||||
{{#authMethods}}
|
{{#authMethods}}
|
||||||
{{#isBasic}}
|
{{#isBasic}}
|
||||||
# Configure HTTP basic authorization: {{{name}}}
|
# Configure HTTP basic authorization: {{{name}}}
|
||||||
api.instance$apiClient$username <- 'TODO_YOUR_USERNAME';
|
api_instance$api_client$username <- 'TODO_YOUR_USERNAME';
|
||||||
api.instance$apiClient$password <- 'TODO_YOUR_PASSWORD';
|
api_instance$api_client$password <- 'TODO_YOUR_PASSWORD';
|
||||||
{{/isBasic}}
|
{{/isBasic}}
|
||||||
{{#isApiKey}}
|
{{#isApiKey}}
|
||||||
# Configure API key authorization: {{{name}}}
|
# 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}}
|
{{/isApiKey}}
|
||||||
{{#isOAuth}}
|
{{#isOAuth}}
|
||||||
# Configure OAuth2 access token for authorization: {{{name}}}
|
# 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}}
|
{{/isOAuth}}
|
||||||
{{/authMethods}}
|
{{/authMethods}}
|
||||||
{{/hasAuthMethods}}
|
{{/hasAuthMethods}}
|
||||||
{{#returnExceptionOnFailure}}
|
{{#returnExceptionOnFailure}}
|
||||||
{{#useRlangExceptionHandling}}
|
{{#useRlangExceptionHandling}}
|
||||||
result <- tryCatch(
|
result <- tryCatch(
|
||||||
api.instance${{{operationId}}}({{#requiredParams}}var.{{{paramName}}}{{^-last}}, {{/-last}}{{/requiredParams}}{{#optionalParams}}{{#-first}}{{#requiredParams.0}}, {{/requiredParams.0}}{{/-first}}{{{paramName}}}=var.{{{paramName}}}{{^-last}}, {{/-last}}{{/optionalParams}}),
|
api_instance${{{operationId}}}({{#requiredParams}}var_{{{paramName}}}{{^-last}}, {{/-last}}{{/requiredParams}}{{#optionalParams}}{{#-first}}{{#requiredParams.0}}, {{/requiredParams.0}}{{/-first}}{{{paramName}}}=var_{{{paramName}}}{{^-last}}, {{/-last}}{{/optionalParams}}),
|
||||||
ApiException = function(ex) ex
|
ApiException = function(ex) ex
|
||||||
)
|
)
|
||||||
# In case of error, print the error object
|
# In case of error, print the error object
|
||||||
if(!is.null(result$ApiException)) {
|
if(!is.null(result$ApiException)) {
|
||||||
cat(result$ApiException$toString())
|
cat(result$ApiException$toString())
|
||||||
} else {
|
} else {
|
||||||
{{#returnType}}
|
{{#returnType}}
|
||||||
# deserialized response object
|
# deserialized response object
|
||||||
response.object <- result$content
|
response.object <- result$content
|
||||||
{{/returnType}}
|
{{/returnType}}
|
||||||
# response headers
|
# response headers
|
||||||
response.headers <- result$response$headers
|
response.headers <- result$response$headers
|
||||||
# response status code
|
# response status code
|
||||||
response.status.code <- result$response$status_code
|
response.status.code <- result$response$status_code
|
||||||
}
|
}
|
||||||
{{/useRlangExceptionHandling}}
|
{{/useRlangExceptionHandling}}
|
||||||
{{/returnExceptionOnFailure}}
|
{{/returnExceptionOnFailure}}
|
||||||
{{^useRlangExceptionHandling}}
|
{{^useRlangExceptionHandling}}
|
||||||
{{#returnType}}result <- {{/returnType}}api.instance${{{operationId}}}({{#requiredParams}}var.{{{paramName}}}{{^-last}}, {{/-last}}{{/requiredParams}}{{#optionalParams}}{{#-first}}{{#requiredParams.0}}, {{/requiredParams.0}}{{/-first}}{{{paramName}}}=var.{{{paramName}}}{{^-last}}, {{/-last}}{{/optionalParams}})
|
{{#returnType}}result <- {{/returnType}}api_instance${{{operationId}}}({{#requiredParams}}var_{{{paramName}}}{{^-last}}, {{/-last}}{{/requiredParams}}{{#optionalParams}}{{#-first}}{{#requiredParams.0}}, {{/requiredParams.0}}{{/-first}}{{{paramName}}}=var_{{{paramName}}}{{^-last}}, {{/-last}}{{/optionalParams}})
|
||||||
{{#returnType}}
|
{{#returnType}}
|
||||||
dput(result)
|
dput(result)
|
||||||
{{/returnType}}
|
{{/returnType}}
|
||||||
|
@ -6,6 +6,7 @@ NAMESPACE
|
|||||||
R/allof_tag_api_response.R
|
R/allof_tag_api_response.R
|
||||||
R/animal.R
|
R/animal.R
|
||||||
R/api_client.R
|
R/api_client.R
|
||||||
|
R/api_exception.R
|
||||||
R/api_response.R
|
R/api_response.R
|
||||||
R/cat.R
|
R/cat.R
|
||||||
R/cat_all_of.R
|
R/cat_all_of.R
|
||||||
|
@ -11,5 +11,5 @@ Encoding: UTF-8
|
|||||||
License: Apache License 2.0
|
License: Apache License 2.0
|
||||||
LazyData: true
|
LazyData: true
|
||||||
Suggests: testthat
|
Suggests: testthat
|
||||||
Imports: jsonlite, httr, R6, base64enc
|
Imports: jsonlite, httr, R6, base64enc, rlang
|
||||||
RoxygenNote: 6.0.1.9000
|
RoxygenNote: 6.0.1.9000
|
||||||
|
@ -9,6 +9,7 @@ import(base64enc)
|
|||||||
# Core
|
# Core
|
||||||
export(ApiClient)
|
export(ApiClient)
|
||||||
export(ApiResponse)
|
export(ApiResponse)
|
||||||
|
export(ApiException)
|
||||||
|
|
||||||
# Models
|
# Models
|
||||||
export(AllofTagApiResponse)
|
export(AllofTagApiResponse)
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#' @field retry_status_codes vector of status codes to retry
|
#' @field retry_status_codes vector of status codes to retry
|
||||||
#' @field max_retry_attempts maximum number of retries for the status codes
|
#' @field max_retry_attempts maximum number of retries for the status codes
|
||||||
#' @importFrom httr add_headers accept timeout content
|
#' @importFrom httr add_headers accept timeout content
|
||||||
|
#' @importFrom rlang abort
|
||||||
#' @export
|
#' @export
|
||||||
ApiClient <- R6::R6Class(
|
ApiClient <- R6::R6Class(
|
||||||
"ApiClient",
|
"ApiClient",
|
||||||
@ -152,7 +153,7 @@ ApiClient <- R6::R6Class(
|
|||||||
httr::DELETE(url, query = query_params, headers, http_timeout, http_timeout, httr::user_agent(self$`user_agent`), ...)
|
httr::DELETE(url, query = query_params, headers, http_timeout, http_timeout, httr::user_agent(self$`user_agent`), ...)
|
||||||
} else {
|
} else {
|
||||||
err_msg <- "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`."
|
||||||
stop(err_msg)
|
rlang::abort(message = err_msg, .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = err_msg))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
54
samples/client/petstore/R/R/api_exception.R
Normal file
54
samples/client/petstore/R/R/api_exception.R
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
#' @docType class
|
||||||
|
#' @title ApiException
|
||||||
|
#' @description ApiException Class
|
||||||
|
#' @format An \code{R6Class} generator object
|
||||||
|
#' @field status Status of the ApiException
|
||||||
|
#' @field reason Reason of the ApiException
|
||||||
|
#' @field body Body of the http response
|
||||||
|
#' @field headers Headers of the http response
|
||||||
|
#' @export
|
||||||
|
ApiException <- R6::R6Class(
|
||||||
|
"ApiException",
|
||||||
|
public = list(
|
||||||
|
status = NULL,
|
||||||
|
reason = NULL,
|
||||||
|
body = NULL,
|
||||||
|
headers = NULL,
|
||||||
|
|
||||||
|
initialize = function(status = NULL, reason = NULL, http_response = NULL) {
|
||||||
|
if (!is.null(http_response)) {
|
||||||
|
self$status <- http_response$status_code
|
||||||
|
errorMsg <- toString(content(http_response))
|
||||||
|
if(errorMsg == ""){
|
||||||
|
errorMsg <- "Api exception encountered."
|
||||||
|
}
|
||||||
|
self$body <- errorMsg
|
||||||
|
self$headers <- http_response$headers
|
||||||
|
self$reason <- httr::http_status(http_response)$reason
|
||||||
|
} else {
|
||||||
|
self$status <- status
|
||||||
|
self$reason <- reason
|
||||||
|
self$body <- NULL
|
||||||
|
self$headers <- NULL
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
# returns the string format of ApiException
|
||||||
|
toString = function() {
|
||||||
|
errorMsg <- ""
|
||||||
|
errorMsg <- paste("status : ", self$status, "\n", sep = "")
|
||||||
|
errorMsg <- paste(errorMsg, "Reason : ", self$reason, "\n", sep = "")
|
||||||
|
if (!is.null(self$headers)) {
|
||||||
|
errorMsg <- paste(errorMsg, "Headers : ", "\n", sep = "")
|
||||||
|
for (name in names(self$headers)) {
|
||||||
|
errorMsg <- paste(errorMsg, name, " : ", self$headers[[name]], "\n", sep = " ")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!is.null(self$body)) {
|
||||||
|
errorMsg <- paste(errorMsg, "Body : ", "\n", sep = "")
|
||||||
|
errorMsg <- paste(errorMsg, self$body,"\n")
|
||||||
|
}
|
||||||
|
errorMsg
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
@ -21,6 +21,7 @@
|
|||||||
#' \item \emph{ @param } var_data_file character
|
#' \item \emph{ @param } var_data_file character
|
||||||
#' \item \emph{ @returnType } \link{User} \cr
|
#' \item \emph{ @returnType } \link{User} \cr
|
||||||
#'
|
#'
|
||||||
|
#' \item On encountering errors, an error of subclass ApiException will be thrown.
|
||||||
#'
|
#'
|
||||||
#' \item status code : 200 | successful operation
|
#' \item status code : 200 | successful operation
|
||||||
#'
|
#'
|
||||||
@ -45,12 +46,27 @@
|
|||||||
#' #test data_file to ensure it's escaped correctly
|
#' #test data_file to ensure it's escaped correctly
|
||||||
#' api.instance <- FakeApi$new()
|
#' api.instance <- FakeApi$new()
|
||||||
#'
|
#'
|
||||||
#' result <- api.instance$FakeDataFile(var.dummy, var_data_file=var.var_data_file)
|
#'result <- tryCatch(
|
||||||
|
#' api.instance$FakeDataFile(var.dummy, var_data_file=var.var_data_file),
|
||||||
|
#' ApiException = function(ex) ex
|
||||||
|
#' )
|
||||||
|
#' # In case of error, print the error object
|
||||||
|
#' if(!is.null(result$ApiException)) {
|
||||||
|
#' cat(result$ApiException$toString())
|
||||||
|
#' } else {
|
||||||
|
#' # deserialized response object
|
||||||
|
#' response.object <- result$content
|
||||||
|
#' # response headers
|
||||||
|
#' response.headers <- result$response$headers
|
||||||
|
#' # response status code
|
||||||
|
#' response.status.code <- result$response$status_code
|
||||||
|
#' }
|
||||||
#'
|
#'
|
||||||
#'
|
#'
|
||||||
#' }
|
#' }
|
||||||
#' @importFrom R6 R6Class
|
#' @importFrom R6 R6Class
|
||||||
#' @importFrom base64enc base64encode
|
#' @importFrom base64enc base64encode
|
||||||
|
#' @importFrom rlang abort
|
||||||
#' @export
|
#' @export
|
||||||
FakeApi <- R6::R6Class(
|
FakeApi <- R6::R6Class(
|
||||||
"FakeApi",
|
"FakeApi",
|
||||||
@ -84,7 +100,7 @@ FakeApi <- R6::R6Class(
|
|||||||
header_params <- c()
|
header_params <- c()
|
||||||
|
|
||||||
if (missing(`dummy`)) {
|
if (missing(`dummy`)) {
|
||||||
stop("Missing required parameter `dummy`.")
|
rlang::abort(message = "Missing required parameter `dummy`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `dummy`."))
|
||||||
}
|
}
|
||||||
|
|
||||||
body <- NULL
|
body <- NULL
|
||||||
@ -106,16 +122,28 @@ FakeApi <- R6::R6Class(
|
|||||||
deserialized_resp_obj <- tryCatch(
|
deserialized_resp_obj <- tryCatch(
|
||||||
self$api_client$deserialize(resp, "User", loadNamespace("petstore")),
|
self$api_client$deserialize(resp, "User", loadNamespace("petstore")),
|
||||||
error = function(e) {
|
error = function(e) {
|
||||||
stop("Failed to deserialize response")
|
rlang::abort(message = "Failed to deserialize response", .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
ApiResponse$new(deserialized_resp_obj, resp)
|
ApiResponse$new(deserialized_resp_obj, resp)
|
||||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
} 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)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||||
ApiResponse$new("API client error", resp)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- "Api client exception encountered."
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||||
ApiResponse$new("API server error", resp)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- "Api server exception encountered."
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#' \item \emph{ @param } pet \link{Pet}
|
#' \item \emph{ @param } pet \link{Pet}
|
||||||
#' \item \emph{ @returnType } \link{Pet} \cr
|
#' \item \emph{ @returnType } \link{Pet} \cr
|
||||||
#'
|
#'
|
||||||
|
#' \item On encountering errors, an error of subclass ApiException will be thrown.
|
||||||
#'
|
#'
|
||||||
#' \item status code : 200 | successful operation
|
#' \item status code : 200 | successful operation
|
||||||
#'
|
#'
|
||||||
@ -44,6 +45,7 @@
|
|||||||
#' \item \emph{ @param } pet_id integer
|
#' \item \emph{ @param } pet_id integer
|
||||||
#' \item \emph{ @param } api_key character
|
#' \item \emph{ @param } api_key character
|
||||||
#'
|
#'
|
||||||
|
#' \item On encountering errors, an error of subclass ApiException will be thrown.
|
||||||
#'
|
#'
|
||||||
#' \item status code : 400 | Invalid pet value
|
#' \item status code : 400 | Invalid pet value
|
||||||
#'
|
#'
|
||||||
@ -61,6 +63,7 @@
|
|||||||
#' \item \emph{ @param } status Enum < [available, pending, sold] >
|
#' \item \emph{ @param } status Enum < [available, pending, sold] >
|
||||||
#' \item \emph{ @returnType } list( \link{Pet} ) \cr
|
#' \item \emph{ @returnType } list( \link{Pet} ) \cr
|
||||||
#'
|
#'
|
||||||
|
#' \item On encountering errors, an error of subclass ApiException will be thrown.
|
||||||
#'
|
#'
|
||||||
#' \item status code : 200 | successful operation
|
#' \item status code : 200 | successful operation
|
||||||
#'
|
#'
|
||||||
@ -85,6 +88,7 @@
|
|||||||
#' \item \emph{ @param } tags list( character )
|
#' \item \emph{ @param } tags list( character )
|
||||||
#' \item \emph{ @returnType } list( \link{Pet} ) \cr
|
#' \item \emph{ @returnType } list( \link{Pet} ) \cr
|
||||||
#'
|
#'
|
||||||
|
#' \item On encountering errors, an error of subclass ApiException will be thrown.
|
||||||
#'
|
#'
|
||||||
#' \item status code : 200 | successful operation
|
#' \item status code : 200 | successful operation
|
||||||
#'
|
#'
|
||||||
@ -109,6 +113,7 @@
|
|||||||
#' \item \emph{ @param } pet_id integer
|
#' \item \emph{ @param } pet_id integer
|
||||||
#' \item \emph{ @returnType } \link{Pet} \cr
|
#' \item \emph{ @returnType } \link{Pet} \cr
|
||||||
#'
|
#'
|
||||||
|
#' \item On encountering errors, an error of subclass ApiException will be thrown.
|
||||||
#'
|
#'
|
||||||
#' \item status code : 200 | successful operation
|
#' \item status code : 200 | successful operation
|
||||||
#'
|
#'
|
||||||
@ -140,6 +145,7 @@
|
|||||||
#' \item \emph{ @param } pet \link{Pet}
|
#' \item \emph{ @param } pet \link{Pet}
|
||||||
#' \item \emph{ @returnType } \link{Pet} \cr
|
#' \item \emph{ @returnType } \link{Pet} \cr
|
||||||
#'
|
#'
|
||||||
|
#' \item On encountering errors, an error of subclass ApiException will be thrown.
|
||||||
#'
|
#'
|
||||||
#' \item status code : 200 | successful operation
|
#' \item status code : 200 | successful operation
|
||||||
#'
|
#'
|
||||||
@ -179,6 +185,7 @@
|
|||||||
#' \item \emph{ @param } name character
|
#' \item \emph{ @param } name character
|
||||||
#' \item \emph{ @param } status character
|
#' \item \emph{ @param } status character
|
||||||
#'
|
#'
|
||||||
|
#' \item On encountering errors, an error of subclass ApiException will be thrown.
|
||||||
#'
|
#'
|
||||||
#' \item status code : 405 | Invalid input
|
#' \item status code : 405 | Invalid input
|
||||||
#'
|
#'
|
||||||
@ -198,6 +205,7 @@
|
|||||||
#' \item \emph{ @param } file data.frame
|
#' \item \emph{ @param } file data.frame
|
||||||
#' \item \emph{ @returnType } \link{ModelApiResponse} \cr
|
#' \item \emph{ @returnType } \link{ModelApiResponse} \cr
|
||||||
#'
|
#'
|
||||||
|
#' \item On encountering errors, an error of subclass ApiException will be thrown.
|
||||||
#'
|
#'
|
||||||
#' \item status code : 200 | successful operation
|
#' \item status code : 200 | successful operation
|
||||||
#'
|
#'
|
||||||
@ -224,7 +232,21 @@
|
|||||||
#' # Configure OAuth2 access token for authorization: petstore_auth
|
#' # Configure OAuth2 access token for authorization: petstore_auth
|
||||||
#' api.instance$api_client$access_token <- 'TODO_YOUR_ACCESS_TOKEN';
|
#' api.instance$api_client$access_token <- 'TODO_YOUR_ACCESS_TOKEN';
|
||||||
#'
|
#'
|
||||||
#' result <- api.instance$AddPet(var.pet)
|
#'result <- tryCatch(
|
||||||
|
#' api.instance$AddPet(var.pet),
|
||||||
|
#' ApiException = function(ex) ex
|
||||||
|
#' )
|
||||||
|
#' # In case of error, print the error object
|
||||||
|
#' if(!is.null(result$ApiException)) {
|
||||||
|
#' cat(result$ApiException$toString())
|
||||||
|
#' } else {
|
||||||
|
#' # deserialized response object
|
||||||
|
#' response.object <- result$content
|
||||||
|
#' # response headers
|
||||||
|
#' response.headers <- result$response$headers
|
||||||
|
#' # response status code
|
||||||
|
#' response.status.code <- result$response$status_code
|
||||||
|
#' }
|
||||||
#'
|
#'
|
||||||
#'
|
#'
|
||||||
#' #################### DeletePet ####################
|
#' #################### DeletePet ####################
|
||||||
@ -239,7 +261,19 @@
|
|||||||
#' # Configure OAuth2 access token for authorization: petstore_auth
|
#' # Configure OAuth2 access token for authorization: petstore_auth
|
||||||
#' api.instance$api_client$access_token <- '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)
|
#'result <- tryCatch(
|
||||||
|
#' api.instance$DeletePet(var.pet_id, api_key=var.api_key),
|
||||||
|
#' ApiException = function(ex) ex
|
||||||
|
#' )
|
||||||
|
#' # In case of error, print the error object
|
||||||
|
#' if(!is.null(result$ApiException)) {
|
||||||
|
#' cat(result$ApiException$toString())
|
||||||
|
#' } else {
|
||||||
|
#' # response headers
|
||||||
|
#' response.headers <- result$response$headers
|
||||||
|
#' # response status code
|
||||||
|
#' response.status.code <- result$response$status_code
|
||||||
|
#' }
|
||||||
#'
|
#'
|
||||||
#'
|
#'
|
||||||
#' #################### FindPetsByStatus ####################
|
#' #################### FindPetsByStatus ####################
|
||||||
@ -253,7 +287,21 @@
|
|||||||
#' # Configure OAuth2 access token for authorization: petstore_auth
|
#' # Configure OAuth2 access token for authorization: petstore_auth
|
||||||
#' api.instance$api_client$access_token <- 'TODO_YOUR_ACCESS_TOKEN';
|
#' api.instance$api_client$access_token <- 'TODO_YOUR_ACCESS_TOKEN';
|
||||||
#'
|
#'
|
||||||
#' result <- api.instance$FindPetsByStatus(var.status)
|
#'result <- tryCatch(
|
||||||
|
#' api.instance$FindPetsByStatus(var.status),
|
||||||
|
#' ApiException = function(ex) ex
|
||||||
|
#' )
|
||||||
|
#' # In case of error, print the error object
|
||||||
|
#' if(!is.null(result$ApiException)) {
|
||||||
|
#' cat(result$ApiException$toString())
|
||||||
|
#' } else {
|
||||||
|
#' # deserialized response object
|
||||||
|
#' response.object <- result$content
|
||||||
|
#' # response headers
|
||||||
|
#' response.headers <- result$response$headers
|
||||||
|
#' # response status code
|
||||||
|
#' response.status.code <- result$response$status_code
|
||||||
|
#' }
|
||||||
#'
|
#'
|
||||||
#'
|
#'
|
||||||
#' #################### FindPetsByTags ####################
|
#' #################### FindPetsByTags ####################
|
||||||
@ -267,7 +315,21 @@
|
|||||||
#' # Configure OAuth2 access token for authorization: petstore_auth
|
#' # Configure OAuth2 access token for authorization: petstore_auth
|
||||||
#' api.instance$api_client$access_token <- 'TODO_YOUR_ACCESS_TOKEN';
|
#' api.instance$api_client$access_token <- 'TODO_YOUR_ACCESS_TOKEN';
|
||||||
#'
|
#'
|
||||||
#' result <- api.instance$FindPetsByTags(var.tags)
|
#'result <- tryCatch(
|
||||||
|
#' api.instance$FindPetsByTags(var.tags),
|
||||||
|
#' ApiException = function(ex) ex
|
||||||
|
#' )
|
||||||
|
#' # In case of error, print the error object
|
||||||
|
#' if(!is.null(result$ApiException)) {
|
||||||
|
#' cat(result$ApiException$toString())
|
||||||
|
#' } else {
|
||||||
|
#' # deserialized response object
|
||||||
|
#' response.object <- result$content
|
||||||
|
#' # response headers
|
||||||
|
#' response.headers <- result$response$headers
|
||||||
|
#' # response status code
|
||||||
|
#' response.status.code <- result$response$status_code
|
||||||
|
#' }
|
||||||
#'
|
#'
|
||||||
#'
|
#'
|
||||||
#' #################### GetPetById ####################
|
#' #################### GetPetById ####################
|
||||||
@ -281,7 +343,21 @@
|
|||||||
#' #Configure API key authorization: api_key
|
#' #Configure API key authorization: api_key
|
||||||
#' api.instance$api_client$api_keys['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)
|
#'result <- tryCatch(
|
||||||
|
#' api.instance$GetPetById(var.pet_id),
|
||||||
|
#' ApiException = function(ex) ex
|
||||||
|
#' )
|
||||||
|
#' # In case of error, print the error object
|
||||||
|
#' if(!is.null(result$ApiException)) {
|
||||||
|
#' cat(result$ApiException$toString())
|
||||||
|
#' } else {
|
||||||
|
#' # deserialized response object
|
||||||
|
#' response.object <- result$content
|
||||||
|
#' # response headers
|
||||||
|
#' response.headers <- result$response$headers
|
||||||
|
#' # response status code
|
||||||
|
#' response.status.code <- result$response$status_code
|
||||||
|
#' }
|
||||||
#'
|
#'
|
||||||
#'
|
#'
|
||||||
#' #################### UpdatePet ####################
|
#' #################### UpdatePet ####################
|
||||||
@ -295,7 +371,21 @@
|
|||||||
#' # Configure OAuth2 access token for authorization: petstore_auth
|
#' # Configure OAuth2 access token for authorization: petstore_auth
|
||||||
#' api.instance$api_client$access_token <- 'TODO_YOUR_ACCESS_TOKEN';
|
#' api.instance$api_client$access_token <- 'TODO_YOUR_ACCESS_TOKEN';
|
||||||
#'
|
#'
|
||||||
#' result <- api.instance$UpdatePet(var.pet)
|
#'result <- tryCatch(
|
||||||
|
#' api.instance$UpdatePet(var.pet),
|
||||||
|
#' ApiException = function(ex) ex
|
||||||
|
#' )
|
||||||
|
#' # In case of error, print the error object
|
||||||
|
#' if(!is.null(result$ApiException)) {
|
||||||
|
#' cat(result$ApiException$toString())
|
||||||
|
#' } else {
|
||||||
|
#' # deserialized response object
|
||||||
|
#' response.object <- result$content
|
||||||
|
#' # response headers
|
||||||
|
#' response.headers <- result$response$headers
|
||||||
|
#' # response status code
|
||||||
|
#' response.status.code <- result$response$status_code
|
||||||
|
#' }
|
||||||
#'
|
#'
|
||||||
#'
|
#'
|
||||||
#' #################### UpdatePetWithForm ####################
|
#' #################### UpdatePetWithForm ####################
|
||||||
@ -311,7 +401,19 @@
|
|||||||
#' # Configure OAuth2 access token for authorization: petstore_auth
|
#' # Configure OAuth2 access token for authorization: petstore_auth
|
||||||
#' api.instance$api_client$access_token <- '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)
|
#'result <- tryCatch(
|
||||||
|
#' api.instance$UpdatePetWithForm(var.pet_id, name=var.name, status=var.status),
|
||||||
|
#' ApiException = function(ex) ex
|
||||||
|
#' )
|
||||||
|
#' # In case of error, print the error object
|
||||||
|
#' if(!is.null(result$ApiException)) {
|
||||||
|
#' cat(result$ApiException$toString())
|
||||||
|
#' } else {
|
||||||
|
#' # response headers
|
||||||
|
#' response.headers <- result$response$headers
|
||||||
|
#' # response status code
|
||||||
|
#' response.status.code <- result$response$status_code
|
||||||
|
#' }
|
||||||
#'
|
#'
|
||||||
#'
|
#'
|
||||||
#' #################### UploadFile ####################
|
#' #################### UploadFile ####################
|
||||||
@ -327,12 +429,27 @@
|
|||||||
#' # Configure OAuth2 access token for authorization: petstore_auth
|
#' # Configure OAuth2 access token for authorization: petstore_auth
|
||||||
#' api.instance$api_client$access_token <- '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)
|
#'result <- tryCatch(
|
||||||
|
#' api.instance$UploadFile(var.pet_id, additional_metadata=var.additional_metadata, file=var.file),
|
||||||
|
#' ApiException = function(ex) ex
|
||||||
|
#' )
|
||||||
|
#' # In case of error, print the error object
|
||||||
|
#' if(!is.null(result$ApiException)) {
|
||||||
|
#' cat(result$ApiException$toString())
|
||||||
|
#' } else {
|
||||||
|
#' # deserialized response object
|
||||||
|
#' response.object <- result$content
|
||||||
|
#' # response headers
|
||||||
|
#' response.headers <- result$response$headers
|
||||||
|
#' # response status code
|
||||||
|
#' response.status.code <- result$response$status_code
|
||||||
|
#' }
|
||||||
#'
|
#'
|
||||||
#'
|
#'
|
||||||
#' }
|
#' }
|
||||||
#' @importFrom R6 R6Class
|
#' @importFrom R6 R6Class
|
||||||
#' @importFrom base64enc base64encode
|
#' @importFrom base64enc base64encode
|
||||||
|
#' @importFrom rlang abort
|
||||||
#' @export
|
#' @export
|
||||||
PetApi <- R6::R6Class(
|
PetApi <- R6::R6Class(
|
||||||
"PetApi",
|
"PetApi",
|
||||||
@ -366,7 +483,7 @@ PetApi <- R6::R6Class(
|
|||||||
header_params <- c()
|
header_params <- c()
|
||||||
|
|
||||||
if (missing(`pet`)) {
|
if (missing(`pet`)) {
|
||||||
stop("Missing required parameter `pet`.")
|
rlang::abort(message = "Missing required parameter `pet`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `pet`."))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!missing(`pet`)) {
|
if (!missing(`pet`)) {
|
||||||
@ -395,16 +512,28 @@ PetApi <- R6::R6Class(
|
|||||||
deserialized_resp_obj <- tryCatch(
|
deserialized_resp_obj <- tryCatch(
|
||||||
self$api_client$deserialize(resp, "Pet", loadNamespace("petstore")),
|
self$api_client$deserialize(resp, "Pet", loadNamespace("petstore")),
|
||||||
error = function(e) {
|
error = function(e) {
|
||||||
stop("Failed to deserialize response")
|
rlang::abort(message = "Failed to deserialize response", .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
ApiResponse$new(deserialized_resp_obj, resp)
|
ApiResponse$new(deserialized_resp_obj, resp)
|
||||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
} 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)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||||
ApiResponse$new("API client error", resp)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- "Api client exception encountered."
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||||
ApiResponse$new("API server error", resp)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- "Api server exception encountered."
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
DeletePet = function(pet_id, api_key=NULL, ...) {
|
DeletePet = function(pet_id, api_key=NULL, ...) {
|
||||||
@ -427,7 +556,7 @@ PetApi <- R6::R6Class(
|
|||||||
header_params <- c()
|
header_params <- c()
|
||||||
|
|
||||||
if (missing(`pet_id`)) {
|
if (missing(`pet_id`)) {
|
||||||
stop("Missing required parameter `pet_id`.")
|
rlang::abort(message = "Missing required parameter `pet_id`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `pet_id`."))
|
||||||
}
|
}
|
||||||
|
|
||||||
body <- NULL
|
body <- NULL
|
||||||
@ -449,11 +578,23 @@ PetApi <- R6::R6Class(
|
|||||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||||
ApiResponse$new(NULL, resp)
|
ApiResponse$new(NULL, resp)
|
||||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
} 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)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||||
ApiResponse$new("API client error", resp)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- "Api client exception encountered."
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||||
ApiResponse$new("API server error", resp)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- "Api server exception encountered."
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
FindPetsByStatus = function(status, data_file=NULL, ...) {
|
FindPetsByStatus = function(status, data_file=NULL, ...) {
|
||||||
@ -476,7 +617,7 @@ PetApi <- R6::R6Class(
|
|||||||
header_params <- c()
|
header_params <- c()
|
||||||
|
|
||||||
if (missing(`status`)) {
|
if (missing(`status`)) {
|
||||||
stop("Missing required parameter `status`.")
|
rlang::abort(message = "Missing required parameter `status`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `status`."))
|
||||||
}
|
}
|
||||||
|
|
||||||
body <- NULL
|
body <- NULL
|
||||||
@ -500,16 +641,28 @@ PetApi <- R6::R6Class(
|
|||||||
deserialized_resp_obj <- tryCatch(
|
deserialized_resp_obj <- tryCatch(
|
||||||
self$api_client$deserialize(resp, "array[Pet]", loadNamespace("petstore")),
|
self$api_client$deserialize(resp, "array[Pet]", loadNamespace("petstore")),
|
||||||
error = function(e) {
|
error = function(e) {
|
||||||
stop("Failed to deserialize response")
|
rlang::abort(message = "Failed to deserialize response", .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
ApiResponse$new(deserialized_resp_obj, resp)
|
ApiResponse$new(deserialized_resp_obj, resp)
|
||||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
} 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)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||||
ApiResponse$new("API client error", resp)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- "Api client exception encountered."
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||||
ApiResponse$new("API server error", resp)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- "Api server exception encountered."
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
FindPetsByTags = function(tags, data_file=NULL, ...) {
|
FindPetsByTags = function(tags, data_file=NULL, ...) {
|
||||||
@ -532,7 +685,7 @@ PetApi <- R6::R6Class(
|
|||||||
header_params <- c()
|
header_params <- c()
|
||||||
|
|
||||||
if (missing(`tags`)) {
|
if (missing(`tags`)) {
|
||||||
stop("Missing required parameter `tags`.")
|
rlang::abort(message = "Missing required parameter `tags`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `tags`."))
|
||||||
}
|
}
|
||||||
|
|
||||||
body <- NULL
|
body <- NULL
|
||||||
@ -556,16 +709,28 @@ PetApi <- R6::R6Class(
|
|||||||
deserialized_resp_obj <- tryCatch(
|
deserialized_resp_obj <- tryCatch(
|
||||||
self$api_client$deserialize(resp, "array[Pet]", loadNamespace("petstore")),
|
self$api_client$deserialize(resp, "array[Pet]", loadNamespace("petstore")),
|
||||||
error = function(e) {
|
error = function(e) {
|
||||||
stop("Failed to deserialize response")
|
rlang::abort(message = "Failed to deserialize response", .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
ApiResponse$new(deserialized_resp_obj, resp)
|
ApiResponse$new(deserialized_resp_obj, resp)
|
||||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
} 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)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||||
ApiResponse$new("API client error", resp)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- "Api client exception encountered."
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||||
ApiResponse$new("API server error", resp)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- "Api server exception encountered."
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
GetPetById = function(pet_id, data_file=NULL, ...) {
|
GetPetById = function(pet_id, data_file=NULL, ...) {
|
||||||
@ -588,7 +753,7 @@ PetApi <- R6::R6Class(
|
|||||||
header_params <- c()
|
header_params <- c()
|
||||||
|
|
||||||
if (missing(`pet_id`)) {
|
if (missing(`pet_id`)) {
|
||||||
stop("Missing required parameter `pet_id`.")
|
rlang::abort(message = "Missing required parameter `pet_id`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `pet_id`."))
|
||||||
}
|
}
|
||||||
|
|
||||||
body <- NULL
|
body <- NULL
|
||||||
@ -618,16 +783,28 @@ PetApi <- R6::R6Class(
|
|||||||
deserialized_resp_obj <- tryCatch(
|
deserialized_resp_obj <- tryCatch(
|
||||||
self$api_client$deserialize(resp, "Pet", loadNamespace("petstore")),
|
self$api_client$deserialize(resp, "Pet", loadNamespace("petstore")),
|
||||||
error = function(e) {
|
error = function(e) {
|
||||||
stop("Failed to deserialize response")
|
rlang::abort(message = "Failed to deserialize response", .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
ApiResponse$new(deserialized_resp_obj, resp)
|
ApiResponse$new(deserialized_resp_obj, resp)
|
||||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
} 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)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||||
ApiResponse$new("API client error", resp)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- "Api client exception encountered."
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||||
ApiResponse$new("API server error", resp)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- "Api server exception encountered."
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
UpdatePet = function(pet, data_file=NULL, ...) {
|
UpdatePet = function(pet, data_file=NULL, ...) {
|
||||||
@ -650,7 +827,7 @@ PetApi <- R6::R6Class(
|
|||||||
header_params <- c()
|
header_params <- c()
|
||||||
|
|
||||||
if (missing(`pet`)) {
|
if (missing(`pet`)) {
|
||||||
stop("Missing required parameter `pet`.")
|
rlang::abort(message = "Missing required parameter `pet`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `pet`."))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!missing(`pet`)) {
|
if (!missing(`pet`)) {
|
||||||
@ -679,16 +856,28 @@ PetApi <- R6::R6Class(
|
|||||||
deserialized_resp_obj <- tryCatch(
|
deserialized_resp_obj <- tryCatch(
|
||||||
self$api_client$deserialize(resp, "Pet", loadNamespace("petstore")),
|
self$api_client$deserialize(resp, "Pet", loadNamespace("petstore")),
|
||||||
error = function(e) {
|
error = function(e) {
|
||||||
stop("Failed to deserialize response")
|
rlang::abort(message = "Failed to deserialize response", .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
ApiResponse$new(deserialized_resp_obj, resp)
|
ApiResponse$new(deserialized_resp_obj, resp)
|
||||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
} 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)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||||
ApiResponse$new("API client error", resp)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- "Api client exception encountered."
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||||
ApiResponse$new("API server error", resp)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- "Api server exception encountered."
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
UpdatePetWithForm = function(pet_id, name=NULL, status=NULL, ...) {
|
UpdatePetWithForm = function(pet_id, name=NULL, status=NULL, ...) {
|
||||||
@ -711,7 +900,7 @@ PetApi <- R6::R6Class(
|
|||||||
header_params <- c()
|
header_params <- c()
|
||||||
|
|
||||||
if (missing(`pet_id`)) {
|
if (missing(`pet_id`)) {
|
||||||
stop("Missing required parameter `pet_id`.")
|
rlang::abort(message = "Missing required parameter `pet_id`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `pet_id`."))
|
||||||
}
|
}
|
||||||
|
|
||||||
body <- list(
|
body <- list(
|
||||||
@ -737,11 +926,23 @@ PetApi <- R6::R6Class(
|
|||||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||||
ApiResponse$new(NULL, resp)
|
ApiResponse$new(NULL, resp)
|
||||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
} 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)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||||
ApiResponse$new("API client error", resp)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- "Api client exception encountered."
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||||
ApiResponse$new("API server error", resp)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- "Api server exception encountered."
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
UploadFile = function(pet_id, additional_metadata=NULL, file=NULL, data_file=NULL, ...) {
|
UploadFile = function(pet_id, additional_metadata=NULL, file=NULL, data_file=NULL, ...) {
|
||||||
@ -764,7 +965,7 @@ PetApi <- R6::R6Class(
|
|||||||
header_params <- c()
|
header_params <- c()
|
||||||
|
|
||||||
if (missing(`pet_id`)) {
|
if (missing(`pet_id`)) {
|
||||||
stop("Missing required parameter `pet_id`.")
|
rlang::abort(message = "Missing required parameter `pet_id`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `pet_id`."))
|
||||||
}
|
}
|
||||||
|
|
||||||
body <- list(
|
body <- list(
|
||||||
@ -796,16 +997,28 @@ PetApi <- R6::R6Class(
|
|||||||
deserialized_resp_obj <- tryCatch(
|
deserialized_resp_obj <- tryCatch(
|
||||||
self$api_client$deserialize(resp, "ModelApiResponse", loadNamespace("petstore")),
|
self$api_client$deserialize(resp, "ModelApiResponse", loadNamespace("petstore")),
|
||||||
error = function(e) {
|
error = function(e) {
|
||||||
stop("Failed to deserialize response")
|
rlang::abort(message = "Failed to deserialize response", .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
ApiResponse$new(deserialized_resp_obj, resp)
|
ApiResponse$new(deserialized_resp_obj, resp)
|
||||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
} 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)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||||
ApiResponse$new("API client error", resp)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- "Api client exception encountered."
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||||
ApiResponse$new("API server error", resp)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- "Api server exception encountered."
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#' \itemize{
|
#' \itemize{
|
||||||
#' \item \emph{ @param } order_id character
|
#' \item \emph{ @param } order_id character
|
||||||
#'
|
#'
|
||||||
|
#' \item On encountering errors, an error of subclass ApiException will be thrown.
|
||||||
#'
|
#'
|
||||||
#' \item status code : 400 | Invalid ID supplied
|
#' \item status code : 400 | Invalid ID supplied
|
||||||
#'
|
#'
|
||||||
@ -41,6 +42,7 @@
|
|||||||
#'
|
#'
|
||||||
#' \itemize{
|
#' \itemize{
|
||||||
#'
|
#'
|
||||||
|
#' \item On encountering errors, an error of subclass ApiException will be thrown.
|
||||||
#'
|
#'
|
||||||
#' \item status code : 200 | successful operation
|
#' \item status code : 200 | successful operation
|
||||||
#'
|
#'
|
||||||
@ -58,6 +60,7 @@
|
|||||||
#' \item \emph{ @param } order_id integer
|
#' \item \emph{ @param } order_id integer
|
||||||
#' \item \emph{ @returnType } \link{Order} \cr
|
#' \item \emph{ @returnType } \link{Order} \cr
|
||||||
#'
|
#'
|
||||||
|
#' \item On encountering errors, an error of subclass ApiException will be thrown.
|
||||||
#'
|
#'
|
||||||
#' \item status code : 200 | successful operation
|
#' \item status code : 200 | successful operation
|
||||||
#'
|
#'
|
||||||
@ -89,6 +92,7 @@
|
|||||||
#' \item \emph{ @param } order \link{Order}
|
#' \item \emph{ @param } order \link{Order}
|
||||||
#' \item \emph{ @returnType } \link{Order} \cr
|
#' \item \emph{ @returnType } \link{Order} \cr
|
||||||
#'
|
#'
|
||||||
|
#' \item On encountering errors, an error of subclass ApiException will be thrown.
|
||||||
#'
|
#'
|
||||||
#' \item status code : 200 | successful operation
|
#' \item status code : 200 | successful operation
|
||||||
#'
|
#'
|
||||||
@ -119,7 +123,19 @@
|
|||||||
#' #Delete purchase order by ID
|
#' #Delete purchase order by ID
|
||||||
#' api.instance <- StoreApi$new()
|
#' api.instance <- StoreApi$new()
|
||||||
#'
|
#'
|
||||||
#' result <- api.instance$DeleteOrder(var.order_id)
|
#'result <- tryCatch(
|
||||||
|
#' api.instance$DeleteOrder(var.order_id),
|
||||||
|
#' ApiException = function(ex) ex
|
||||||
|
#' )
|
||||||
|
#' # In case of error, print the error object
|
||||||
|
#' if(!is.null(result$ApiException)) {
|
||||||
|
#' cat(result$ApiException$toString())
|
||||||
|
#' } else {
|
||||||
|
#' # response headers
|
||||||
|
#' response.headers <- result$response$headers
|
||||||
|
#' # response status code
|
||||||
|
#' response.status.code <- result$response$status_code
|
||||||
|
#' }
|
||||||
#'
|
#'
|
||||||
#'
|
#'
|
||||||
#' #################### GetInventory ####################
|
#' #################### GetInventory ####################
|
||||||
@ -132,7 +148,21 @@
|
|||||||
#' #Configure API key authorization: api_key
|
#' #Configure API key authorization: api_key
|
||||||
#' api.instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY';
|
#' api.instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY';
|
||||||
#'
|
#'
|
||||||
#' result <- api.instance$GetInventory()
|
#'result <- tryCatch(
|
||||||
|
#' api.instance$GetInventory(),
|
||||||
|
#' ApiException = function(ex) ex
|
||||||
|
#' )
|
||||||
|
#' # In case of error, print the error object
|
||||||
|
#' if(!is.null(result$ApiException)) {
|
||||||
|
#' cat(result$ApiException$toString())
|
||||||
|
#' } else {
|
||||||
|
#' # deserialized response object
|
||||||
|
#' response.object <- result$content
|
||||||
|
#' # response headers
|
||||||
|
#' response.headers <- result$response$headers
|
||||||
|
#' # response status code
|
||||||
|
#' response.status.code <- result$response$status_code
|
||||||
|
#' }
|
||||||
#'
|
#'
|
||||||
#'
|
#'
|
||||||
#' #################### GetOrderById ####################
|
#' #################### GetOrderById ####################
|
||||||
@ -143,7 +173,21 @@
|
|||||||
#' #Find purchase order by ID
|
#' #Find purchase order by ID
|
||||||
#' api.instance <- StoreApi$new()
|
#' api.instance <- StoreApi$new()
|
||||||
#'
|
#'
|
||||||
#' result <- api.instance$GetOrderById(var.order_id)
|
#'result <- tryCatch(
|
||||||
|
#' api.instance$GetOrderById(var.order_id),
|
||||||
|
#' ApiException = function(ex) ex
|
||||||
|
#' )
|
||||||
|
#' # In case of error, print the error object
|
||||||
|
#' if(!is.null(result$ApiException)) {
|
||||||
|
#' cat(result$ApiException$toString())
|
||||||
|
#' } else {
|
||||||
|
#' # deserialized response object
|
||||||
|
#' response.object <- result$content
|
||||||
|
#' # response headers
|
||||||
|
#' response.headers <- result$response$headers
|
||||||
|
#' # response status code
|
||||||
|
#' response.status.code <- result$response$status_code
|
||||||
|
#' }
|
||||||
#'
|
#'
|
||||||
#'
|
#'
|
||||||
#' #################### PlaceOrder ####################
|
#' #################### PlaceOrder ####################
|
||||||
@ -154,12 +198,27 @@
|
|||||||
#' #Place an order for a pet
|
#' #Place an order for a pet
|
||||||
#' api.instance <- StoreApi$new()
|
#' api.instance <- StoreApi$new()
|
||||||
#'
|
#'
|
||||||
#' result <- api.instance$PlaceOrder(var.order)
|
#'result <- tryCatch(
|
||||||
|
#' api.instance$PlaceOrder(var.order),
|
||||||
|
#' ApiException = function(ex) ex
|
||||||
|
#' )
|
||||||
|
#' # In case of error, print the error object
|
||||||
|
#' if(!is.null(result$ApiException)) {
|
||||||
|
#' cat(result$ApiException$toString())
|
||||||
|
#' } else {
|
||||||
|
#' # deserialized response object
|
||||||
|
#' response.object <- result$content
|
||||||
|
#' # response headers
|
||||||
|
#' response.headers <- result$response$headers
|
||||||
|
#' # response status code
|
||||||
|
#' response.status.code <- result$response$status_code
|
||||||
|
#' }
|
||||||
#'
|
#'
|
||||||
#'
|
#'
|
||||||
#' }
|
#' }
|
||||||
#' @importFrom R6 R6Class
|
#' @importFrom R6 R6Class
|
||||||
#' @importFrom base64enc base64encode
|
#' @importFrom base64enc base64encode
|
||||||
|
#' @importFrom rlang abort
|
||||||
#' @export
|
#' @export
|
||||||
StoreApi <- R6::R6Class(
|
StoreApi <- R6::R6Class(
|
||||||
"StoreApi",
|
"StoreApi",
|
||||||
@ -193,7 +252,7 @@ StoreApi <- R6::R6Class(
|
|||||||
header_params <- c()
|
header_params <- c()
|
||||||
|
|
||||||
if (missing(`order_id`)) {
|
if (missing(`order_id`)) {
|
||||||
stop("Missing required parameter `order_id`.")
|
rlang::abort(message = "Missing required parameter `order_id`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `order_id`."))
|
||||||
}
|
}
|
||||||
|
|
||||||
body <- NULL
|
body <- NULL
|
||||||
@ -213,11 +272,23 @@ StoreApi <- R6::R6Class(
|
|||||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||||
ApiResponse$new(NULL, resp)
|
ApiResponse$new(NULL, resp)
|
||||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
} 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)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||||
ApiResponse$new("API client error", resp)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- "Api client exception encountered."
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||||
ApiResponse$new("API server error", resp)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- "Api server exception encountered."
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
GetInventory = function(data_file=NULL, ...) {
|
GetInventory = function(data_file=NULL, ...) {
|
||||||
@ -262,16 +333,28 @@ StoreApi <- R6::R6Class(
|
|||||||
deserialized_resp_obj <- tryCatch(
|
deserialized_resp_obj <- tryCatch(
|
||||||
self$api_client$deserialize(resp, "map(integer)", loadNamespace("petstore")),
|
self$api_client$deserialize(resp, "map(integer)", loadNamespace("petstore")),
|
||||||
error = function(e) {
|
error = function(e) {
|
||||||
stop("Failed to deserialize response")
|
rlang::abort(message = "Failed to deserialize response", .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
ApiResponse$new(deserialized_resp_obj, resp)
|
ApiResponse$new(deserialized_resp_obj, resp)
|
||||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
} 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)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||||
ApiResponse$new("API client error", resp)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- "Api client exception encountered."
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||||
ApiResponse$new("API server error", resp)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- "Api server exception encountered."
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
GetOrderById = function(order_id, data_file=NULL, ...) {
|
GetOrderById = function(order_id, data_file=NULL, ...) {
|
||||||
@ -294,7 +377,7 @@ StoreApi <- R6::R6Class(
|
|||||||
header_params <- c()
|
header_params <- c()
|
||||||
|
|
||||||
if (missing(`order_id`)) {
|
if (missing(`order_id`)) {
|
||||||
stop("Missing required parameter `order_id`.")
|
rlang::abort(message = "Missing required parameter `order_id`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `order_id`."))
|
||||||
}
|
}
|
||||||
|
|
||||||
body <- NULL
|
body <- NULL
|
||||||
@ -320,16 +403,28 @@ StoreApi <- R6::R6Class(
|
|||||||
deserialized_resp_obj <- tryCatch(
|
deserialized_resp_obj <- tryCatch(
|
||||||
self$api_client$deserialize(resp, "Order", loadNamespace("petstore")),
|
self$api_client$deserialize(resp, "Order", loadNamespace("petstore")),
|
||||||
error = function(e) {
|
error = function(e) {
|
||||||
stop("Failed to deserialize response")
|
rlang::abort(message = "Failed to deserialize response", .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
ApiResponse$new(deserialized_resp_obj, resp)
|
ApiResponse$new(deserialized_resp_obj, resp)
|
||||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
} 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)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||||
ApiResponse$new("API client error", resp)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- "Api client exception encountered."
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||||
ApiResponse$new("API server error", resp)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- "Api server exception encountered."
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
PlaceOrder = function(order, data_file=NULL, ...) {
|
PlaceOrder = function(order, data_file=NULL, ...) {
|
||||||
@ -352,7 +447,7 @@ StoreApi <- R6::R6Class(
|
|||||||
header_params <- c()
|
header_params <- c()
|
||||||
|
|
||||||
if (missing(`order`)) {
|
if (missing(`order`)) {
|
||||||
stop("Missing required parameter `order`.")
|
rlang::abort(message = "Missing required parameter `order`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `order`."))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!missing(`order`)) {
|
if (!missing(`order`)) {
|
||||||
@ -379,16 +474,28 @@ StoreApi <- R6::R6Class(
|
|||||||
deserialized_resp_obj <- tryCatch(
|
deserialized_resp_obj <- tryCatch(
|
||||||
self$api_client$deserialize(resp, "Order", loadNamespace("petstore")),
|
self$api_client$deserialize(resp, "Order", loadNamespace("petstore")),
|
||||||
error = function(e) {
|
error = function(e) {
|
||||||
stop("Failed to deserialize response")
|
rlang::abort(message = "Failed to deserialize response", .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
ApiResponse$new(deserialized_resp_obj, resp)
|
ApiResponse$new(deserialized_resp_obj, resp)
|
||||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
} 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)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||||
ApiResponse$new("API client error", resp)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- "Api client exception encountered."
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||||
ApiResponse$new("API server error", resp)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- "Api server exception encountered."
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#' \itemize{
|
#' \itemize{
|
||||||
#' \item \emph{ @param } user \link{User}
|
#' \item \emph{ @param } user \link{User}
|
||||||
#'
|
#'
|
||||||
|
#' \item On encountering errors, an error of subclass ApiException will be thrown.
|
||||||
#'
|
#'
|
||||||
#' \item status code : 0 | successful operation
|
#' \item status code : 0 | successful operation
|
||||||
#'
|
#'
|
||||||
@ -35,6 +36,7 @@
|
|||||||
#' \itemize{
|
#' \itemize{
|
||||||
#' \item \emph{ @param } user list( \link{User} )
|
#' \item \emph{ @param } user list( \link{User} )
|
||||||
#'
|
#'
|
||||||
|
#' \item On encountering errors, an error of subclass ApiException will be thrown.
|
||||||
#'
|
#'
|
||||||
#' \item status code : 0 | successful operation
|
#' \item status code : 0 | successful operation
|
||||||
#'
|
#'
|
||||||
@ -51,6 +53,7 @@
|
|||||||
#' \itemize{
|
#' \itemize{
|
||||||
#' \item \emph{ @param } user list( \link{User} )
|
#' \item \emph{ @param } user list( \link{User} )
|
||||||
#'
|
#'
|
||||||
|
#' \item On encountering errors, an error of subclass ApiException will be thrown.
|
||||||
#'
|
#'
|
||||||
#' \item status code : 0 | successful operation
|
#' \item status code : 0 | successful operation
|
||||||
#'
|
#'
|
||||||
@ -67,6 +70,7 @@
|
|||||||
#' \itemize{
|
#' \itemize{
|
||||||
#' \item \emph{ @param } username character
|
#' \item \emph{ @param } username character
|
||||||
#'
|
#'
|
||||||
|
#' \item On encountering errors, an error of subclass ApiException will be thrown.
|
||||||
#'
|
#'
|
||||||
#' \item status code : 400 | Invalid username supplied
|
#' \item status code : 400 | Invalid username supplied
|
||||||
#'
|
#'
|
||||||
@ -91,6 +95,7 @@
|
|||||||
#' \item \emph{ @param } username character
|
#' \item \emph{ @param } username character
|
||||||
#' \item \emph{ @returnType } \link{User} \cr
|
#' \item \emph{ @returnType } \link{User} \cr
|
||||||
#'
|
#'
|
||||||
|
#' \item On encountering errors, an error of subclass ApiException will be thrown.
|
||||||
#'
|
#'
|
||||||
#' \item status code : 200 | successful operation
|
#' \item status code : 200 | successful operation
|
||||||
#'
|
#'
|
||||||
@ -122,6 +127,7 @@
|
|||||||
#' \item \emph{ @param } username character
|
#' \item \emph{ @param } username character
|
||||||
#' \item \emph{ @param } password character
|
#' \item \emph{ @param } password character
|
||||||
#'
|
#'
|
||||||
|
#' \item On encountering errors, an error of subclass ApiException will be thrown.
|
||||||
#'
|
#'
|
||||||
#' \item status code : 200 | successful operation
|
#' \item status code : 200 | successful operation
|
||||||
#'
|
#'
|
||||||
@ -147,6 +153,7 @@
|
|||||||
#'
|
#'
|
||||||
#' \itemize{
|
#' \itemize{
|
||||||
#'
|
#'
|
||||||
|
#' \item On encountering errors, an error of subclass ApiException will be thrown.
|
||||||
#'
|
#'
|
||||||
#' \item status code : 0 | successful operation
|
#' \item status code : 0 | successful operation
|
||||||
#'
|
#'
|
||||||
@ -164,6 +171,7 @@
|
|||||||
#' \item \emph{ @param } username character
|
#' \item \emph{ @param } username character
|
||||||
#' \item \emph{ @param } user \link{User}
|
#' \item \emph{ @param } user \link{User}
|
||||||
#'
|
#'
|
||||||
|
#' \item On encountering errors, an error of subclass ApiException will be thrown.
|
||||||
#'
|
#'
|
||||||
#' \item status code : 400 | Invalid user supplied
|
#' \item status code : 400 | Invalid user supplied
|
||||||
#'
|
#'
|
||||||
@ -197,7 +205,19 @@
|
|||||||
#' #Configure API key authorization: api_key
|
#' #Configure API key authorization: api_key
|
||||||
#' api.instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY';
|
#' api.instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY';
|
||||||
#'
|
#'
|
||||||
#' result <- api.instance$CreateUser(var.user)
|
#'result <- tryCatch(
|
||||||
|
#' api.instance$CreateUser(var.user),
|
||||||
|
#' ApiException = function(ex) ex
|
||||||
|
#' )
|
||||||
|
#' # In case of error, print the error object
|
||||||
|
#' if(!is.null(result$ApiException)) {
|
||||||
|
#' cat(result$ApiException$toString())
|
||||||
|
#' } else {
|
||||||
|
#' # response headers
|
||||||
|
#' response.headers <- result$response$headers
|
||||||
|
#' # response status code
|
||||||
|
#' response.status.code <- result$response$status_code
|
||||||
|
#' }
|
||||||
#'
|
#'
|
||||||
#'
|
#'
|
||||||
#' #################### CreateUsersWithArrayInput ####################
|
#' #################### CreateUsersWithArrayInput ####################
|
||||||
@ -211,7 +231,19 @@
|
|||||||
#' #Configure API key authorization: api_key
|
#' #Configure API key authorization: api_key
|
||||||
#' api.instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY';
|
#' api.instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY';
|
||||||
#'
|
#'
|
||||||
#' result <- api.instance$CreateUsersWithArrayInput(var.user)
|
#'result <- tryCatch(
|
||||||
|
#' api.instance$CreateUsersWithArrayInput(var.user),
|
||||||
|
#' ApiException = function(ex) ex
|
||||||
|
#' )
|
||||||
|
#' # In case of error, print the error object
|
||||||
|
#' if(!is.null(result$ApiException)) {
|
||||||
|
#' cat(result$ApiException$toString())
|
||||||
|
#' } else {
|
||||||
|
#' # response headers
|
||||||
|
#' response.headers <- result$response$headers
|
||||||
|
#' # response status code
|
||||||
|
#' response.status.code <- result$response$status_code
|
||||||
|
#' }
|
||||||
#'
|
#'
|
||||||
#'
|
#'
|
||||||
#' #################### CreateUsersWithListInput ####################
|
#' #################### CreateUsersWithListInput ####################
|
||||||
@ -225,7 +257,19 @@
|
|||||||
#' #Configure API key authorization: api_key
|
#' #Configure API key authorization: api_key
|
||||||
#' api.instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY';
|
#' api.instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY';
|
||||||
#'
|
#'
|
||||||
#' result <- api.instance$CreateUsersWithListInput(var.user)
|
#'result <- tryCatch(
|
||||||
|
#' api.instance$CreateUsersWithListInput(var.user),
|
||||||
|
#' ApiException = function(ex) ex
|
||||||
|
#' )
|
||||||
|
#' # In case of error, print the error object
|
||||||
|
#' if(!is.null(result$ApiException)) {
|
||||||
|
#' cat(result$ApiException$toString())
|
||||||
|
#' } else {
|
||||||
|
#' # response headers
|
||||||
|
#' response.headers <- result$response$headers
|
||||||
|
#' # response status code
|
||||||
|
#' response.status.code <- result$response$status_code
|
||||||
|
#' }
|
||||||
#'
|
#'
|
||||||
#'
|
#'
|
||||||
#' #################### DeleteUser ####################
|
#' #################### DeleteUser ####################
|
||||||
@ -239,7 +283,19 @@
|
|||||||
#' #Configure API key authorization: api_key
|
#' #Configure API key authorization: api_key
|
||||||
#' api.instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY';
|
#' api.instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY';
|
||||||
#'
|
#'
|
||||||
#' result <- api.instance$DeleteUser(var.username)
|
#'result <- tryCatch(
|
||||||
|
#' api.instance$DeleteUser(var.username),
|
||||||
|
#' ApiException = function(ex) ex
|
||||||
|
#' )
|
||||||
|
#' # In case of error, print the error object
|
||||||
|
#' if(!is.null(result$ApiException)) {
|
||||||
|
#' cat(result$ApiException$toString())
|
||||||
|
#' } else {
|
||||||
|
#' # response headers
|
||||||
|
#' response.headers <- result$response$headers
|
||||||
|
#' # response status code
|
||||||
|
#' response.status.code <- result$response$status_code
|
||||||
|
#' }
|
||||||
#'
|
#'
|
||||||
#'
|
#'
|
||||||
#' #################### GetUserByName ####################
|
#' #################### GetUserByName ####################
|
||||||
@ -250,7 +306,21 @@
|
|||||||
#' #Get user by user name
|
#' #Get user by user name
|
||||||
#' api.instance <- UserApi$new()
|
#' api.instance <- UserApi$new()
|
||||||
#'
|
#'
|
||||||
#' result <- api.instance$GetUserByName(var.username)
|
#'result <- tryCatch(
|
||||||
|
#' api.instance$GetUserByName(var.username),
|
||||||
|
#' ApiException = function(ex) ex
|
||||||
|
#' )
|
||||||
|
#' # In case of error, print the error object
|
||||||
|
#' if(!is.null(result$ApiException)) {
|
||||||
|
#' cat(result$ApiException$toString())
|
||||||
|
#' } else {
|
||||||
|
#' # deserialized response object
|
||||||
|
#' response.object <- result$content
|
||||||
|
#' # response headers
|
||||||
|
#' response.headers <- result$response$headers
|
||||||
|
#' # response status code
|
||||||
|
#' response.status.code <- result$response$status_code
|
||||||
|
#' }
|
||||||
#'
|
#'
|
||||||
#'
|
#'
|
||||||
#' #################### LoginUser ####################
|
#' #################### LoginUser ####################
|
||||||
@ -262,7 +332,21 @@
|
|||||||
#' #Logs user into the system
|
#' #Logs user into the system
|
||||||
#' api.instance <- UserApi$new()
|
#' api.instance <- UserApi$new()
|
||||||
#'
|
#'
|
||||||
#' result <- api.instance$LoginUser(var.username, var.password)
|
#'result <- tryCatch(
|
||||||
|
#' api.instance$LoginUser(var.username, var.password),
|
||||||
|
#' ApiException = function(ex) ex
|
||||||
|
#' )
|
||||||
|
#' # In case of error, print the error object
|
||||||
|
#' if(!is.null(result$ApiException)) {
|
||||||
|
#' cat(result$ApiException$toString())
|
||||||
|
#' } else {
|
||||||
|
#' # deserialized response object
|
||||||
|
#' response.object <- result$content
|
||||||
|
#' # response headers
|
||||||
|
#' response.headers <- result$response$headers
|
||||||
|
#' # response status code
|
||||||
|
#' response.status.code <- result$response$status_code
|
||||||
|
#' }
|
||||||
#'
|
#'
|
||||||
#'
|
#'
|
||||||
#' #################### LogoutUser ####################
|
#' #################### LogoutUser ####################
|
||||||
@ -275,7 +359,19 @@
|
|||||||
#' #Configure API key authorization: api_key
|
#' #Configure API key authorization: api_key
|
||||||
#' api.instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY';
|
#' api.instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY';
|
||||||
#'
|
#'
|
||||||
#' result <- api.instance$LogoutUser()
|
#'result <- tryCatch(
|
||||||
|
#' api.instance$LogoutUser(),
|
||||||
|
#' ApiException = function(ex) ex
|
||||||
|
#' )
|
||||||
|
#' # In case of error, print the error object
|
||||||
|
#' if(!is.null(result$ApiException)) {
|
||||||
|
#' cat(result$ApiException$toString())
|
||||||
|
#' } else {
|
||||||
|
#' # response headers
|
||||||
|
#' response.headers <- result$response$headers
|
||||||
|
#' # response status code
|
||||||
|
#' response.status.code <- result$response$status_code
|
||||||
|
#' }
|
||||||
#'
|
#'
|
||||||
#'
|
#'
|
||||||
#' #################### UpdateUser ####################
|
#' #################### UpdateUser ####################
|
||||||
@ -290,12 +386,25 @@
|
|||||||
#' #Configure API key authorization: api_key
|
#' #Configure API key authorization: api_key
|
||||||
#' api.instance$api_client$api_keys['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)
|
#'result <- tryCatch(
|
||||||
|
#' api.instance$UpdateUser(var.username, var.user),
|
||||||
|
#' ApiException = function(ex) ex
|
||||||
|
#' )
|
||||||
|
#' # In case of error, print the error object
|
||||||
|
#' if(!is.null(result$ApiException)) {
|
||||||
|
#' cat(result$ApiException$toString())
|
||||||
|
#' } else {
|
||||||
|
#' # response headers
|
||||||
|
#' response.headers <- result$response$headers
|
||||||
|
#' # response status code
|
||||||
|
#' response.status.code <- result$response$status_code
|
||||||
|
#' }
|
||||||
#'
|
#'
|
||||||
#'
|
#'
|
||||||
#' }
|
#' }
|
||||||
#' @importFrom R6 R6Class
|
#' @importFrom R6 R6Class
|
||||||
#' @importFrom base64enc base64encode
|
#' @importFrom base64enc base64encode
|
||||||
|
#' @importFrom rlang abort
|
||||||
#' @export
|
#' @export
|
||||||
UserApi <- R6::R6Class(
|
UserApi <- R6::R6Class(
|
||||||
"UserApi",
|
"UserApi",
|
||||||
@ -329,7 +438,7 @@ UserApi <- R6::R6Class(
|
|||||||
header_params <- c()
|
header_params <- c()
|
||||||
|
|
||||||
if (missing(`user`)) {
|
if (missing(`user`)) {
|
||||||
stop("Missing required parameter `user`.")
|
rlang::abort(message = "Missing required parameter `user`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `user`."))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!missing(`user`)) {
|
if (!missing(`user`)) {
|
||||||
@ -354,11 +463,23 @@ UserApi <- R6::R6Class(
|
|||||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||||
ApiResponse$new(NULL, resp)
|
ApiResponse$new(NULL, resp)
|
||||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
} 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)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||||
ApiResponse$new("API client error", resp)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- "Api client exception encountered."
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||||
ApiResponse$new("API server error", resp)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- "Api server exception encountered."
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
CreateUsersWithArrayInput = function(user, ...) {
|
CreateUsersWithArrayInput = function(user, ...) {
|
||||||
@ -381,7 +502,7 @@ UserApi <- R6::R6Class(
|
|||||||
header_params <- c()
|
header_params <- c()
|
||||||
|
|
||||||
if (missing(`user`)) {
|
if (missing(`user`)) {
|
||||||
stop("Missing required parameter `user`.")
|
rlang::abort(message = "Missing required parameter `user`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `user`."))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!missing(`user`)) {
|
if (!missing(`user`)) {
|
||||||
@ -407,11 +528,23 @@ UserApi <- R6::R6Class(
|
|||||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||||
ApiResponse$new(NULL, resp)
|
ApiResponse$new(NULL, resp)
|
||||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
} 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)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||||
ApiResponse$new("API client error", resp)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- "Api client exception encountered."
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||||
ApiResponse$new("API server error", resp)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- "Api server exception encountered."
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
CreateUsersWithListInput = function(user, ...) {
|
CreateUsersWithListInput = function(user, ...) {
|
||||||
@ -434,7 +567,7 @@ UserApi <- R6::R6Class(
|
|||||||
header_params <- c()
|
header_params <- c()
|
||||||
|
|
||||||
if (missing(`user`)) {
|
if (missing(`user`)) {
|
||||||
stop("Missing required parameter `user`.")
|
rlang::abort(message = "Missing required parameter `user`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `user`."))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!missing(`user`)) {
|
if (!missing(`user`)) {
|
||||||
@ -460,11 +593,23 @@ UserApi <- R6::R6Class(
|
|||||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||||
ApiResponse$new(NULL, resp)
|
ApiResponse$new(NULL, resp)
|
||||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
} 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)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||||
ApiResponse$new("API client error", resp)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- "Api client exception encountered."
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||||
ApiResponse$new("API server error", resp)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- "Api server exception encountered."
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
DeleteUser = function(username, ...) {
|
DeleteUser = function(username, ...) {
|
||||||
@ -487,7 +632,7 @@ UserApi <- R6::R6Class(
|
|||||||
header_params <- c()
|
header_params <- c()
|
||||||
|
|
||||||
if (missing(`username`)) {
|
if (missing(`username`)) {
|
||||||
stop("Missing required parameter `username`.")
|
rlang::abort(message = "Missing required parameter `username`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `username`."))
|
||||||
}
|
}
|
||||||
|
|
||||||
body <- NULL
|
body <- NULL
|
||||||
@ -511,11 +656,23 @@ UserApi <- R6::R6Class(
|
|||||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||||
ApiResponse$new(NULL, resp)
|
ApiResponse$new(NULL, resp)
|
||||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
} 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)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||||
ApiResponse$new("API client error", resp)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- "Api client exception encountered."
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||||
ApiResponse$new("API server error", resp)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- "Api server exception encountered."
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
GetUserByName = function(username, data_file=NULL, ...) {
|
GetUserByName = function(username, data_file=NULL, ...) {
|
||||||
@ -538,7 +695,7 @@ UserApi <- R6::R6Class(
|
|||||||
header_params <- c()
|
header_params <- c()
|
||||||
|
|
||||||
if (missing(`username`)) {
|
if (missing(`username`)) {
|
||||||
stop("Missing required parameter `username`.")
|
rlang::abort(message = "Missing required parameter `username`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `username`."))
|
||||||
}
|
}
|
||||||
|
|
||||||
body <- NULL
|
body <- NULL
|
||||||
@ -564,16 +721,28 @@ UserApi <- R6::R6Class(
|
|||||||
deserialized_resp_obj <- tryCatch(
|
deserialized_resp_obj <- tryCatch(
|
||||||
self$api_client$deserialize(resp, "User", loadNamespace("petstore")),
|
self$api_client$deserialize(resp, "User", loadNamespace("petstore")),
|
||||||
error = function(e) {
|
error = function(e) {
|
||||||
stop("Failed to deserialize response")
|
rlang::abort(message = "Failed to deserialize response", .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
ApiResponse$new(deserialized_resp_obj, resp)
|
ApiResponse$new(deserialized_resp_obj, resp)
|
||||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
} 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)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||||
ApiResponse$new("API client error", resp)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- "Api client exception encountered."
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||||
ApiResponse$new("API server error", resp)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- "Api server exception encountered."
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
LoginUser = function(username, password, data_file=NULL, ...) {
|
LoginUser = function(username, password, data_file=NULL, ...) {
|
||||||
@ -596,11 +765,11 @@ UserApi <- R6::R6Class(
|
|||||||
header_params <- c()
|
header_params <- c()
|
||||||
|
|
||||||
if (missing(`username`)) {
|
if (missing(`username`)) {
|
||||||
stop("Missing required parameter `username`.")
|
rlang::abort(message = "Missing required parameter `username`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `username`."))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (missing(`password`)) {
|
if (missing(`password`)) {
|
||||||
stop("Missing required parameter `password`.")
|
rlang::abort(message = "Missing required parameter `password`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `password`."))
|
||||||
}
|
}
|
||||||
|
|
||||||
body <- NULL
|
body <- NULL
|
||||||
@ -622,16 +791,28 @@ UserApi <- R6::R6Class(
|
|||||||
deserialized_resp_obj <- tryCatch(
|
deserialized_resp_obj <- tryCatch(
|
||||||
self$api_client$deserialize(resp, "character", loadNamespace("petstore")),
|
self$api_client$deserialize(resp, "character", loadNamespace("petstore")),
|
||||||
error = function(e) {
|
error = function(e) {
|
||||||
stop("Failed to deserialize response")
|
rlang::abort(message = "Failed to deserialize response", .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
ApiResponse$new(deserialized_resp_obj, resp)
|
ApiResponse$new(deserialized_resp_obj, resp)
|
||||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
} 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)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||||
ApiResponse$new("API client error", resp)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- "Api client exception encountered."
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||||
ApiResponse$new("API server error", resp)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- "Api server exception encountered."
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
LogoutUser = function(...) {
|
LogoutUser = function(...) {
|
||||||
@ -670,11 +851,23 @@ UserApi <- R6::R6Class(
|
|||||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||||
ApiResponse$new(NULL, resp)
|
ApiResponse$new(NULL, resp)
|
||||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
} 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)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||||
ApiResponse$new("API client error", resp)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- "Api client exception encountered."
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||||
ApiResponse$new("API server error", resp)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- "Api server exception encountered."
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
UpdateUser = function(username, user, ...) {
|
UpdateUser = function(username, user, ...) {
|
||||||
@ -697,11 +890,11 @@ UserApi <- R6::R6Class(
|
|||||||
header_params <- c()
|
header_params <- c()
|
||||||
|
|
||||||
if (missing(`username`)) {
|
if (missing(`username`)) {
|
||||||
stop("Missing required parameter `username`.")
|
rlang::abort(message = "Missing required parameter `username`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `username`."))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (missing(`user`)) {
|
if (missing(`user`)) {
|
||||||
stop("Missing required parameter `user`.")
|
rlang::abort(message = "Missing required parameter `user`.", .subclass = "ApiException", ApiException = ApiException$new(status = 0, reason = "Missing required parameter `user`."))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!missing(`user`)) {
|
if (!missing(`user`)) {
|
||||||
@ -730,11 +923,23 @@ UserApi <- R6::R6Class(
|
|||||||
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
|
||||||
ApiResponse$new(NULL, resp)
|
ApiResponse$new(NULL, resp)
|
||||||
} else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
|
} 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)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- paste("Server returned ", httr::status_code(resp), " response status code.")
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
} else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
|
||||||
ApiResponse$new("API client error", resp)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- "Api client exception encountered."
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
} else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
|
||||||
ApiResponse$new("API server error", resp)
|
error_msg <- toString(content(resp))
|
||||||
|
if(error_msg == "") {
|
||||||
|
error_msg <- "Api server exception encountered."
|
||||||
|
}
|
||||||
|
rlang::abort(message = error_msg, .subclass = "ApiException", ApiException = ApiException$new(http_response = resp))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -18,13 +18,26 @@ test data_file to ensure it's escaped correctly
|
|||||||
```R
|
```R
|
||||||
library(petstore)
|
library(petstore)
|
||||||
|
|
||||||
var.dummy <- 'dummy_example' # character | dummy required parameter
|
var_dummy <- 'dummy_example' # character | dummy required parameter
|
||||||
var.var_data_file <- 'var_data_file_example' # character | header data file
|
var_var_data_file <- 'var_data_file_example' # character | header data file
|
||||||
|
|
||||||
#test data_file to ensure it's escaped correctly
|
#test data_file to ensure it's escaped correctly
|
||||||
api.instance <- FakeApi$new()
|
api_instance <- FakeApi$new()
|
||||||
result <- api.instance$FakeDataFile(var.dummy, var_data_file=var.var_data_file)
|
result <- tryCatch(
|
||||||
dput(result)
|
api_instance$FakeDataFile(var_dummy, var_data_file=var_var_data_file),
|
||||||
|
ApiException = function(ex) ex
|
||||||
|
)
|
||||||
|
# In case of error, print the error object
|
||||||
|
if(!is.null(result$ApiException)) {
|
||||||
|
cat(result$ApiException$toString())
|
||||||
|
} else {
|
||||||
|
# deserialized response object
|
||||||
|
response.object <- result$content
|
||||||
|
# response headers
|
||||||
|
response.headers <- result$response$headers
|
||||||
|
# response status code
|
||||||
|
response.status.code <- result$response$status_code
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
|
@ -25,14 +25,27 @@ Add a new pet to the store
|
|||||||
```R
|
```R
|
||||||
library(petstore)
|
library(petstore)
|
||||||
|
|
||||||
var.pet <- Pet$new("name_example", list("photoUrls_example"), 123, Category$new(123, "name_example"), list(Tag$new(123, "name_example")), "available") # Pet | Pet object that needs to be added to the store
|
var_pet <- Pet$new("name_example", list("photoUrls_example"), 123, Category$new(123, "name_example"), list(Tag$new(123, "name_example")), "available") # Pet | Pet object that needs to be added to the store
|
||||||
|
|
||||||
#Add a new pet to the store
|
#Add a new pet to the store
|
||||||
api.instance <- PetApi$new()
|
api_instance <- PetApi$new()
|
||||||
# Configure OAuth2 access token for authorization: petstore_auth
|
# 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)
|
result <- tryCatch(
|
||||||
dput(result)
|
api_instance$AddPet(var_pet),
|
||||||
|
ApiException = function(ex) ex
|
||||||
|
)
|
||||||
|
# In case of error, print the error object
|
||||||
|
if(!is.null(result$ApiException)) {
|
||||||
|
cat(result$ApiException$toString())
|
||||||
|
} else {
|
||||||
|
# deserialized response object
|
||||||
|
response.object <- result$content
|
||||||
|
# response headers
|
||||||
|
response.headers <- result$response$headers
|
||||||
|
# response status code
|
||||||
|
response.status.code <- result$response$status_code
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
@ -71,14 +84,26 @@ Deletes a pet
|
|||||||
```R
|
```R
|
||||||
library(petstore)
|
library(petstore)
|
||||||
|
|
||||||
var.pet_id <- 56 # integer | Pet id to delete
|
var_pet_id <- 56 # integer | Pet id to delete
|
||||||
var.api_key <- 'api_key_example' # character |
|
var_api_key <- 'api_key_example' # character |
|
||||||
|
|
||||||
#Deletes a pet
|
#Deletes a pet
|
||||||
api.instance <- PetApi$new()
|
api_instance <- PetApi$new()
|
||||||
# Configure OAuth2 access token for authorization: petstore_auth
|
# 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';
|
||||||
api.instance$DeletePet(var.pet_id, api_key=var.api_key)
|
result <- tryCatch(
|
||||||
|
api_instance$DeletePet(var_pet_id, api_key=var_api_key),
|
||||||
|
ApiException = function(ex) ex
|
||||||
|
)
|
||||||
|
# In case of error, print the error object
|
||||||
|
if(!is.null(result$ApiException)) {
|
||||||
|
cat(result$ApiException$toString())
|
||||||
|
} else {
|
||||||
|
# response headers
|
||||||
|
response.headers <- result$response$headers
|
||||||
|
# response status code
|
||||||
|
response.status.code <- result$response$status_code
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
@ -117,14 +142,27 @@ Multiple status values can be provided with comma separated strings
|
|||||||
```R
|
```R
|
||||||
library(petstore)
|
library(petstore)
|
||||||
|
|
||||||
var.status <- list("available") # array[character] | Status values that need to be considered for filter
|
var_status <- list("available") # array[character] | Status values that need to be considered for filter
|
||||||
|
|
||||||
#Finds Pets by status
|
#Finds Pets by status
|
||||||
api.instance <- PetApi$new()
|
api_instance <- PetApi$new()
|
||||||
# Configure OAuth2 access token for authorization: petstore_auth
|
# 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)
|
result <- tryCatch(
|
||||||
dput(result)
|
api_instance$FindPetsByStatus(var_status),
|
||||||
|
ApiException = function(ex) ex
|
||||||
|
)
|
||||||
|
# In case of error, print the error object
|
||||||
|
if(!is.null(result$ApiException)) {
|
||||||
|
cat(result$ApiException$toString())
|
||||||
|
} else {
|
||||||
|
# deserialized response object
|
||||||
|
response.object <- result$content
|
||||||
|
# response headers
|
||||||
|
response.headers <- result$response$headers
|
||||||
|
# response status code
|
||||||
|
response.status.code <- result$response$status_code
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
@ -163,14 +201,27 @@ Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3
|
|||||||
```R
|
```R
|
||||||
library(petstore)
|
library(petstore)
|
||||||
|
|
||||||
var.tags <- list("inner_example") # array[character] | Tags to filter by
|
var_tags <- list("inner_example") # array[character] | Tags to filter by
|
||||||
|
|
||||||
#Finds Pets by tags
|
#Finds Pets by tags
|
||||||
api.instance <- PetApi$new()
|
api_instance <- PetApi$new()
|
||||||
# Configure OAuth2 access token for authorization: petstore_auth
|
# 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)
|
result <- tryCatch(
|
||||||
dput(result)
|
api_instance$FindPetsByTags(var_tags),
|
||||||
|
ApiException = function(ex) ex
|
||||||
|
)
|
||||||
|
# In case of error, print the error object
|
||||||
|
if(!is.null(result$ApiException)) {
|
||||||
|
cat(result$ApiException$toString())
|
||||||
|
} else {
|
||||||
|
# deserialized response object
|
||||||
|
response.object <- result$content
|
||||||
|
# response headers
|
||||||
|
response.headers <- result$response$headers
|
||||||
|
# response status code
|
||||||
|
response.status.code <- result$response$status_code
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
@ -209,14 +260,27 @@ Returns a single pet
|
|||||||
```R
|
```R
|
||||||
library(petstore)
|
library(petstore)
|
||||||
|
|
||||||
var.pet_id <- 56 # integer | ID of pet to return
|
var_pet_id <- 56 # integer | ID of pet to return
|
||||||
|
|
||||||
#Find pet by ID
|
#Find pet by ID
|
||||||
api.instance <- PetApi$new()
|
api_instance <- PetApi$new()
|
||||||
# Configure API key authorization: api_key
|
# 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)
|
result <- tryCatch(
|
||||||
dput(result)
|
api_instance$GetPetById(var_pet_id),
|
||||||
|
ApiException = function(ex) ex
|
||||||
|
)
|
||||||
|
# In case of error, print the error object
|
||||||
|
if(!is.null(result$ApiException)) {
|
||||||
|
cat(result$ApiException$toString())
|
||||||
|
} else {
|
||||||
|
# deserialized response object
|
||||||
|
response.object <- result$content
|
||||||
|
# response headers
|
||||||
|
response.headers <- result$response$headers
|
||||||
|
# response status code
|
||||||
|
response.status.code <- result$response$status_code
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
@ -256,14 +320,27 @@ Update an existing pet
|
|||||||
```R
|
```R
|
||||||
library(petstore)
|
library(petstore)
|
||||||
|
|
||||||
var.pet <- Pet$new("name_example", list("photoUrls_example"), 123, Category$new(123, "name_example"), list(Tag$new(123, "name_example")), "available") # Pet | Pet object that needs to be added to the store
|
var_pet <- Pet$new("name_example", list("photoUrls_example"), 123, Category$new(123, "name_example"), list(Tag$new(123, "name_example")), "available") # Pet | Pet object that needs to be added to the store
|
||||||
|
|
||||||
#Update an existing pet
|
#Update an existing pet
|
||||||
api.instance <- PetApi$new()
|
api_instance <- PetApi$new()
|
||||||
# Configure OAuth2 access token for authorization: petstore_auth
|
# 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)
|
result <- tryCatch(
|
||||||
dput(result)
|
api_instance$UpdatePet(var_pet),
|
||||||
|
ApiException = function(ex) ex
|
||||||
|
)
|
||||||
|
# In case of error, print the error object
|
||||||
|
if(!is.null(result$ApiException)) {
|
||||||
|
cat(result$ApiException$toString())
|
||||||
|
} else {
|
||||||
|
# deserialized response object
|
||||||
|
response.object <- result$content
|
||||||
|
# response headers
|
||||||
|
response.headers <- result$response$headers
|
||||||
|
# response status code
|
||||||
|
response.status.code <- result$response$status_code
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
@ -304,15 +381,27 @@ Updates a pet in the store with form data
|
|||||||
```R
|
```R
|
||||||
library(petstore)
|
library(petstore)
|
||||||
|
|
||||||
var.pet_id <- 56 # integer | ID of pet that needs to be updated
|
var_pet_id <- 56 # integer | ID of pet that needs to be updated
|
||||||
var.name <- 'name_example' # character | Updated name of the pet
|
var_name <- 'name_example' # character | Updated name of the pet
|
||||||
var.status <- 'status_example' # character | Updated status of the pet
|
var_status <- 'status_example' # character | Updated status of the pet
|
||||||
|
|
||||||
#Updates a pet in the store with form data
|
#Updates a pet in the store with form data
|
||||||
api.instance <- PetApi$new()
|
api_instance <- PetApi$new()
|
||||||
# Configure OAuth2 access token for authorization: petstore_auth
|
# 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';
|
||||||
api.instance$UpdatePetWithForm(var.pet_id, name=var.name, status=var.status)
|
result <- tryCatch(
|
||||||
|
api_instance$UpdatePetWithForm(var_pet_id, name=var_name, status=var_status),
|
||||||
|
ApiException = function(ex) ex
|
||||||
|
)
|
||||||
|
# In case of error, print the error object
|
||||||
|
if(!is.null(result$ApiException)) {
|
||||||
|
cat(result$ApiException$toString())
|
||||||
|
} else {
|
||||||
|
# response headers
|
||||||
|
response.headers <- result$response$headers
|
||||||
|
# response status code
|
||||||
|
response.status.code <- result$response$status_code
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
@ -352,16 +441,29 @@ uploads an image
|
|||||||
```R
|
```R
|
||||||
library(petstore)
|
library(petstore)
|
||||||
|
|
||||||
var.pet_id <- 56 # integer | ID of pet to update
|
var_pet_id <- 56 # integer | ID of pet to update
|
||||||
var.additional_metadata <- 'additional_metadata_example' # character | Additional data to pass to server
|
var_additional_metadata <- 'additional_metadata_example' # character | Additional data to pass to server
|
||||||
var.file <- File.new('/path/to/file') # data.frame | file to upload
|
var_file <- File.new('/path/to/file') # data.frame | file to upload
|
||||||
|
|
||||||
#uploads an image
|
#uploads an image
|
||||||
api.instance <- PetApi$new()
|
api_instance <- PetApi$new()
|
||||||
# Configure OAuth2 access token for authorization: petstore_auth
|
# 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)
|
result <- tryCatch(
|
||||||
dput(result)
|
api_instance$UploadFile(var_pet_id, additional_metadata=var_additional_metadata, file=var_file),
|
||||||
|
ApiException = function(ex) ex
|
||||||
|
)
|
||||||
|
# In case of error, print the error object
|
||||||
|
if(!is.null(result$ApiException)) {
|
||||||
|
cat(result$ApiException$toString())
|
||||||
|
} else {
|
||||||
|
# deserialized response object
|
||||||
|
response.object <- result$content
|
||||||
|
# response headers
|
||||||
|
response.headers <- result$response$headers
|
||||||
|
# response status code
|
||||||
|
response.status.code <- result$response$status_code
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
|
@ -21,11 +21,23 @@ For valid response try integer IDs with value < 1000. Anything above 1000 or non
|
|||||||
```R
|
```R
|
||||||
library(petstore)
|
library(petstore)
|
||||||
|
|
||||||
var.order_id <- 'order_id_example' # character | ID of the order that needs to be deleted
|
var_order_id <- 'order_id_example' # character | ID of the order that needs to be deleted
|
||||||
|
|
||||||
#Delete purchase order by ID
|
#Delete purchase order by ID
|
||||||
api.instance <- StoreApi$new()
|
api_instance <- StoreApi$new()
|
||||||
api.instance$DeleteOrder(var.order_id)
|
result <- tryCatch(
|
||||||
|
api_instance$DeleteOrder(var_order_id),
|
||||||
|
ApiException = function(ex) ex
|
||||||
|
)
|
||||||
|
# In case of error, print the error object
|
||||||
|
if(!is.null(result$ApiException)) {
|
||||||
|
cat(result$ApiException$toString())
|
||||||
|
} else {
|
||||||
|
# response headers
|
||||||
|
response.headers <- result$response$headers
|
||||||
|
# response status code
|
||||||
|
response.status.code <- result$response$status_code
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
@ -66,11 +78,24 @@ library(petstore)
|
|||||||
|
|
||||||
|
|
||||||
#Returns pet inventories by status
|
#Returns pet inventories by status
|
||||||
api.instance <- StoreApi$new()
|
api_instance <- StoreApi$new()
|
||||||
# Configure API key authorization: api_key
|
# 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()
|
result <- tryCatch(
|
||||||
dput(result)
|
api_instance$GetInventory(),
|
||||||
|
ApiException = function(ex) ex
|
||||||
|
)
|
||||||
|
# In case of error, print the error object
|
||||||
|
if(!is.null(result$ApiException)) {
|
||||||
|
cat(result$ApiException$toString())
|
||||||
|
} else {
|
||||||
|
# deserialized response object
|
||||||
|
response.object <- result$content
|
||||||
|
# response headers
|
||||||
|
response.headers <- result$response$headers
|
||||||
|
# response status code
|
||||||
|
response.status.code <- result$response$status_code
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
@ -105,12 +130,25 @@ For valid response try integer IDs with value <= 5 or > 10. Other values will ge
|
|||||||
```R
|
```R
|
||||||
library(petstore)
|
library(petstore)
|
||||||
|
|
||||||
var.order_id <- 56 # integer | ID of pet that needs to be fetched
|
var_order_id <- 56 # integer | ID of pet that needs to be fetched
|
||||||
|
|
||||||
#Find purchase order by ID
|
#Find purchase order by ID
|
||||||
api.instance <- StoreApi$new()
|
api_instance <- StoreApi$new()
|
||||||
result <- api.instance$GetOrderById(var.order_id)
|
result <- tryCatch(
|
||||||
dput(result)
|
api_instance$GetOrderById(var_order_id),
|
||||||
|
ApiException = function(ex) ex
|
||||||
|
)
|
||||||
|
# In case of error, print the error object
|
||||||
|
if(!is.null(result$ApiException)) {
|
||||||
|
cat(result$ApiException$toString())
|
||||||
|
} else {
|
||||||
|
# deserialized response object
|
||||||
|
response.object <- result$content
|
||||||
|
# response headers
|
||||||
|
response.headers <- result$response$headers
|
||||||
|
# response status code
|
||||||
|
response.status.code <- result$response$status_code
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
@ -150,12 +188,25 @@ Place an order for a pet
|
|||||||
```R
|
```R
|
||||||
library(petstore)
|
library(petstore)
|
||||||
|
|
||||||
var.order <- Order$new(123, 123, 123, "shipDate_example", "placed", "complete_example") # Order | order placed for purchasing the pet
|
var_order <- Order$new(123, 123, 123, "shipDate_example", "placed", "complete_example") # Order | order placed for purchasing the pet
|
||||||
|
|
||||||
#Place an order for a pet
|
#Place an order for a pet
|
||||||
api.instance <- StoreApi$new()
|
api_instance <- StoreApi$new()
|
||||||
result <- api.instance$PlaceOrder(var.order)
|
result <- tryCatch(
|
||||||
dput(result)
|
api_instance$PlaceOrder(var_order),
|
||||||
|
ApiException = function(ex) ex
|
||||||
|
)
|
||||||
|
# In case of error, print the error object
|
||||||
|
if(!is.null(result$ApiException)) {
|
||||||
|
cat(result$ApiException$toString())
|
||||||
|
} else {
|
||||||
|
# deserialized response object
|
||||||
|
response.object <- result$content
|
||||||
|
# response headers
|
||||||
|
response.headers <- result$response$headers
|
||||||
|
# response status code
|
||||||
|
response.status.code <- result$response$status_code
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
|
@ -25,13 +25,25 @@ This can only be done by the logged in user.
|
|||||||
```R
|
```R
|
||||||
library(petstore)
|
library(petstore)
|
||||||
|
|
||||||
var.user <- User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123) # User | Created user object
|
var_user <- User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123) # User | Created user object
|
||||||
|
|
||||||
#Create user
|
#Create user
|
||||||
api.instance <- UserApi$new()
|
api_instance <- UserApi$new()
|
||||||
# Configure API key authorization: api_key
|
# 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';
|
||||||
api.instance$CreateUser(var.user)
|
result <- tryCatch(
|
||||||
|
api_instance$CreateUser(var_user),
|
||||||
|
ApiException = function(ex) ex
|
||||||
|
)
|
||||||
|
# In case of error, print the error object
|
||||||
|
if(!is.null(result$ApiException)) {
|
||||||
|
cat(result$ApiException$toString())
|
||||||
|
} else {
|
||||||
|
# response headers
|
||||||
|
response.headers <- result$response$headers
|
||||||
|
# response status code
|
||||||
|
response.status.code <- result$response$status_code
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
@ -69,13 +81,25 @@ Creates list of users with given input array
|
|||||||
```R
|
```R
|
||||||
library(petstore)
|
library(petstore)
|
||||||
|
|
||||||
var.user <- list(User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123)) # array[User] | List of user object
|
var_user <- list(User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123)) # array[User] | List of user object
|
||||||
|
|
||||||
#Creates list of users with given input array
|
#Creates list of users with given input array
|
||||||
api.instance <- UserApi$new()
|
api_instance <- UserApi$new()
|
||||||
# Configure API key authorization: api_key
|
# 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';
|
||||||
api.instance$CreateUsersWithArrayInput(var.user)
|
result <- tryCatch(
|
||||||
|
api_instance$CreateUsersWithArrayInput(var_user),
|
||||||
|
ApiException = function(ex) ex
|
||||||
|
)
|
||||||
|
# In case of error, print the error object
|
||||||
|
if(!is.null(result$ApiException)) {
|
||||||
|
cat(result$ApiException$toString())
|
||||||
|
} else {
|
||||||
|
# response headers
|
||||||
|
response.headers <- result$response$headers
|
||||||
|
# response status code
|
||||||
|
response.status.code <- result$response$status_code
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
@ -113,13 +137,25 @@ Creates list of users with given input array
|
|||||||
```R
|
```R
|
||||||
library(petstore)
|
library(petstore)
|
||||||
|
|
||||||
var.user <- list(User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123)) # array[User] | List of user object
|
var_user <- list(User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123)) # array[User] | List of user object
|
||||||
|
|
||||||
#Creates list of users with given input array
|
#Creates list of users with given input array
|
||||||
api.instance <- UserApi$new()
|
api_instance <- UserApi$new()
|
||||||
# Configure API key authorization: api_key
|
# 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';
|
||||||
api.instance$CreateUsersWithListInput(var.user)
|
result <- tryCatch(
|
||||||
|
api_instance$CreateUsersWithListInput(var_user),
|
||||||
|
ApiException = function(ex) ex
|
||||||
|
)
|
||||||
|
# In case of error, print the error object
|
||||||
|
if(!is.null(result$ApiException)) {
|
||||||
|
cat(result$ApiException$toString())
|
||||||
|
} else {
|
||||||
|
# response headers
|
||||||
|
response.headers <- result$response$headers
|
||||||
|
# response status code
|
||||||
|
response.status.code <- result$response$status_code
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
@ -157,13 +193,25 @@ This can only be done by the logged in user.
|
|||||||
```R
|
```R
|
||||||
library(petstore)
|
library(petstore)
|
||||||
|
|
||||||
var.username <- 'username_example' # character | The name that needs to be deleted
|
var_username <- 'username_example' # character | The name that needs to be deleted
|
||||||
|
|
||||||
#Delete user
|
#Delete user
|
||||||
api.instance <- UserApi$new()
|
api_instance <- UserApi$new()
|
||||||
# Configure API key authorization: api_key
|
# 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';
|
||||||
api.instance$DeleteUser(var.username)
|
result <- tryCatch(
|
||||||
|
api_instance$DeleteUser(var_username),
|
||||||
|
ApiException = function(ex) ex
|
||||||
|
)
|
||||||
|
# In case of error, print the error object
|
||||||
|
if(!is.null(result$ApiException)) {
|
||||||
|
cat(result$ApiException$toString())
|
||||||
|
} else {
|
||||||
|
# response headers
|
||||||
|
response.headers <- result$response$headers
|
||||||
|
# response status code
|
||||||
|
response.status.code <- result$response$status_code
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
@ -202,12 +250,25 @@ Get user by user name
|
|||||||
```R
|
```R
|
||||||
library(petstore)
|
library(petstore)
|
||||||
|
|
||||||
var.username <- 'username_example' # character | The name that needs to be fetched. Use user1 for testing.
|
var_username <- 'username_example' # character | The name that needs to be fetched. Use user1 for testing.
|
||||||
|
|
||||||
#Get user by user name
|
#Get user by user name
|
||||||
api.instance <- UserApi$new()
|
api_instance <- UserApi$new()
|
||||||
result <- api.instance$GetUserByName(var.username)
|
result <- tryCatch(
|
||||||
dput(result)
|
api_instance$GetUserByName(var_username),
|
||||||
|
ApiException = function(ex) ex
|
||||||
|
)
|
||||||
|
# In case of error, print the error object
|
||||||
|
if(!is.null(result$ApiException)) {
|
||||||
|
cat(result$ApiException$toString())
|
||||||
|
} else {
|
||||||
|
# deserialized response object
|
||||||
|
response.object <- result$content
|
||||||
|
# response headers
|
||||||
|
response.headers <- result$response$headers
|
||||||
|
# response status code
|
||||||
|
response.status.code <- result$response$status_code
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
@ -247,13 +308,26 @@ Logs user into the system
|
|||||||
```R
|
```R
|
||||||
library(petstore)
|
library(petstore)
|
||||||
|
|
||||||
var.username <- 'username_example' # character | The user name for login
|
var_username <- 'username_example' # character | The user name for login
|
||||||
var.password <- 'password_example' # character | The password for login in clear text
|
var_password <- 'password_example' # character | The password for login in clear text
|
||||||
|
|
||||||
#Logs user into the system
|
#Logs user into the system
|
||||||
api.instance <- UserApi$new()
|
api_instance <- UserApi$new()
|
||||||
result <- api.instance$LoginUser(var.username, var.password)
|
result <- tryCatch(
|
||||||
dput(result)
|
api_instance$LoginUser(var_username, var_password),
|
||||||
|
ApiException = function(ex) ex
|
||||||
|
)
|
||||||
|
# In case of error, print the error object
|
||||||
|
if(!is.null(result$ApiException)) {
|
||||||
|
cat(result$ApiException$toString())
|
||||||
|
} else {
|
||||||
|
# deserialized response object
|
||||||
|
response.object <- result$content
|
||||||
|
# response headers
|
||||||
|
response.headers <- result$response$headers
|
||||||
|
# response status code
|
||||||
|
response.status.code <- result$response$status_code
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
@ -295,10 +369,22 @@ library(petstore)
|
|||||||
|
|
||||||
|
|
||||||
#Logs out current logged in user session
|
#Logs out current logged in user session
|
||||||
api.instance <- UserApi$new()
|
api_instance <- UserApi$new()
|
||||||
# Configure API key authorization: api_key
|
# 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';
|
||||||
api.instance$LogoutUser()
|
result <- tryCatch(
|
||||||
|
api_instance$LogoutUser(),
|
||||||
|
ApiException = function(ex) ex
|
||||||
|
)
|
||||||
|
# In case of error, print the error object
|
||||||
|
if(!is.null(result$ApiException)) {
|
||||||
|
cat(result$ApiException$toString())
|
||||||
|
} else {
|
||||||
|
# response headers
|
||||||
|
response.headers <- result$response$headers
|
||||||
|
# response status code
|
||||||
|
response.status.code <- result$response$status_code
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
@ -333,14 +419,26 @@ This can only be done by the logged in user.
|
|||||||
```R
|
```R
|
||||||
library(petstore)
|
library(petstore)
|
||||||
|
|
||||||
var.username <- 'username_example' # character | name that need to be deleted
|
var_username <- 'username_example' # character | name that need to be deleted
|
||||||
var.user <- User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123) # User | Updated user object
|
var_user <- User$new(123, "username_example", "firstName_example", "lastName_example", "email_example", "password_example", "phone_example", 123) # User | Updated user object
|
||||||
|
|
||||||
#Updated user
|
#Updated user
|
||||||
api.instance <- UserApi$new()
|
api_instance <- UserApi$new()
|
||||||
# Configure API key authorization: api_key
|
# 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';
|
||||||
api.instance$UpdateUser(var.username, var.user)
|
result <- tryCatch(
|
||||||
|
api_instance$UpdateUser(var_username, var_user),
|
||||||
|
ApiException = function(ex) ex
|
||||||
|
)
|
||||||
|
# In case of error, print the error object
|
||||||
|
if(!is.null(result$ApiException)) {
|
||||||
|
cat(result$ApiException$toString())
|
||||||
|
} else {
|
||||||
|
# response headers
|
||||||
|
response.headers <- result$response$headers
|
||||||
|
# response status code
|
||||||
|
response.status.code <- result$response$status_code
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
|
24
samples/client/petstore/R/test_petstore.R
Normal file
24
samples/client/petstore/R/test_petstore.R
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
library(petstore)
|
||||||
|
|
||||||
|
var_pet_id <- 56 # integer | ID of pet to return
|
||||||
|
|
||||||
|
#Find pet by ID
|
||||||
|
api_instance <- PetApi$new()
|
||||||
|
# Configure API key authorization: api_key
|
||||||
|
api_instance$api_client$api_keys['api_key'] <- 'TODO_YOUR_API_KEY';
|
||||||
|
result <- tryCatch(
|
||||||
|
api_instance$GetPetById(var_pet_id),
|
||||||
|
ApiException = function(ex) ex
|
||||||
|
)
|
||||||
|
# In case of error, print the error object
|
||||||
|
if(!is.null(result$ApiException)) {
|
||||||
|
cat(result$ApiException$toString())
|
||||||
|
} else {
|
||||||
|
# deserialized response object
|
||||||
|
response.object <- result$content
|
||||||
|
# response headers
|
||||||
|
response.headers <- result$response$headers
|
||||||
|
# response status code
|
||||||
|
response.status.code <- result$response$status_code
|
||||||
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user