R/CompanyContext.r

# Altana Atlas API
#
# Altana Atlas for Regulatory Risk and Trade Compliance
#
# OpenAPI spec version: {{ version or \"v0.0.1\" }}
# Contact: engineering@altanatech.com
# Generated by: https://github.com/swagger-api/swagger-codegen.git

#' CompanyContext Class
#'
#' @field number_records 
#' @field trading_partners 
#' @field suppliers 
#' @field buyers 
#' @field countries_of_origin 
#' @field countries_of_destination 
#' @field countries_of_operation 
#' @field hs_traded 
#' @field industries 
#' @field products_sent 
#' @field products_received 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
CompanyContext <- R6::R6Class(
  'CompanyContext',
  public = list(
    `number_records` = NULL,
    `trading_partners` = NULL,
    `suppliers` = NULL,
    `buyers` = NULL,
    `countries_of_origin` = NULL,
    `countries_of_destination` = NULL,
    `countries_of_operation` = NULL,
    `hs_traded` = NULL,
    `industries` = NULL,
    `products_sent` = NULL,
    `products_received` = NULL,
    initialize = function(`number_records`, `trading_partners`, `suppliers`, `buyers`, `countries_of_origin`, `countries_of_destination`, `countries_of_operation`, `hs_traded`, `industries`, `products_sent`, `products_received`){
      if (!missing(`number_records`)) {
        stopifnot(is.numeric(`number_records`), length(`number_records`) == 1)
        self$`number_records` <- `number_records`
      }
      if (!missing(`trading_partners`)) {
        stopifnot(is.list(`trading_partners`), length(`trading_partners`) != 0)
        lapply(`trading_partners`, function(x) stopifnot(is.character(x)))
        self$`trading_partners` <- `trading_partners`
      }
      if (!missing(`suppliers`)) {
        stopifnot(is.list(`suppliers`), length(`suppliers`) != 0)
        lapply(`suppliers`, function(x) stopifnot(is.character(x)))
        self$`suppliers` <- `suppliers`
      }
      if (!missing(`buyers`)) {
        stopifnot(is.list(`buyers`), length(`buyers`) != 0)
        lapply(`buyers`, function(x) stopifnot(is.character(x)))
        self$`buyers` <- `buyers`
      }
      if (!missing(`countries_of_origin`)) {
        stopifnot(is.list(`countries_of_origin`), length(`countries_of_origin`) != 0)
        lapply(`countries_of_origin`, function(x) stopifnot(is.character(x)))
        self$`countries_of_origin` <- `countries_of_origin`
      }
      if (!missing(`countries_of_destination`)) {
        stopifnot(is.list(`countries_of_destination`), length(`countries_of_destination`) != 0)
        lapply(`countries_of_destination`, function(x) stopifnot(is.character(x)))
        self$`countries_of_destination` <- `countries_of_destination`
      }
      if (!missing(`countries_of_operation`)) {
        stopifnot(is.list(`countries_of_operation`), length(`countries_of_operation`) != 0)
        lapply(`countries_of_operation`, function(x) stopifnot(is.character(x)))
        self$`countries_of_operation` <- `countries_of_operation`
      }
      if (!missing(`hs_traded`)) {
        stopifnot(is.list(`hs_traded`), length(`hs_traded`) != 0)
        lapply(`hs_traded`, function(x) stopifnot(is.character(x)))
        self$`hs_traded` <- `hs_traded`
      }
      if (!missing(`industries`)) {
        stopifnot(is.list(`industries`), length(`industries`) != 0)
        lapply(`industries`, function(x) stopifnot(is.character(x)))
        self$`industries` <- `industries`
      }
      if (!missing(`products_sent`)) {
        stopifnot(is.list(`products_sent`), length(`products_sent`) != 0)
        lapply(`products_sent`, function(x) stopifnot(is.character(x)))
        self$`products_sent` <- `products_sent`
      }
      if (!missing(`products_received`)) {
        stopifnot(is.list(`products_received`), length(`products_received`) != 0)
        lapply(`products_received`, function(x) stopifnot(is.character(x)))
        self$`products_received` <- `products_received`
      }
    },
    toJSON = function() {
      CompanyContextObject <- list()
      if (!is.null(self$`number_records`)) {
        CompanyContextObject[['number_records']] <- self$`number_records`
      }
      if (!is.null(self$`trading_partners`)) {
        CompanyContextObject[['trading_partners']] <- self$`trading_partners`
      }
      if (!is.null(self$`suppliers`)) {
        CompanyContextObject[['suppliers']] <- self$`suppliers`
      }
      if (!is.null(self$`buyers`)) {
        CompanyContextObject[['buyers']] <- self$`buyers`
      }
      if (!is.null(self$`countries_of_origin`)) {
        CompanyContextObject[['countries_of_origin']] <- self$`countries_of_origin`
      }
      if (!is.null(self$`countries_of_destination`)) {
        CompanyContextObject[['countries_of_destination']] <- self$`countries_of_destination`
      }
      if (!is.null(self$`countries_of_operation`)) {
        CompanyContextObject[['countries_of_operation']] <- self$`countries_of_operation`
      }
      if (!is.null(self$`hs_traded`)) {
        CompanyContextObject[['hs_traded']] <- self$`hs_traded`
      }
      if (!is.null(self$`industries`)) {
        CompanyContextObject[['industries']] <- self$`industries`
      }
      if (!is.null(self$`products_sent`)) {
        CompanyContextObject[['products_sent']] <- self$`products_sent`
      }
      if (!is.null(self$`products_received`)) {
        CompanyContextObject[['products_received']] <- self$`products_received`
      }

      CompanyContextObject
    },
    fromJSON = function(CompanyContextJson) {
      CompanyContextObject <- jsonlite::fromJSON(CompanyContextJson)
      if (!is.null(CompanyContextObject$`number_records`)) {
        self$`number_records` <- CompanyContextObject$`number_records`
      }
      if (!is.null(CompanyContextObject$`trading_partners`)) {
        self$`trading_partners` <- CompanyContextObject$`trading_partners`
      }
      if (!is.null(CompanyContextObject$`suppliers`)) {
        self$`suppliers` <- CompanyContextObject$`suppliers`
      }
      if (!is.null(CompanyContextObject$`buyers`)) {
        self$`buyers` <- CompanyContextObject$`buyers`
      }
      if (!is.null(CompanyContextObject$`countries_of_origin`)) {
        self$`countries_of_origin` <- CompanyContextObject$`countries_of_origin`
      }
      if (!is.null(CompanyContextObject$`countries_of_destination`)) {
        self$`countries_of_destination` <- CompanyContextObject$`countries_of_destination`
      }
      if (!is.null(CompanyContextObject$`countries_of_operation`)) {
        self$`countries_of_operation` <- CompanyContextObject$`countries_of_operation`
      }
      if (!is.null(CompanyContextObject$`hs_traded`)) {
        self$`hs_traded` <- CompanyContextObject$`hs_traded`
      }
      if (!is.null(CompanyContextObject$`industries`)) {
        self$`industries` <- CompanyContextObject$`industries`
      }
      if (!is.null(CompanyContextObject$`products_sent`)) {
        self$`products_sent` <- CompanyContextObject$`products_sent`
      }
      if (!is.null(CompanyContextObject$`products_received`)) {
        self$`products_received` <- CompanyContextObject$`products_received`
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "number_records": %d,
           "trading_partners": [%s],
           "suppliers": [%s],
           "buyers": [%s],
           "countries_of_origin": [%s],
           "countries_of_destination": [%s],
           "countries_of_operation": [%s],
           "hs_traded": [%s],
           "industries": [%s],
           "products_sent": [%s],
           "products_received": [%s]
        }',
        self$`number_records`,
        lapply(self$`trading_partners`, function(x) paste(paste0('"', x, '"'), sep=",")),
        lapply(self$`suppliers`, function(x) paste(paste0('"', x, '"'), sep=",")),
        lapply(self$`buyers`, function(x) paste(paste0('"', x, '"'), sep=",")),
        lapply(self$`countries_of_origin`, function(x) paste(paste0('"', x, '"'), sep=",")),
        lapply(self$`countries_of_destination`, function(x) paste(paste0('"', x, '"'), sep=",")),
        lapply(self$`countries_of_operation`, function(x) paste(paste0('"', x, '"'), sep=",")),
        lapply(self$`hs_traded`, function(x) paste(paste0('"', x, '"'), sep=",")),
        lapply(self$`industries`, function(x) paste(paste0('"', x, '"'), sep=",")),
        lapply(self$`products_sent`, function(x) paste(paste0('"', x, '"'), sep=",")),
        lapply(self$`products_received`, function(x) paste(paste0('"', x, '"'), sep=","))
      )
    },
    fromJSONString = function(CompanyContextJson) {
      CompanyContextObject <- jsonlite::fromJSON(CompanyContextJson)
      self$`number_records` <- CompanyContextObject$`number_records`
      self$`trading_partners` <- CompanyContextObject$`trading_partners`
      self$`suppliers` <- CompanyContextObject$`suppliers`
      self$`buyers` <- CompanyContextObject$`buyers`
      self$`countries_of_origin` <- CompanyContextObject$`countries_of_origin`
      self$`countries_of_destination` <- CompanyContextObject$`countries_of_destination`
      self$`countries_of_operation` <- CompanyContextObject$`countries_of_operation`
      self$`hs_traded` <- CompanyContextObject$`hs_traded`
      self$`industries` <- CompanyContextObject$`industries`
      self$`products_sent` <- CompanyContextObject$`products_sent`
      self$`products_received` <- CompanyContextObject$`products_received`
    }
  )
)
altana-tech/atlas-api-r-sdk documentation built on Dec. 19, 2021, 1:36 a.m.