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

#' TransactionRecord Class
#'
#' @field id 
#' @field transaction_date_time 
#' @field trade_direction 
#' @field declared 
#' @field route 
#' @field importer 
#' @field exporter 
#' @field quantity 
#' @field weight 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
TransactionRecord <- R6::R6Class(
  'TransactionRecord',
  public = list(
    `id` = NULL,
    `transaction_date_time` = NULL,
    `trade_direction` = NULL,
    `declared` = NULL,
    `route` = NULL,
    `importer` = NULL,
    `exporter` = NULL,
    `quantity` = NULL,
    `weight` = NULL,
    initialize = function(`id`, `transaction_date_time`, `trade_direction`, `declared`, `route`, `importer`, `exporter`, `quantity`, `weight`){
      if (!missing(`id`)) {
        stopifnot(is.character(`id`), length(`id`) == 1)
        self$`id` <- `id`
      }
      if (!missing(`transaction_date_time`)) {
        stopifnot(is.character(`transaction_date_time`), length(`transaction_date_time`) == 1)
        self$`transaction_date_time` <- `transaction_date_time`
      }
      if (!missing(`trade_direction`)) {
        stopifnot(is.character(`trade_direction`), length(`trade_direction`) == 1)
        self$`trade_direction` <- `trade_direction`
      }
      if (!missing(`declared`)) {
        stopifnot(R6::is.R6(`declared`))
        self$`declared` <- `declared`
      }
      if (!missing(`route`)) {
        stopifnot(R6::is.R6(`route`))
        self$`route` <- `route`
      }
      if (!missing(`importer`)) {
        stopifnot(R6::is.R6(`importer`))
        self$`importer` <- `importer`
      }
      if (!missing(`exporter`)) {
        stopifnot(R6::is.R6(`exporter`))
        self$`exporter` <- `exporter`
      }
      if (!missing(`quantity`)) {
        stopifnot(R6::is.R6(`quantity`))
        self$`quantity` <- `quantity`
      }
      if (!missing(`weight`)) {
        stopifnot(R6::is.R6(`weight`))
        self$`weight` <- `weight`
      }
    },
    toJSON = function() {
      TransactionRecordObject <- list()
      if (!is.null(self$`id`)) {
        TransactionRecordObject[['id']] <- self$`id`
      }
      if (!is.null(self$`transaction_date_time`)) {
        TransactionRecordObject[['transaction_date_time']] <- self$`transaction_date_time`
      }
      if (!is.null(self$`trade_direction`)) {
        TransactionRecordObject[['trade_direction']] <- self$`trade_direction`
      }
      if (!is.null(self$`declared`)) {
        TransactionRecordObject[['declared']] <- self$`declared`$toJSON()
      }
      if (!is.null(self$`route`)) {
        TransactionRecordObject[['route']] <- self$`route`$toJSON()
      }
      if (!is.null(self$`importer`)) {
        TransactionRecordObject[['importer']] <- self$`importer`$toJSON()
      }
      if (!is.null(self$`exporter`)) {
        TransactionRecordObject[['exporter']] <- self$`exporter`$toJSON()
      }
      if (!is.null(self$`quantity`)) {
        TransactionRecordObject[['quantity']] <- self$`quantity`$toJSON()
      }
      if (!is.null(self$`weight`)) {
        TransactionRecordObject[['weight']] <- self$`weight`$toJSON()
      }

      TransactionRecordObject
    },
    fromJSON = function(TransactionRecordJson) {
      TransactionRecordObject <- jsonlite::fromJSON(TransactionRecordJson)
      if (!is.null(TransactionRecordObject$`id`)) {
        self$`id` <- TransactionRecordObject$`id`
      }
      if (!is.null(TransactionRecordObject$`transaction_date_time`)) {
        self$`transaction_date_time` <- TransactionRecordObject$`transaction_date_time`
      }
      if (!is.null(TransactionRecordObject$`trade_direction`)) {
        self$`trade_direction` <- TransactionRecordObject$`trade_direction`
      }
      if (!is.null(TransactionRecordObject$`declared`)) {
        declaredObject <- DeclaredGoods$new()
        declaredObject$fromJSON(jsonlite::toJSON(TransactionRecordObject$declared, auto_unbox = TRUE))
        self$`declared` <- declaredObject
      }
      if (!is.null(TransactionRecordObject$`route`)) {
        routeObject <- TradeRoute$new()
        routeObject$fromJSON(jsonlite::toJSON(TransactionRecordObject$route, auto_unbox = TRUE))
        self$`route` <- routeObject
      }
      if (!is.null(TransactionRecordObject$`importer`)) {
        importerObject <- Party$new()
        importerObject$fromJSON(jsonlite::toJSON(TransactionRecordObject$importer, auto_unbox = TRUE))
        self$`importer` <- importerObject
      }
      if (!is.null(TransactionRecordObject$`exporter`)) {
        exporterObject <- Party$new()
        exporterObject$fromJSON(jsonlite::toJSON(TransactionRecordObject$exporter, auto_unbox = TRUE))
        self$`exporter` <- exporterObject
      }
      if (!is.null(TransactionRecordObject$`quantity`)) {
        quantityObject <- GoodsMeasure$new()
        quantityObject$fromJSON(jsonlite::toJSON(TransactionRecordObject$quantity, auto_unbox = TRUE))
        self$`quantity` <- quantityObject
      }
      if (!is.null(TransactionRecordObject$`weight`)) {
        weightObject <- GoodsMeasure$new()
        weightObject$fromJSON(jsonlite::toJSON(TransactionRecordObject$weight, auto_unbox = TRUE))
        self$`weight` <- weightObject
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "id": %s,
           "transaction_date_time": %s,
           "trade_direction": %s,
           "declared": %s,
           "route": %s,
           "importer": %s,
           "exporter": %s,
           "quantity": %s,
           "weight": %s
        }',
        self$`id`,
        self$`transaction_date_time`,
        self$`trade_direction`,
        self$`declared`$toJSON(),
        self$`route`$toJSON(),
        self$`importer`$toJSON(),
        self$`exporter`$toJSON(),
        self$`quantity`$toJSON(),
        self$`weight`$toJSON()
      )
    },
    fromJSONString = function(TransactionRecordJson) {
      TransactionRecordObject <- jsonlite::fromJSON(TransactionRecordJson)
      self$`id` <- TransactionRecordObject$`id`
      self$`transaction_date_time` <- TransactionRecordObject$`transaction_date_time`
      self$`trade_direction` <- TransactionRecordObject$`trade_direction`
      DeclaredGoodsObject <- DeclaredGoods$new()
      self$`declared` <- DeclaredGoodsObject$fromJSON(jsonlite::toJSON(TransactionRecordObject$declared, auto_unbox = TRUE))
      TradeRouteObject <- TradeRoute$new()
      self$`route` <- TradeRouteObject$fromJSON(jsonlite::toJSON(TransactionRecordObject$route, auto_unbox = TRUE))
      PartyObject <- Party$new()
      self$`importer` <- PartyObject$fromJSON(jsonlite::toJSON(TransactionRecordObject$importer, auto_unbox = TRUE))
      PartyObject <- Party$new()
      self$`exporter` <- PartyObject$fromJSON(jsonlite::toJSON(TransactionRecordObject$exporter, auto_unbox = TRUE))
      GoodsMeasureObject <- GoodsMeasure$new()
      self$`quantity` <- GoodsMeasureObject$fromJSON(jsonlite::toJSON(TransactionRecordObject$quantity, auto_unbox = TRUE))
      GoodsMeasureObject <- GoodsMeasure$new()
      self$`weight` <- GoodsMeasureObject$fromJSON(jsonlite::toJSON(TransactionRecordObject$weight, auto_unbox = TRUE))
    }
  )
)
altana-tech/atlas-api-r-sdk documentation built on Dec. 19, 2021, 1:36 a.m.