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


#' Location Class
#'
#' @field timestamp 
#' @field uuid 
#' @field longitude 
#' @field latitude 
#' @field location_type 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
Location <- R6::R6Class(
  'Location',
  public = list(
    `timestamp` = NULL,
    `uuid` = NULL,
    `longitude` = NULL,
    `latitude` = NULL,
    `location_type` = NULL,
    initialize = function(`timestamp`, `uuid`, `longitude`, `latitude`, `location_type`){
      if (!missing(`timestamp`)) {
                stopifnot(is.numeric(`timestamp`), length(`timestamp`) == 1)
        self$`timestamp` <- `timestamp`
      }
      if (!missing(`uuid`)) {
                stopifnot(is.character(`uuid`), length(`uuid`) == 1)
        self$`uuid` <- `uuid`
      }
      if (!missing(`longitude`)) {
                stopifnot(is.numeric(`longitude`), length(`longitude`) == 1)
        self$`longitude` <- `longitude`
      }
      if (!missing(`latitude`)) {
                stopifnot(is.numeric(`latitude`), length(`latitude`) == 1)
        self$`latitude` <- `latitude`
      }
      if (!missing(`location_type`)) {
                stopifnot(is.character(`location_type`), length(`location_type`) == 1)
        self$`location_type` <- `location_type`
      }
    },
    toJSON = function() {
      LocationObject <- list()
      if (!is.null(self$`timestamp`)) {
        LocationObject[['timestamp']] <-
                self$`timestamp`
      }
      if (!is.null(self$`uuid`)) {
        LocationObject[['uuid']] <-
                self$`uuid`
      }
      if (!is.null(self$`longitude`)) {
        LocationObject[['longitude']] <-
                self$`longitude`
      }
      if (!is.null(self$`latitude`)) {
        LocationObject[['latitude']] <-
                self$`latitude`
      }
      if (!is.null(self$`location_type`)) {
        LocationObject[['location_type']] <-
                self$`location_type`
      }

      LocationObject
    },
    fromJSON = function(LocationJson) {
      LocationObject <- jsonlite::fromJSON(LocationJson)
      if (!is.null(LocationObject$`timestamp`)) {
                self$`timestamp` <- LocationObject$`timestamp`
      }
      if (!is.null(LocationObject$`uuid`)) {
                self$`uuid` <- LocationObject$`uuid`
      }
      if (!is.null(LocationObject$`longitude`)) {
                self$`longitude` <- LocationObject$`longitude`
      }
      if (!is.null(LocationObject$`latitude`)) {
                self$`latitude` <- LocationObject$`latitude`
      }
      if (!is.null(LocationObject$`location_type`)) {
                self$`location_type` <- LocationObject$`location_type`
      }
    },
    toJSONString = function() {
       outstring <- sprintf(
        '{
           "timestamp":
                      %d
                      
                  
              ,
           "uuid":
                      
                      "%s"
                  
              ,
           "longitude":
                      %d
                      
                  
              ,
           "latitude":
                      %d
                      
                  
              ,
           "location_type":
                      
                      "%s"
                  
              
        }',
                self$`timestamp`,
                self$`uuid`,
                self$`longitude`,
                self$`latitude`,
                self$`location_type`
      )
      gsub("[\r\n]| ", "", outstring)
    },
    fromJSONString = function(LocationJson) {
      LocationObject <- jsonlite::fromJSON(LocationJson)
              self$`timestamp` <- LocationObject$`timestamp`
              self$`uuid` <- LocationObject$`uuid`
              self$`longitude` <- LocationObject$`longitude`
              self$`latitude` <- LocationObject$`latitude`
              self$`location_type` <- LocationObject$`location_type`
    }
  )
)
Pharmatrace/rPtApiClient documentation built on May 21, 2019, 4:04 a.m.