R/Container.r

# PharmaTrace Supply Chain Information Network API
#
# The PharmaTrace SCIN API provides network members a resource and process oriented access to the blockchain backed market and inventory information. It represents a layer of abstraction above the Hyperledger network to facilitate a business focused development of clients and integration systems without the need to directly connect to Hyperledger nodes.
#
# OpenAPI spec version: 0.0.1
# Contact: api@pharmatrace.io
# Generated by: https://openapi-generator.tech


#' Container Class
#'
#' @field container_id 
#' @field epc_code 
#' @field label 
#' @field barcode 
#' @field rf_id 
#' @field quantity 
#' @field unit 
#' @field current_location_id 
#' @field owner_stakeholder_id 
#' @field parent_container_id 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
Container <- R6::R6Class(
  'Container',
  public = list(
    `container_id` = NULL,
    `epc_code` = NULL,
    `label` = NULL,
    `barcode` = NULL,
    `rf_id` = NULL,
    `quantity` = NULL,
    `unit` = NULL,
    `current_location_id` = NULL,
    `owner_stakeholder_id` = NULL,
    `parent_container_id` = NULL,
    initialize = function(`container_id`, `epc_code`, `label`, `barcode`, `rf_id`, `quantity`, `unit`, `current_location_id`, `owner_stakeholder_id`, `parent_container_id`){
      if (!missing(`container_id`)) {
                stopifnot(is.character(`container_id`), length(`container_id`) == 1)
        self$`container_id` <- `container_id`
      }
      if (!missing(`epc_code`)) {
                stopifnot(is.character(`epc_code`), length(`epc_code`) == 1)
        self$`epc_code` <- `epc_code`
      }
      if (!missing(`label`)) {
                stopifnot(is.character(`label`), length(`label`) == 1)
        self$`label` <- `label`
      }
      if (!missing(`barcode`)) {
                stopifnot(is.character(`barcode`), length(`barcode`) == 1)
        self$`barcode` <- `barcode`
      }
      if (!missing(`rf_id`)) {
                stopifnot(is.character(`rf_id`), length(`rf_id`) == 1)
        self$`rf_id` <- `rf_id`
      }
      if (!missing(`quantity`)) {
                stopifnot(is.numeric(`quantity`), length(`quantity`) == 1)
        self$`quantity` <- `quantity`
      }
      if (!missing(`unit`)) {
                stopifnot(is.character(`unit`), length(`unit`) == 1)
        self$`unit` <- `unit`
      }
      if (!missing(`current_location_id`)) {
                stopifnot(is.character(`current_location_id`), length(`current_location_id`) == 1)
        self$`current_location_id` <- `current_location_id`
      }
      if (!missing(`owner_stakeholder_id`)) {
                stopifnot(is.character(`owner_stakeholder_id`), length(`owner_stakeholder_id`) == 1)
        self$`owner_stakeholder_id` <- `owner_stakeholder_id`
      }
      if (!missing(`parent_container_id`)) {
                stopifnot(is.character(`parent_container_id`), length(`parent_container_id`) == 1)
        self$`parent_container_id` <- `parent_container_id`
      }
    },
    toJSON = function() {
      ContainerObject <- list()
      if (!is.null(self$`container_id`)) {
        ContainerObject[['container_id']] <-
                self$`container_id`
      }
      if (!is.null(self$`epc_code`)) {
        ContainerObject[['epc_code']] <-
                self$`epc_code`
      }
      if (!is.null(self$`label`)) {
        ContainerObject[['label']] <-
                self$`label`
      }
      if (!is.null(self$`barcode`)) {
        ContainerObject[['barcode']] <-
                self$`barcode`
      }
      if (!is.null(self$`rf_id`)) {
        ContainerObject[['rf_id']] <-
                self$`rf_id`
      }
      if (!is.null(self$`quantity`)) {
        ContainerObject[['quantity']] <-
                self$`quantity`
      }
      if (!is.null(self$`unit`)) {
        ContainerObject[['unit']] <-
                self$`unit`
      }
      if (!is.null(self$`current_location_id`)) {
        ContainerObject[['current_location_id']] <-
                self$`current_location_id`
      }
      if (!is.null(self$`owner_stakeholder_id`)) {
        ContainerObject[['owner_stakeholder_id']] <-
                self$`owner_stakeholder_id`
      }
      if (!is.null(self$`parent_container_id`)) {
        ContainerObject[['parent_container_id']] <-
                self$`parent_container_id`
      }

      ContainerObject
    },
    fromJSON = function(ContainerJson) {
      ContainerObject <- jsonlite::fromJSON(ContainerJson)
      if (!is.null(ContainerObject$`container_id`)) {
                self$`container_id` <- ContainerObject$`container_id`
      }
      if (!is.null(ContainerObject$`epc_code`)) {
                self$`epc_code` <- ContainerObject$`epc_code`
      }
      if (!is.null(ContainerObject$`label`)) {
                self$`label` <- ContainerObject$`label`
      }
      if (!is.null(ContainerObject$`barcode`)) {
                self$`barcode` <- ContainerObject$`barcode`
      }
      if (!is.null(ContainerObject$`rf_id`)) {
                self$`rf_id` <- ContainerObject$`rf_id`
      }
      if (!is.null(ContainerObject$`quantity`)) {
                self$`quantity` <- ContainerObject$`quantity`
      }
      if (!is.null(ContainerObject$`unit`)) {
                self$`unit` <- ContainerObject$`unit`
      }
      if (!is.null(ContainerObject$`current_location_id`)) {
                self$`current_location_id` <- ContainerObject$`current_location_id`
      }
      if (!is.null(ContainerObject$`owner_stakeholder_id`)) {
                self$`owner_stakeholder_id` <- ContainerObject$`owner_stakeholder_id`
      }
      if (!is.null(ContainerObject$`parent_container_id`)) {
                self$`parent_container_id` <- ContainerObject$`parent_container_id`
      }
    },
    toJSONString = function() {
       outstring <- sprintf(
        '{
           "container_id":
                      
                      "%s"
                  
              ,
           "epc_code":
                      
                      "%s"
                  
              ,
           "label":
                      
                      "%s"
                  
              ,
           "barcode":
                      
                      "%s"
                  
              ,
           "rf_id":
                      
                      "%s"
                  
              ,
           "quantity":
                      %d
                      
                  
              ,
           "unit":
                      
                      "%s"
                  
              ,
           "current_location_id":
                      
                      "%s"
                  
              ,
           "owner_stakeholder_id":
                      
                      "%s"
                  
              ,
           "parent_container_id":
                      
                      "%s"
                  
              
        }',
                self$`container_id`,
                self$`epc_code`,
                self$`label`,
                self$`barcode`,
                self$`rf_id`,
                self$`quantity`,
                self$`unit`,
                self$`current_location_id`,
                self$`owner_stakeholder_id`,
                self$`parent_container_id`
      )
      gsub("[\r\n]| ", "", outstring)
    },
    fromJSONString = function(ContainerJson) {
      ContainerObject <- jsonlite::fromJSON(ContainerJson)
              self$`container_id` <- ContainerObject$`container_id`
              self$`epc_code` <- ContainerObject$`epc_code`
              self$`label` <- ContainerObject$`label`
              self$`barcode` <- ContainerObject$`barcode`
              self$`rf_id` <- ContainerObject$`rf_id`
              self$`quantity` <- ContainerObject$`quantity`
              self$`unit` <- ContainerObject$`unit`
              self$`current_location_id` <- ContainerObject$`current_location_id`
              self$`owner_stakeholder_id` <- ContainerObject$`owner_stakeholder_id`
              self$`parent_container_id` <- ContainerObject$`parent_container_id`
    }
  )
)
Pharmatrace/rPtApiClient documentation built on May 21, 2019, 4:04 a.m.