R/api_counter_v2_out.R

# NamSor API v2
#
# NamSor API v2 : enpoints to process personal names (gender, cultural origin or ethnicity) in all alphabets or languages. Use GET methods for small tests, but prefer POST methods for higher throughput (batch processing of up to 100 names at a time). Need something you can't find here? We have many more features coming soon. Let us know, we'll do our best to add it! 
#
# The version of the OpenAPI document: 2.0.10
# Contact: contact@namsor.com
# Generated by: https://openapi-generator.tech

#' @docType class
#' @title APICounterV2Out
#' @description APICounterV2Out Class
#' @format An \code{R6Class} generator object
#' @field apiKey  \link{APIKeyOut} [optional]
#'
#' @field apiService  character [optional]
#'
#' @field createdDateTime  integer [optional]
#'
#' @field totalUsage  integer [optional]
#'
#' @field lastFlushedDateTime  integer [optional]
#'
#' @field lastUsedDateTime  integer [optional]
#'
#' @field serviceFeaturesUsage  named list( integer ) [optional]
#'
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
APICounterV2Out <- R6::R6Class(
  'APICounterV2Out',
  public = list(
    `apiKey` = NULL,
    `apiService` = NULL,
    `createdDateTime` = NULL,
    `totalUsage` = NULL,
    `lastFlushedDateTime` = NULL,
    `lastUsedDateTime` = NULL,
    `serviceFeaturesUsage` = NULL,
    initialize = function(`apiKey`=NULL, `apiService`=NULL, `createdDateTime`=NULL, `totalUsage`=NULL, `lastFlushedDateTime`=NULL, `lastUsedDateTime`=NULL, `serviceFeaturesUsage`=NULL, ...){
      local.optional.var <- list(...)
      if (!is.null(`apiKey`)) {
        stopifnot(R6::is.R6(`apiKey`))
        self$`apiKey` <- `apiKey`
      }
      if (!is.null(`apiService`)) {
        stopifnot(is.character(`apiService`), length(`apiService`) == 1)
        self$`apiService` <- `apiService`
      }
      if (!is.null(`createdDateTime`)) {
        stopifnot(is.numeric(`createdDateTime`), length(`createdDateTime`) == 1)
        self$`createdDateTime` <- `createdDateTime`
      }
      if (!is.null(`totalUsage`)) {
        stopifnot(is.numeric(`totalUsage`), length(`totalUsage`) == 1)
        self$`totalUsage` <- `totalUsage`
      }
      if (!is.null(`lastFlushedDateTime`)) {
        stopifnot(is.numeric(`lastFlushedDateTime`), length(`lastFlushedDateTime`) == 1)
        self$`lastFlushedDateTime` <- `lastFlushedDateTime`
      }
      if (!is.null(`lastUsedDateTime`)) {
        stopifnot(is.numeric(`lastUsedDateTime`), length(`lastUsedDateTime`) == 1)
        self$`lastUsedDateTime` <- `lastUsedDateTime`
      }
      if (!is.null(`serviceFeaturesUsage`)) {
        stopifnot(is.vector(`serviceFeaturesUsage`), length(`serviceFeaturesUsage`) != 0)
        sapply(`serviceFeaturesUsage`, function(x) stopifnot(is.character(x)))
        self$`serviceFeaturesUsage` <- `serviceFeaturesUsage`
      }
    },
    toJSON = function() {
      APICounterV2OutObject <- list()
      if (!is.null(self$`apiKey`)) {
        APICounterV2OutObject[['apiKey']] <-
          self$`apiKey`$toJSON()
      }
      if (!is.null(self$`apiService`)) {
        APICounterV2OutObject[['apiService']] <-
          self$`apiService`
      }
      if (!is.null(self$`createdDateTime`)) {
        APICounterV2OutObject[['createdDateTime']] <-
          self$`createdDateTime`
      }
      if (!is.null(self$`totalUsage`)) {
        APICounterV2OutObject[['totalUsage']] <-
          self$`totalUsage`
      }
      if (!is.null(self$`lastFlushedDateTime`)) {
        APICounterV2OutObject[['lastFlushedDateTime']] <-
          self$`lastFlushedDateTime`
      }
      if (!is.null(self$`lastUsedDateTime`)) {
        APICounterV2OutObject[['lastUsedDateTime']] <-
          self$`lastUsedDateTime`
      }
      if (!is.null(self$`serviceFeaturesUsage`)) {
        APICounterV2OutObject[['serviceFeaturesUsage']] <-
          self$`serviceFeaturesUsage`
      }

      APICounterV2OutObject
    },
    fromJSON = function(APICounterV2OutJson) {
      APICounterV2OutObject <- jsonlite::fromJSON(APICounterV2OutJson)
      if (!is.null(APICounterV2OutObject$`apiKey`)) {
        apiKeyObject <- APIKeyOut$new()
        apiKeyObject$fromJSON(jsonlite::toJSON(APICounterV2OutObject$apiKey, auto_unbox = TRUE, digits = NA))
        self$`apiKey` <- apiKeyObject
      }
      if (!is.null(APICounterV2OutObject$`apiService`)) {
        self$`apiService` <- APICounterV2OutObject$`apiService`
      }
      if (!is.null(APICounterV2OutObject$`createdDateTime`)) {
        self$`createdDateTime` <- APICounterV2OutObject$`createdDateTime`
      }
      if (!is.null(APICounterV2OutObject$`totalUsage`)) {
        self$`totalUsage` <- APICounterV2OutObject$`totalUsage`
      }
      if (!is.null(APICounterV2OutObject$`lastFlushedDateTime`)) {
        self$`lastFlushedDateTime` <- APICounterV2OutObject$`lastFlushedDateTime`
      }
      if (!is.null(APICounterV2OutObject$`lastUsedDateTime`)) {
        self$`lastUsedDateTime` <- APICounterV2OutObject$`lastUsedDateTime`
      }
      if (!is.null(APICounterV2OutObject$`serviceFeaturesUsage`)) {
        self$`serviceFeaturesUsage` <- ApiClient$new()$deserializeObj(APICounterV2OutObject$`serviceFeaturesUsage`, "map(integer)", loadNamespace("namsor"))
      }
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`apiKey`)) {
        sprintf(
        '"apiKey":
        %s
        ',
        jsonlite::toJSON(self$`apiKey`$toJSON(), auto_unbox=TRUE, digits = NA)
        )},
        if (!is.null(self$`apiService`)) {
        sprintf(
        '"apiService":
          "%s"
                ',
        self$`apiService`
        )},
        if (!is.null(self$`createdDateTime`)) {
        sprintf(
        '"createdDateTime":
          %d
                ',
        self$`createdDateTime`
        )},
        if (!is.null(self$`totalUsage`)) {
        sprintf(
        '"totalUsage":
          %d
                ',
        self$`totalUsage`
        )},
        if (!is.null(self$`lastFlushedDateTime`)) {
        sprintf(
        '"lastFlushedDateTime":
          %d
                ',
        self$`lastFlushedDateTime`
        )},
        if (!is.null(self$`lastUsedDateTime`)) {
        sprintf(
        '"lastUsedDateTime":
          %d
                ',
        self$`lastUsedDateTime`
        )},
        if (!is.null(self$`serviceFeaturesUsage`)) {
        sprintf(
        '"serviceFeaturesUsage":
          "%s"
        ',
        jsonlite::toJSON(lapply(self$`serviceFeaturesUsage`, function(x){ x }), auto_unbox = TRUE, digits=NA)
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(APICounterV2OutJson) {
      APICounterV2OutObject <- jsonlite::fromJSON(APICounterV2OutJson)
      self$`apiKey` <- APIKeyOut$new()$fromJSON(jsonlite::toJSON(APICounterV2OutObject$apiKey, auto_unbox = TRUE, digits = NA))
      self$`apiService` <- APICounterV2OutObject$`apiService`
      self$`createdDateTime` <- APICounterV2OutObject$`createdDateTime`
      self$`totalUsage` <- APICounterV2OutObject$`totalUsage`
      self$`lastFlushedDateTime` <- APICounterV2OutObject$`lastFlushedDateTime`
      self$`lastUsedDateTime` <- APICounterV2OutObject$`lastUsedDateTime`
      self$`serviceFeaturesUsage` <- ApiClient$new()$deserializeObj(APICounterV2OutObject$`serviceFeaturesUsage`, "map(integer)", loadNamespace("namsor"))
      self
    }
  )
)
namsor/namsor-r-sdk2 documentation built on March 15, 2021, 7:12 p.m.