R/Client.r

# Agave Platform Science API
#
# Power your digital lab and reduce the time from theory to discovery using the Agave Science-as-a-Service API Platform. Agave provides hosted services that allow researchers to manage data, conduct experiments, and publish and share results from anywhere at any time.
#
# Agave Platform version: 2.2.14
#
# Generated by: https://github.com/swagger-api/swagger-codegen.git


#' Client Class
#'
#' @field key The API key for this client.
#' @field secret The API secret for this client.
#' @field callbackUrl Callback URL for OAuth authentication grant.
#' @field description Description of the client. This will be shown to users when authentication via OAuth web flows
#' @field name The name of the client.
#' @field tier The access tier for this client. Usually "UNLIMITED"
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
Client <- R6::R6Class(
  'Client',
  public = list(
    `key` = NULL,
    `secret` = NULL,
    `callbackUrl` = NULL,
    `description` = NULL,
    `clientName` = NULL,
    `tier` = NULL,
    initialize = function(`key`, `secret`, `callbackUrl`, `description`, `clientName`, `tier`){
      if (!missing(`key`)) {
        stopifnot(is.character(`key`), length(`key`) == 1)
        self$`key` <- `key`
      }
      if (!missing(`secret`)) {
        stopifnot(is.character(`secret`), length(`secret`) == 1)
        self$`secret` <- `secret`
      }
      if (!missing(`callbackUrl`)) {
        stopifnot(is.character(`callbackUrl`), length(`callbackUrl`) == 1)
        self$`callbackUrl` <- `callbackUrl`
      }
      if (!missing(`description`)) {
        stopifnot(is.character(`description`), length(`description`) == 1)
        self$`description` <- `description`
      }
      if (!missing(`clientName`)) {
        stopifnot(is.character(`clientName`), length(`clientName`) == 1)
        self$`clientName` <- `clientName`
      }
      if (!missing(`tier`)) {
        stopifnot(is.character(`tier`), length(`tier`) == 1)
        self$`tier` <- `tier`
      }
    },
    toJSON = function() {
      ClientObject <- list()
      if (!is.null(self$`key`)) {
        ClientObject[['key']] <- self$`key`
      }
      if (!is.null(self$`secret`)) {
        ClientObject[['secret']] <- self$`secret`
      }
      if (!is.null(self$`callbackUrl`)) {
        ClientObject[['callbackUrl']] <- self$`callbackUrl`
      }
      if (!is.null(self$`description`)) {
        ClientObject[['description']] <- self$`description`
      }
      if (!is.null(self$`clientName`)) {
        ClientObject[['clientName']] <- self$`clientName`
      }
      if (!is.null(self$`tier`)) {
        ClientObject[['tier']] <- self$`tier`
      }

      ClientObject
    },
    fromJSON = function(ClientObject) {
      if (is.character(ClientObject) || is.primitive(ClientObject)) {
        self$fromJSONString(ClientObject)
      }
      else {
        if ("result" %in% names(ClientObject)) {
          ClientObject <- ClientObject$result
        }
        if (!is.null(ClientObject$`key`)) {
          self$`key` <- ClientObject$`key`
        }
        if (!is.null(ClientObject$`consumerKey`)) {
          self$`key` <- ClientObject$`consumerKey`
        }
        if (!is.null(ClientObject$`secret`)) {
          self$`secret` <- ClientObject$`secret`
        }
        if (!is.null(ClientObject$`consumerSecret`)) {
          self$`secret` <- ClientObject$`consumerSecret`
        }
        if (!is.null(ClientObject$`callbackUrl`)) {
          self$`callbackUrl` <- ClientObject$`callbackUrl`
        }
        if (!is.null(ClientObject$`description`)) {
          self$`description` <- ClientObject$`description`
        }
        if (!is.null(ClientObject$`name`)) {
          self$`clientName` <- ClientObject$`name`
        }
        if (!is.null(ClientObject$`client_name`)) {
          self$`clientName` <- ClientObject$`client_name`
        }
        if (!is.null(ClientObject$`clientName`)) {
          self$`clientName` <- ClientObject$`clientName`
        }
        if (!is.null(ClientObject$`tier`)) {
          self$`tier` <- ClientObject$`tier`
        }
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "key": %s,
           "secret": %s,
           "callbackUrl": %s,
           "description": %s,
           "clientName": %s,
           "tier": %s
        }',
        private$enquote(self$`key`),
        private$enquote(self$`secret`),
        private$enquote(self$`callbackUrl`),
        private$enquote(self$`description`),
        private$enquote(self$`clientName`),
        private$enquote(self$`tier`)
      )
    },
    fromJSONString = function(ClientJson) {
      ClientObject <- jsonlite::fromJSON(ClientJson, simplifyVector = TRUE)
      if ("result" %in% names(ClientObject)) {
        ClientObject <- ClientObject$result
      }
      self$fromJSON(ClientObject)
    }
  ),
  private = list(
    enquote = function(val) {
      if (is.null(val)) {
        "null"
      }
      else if (is.numeric(val)) {
        val
      }
      else {
        paste0(c('"',self$`access_token`,'"'),collapse = '')
      }
    }
  )
)
agaveplatform/r-sdk documentation built on May 13, 2019, 8:20 a.m.