R/TradeRoute.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

#' TradeRoute Class
#'
#' @field country_of_origin 
#' @field country_of_destination 
#' @field port_of_origin 
#' @field port_of_destination 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
TradeRoute <- R6::R6Class(
  'TradeRoute',
  public = list(
    `country_of_origin` = NULL,
    `country_of_destination` = NULL,
    `port_of_origin` = NULL,
    `port_of_destination` = NULL,
    initialize = function(`country_of_origin`, `country_of_destination`, `port_of_origin`, `port_of_destination`){
      if (!missing(`country_of_origin`)) {
        stopifnot(is.character(`country_of_origin`), length(`country_of_origin`) == 1)
        self$`country_of_origin` <- `country_of_origin`
      }
      if (!missing(`country_of_destination`)) {
        stopifnot(is.character(`country_of_destination`), length(`country_of_destination`) == 1)
        self$`country_of_destination` <- `country_of_destination`
      }
      if (!missing(`port_of_origin`)) {
        stopifnot(is.character(`port_of_origin`), length(`port_of_origin`) == 1)
        self$`port_of_origin` <- `port_of_origin`
      }
      if (!missing(`port_of_destination`)) {
        stopifnot(is.character(`port_of_destination`), length(`port_of_destination`) == 1)
        self$`port_of_destination` <- `port_of_destination`
      }
    },
    toJSON = function() {
      TradeRouteObject <- list()
      if (!is.null(self$`country_of_origin`)) {
        TradeRouteObject[['country_of_origin']] <- self$`country_of_origin`
      }
      if (!is.null(self$`country_of_destination`)) {
        TradeRouteObject[['country_of_destination']] <- self$`country_of_destination`
      }
      if (!is.null(self$`port_of_origin`)) {
        TradeRouteObject[['port_of_origin']] <- self$`port_of_origin`
      }
      if (!is.null(self$`port_of_destination`)) {
        TradeRouteObject[['port_of_destination']] <- self$`port_of_destination`
      }

      TradeRouteObject
    },
    fromJSON = function(TradeRouteJson) {
      TradeRouteObject <- jsonlite::fromJSON(TradeRouteJson)
      if (!is.null(TradeRouteObject$`country_of_origin`)) {
        self$`country_of_origin` <- TradeRouteObject$`country_of_origin`
      }
      if (!is.null(TradeRouteObject$`country_of_destination`)) {
        self$`country_of_destination` <- TradeRouteObject$`country_of_destination`
      }
      if (!is.null(TradeRouteObject$`port_of_origin`)) {
        self$`port_of_origin` <- TradeRouteObject$`port_of_origin`
      }
      if (!is.null(TradeRouteObject$`port_of_destination`)) {
        self$`port_of_destination` <- TradeRouteObject$`port_of_destination`
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "country_of_origin": %s,
           "country_of_destination": %s,
           "port_of_origin": %s,
           "port_of_destination": %s
        }',
        self$`country_of_origin`,
        self$`country_of_destination`,
        self$`port_of_origin`,
        self$`port_of_destination`
      )
    },
    fromJSONString = function(TradeRouteJson) {
      TradeRouteObject <- jsonlite::fromJSON(TradeRouteJson)
      self$`country_of_origin` <- TradeRouteObject$`country_of_origin`
      self$`country_of_destination` <- TradeRouteObject$`country_of_destination`
      self$`port_of_origin` <- TradeRouteObject$`port_of_origin`
      self$`port_of_destination` <- TradeRouteObject$`port_of_destination`
    }
  )
)
altana-tech/atlas-api-r-sdk documentation built on Dec. 19, 2021, 1:36 a.m.