# Location API
#
# Geolocation, Geocoding and Maps
#
# OpenAPI spec version: 2.0.0
# 
# Generated by: https://openapi-generator.tech


#' GeolocationResponseSchema Class
#'
#' @field status status
#' @field message 
#' @field balance 
#' @field balance_slots 
#' @field lat 
#' @field lon 
#' @field accuracy 
#' @field address 
#' @field address_details 
#' @field aged 
#' @field fallback 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
GeolocationResponseSchema <- R6::R6Class(
  'GeolocationResponseSchema',
  public = list(
    `status` = NULL,
    `message` = NULL,
    `balance` = NULL,
    `balance_slots` = NULL,
    `lat` = NULL,
    `lon` = NULL,
    `accuracy` = NULL,
    `address` = NULL,
    `address_details` = NULL,
    `aged` = NULL,
    `fallback` = NULL,
    initialize = function(`status`, `message`, `balance`, `balance_slots`, `lat`, `lon`, `accuracy`, `address`, `address_details`, `aged`, `fallback`){
      if (!missing(`status`)) {
        stopifnot(is.character(`status`), length(`status`) == 1)
        self$`status` <- `status`
      }
      if (!missing(`message`)) {
        stopifnot(is.character(`message`), length(`message`) == 1)
        self$`message` <- `message`
      }
      if (!missing(`balance`)) {
        stopifnot(is.numeric(`balance`), length(`balance`) == 1)
        self$`balance` <- `balance`
      }
      if (!missing(`balance_slots`)) {
        stopifnot(is.numeric(`balance_slots`), length(`balance_slots`) == 1)
        self$`balance_slots` <- `balance_slots`
      }
      if (!missing(`lat`)) {
        stopifnot(is.numeric(`lat`), length(`lat`) == 1)
        self$`lat` <- `lat`
      }
      if (!missing(`lon`)) {
        stopifnot(is.numeric(`lon`), length(`lon`) == 1)
        self$`lon` <- `lon`
      }
      if (!missing(`accuracy`)) {
        stopifnot(is.numeric(`accuracy`), length(`accuracy`) == 1)
        self$`accuracy` <- `accuracy`
      }
      if (!missing(`address`)) {
        stopifnot(is.character(`address`), length(`address`) == 1)
        self$`address` <- `address`
      }
      if (!missing(`address_details`)) {
        stopifnot(R6::is.R6(`address_details`))
        self$`address_details` <- `address_details`
      }
      if (!missing(`aged`)) {
        stopifnot(is.numeric(`aged`), length(`aged`) == 1)
        self$`aged` <- `aged`
      }
      if (!missing(`fallback`)) {
        stopifnot(R6::is.R6(`fallback`))
        self$`fallback` <- `fallback`
      }
    },
    toJSON = function() {
      GeolocationResponseSchemaObject <- list()
      if (!is.null(self$`status`)) {
        GeolocationResponseSchemaObject[['status']] <- self$`status`
      }
      if (!is.null(self$`message`)) {
        GeolocationResponseSchemaObject[['message']] <- self$`message`
      }
      if (!is.null(self$`balance`)) {
        GeolocationResponseSchemaObject[['balance']] <- self$`balance`
      }
      if (!is.null(self$`balance_slots`)) {
        GeolocationResponseSchemaObject[['balance_slots']] <- self$`balance_slots`
      }
      if (!is.null(self$`lat`)) {
        GeolocationResponseSchemaObject[['lat']] <- self$`lat`
      }
      if (!is.null(self$`lon`)) {
        GeolocationResponseSchemaObject[['lon']] <- self$`lon`
      }
      if (!is.null(self$`accuracy`)) {
        GeolocationResponseSchemaObject[['accuracy']] <- self$`accuracy`
      }
      if (!is.null(self$`address`)) {
        GeolocationResponseSchemaObject[['address']] <- self$`address`
      }
      if (!is.null(self$`address_details`)) {
        GeolocationResponseSchemaObject[['address_details']] <- self$`address_details`$toJSON()
      }
      if (!is.null(self$`aged`)) {
        GeolocationResponseSchemaObject[['aged']] <- self$`aged`
      }
      if (!is.null(self$`fallback`)) {
        GeolocationResponseSchemaObject[['fallback']] <- self$`fallback`$toJSON()
      }

      GeolocationResponseSchemaObject
    },
    fromJSON = function(GeolocationResponseSchemaJson) {
      GeolocationResponseSchemaObject <- jsonlite::fromJSON(GeolocationResponseSchemaJson)
      if (!is.null(GeolocationResponseSchemaObject$`status`)) {
        self$`status` <- GeolocationResponseSchemaObject$`status`
      }
      if (!is.null(GeolocationResponseSchemaObject$`message`)) {
        self$`message` <- GeolocationResponseSchemaObject$`message`
      }
      if (!is.null(GeolocationResponseSchemaObject$`balance`)) {
        self$`balance` <- GeolocationResponseSchemaObject$`balance`
      }
      if (!is.null(GeolocationResponseSchemaObject$`balance_slots`)) {
        self$`balance_slots` <- GeolocationResponseSchemaObject$`balance_slots`
      }
      if (!is.null(GeolocationResponseSchemaObject$`lat`)) {
        self$`lat` <- GeolocationResponseSchemaObject$`lat`
      }
      if (!is.null(GeolocationResponseSchemaObject$`lon`)) {
        self$`lon` <- GeolocationResponseSchemaObject$`lon`
      }
      if (!is.null(GeolocationResponseSchemaObject$`accuracy`)) {
        self$`accuracy` <- GeolocationResponseSchemaObject$`accuracy`
      }
      if (!is.null(GeolocationResponseSchemaObject$`address`)) {
        self$`address` <- GeolocationResponseSchemaObject$`address`
      }
      if (!is.null(GeolocationResponseSchemaObject$`address_details`)) {
        address_detailsObject <- AddressDetailsSchema$new()
        address_detailsObject$fromJSON(jsonlite::toJSON(GeolocationResponseSchemaObject$address_details, auto_unbox = TRUE))
        self$`address_details` <- address_detailsObject
      }
      if (!is.null(GeolocationResponseSchemaObject$`aged`)) {
        self$`aged` <- GeolocationResponseSchemaObject$`aged`
      }
      if (!is.null(GeolocationResponseSchemaObject$`fallback`)) {
        fallbackObject <- FallbackSchema$new()
        fallbackObject$fromJSON(jsonlite::toJSON(GeolocationResponseSchemaObject$fallback, auto_unbox = TRUE))
        self$`fallback` <- fallbackObject
      }
    },
    toJSONString = function() {
       sprintf(
        '{
           "status": %s,
           "message": %s,
           "balance": %d,
           "balance_slots": %d,
           "lat": %d,
           "lon": %d,
           "accuracy": %d,
           "address": %s,
           "address_details": %s,
           "aged": %d,
           "fallback": %s
        }',
        self$`status`,
        self$`message`,
        self$`balance`,
        self$`balance_slots`,
        self$`lat`,
        self$`lon`,
        self$`accuracy`,
        self$`address`,
        self$`address_details`$toJSON(),
        self$`aged`,
        self$`fallback`$toJSON()
      )
    },
    fromJSONString = function(GeolocationResponseSchemaJson) {
      GeolocationResponseSchemaObject <- jsonlite::fromJSON(GeolocationResponseSchemaJson)
      self$`status` <- GeolocationResponseSchemaObject$`status`
      self$`message` <- GeolocationResponseSchemaObject$`message`
      self$`balance` <- GeolocationResponseSchemaObject$`balance`
      self$`balance_slots` <- GeolocationResponseSchemaObject$`balance_slots`
      self$`lat` <- GeolocationResponseSchemaObject$`lat`
      self$`lon` <- GeolocationResponseSchemaObject$`lon`
      self$`accuracy` <- GeolocationResponseSchemaObject$`accuracy`
      self$`address` <- GeolocationResponseSchemaObject$`address`
      AddressDetailsSchemaObject <- AddressDetailsSchema$new()
      self$`address_details` <- AddressDetailsSchemaObject$fromJSON(jsonlite::toJSON(GeolocationResponseSchemaObject$address_details, auto_unbox = TRUE))
      self$`aged` <- GeolocationResponseSchemaObject$`aged`
      FallbackSchemaObject <- FallbackSchema$new()
      self$`fallback` <- FallbackSchemaObject$fromJSON(jsonlite::toJSON(GeolocationResponseSchemaObject$fallback, auto_unbox = TRUE))
    }
  )
)
