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

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

      CoordinatesObject
    },
    fromJSON = function(CoordinatesJson) {
      CoordinatesObject <- jsonlite::fromJSON(CoordinatesJson)
      if (!is.null(CoordinatesObject$`latitude`)) {
        latitudeObject <- BigDecimal$new()
        latitudeObject$fromJSON(jsonlite::toJSON(CoordinatesObject$latitude, auto_unbox = TRUE))
        self$`latitude` <- latitudeObject
      }
      if (!is.null(CoordinatesObject$`longitude`)) {
        longitudeObject <- BigDecimal$new()
        longitudeObject$fromJSON(jsonlite::toJSON(CoordinatesObject$longitude, auto_unbox = TRUE))
        self$`longitude` <- longitudeObject
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "latitude": %s,
           "longitude": %s
        }',
        self$`latitude`$toJSON(),
        self$`longitude`$toJSON()
      )
    },
    fromJSONString = function(CoordinatesJson) {
      CoordinatesObject <- jsonlite::fromJSON(CoordinatesJson)
      BigDecimalObject <- BigDecimal$new()
      self$`latitude` <- BigDecimalObject$fromJSON(jsonlite::toJSON(CoordinatesObject$latitude, auto_unbox = TRUE))
      BigDecimalObject <- BigDecimal$new()
      self$`longitude` <- BigDecimalObject$fromJSON(jsonlite::toJSON(CoordinatesObject$longitude, auto_unbox = TRUE))
    }
  )
)
altana-tech/atlas-api-r-sdk documentation built on Dec. 19, 2021, 1:36 a.m.