R/api_period_usage_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 APIPeriodUsageOut
#' @description APIPeriodUsageOut Class
#' @format An \code{R6Class} generator object
#' @field subscription  \link{APIPlanSubscriptionOut} [optional]
#'
#' @field billingPeriod  \link{APIBillingPeriodUsageOut} [optional]
#'
#' @field overageExclTax  numeric [optional]
#'
#' @field overageInclTax  numeric [optional]
#'
#' @field overageCurrency  character [optional]
#'
#' @field overageQuantity  integer [optional]
#'
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
APIPeriodUsageOut <- R6::R6Class(
  'APIPeriodUsageOut',
  public = list(
    `subscription` = NULL,
    `billingPeriod` = NULL,
    `overageExclTax` = NULL,
    `overageInclTax` = NULL,
    `overageCurrency` = NULL,
    `overageQuantity` = NULL,
    initialize = function(`subscription`=NULL, `billingPeriod`=NULL, `overageExclTax`=NULL, `overageInclTax`=NULL, `overageCurrency`=NULL, `overageQuantity`=NULL, ...){
      local.optional.var <- list(...)
      if (!is.null(`subscription`)) {
        stopifnot(R6::is.R6(`subscription`))
        self$`subscription` <- `subscription`
      }
      if (!is.null(`billingPeriod`)) {
        stopifnot(R6::is.R6(`billingPeriod`))
        self$`billingPeriod` <- `billingPeriod`
      }
      if (!is.null(`overageExclTax`)) {
        stopifnot(is.numeric(`overageExclTax`), length(`overageExclTax`) == 1)
        self$`overageExclTax` <- `overageExclTax`
      }
      if (!is.null(`overageInclTax`)) {
        stopifnot(is.numeric(`overageInclTax`), length(`overageInclTax`) == 1)
        self$`overageInclTax` <- `overageInclTax`
      }
      if (!is.null(`overageCurrency`)) {
        stopifnot(is.character(`overageCurrency`), length(`overageCurrency`) == 1)
        self$`overageCurrency` <- `overageCurrency`
      }
      if (!is.null(`overageQuantity`)) {
        stopifnot(is.numeric(`overageQuantity`), length(`overageQuantity`) == 1)
        self$`overageQuantity` <- `overageQuantity`
      }
    },
    toJSON = function() {
      APIPeriodUsageOutObject <- list()
      if (!is.null(self$`subscription`)) {
        APIPeriodUsageOutObject[['subscription']] <-
          self$`subscription`$toJSON()
      }
      if (!is.null(self$`billingPeriod`)) {
        APIPeriodUsageOutObject[['billingPeriod']] <-
          self$`billingPeriod`$toJSON()
      }
      if (!is.null(self$`overageExclTax`)) {
        APIPeriodUsageOutObject[['overageExclTax']] <-
          self$`overageExclTax`
      }
      if (!is.null(self$`overageInclTax`)) {
        APIPeriodUsageOutObject[['overageInclTax']] <-
          self$`overageInclTax`
      }
      if (!is.null(self$`overageCurrency`)) {
        APIPeriodUsageOutObject[['overageCurrency']] <-
          self$`overageCurrency`
      }
      if (!is.null(self$`overageQuantity`)) {
        APIPeriodUsageOutObject[['overageQuantity']] <-
          self$`overageQuantity`
      }

      APIPeriodUsageOutObject
    },
    fromJSON = function(APIPeriodUsageOutJson) {
      APIPeriodUsageOutObject <- jsonlite::fromJSON(APIPeriodUsageOutJson)
      if (!is.null(APIPeriodUsageOutObject$`subscription`)) {
        subscriptionObject <- APIPlanSubscriptionOut$new()
        subscriptionObject$fromJSON(jsonlite::toJSON(APIPeriodUsageOutObject$subscription, auto_unbox = TRUE, digits = NA))
        self$`subscription` <- subscriptionObject
      }
      if (!is.null(APIPeriodUsageOutObject$`billingPeriod`)) {
        billingPeriodObject <- APIBillingPeriodUsageOut$new()
        billingPeriodObject$fromJSON(jsonlite::toJSON(APIPeriodUsageOutObject$billingPeriod, auto_unbox = TRUE, digits = NA))
        self$`billingPeriod` <- billingPeriodObject
      }
      if (!is.null(APIPeriodUsageOutObject$`overageExclTax`)) {
        self$`overageExclTax` <- APIPeriodUsageOutObject$`overageExclTax`
      }
      if (!is.null(APIPeriodUsageOutObject$`overageInclTax`)) {
        self$`overageInclTax` <- APIPeriodUsageOutObject$`overageInclTax`
      }
      if (!is.null(APIPeriodUsageOutObject$`overageCurrency`)) {
        self$`overageCurrency` <- APIPeriodUsageOutObject$`overageCurrency`
      }
      if (!is.null(APIPeriodUsageOutObject$`overageQuantity`)) {
        self$`overageQuantity` <- APIPeriodUsageOutObject$`overageQuantity`
      }
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`subscription`)) {
        sprintf(
        '"subscription":
        %s
        ',
        jsonlite::toJSON(self$`subscription`$toJSON(), auto_unbox=TRUE, digits = NA)
        )},
        if (!is.null(self$`billingPeriod`)) {
        sprintf(
        '"billingPeriod":
        %s
        ',
        jsonlite::toJSON(self$`billingPeriod`$toJSON(), auto_unbox=TRUE, digits = NA)
        )},
        if (!is.null(self$`overageExclTax`)) {
        sprintf(
        '"overageExclTax":
          %d
                ',
        self$`overageExclTax`
        )},
        if (!is.null(self$`overageInclTax`)) {
        sprintf(
        '"overageInclTax":
          %d
                ',
        self$`overageInclTax`
        )},
        if (!is.null(self$`overageCurrency`)) {
        sprintf(
        '"overageCurrency":
          "%s"
                ',
        self$`overageCurrency`
        )},
        if (!is.null(self$`overageQuantity`)) {
        sprintf(
        '"overageQuantity":
          %d
                ',
        self$`overageQuantity`
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(APIPeriodUsageOutJson) {
      APIPeriodUsageOutObject <- jsonlite::fromJSON(APIPeriodUsageOutJson)
      self$`subscription` <- APIPlanSubscriptionOut$new()$fromJSON(jsonlite::toJSON(APIPeriodUsageOutObject$subscription, auto_unbox = TRUE, digits = NA))
      self$`billingPeriod` <- APIBillingPeriodUsageOut$new()$fromJSON(jsonlite::toJSON(APIPeriodUsageOutObject$billingPeriod, auto_unbox = TRUE, digits = NA))
      self$`overageExclTax` <- APIPeriodUsageOutObject$`overageExclTax`
      self$`overageInclTax` <- APIPeriodUsageOutObject$`overageInclTax`
      self$`overageCurrency` <- APIPeriodUsageOutObject$`overageCurrency`
      self$`overageQuantity` <- APIPeriodUsageOutObject$`overageQuantity`
      self
    }
  )
)
namsor/namsor-r-sdk2 documentation built on March 15, 2021, 7:12 p.m.