R/api_plans_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 APIPlansOut
#' @description APIPlansOut Class
#' @format An \code{R6Class} generator object
#' @field usageRatioForDupplicates  integer [optional]
#'
#' @field currencyIso3  character [optional]
#'
#' @field currencySymbol  character [optional]
#'
#' @field plans  list( \link{APIPlanOut} ) [optional]
#'
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
APIPlansOut <- R6::R6Class(
  'APIPlansOut',
  public = list(
    `usageRatioForDupplicates` = NULL,
    `currencyIso3` = NULL,
    `currencySymbol` = NULL,
    `plans` = NULL,
    initialize = function(`usageRatioForDupplicates`=NULL, `currencyIso3`=NULL, `currencySymbol`=NULL, `plans`=NULL, ...){
      local.optional.var <- list(...)
      if (!is.null(`usageRatioForDupplicates`)) {
        stopifnot(is.numeric(`usageRatioForDupplicates`), length(`usageRatioForDupplicates`) == 1)
        self$`usageRatioForDupplicates` <- `usageRatioForDupplicates`
      }
      if (!is.null(`currencyIso3`)) {
        stopifnot(is.character(`currencyIso3`), length(`currencyIso3`) == 1)
        self$`currencyIso3` <- `currencyIso3`
      }
      if (!is.null(`currencySymbol`)) {
        stopifnot(is.character(`currencySymbol`), length(`currencySymbol`) == 1)
        self$`currencySymbol` <- `currencySymbol`
      }
      if (!is.null(`plans`)) {
        stopifnot(is.vector(`plans`), length(`plans`) != 0)
        sapply(`plans`, function(x) stopifnot(R6::is.R6(x)))
        self$`plans` <- `plans`
      }
    },
    toJSON = function() {
      APIPlansOutObject <- list()
      if (!is.null(self$`usageRatioForDupplicates`)) {
        APIPlansOutObject[['usageRatioForDupplicates']] <-
          self$`usageRatioForDupplicates`
      }
      if (!is.null(self$`currencyIso3`)) {
        APIPlansOutObject[['currencyIso3']] <-
          self$`currencyIso3`
      }
      if (!is.null(self$`currencySymbol`)) {
        APIPlansOutObject[['currencySymbol']] <-
          self$`currencySymbol`
      }
      if (!is.null(self$`plans`)) {
        APIPlansOutObject[['plans']] <-
          lapply(self$`plans`, function(x) x$toJSON())
      }

      APIPlansOutObject
    },
    fromJSON = function(APIPlansOutJson) {
      APIPlansOutObject <- jsonlite::fromJSON(APIPlansOutJson)
      if (!is.null(APIPlansOutObject$`usageRatioForDupplicates`)) {
        self$`usageRatioForDupplicates` <- APIPlansOutObject$`usageRatioForDupplicates`
      }
      if (!is.null(APIPlansOutObject$`currencyIso3`)) {
        self$`currencyIso3` <- APIPlansOutObject$`currencyIso3`
      }
      if (!is.null(APIPlansOutObject$`currencySymbol`)) {
        self$`currencySymbol` <- APIPlansOutObject$`currencySymbol`
      }
      if (!is.null(APIPlansOutObject$`plans`)) {
        self$`plans` <- ApiClient$new()$deserializeObj(APIPlansOutObject$`plans`, "array[APIPlanOut]", loadNamespace("namsor"))
      }
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`usageRatioForDupplicates`)) {
        sprintf(
        '"usageRatioForDupplicates":
          %d
                ',
        self$`usageRatioForDupplicates`
        )},
        if (!is.null(self$`currencyIso3`)) {
        sprintf(
        '"currencyIso3":
          "%s"
                ',
        self$`currencyIso3`
        )},
        if (!is.null(self$`currencySymbol`)) {
        sprintf(
        '"currencySymbol":
          "%s"
                ',
        self$`currencySymbol`
        )},
        if (!is.null(self$`plans`)) {
        sprintf(
        '"plans":
        [%s]
',
        paste(sapply(self$`plans`, function(x) jsonlite::toJSON(x$toJSON(), auto_unbox=TRUE, digits = NA)), collapse=",")
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(APIPlansOutJson) {
      APIPlansOutObject <- jsonlite::fromJSON(APIPlansOutJson)
      self$`usageRatioForDupplicates` <- APIPlansOutObject$`usageRatioForDupplicates`
      self$`currencyIso3` <- APIPlansOutObject$`currencyIso3`
      self$`currencySymbol` <- APIPlansOutObject$`currencySymbol`
      self$`plans` <- ApiClient$new()$deserializeObj(APIPlansOutObject$`plans`, "array[APIPlanOut]", loadNamespace("namsor"))
      self
    }
  )
)
namsor/namsor-r-sdk2 documentation built on March 15, 2021, 7:12 p.m.