R/ap_is_api.R

# Singlearity Baseball API
#
# Baseball optimization API using machine learning
#
# The version of the OpenAPI document: 0.1.1
# 
# Generated by: https://openapi-generator.tech

#' @docType class
#' @title APIs operations
#' @description singlearity.APIs
#' @format An \code{R6Class} generator object
#' @field apiClient Handles the client-server communication.
#'
#' @section Methods:
#' \describe{
#' \strong{ GetGameSim } \emph{ Get Game Sim }
#' 
#'
#' \itemize{
#' \item \emph{ @param } body.get.game.sim.game.sim.post \link{BodyGetGameSimGameSimPost}
#' \item \emph{ @param } num.sims integer
#' \item \emph{ @returnType } list( \link{GameSimResults} ) \cr
#'
#'
#' \item status code : 200 | Successful Response
#'
#' \item return type : array[GameSimResults] 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 422 | Validation Error
#'
#' \item return type : HTTPValidationError 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ GetPaSim } \emph{ Get Pa Sim }
#' 
#'
#' \itemize{
#' \item \emph{ @param } matchup list( \link{Matchup} )
#' \item \emph{ @param } return.features character
#' \item \emph{ @param } model.name character
#'
#'
#' \item status code : 200 | Successful Response
#'
#' \item return type : object 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 422 | Validation Error
#'
#' \item return type : HTTPValidationError 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ GetPlayers } \emph{ Get Players }
#' 
#'
#' \itemize{
#' \item \emph{ @param } name character
#' \item \emph{ @param } id integer
#' \item \emph{ @param } team.name character
#' \item \emph{ @param } team.id integer
#' \item \emph{ @param } position list( character )
#' \item \emph{ @param } age.min integer
#' \item \emph{ @param } age.max integer
#' \item \emph{ @param } pitch.hand list( character )
#' \item \emph{ @param } bat.side list( character )
#' \item \emph{ @param } active character
#' \item \emph{ @param } on.40 character
#' \item \emph{ @returnType } list( \link{Player} ) \cr
#'
#'
#' \item status code : 200 | Successful Response
#'
#' \item return type : array[Player] 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 422 | Validation Error
#'
#' \item return type : HTTPValidationError 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ GetTeams } \emph{ Get Teams }
#' 
#'
#' \itemize{
#' \item \emph{ @param } name character
#' \item \emph{ @returnType } list( \link{Team} ) \cr
#'
#'
#' \item status code : 200 | Successful Response
#'
#' \item return type : array[Team] 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 422 | Validation Error
#'
#' \item return type : HTTPValidationError 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ GetVenues } \emph{ Get Venues }
#' 
#'
#' \itemize{
#' \item \emph{ @param } stadium.name character
#' \item \emph{ @param } team.name character
#' \item \emph{ @returnType } list( \link{Venue} ) \cr
#'
#'
#' \item status code : 200 | Successful Response
#'
#' \item return type : array[Venue] 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' \item status code : 422 | Validation Error
#'
#' \item return type : HTTPValidationError 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ Hello } \emph{ Hello }
#' 
#'
#' \itemize{
#'
#'
#' \item status code : 200 | Successful Response
#'
#' \item return type : object 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' \strong{ HelloWithKey } \emph{ Hello With Key }
#' 
#'
#' \itemize{
#'
#'
#' \item status code : 200 | Successful Response
#'
#' \item return type : object 
#' \item response headers :
#'
#' \tabular{ll}{
#' }
#' }
#'
#' }
#'
#'
#' @examples
#' \dontrun{
#' ####################  GetGameSim  ####################
#'
#' library(singlearity)
#' var.body.get.game.sim.game.sim.post <- BodyGetGameSimGameSimPost$new() # BodyGetGameSimGameSimPost | 
#' var.num.sims <- 100 # integer | 
#'
#' #Get Game Sim
#' api.instance <- APIsApi$new()
#'
#' #Configure API key authorization: APIKeyHeader
#' api.instance$apiClient$apiKeys['SINGLEARITY_API_KEY'] <- 'TODO_YOUR_API_KEY';
#'
#' #Configure API key authorization: APIKeyQuery
#' api.instance$apiClient$apiKeys['SINGLEARITY_API_KEY'] <- 'TODO_YOUR_API_KEY';
#'
#' result <- api.instance$GetGameSim(var.body.get.game.sim.game.sim.post, num.sims=var.num.sims)
#'
#'
#' ####################  GetPaSim  ####################
#'
#' library(singlearity)
#' var.matchup <- [Matchup$new()] # array[Matchup] | 
#' var.return.features <- FALSE # character | 
#' var.model.name <- 'model.name_example' # character | 
#'
#' #Get Pa Sim
#' api.instance <- APIsApi$new()
#'
#' #Configure API key authorization: APIKeyHeader
#' api.instance$apiClient$apiKeys['SINGLEARITY_API_KEY'] <- 'TODO_YOUR_API_KEY';
#'
#' #Configure API key authorization: APIKeyQuery
#' api.instance$apiClient$apiKeys['SINGLEARITY_API_KEY'] <- 'TODO_YOUR_API_KEY';
#'
#' result <- api.instance$GetPaSim(var.matchup, return.features=var.return.features, model.name=var.model.name)
#'
#'
#' ####################  GetPlayers  ####################
#'
#' library(singlearity)
#' var.name <- 'name_example' # character | 
#' var.id <- 56 # integer | 
#' var.team.name <- 'team.name_example' # character | 
#' var.team.id <- 56 # integer | 
#' var.position <- ['position_example'] # array[character] | 
#' var.age.min <- 56 # integer | 
#' var.age.max <- 56 # integer | 
#' var.pitch.hand <- ['pitch.hand_example'] # array[character] | 
#' var.bat.side <- ['bat.side_example'] # array[character] | 
#' var.active <- 'active_example' # character | 
#' var.on.40 <- 'on.40_example' # character | 
#'
#' #Get Players
#' api.instance <- APIsApi$new()
#'
#' #Configure API key authorization: APIKeyHeader
#' api.instance$apiClient$apiKeys['SINGLEARITY_API_KEY'] <- 'TODO_YOUR_API_KEY';
#'
#' #Configure API key authorization: APIKeyQuery
#' api.instance$apiClient$apiKeys['SINGLEARITY_API_KEY'] <- 'TODO_YOUR_API_KEY';
#'
#' result <- api.instance$GetPlayers(name=var.name, id=var.id, team.name=var.team.name, team.id=var.team.id, position=var.position, age.min=var.age.min, age.max=var.age.max, pitch.hand=var.pitch.hand, bat.side=var.bat.side, active=var.active, on.40=var.on.40)
#'
#'
#' ####################  GetTeams  ####################
#'
#' library(singlearity)
#' var.name <- 'name_example' # character | 
#'
#' #Get Teams
#' api.instance <- APIsApi$new()
#'
#' #Configure API key authorization: APIKeyHeader
#' api.instance$apiClient$apiKeys['SINGLEARITY_API_KEY'] <- 'TODO_YOUR_API_KEY';
#'
#' #Configure API key authorization: APIKeyQuery
#' api.instance$apiClient$apiKeys['SINGLEARITY_API_KEY'] <- 'TODO_YOUR_API_KEY';
#'
#' result <- api.instance$GetTeams(name=var.name)
#'
#'
#' ####################  GetVenues  ####################
#'
#' library(singlearity)
#' var.stadium.name <- 'stadium.name_example' # character | 
#' var.team.name <- 'team.name_example' # character | 
#'
#' #Get Venues
#' api.instance <- APIsApi$new()
#'
#' #Configure API key authorization: APIKeyHeader
#' api.instance$apiClient$apiKeys['SINGLEARITY_API_KEY'] <- 'TODO_YOUR_API_KEY';
#'
#' #Configure API key authorization: APIKeyQuery
#' api.instance$apiClient$apiKeys['SINGLEARITY_API_KEY'] <- 'TODO_YOUR_API_KEY';
#'
#' result <- api.instance$GetVenues(stadium.name=var.stadium.name, team.name=var.team.name)
#'
#'
#' ####################  Hello  ####################
#'
#' library(singlearity)
#'
#' #Hello
#' api.instance <- APIsApi$new()
#'
#' result <- api.instance$Hello()
#'
#'
#' ####################  HelloWithKey  ####################
#'
#' library(singlearity)
#'
#' #Hello With Key
#' api.instance <- APIsApi$new()
#'
#' #Configure API key authorization: APIKeyHeader
#' api.instance$apiClient$apiKeys['SINGLEARITY_API_KEY'] <- 'TODO_YOUR_API_KEY';
#'
#' #Configure API key authorization: APIKeyQuery
#' api.instance$apiClient$apiKeys['SINGLEARITY_API_KEY'] <- 'TODO_YOUR_API_KEY';
#'
#' result <- api.instance$HelloWithKey()
#'
#'
#' }
#' @importFrom R6 R6Class
#' @importFrom base64enc base64encode
#' @export
APIsApi <- R6::R6Class(
  'APIsApi',
  public = list(
    apiClient = NULL,
    initialize = function(apiClient){
      if (!missing(apiClient)) {
        self$apiClient <- apiClient
      }
      else {
        self$apiClient <- ApiClient$new()
      }
    },
    GetGameSim = function(body.get.game.sim.game.sim.post, num.sims=100, ...){
      local.optional.var = list(...)
      if (length(local.optional.var) > 0) {
        stop(paste("Unknown argument(s) in calling function GetGameSim: ", paste(names(local.optional.var), collapse=", "), collapse=" "))
      }
      apiResponse <- self$GetGameSimWithHttpInfo(body.get.game.sim.game.sim.post, num.sims, ...)
      resp <- apiResponse$response
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        apiResponse$content
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        apiResponse
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        apiResponse
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        apiResponse
      }
    },

    GetGameSimWithHttpInfo = function(body.get.game.sim.game.sim.post, num.sims=100, ...){
      args <- list(...)
      local.optional.var = list(...)
      if (length(local.optional.var) > 0) {
        stop(paste("Unknown argument(s) in calling function GetGameSim: ", paste(names(local.optional.var), collapse=", "), collapse=" "))
      }
      queryParams <- list()
      headerParams <- c()

      if (missing(`body.get.game.sim.game.sim.post`)) {
        stop("Missing required parameter `body.get.game.sim.game.sim.post`.")
      }

      queryParams['num_sims'] <- num.sims

      if (!missing(`body.get.game.sim.game.sim.post`)) {
        body <- `body.get.game.sim.game.sim.post`$toJSONString()
      } else {
        body <- NULL
      }

      urlPath <- "/game_sim"
      # API key authentication
      if ("SINGLEARITY_API_KEY" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["SINGLEARITY_API_KEY"]) > 0) {
        headerParams['SINGLEARITY_API_KEY'] <- paste(unlist(self$apiClient$apiKeys["SINGLEARITY_API_KEY"]), collapse='')
      }
      # API key authentication
      if ("SINGLEARITY_API_KEY" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["SINGLEARITY_API_KEY"]) > 0) {
        queryParams['SINGLEARITY_API_KEY'] <- paste(unlist(self$apiClient$apiKeys["SINGLEARITY_API_KEY"]), collapse='')
      }

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "POST",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        deserializedRespObj <- tryCatch(
          self$apiClient$deserialize(resp, "array[GameSimResults]", loadNamespace("singlearity")),
          error = function(e){
             stop("Failed to deserialize response")
          }
        )
        ApiResponse$new(deserializedRespObj, resp)
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }
    },
    GetPaSim = function(matchup, return.features=FALSE, model.name=NULL, ...){
      local.optional.var = list(...)
      if (length(local.optional.var) > 0) {
        stop(paste("Unknown argument(s) in calling function GetPaSim: ", paste(names(local.optional.var), collapse=", "), collapse=" "))
      }
      apiResponse <- self$GetPaSimWithHttpInfo(matchup, return.features, model.name, ...)
      resp <- apiResponse$response
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        apiResponse$content
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        apiResponse
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        apiResponse
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        apiResponse
      }
    },

    GetPaSimWithHttpInfo = function(matchup, return.features=FALSE, model.name=NULL, ...){
      args <- list(...)
      local.optional.var = list(...)
      if (length(local.optional.var) > 0) {
        stop(paste("Unknown argument(s) in calling function GetPaSim: ", paste(names(local.optional.var), collapse=", "), collapse=" "))
      }
      queryParams <- list()
      headerParams <- c()

      if (missing(`matchup`)) {
        stop("Missing required parameter `matchup`.")
      }

      queryParams['return_features'] <- return.features

      queryParams['model_name'] <- model.name

      if (!missing(`matchup`)) {
        body.items = paste(unlist(lapply(matchup, function(param){param$toJSONString()})), collapse = ",")
        body <- paste0('[', body.items, ']')
      } else {
        body <- NULL
      }

      urlPath <- "/pa_sim/"
      # API key authentication
      if ("SINGLEARITY_API_KEY" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["SINGLEARITY_API_KEY"]) > 0) {
        headerParams['SINGLEARITY_API_KEY'] <- paste(unlist(self$apiClient$apiKeys["SINGLEARITY_API_KEY"]), collapse='')
      }
      # API key authentication
      if ("SINGLEARITY_API_KEY" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["SINGLEARITY_API_KEY"]) > 0) {
        queryParams['SINGLEARITY_API_KEY'] <- paste(unlist(self$apiClient$apiKeys["SINGLEARITY_API_KEY"]), collapse='')
      }

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "POST",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        deserializedRespObj <- tryCatch(
          self$apiClient$deserialize(resp, "object", loadNamespace("singlearity")),
          error = function(e){
             stop("Failed to deserialize response")
          }
        )
        ApiResponse$new(deserializedRespObj, resp)
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }
    },
    GetPlayers = function(name=NULL, id=NULL, team.name=NULL, team.id=NULL, position=NULL, age.min=NULL, age.max=NULL, pitch.hand=NULL, bat.side=NULL, active=NULL, on.40=NULL, ...){
      local.optional.var = list(...)
      if (length(local.optional.var) > 0) {
        stop(paste("Unknown argument(s) in calling function GetPlayers: ", paste(names(local.optional.var), collapse=", "), collapse=" "))
      }
      apiResponse <- self$GetPlayersWithHttpInfo(name, id, team.name, team.id, position, age.min, age.max, pitch.hand, bat.side, active, on.40, ...)
      resp <- apiResponse$response
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        apiResponse$content
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        apiResponse
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        apiResponse
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        apiResponse
      }
    },

    GetPlayersWithHttpInfo = function(name=NULL, id=NULL, team.name=NULL, team.id=NULL, position=NULL, age.min=NULL, age.max=NULL, pitch.hand=NULL, bat.side=NULL, active=NULL, on.40=NULL, ...){
      args <- list(...)
      local.optional.var = list(...)
      if (length(local.optional.var) > 0) {
        stop(paste("Unknown argument(s) in calling function GetPlayers: ", paste(names(local.optional.var), collapse=", "), collapse=" "))
      }
      queryParams <- list()
      headerParams <- c()

      queryParams['name'] <- name

      queryParams['id'] <- id

      queryParams['team_name'] <- team.name

      queryParams['team_id'] <- team.id

      queryParams['position'] <- position

      queryParams['age_min'] <- age.min

      queryParams['age_max'] <- age.max

      queryParams['pitch_hand'] <- pitch.hand

      queryParams['bat_side'] <- bat.side

      queryParams['active'] <- active

      queryParams['on_40'] <- on.40

      urlPath <- "/players/"
      # API key authentication
      if ("SINGLEARITY_API_KEY" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["SINGLEARITY_API_KEY"]) > 0) {
        headerParams['SINGLEARITY_API_KEY'] <- paste(unlist(self$apiClient$apiKeys["SINGLEARITY_API_KEY"]), collapse='')
      }
      # API key authentication
      if ("SINGLEARITY_API_KEY" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["SINGLEARITY_API_KEY"]) > 0) {
        queryParams['SINGLEARITY_API_KEY'] <- paste(unlist(self$apiClient$apiKeys["SINGLEARITY_API_KEY"]), collapse='')
      }

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "GET",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        deserializedRespObj <- tryCatch(
          self$apiClient$deserialize(resp, "array[Player]", loadNamespace("singlearity")),
          error = function(e){
             stop("Failed to deserialize response")
          }
        )
        ApiResponse$new(deserializedRespObj, resp)
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }
    },
    GetTeams = function(name=NULL, ...){
      local.optional.var = list(...)
      if (length(local.optional.var) > 0) {
        stop(paste("Unknown argument(s) in calling function GetTeams: ", paste(names(local.optional.var), collapse=", "), collapse=" "))
      }
      apiResponse <- self$GetTeamsWithHttpInfo(name, ...)
      resp <- apiResponse$response
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        apiResponse$content
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        apiResponse
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        apiResponse
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        apiResponse
      }
    },

    GetTeamsWithHttpInfo = function(name=NULL, ...){
      args <- list(...)
      local.optional.var = list(...)
      if (length(local.optional.var) > 0) {
        stop(paste("Unknown argument(s) in calling function GetTeams: ", paste(names(local.optional.var), collapse=", "), collapse=" "))
      }
      queryParams <- list()
      headerParams <- c()

      queryParams['name'] <- name

      urlPath <- "/teams/"
      # API key authentication
      if ("SINGLEARITY_API_KEY" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["SINGLEARITY_API_KEY"]) > 0) {
        headerParams['SINGLEARITY_API_KEY'] <- paste(unlist(self$apiClient$apiKeys["SINGLEARITY_API_KEY"]), collapse='')
      }
      # API key authentication
      if ("SINGLEARITY_API_KEY" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["SINGLEARITY_API_KEY"]) > 0) {
        queryParams['SINGLEARITY_API_KEY'] <- paste(unlist(self$apiClient$apiKeys["SINGLEARITY_API_KEY"]), collapse='')
      }

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "GET",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        deserializedRespObj <- tryCatch(
          self$apiClient$deserialize(resp, "array[Team]", loadNamespace("singlearity")),
          error = function(e){
             stop("Failed to deserialize response")
          }
        )
        ApiResponse$new(deserializedRespObj, resp)
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }
    },
    GetVenues = function(stadium.name=NULL, team.name=NULL, ...){
      local.optional.var = list(...)
      if (length(local.optional.var) > 0) {
        stop(paste("Unknown argument(s) in calling function GetVenues: ", paste(names(local.optional.var), collapse=", "), collapse=" "))
      }
      apiResponse <- self$GetVenuesWithHttpInfo(stadium.name, team.name, ...)
      resp <- apiResponse$response
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        apiResponse$content
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        apiResponse
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        apiResponse
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        apiResponse
      }
    },

    GetVenuesWithHttpInfo = function(stadium.name=NULL, team.name=NULL, ...){
      args <- list(...)
      local.optional.var = list(...)
      if (length(local.optional.var) > 0) {
        stop(paste("Unknown argument(s) in calling function GetVenues: ", paste(names(local.optional.var), collapse=", "), collapse=" "))
      }
      queryParams <- list()
      headerParams <- c()

      queryParams['stadium_name'] <- stadium.name

      queryParams['team_name'] <- team.name

      urlPath <- "/venues/"
      # API key authentication
      if ("SINGLEARITY_API_KEY" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["SINGLEARITY_API_KEY"]) > 0) {
        headerParams['SINGLEARITY_API_KEY'] <- paste(unlist(self$apiClient$apiKeys["SINGLEARITY_API_KEY"]), collapse='')
      }
      # API key authentication
      if ("SINGLEARITY_API_KEY" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["SINGLEARITY_API_KEY"]) > 0) {
        queryParams['SINGLEARITY_API_KEY'] <- paste(unlist(self$apiClient$apiKeys["SINGLEARITY_API_KEY"]), collapse='')
      }

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "GET",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        deserializedRespObj <- tryCatch(
          self$apiClient$deserialize(resp, "array[Venue]", loadNamespace("singlearity")),
          error = function(e){
             stop("Failed to deserialize response")
          }
        )
        ApiResponse$new(deserializedRespObj, resp)
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }
    },
    Hello = function(...){
      local.optional.var = list(...)
      if (length(local.optional.var) > 0) {
        stop(paste("Unknown argument(s) in calling function Hello: ", paste(names(local.optional.var), collapse=", "), collapse=" "))
      }
      apiResponse <- self$HelloWithHttpInfo(...)
      resp <- apiResponse$response
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        apiResponse$content
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        apiResponse
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        apiResponse
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        apiResponse
      }
    },

    HelloWithHttpInfo = function(...){
      args <- list(...)
      local.optional.var = list(...)
      if (length(local.optional.var) > 0) {
        stop(paste("Unknown argument(s) in calling function Hello: ", paste(names(local.optional.var), collapse=", "), collapse=" "))
      }
      queryParams <- list()
      headerParams <- c()

      urlPath <- "/hello/"

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "GET",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        deserializedRespObj <- tryCatch(
          self$apiClient$deserialize(resp, "object", loadNamespace("singlearity")),
          error = function(e){
             stop("Failed to deserialize response")
          }
        )
        ApiResponse$new(deserializedRespObj, resp)
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }
    },
    HelloWithKey = function(...){
      local.optional.var = list(...)
      if (length(local.optional.var) > 0) {
        stop(paste("Unknown argument(s) in calling function HelloWithKey: ", paste(names(local.optional.var), collapse=", "), collapse=" "))
      }
      apiResponse <- self$HelloWithKeyWithHttpInfo(...)
      resp <- apiResponse$response
      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        apiResponse$content
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        apiResponse
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        apiResponse
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        apiResponse
      }
    },

    HelloWithKeyWithHttpInfo = function(...){
      args <- list(...)
      local.optional.var = list(...)
      if (length(local.optional.var) > 0) {
        stop(paste("Unknown argument(s) in calling function HelloWithKey: ", paste(names(local.optional.var), collapse=", "), collapse=" "))
      }
      queryParams <- list()
      headerParams <- c()

      urlPath <- "/hello_with_key/"
      # API key authentication
      if ("SINGLEARITY_API_KEY" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["SINGLEARITY_API_KEY"]) > 0) {
        headerParams['SINGLEARITY_API_KEY'] <- paste(unlist(self$apiClient$apiKeys["SINGLEARITY_API_KEY"]), collapse='')
      }
      # API key authentication
      if ("SINGLEARITY_API_KEY" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["SINGLEARITY_API_KEY"]) > 0) {
        queryParams['SINGLEARITY_API_KEY'] <- paste(unlist(self$apiClient$apiKeys["SINGLEARITY_API_KEY"]), collapse='')
      }

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "GET",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        deserializedRespObj <- tryCatch(
          self$apiClient$deserialize(resp, "object", loadNamespace("singlearity")),
          error = function(e){
             stop("Failed to deserialize response")
          }
        )
        ApiResponse$new(deserializedRespObj, resp)
      } else if (httr::status_code(resp) >= 300 && httr::status_code(resp) <= 399) {
        ApiResponse$new(paste("Server returned " , httr::status_code(resp) , " response status code."), resp)
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }
    }
  )
)
singlearity-sports/singlearity-R documentation built on April 21, 2022, 3:48 a.m.