R/directions_matrix_sources.R

# LocationIQ
#
# LocationIQ provides flexible enterprise-grade location based solutions. We work with developers, startups and enterprises worldwide serving billions of requests everyday. This page provides an overview of the technical aspects of our API and will help you get started.
#
# The version of the OpenAPI document: 1.1.0
# 
# Generated by: https://openapi-generator.tech

#' @docType class
#' @title DirectionsMatrixSources
#' @description DirectionsMatrixSources Class
#' @format An \code{R6Class} generator object
#' @field distance  numeric [optional]
#'
#' @field location  list( numeric ) [optional]
#'
#' @field name  character [optional]
#'
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
DirectionsMatrixSources <- R6::R6Class(
  'DirectionsMatrixSources',
  public = list(
    `distance` = NULL,
    `location` = NULL,
    `name` = NULL,
    initialize = function(`distance`=NULL, `location`=NULL, `name`=NULL, ...){
      local.optional.var <- list(...)
      if (!is.null(`distance`)) {
        self$`distance` <- `distance`
      }
      if (!is.null(`location`)) {
        stopifnot(is.vector(`location`), length(`location`) != 0)
        sapply(`location`, function(x) stopifnot(is.character(x)))
        self$`location` <- `location`
      }
      if (!is.null(`name`)) {
        stopifnot(is.character(`name`), length(`name`) == 1)
        self$`name` <- `name`
      }
    },
    toJSON = function() {
      DirectionsMatrixSourcesObject <- list()
      if (!is.null(self$`distance`)) {
        DirectionsMatrixSourcesObject[['distance']] <-
          self$`distance`
      }
      if (!is.null(self$`location`)) {
        DirectionsMatrixSourcesObject[['location']] <-
          self$`location`
      }
      if (!is.null(self$`name`)) {
        DirectionsMatrixSourcesObject[['name']] <-
          self$`name`
      }

      DirectionsMatrixSourcesObject
    },
    fromJSON = function(DirectionsMatrixSourcesJson) {
      DirectionsMatrixSourcesObject <- jsonlite::fromJSON(DirectionsMatrixSourcesJson)
      if (!is.null(DirectionsMatrixSourcesObject$`distance`)) {
        self$`distance` <- DirectionsMatrixSourcesObject$`distance`
      }
      if (!is.null(DirectionsMatrixSourcesObject$`location`)) {
        self$`location` <- ApiClient$new()$deserializeObj(DirectionsMatrixSourcesObject$`location`, "array[numeric]", loadNamespace("locationiq"))
      }
      if (!is.null(DirectionsMatrixSourcesObject$`name`)) {
        self$`name` <- DirectionsMatrixSourcesObject$`name`
      }
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`distance`)) {
        sprintf(
        '"distance":
          %d
                ',
        self$`distance`
        )},
        if (!is.null(self$`location`)) {
        sprintf(
        '"location":
           [%s]
        ',
        paste(unlist(lapply(self$`location`, function(x) paste0('"', x, '"'))), collapse=",")
        )},
        if (!is.null(self$`name`)) {
        sprintf(
        '"name":
          "%s"
                ',
        self$`name`
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(DirectionsMatrixSourcesJson) {
      DirectionsMatrixSourcesObject <- jsonlite::fromJSON(DirectionsMatrixSourcesJson)
      self$`distance` <- DirectionsMatrixSourcesObject$`distance`
      self$`location` <- ApiClient$new()$deserializeObj(DirectionsMatrixSourcesObject$`location`, "array[numeric]", loadNamespace("locationiq"))
      self$`name` <- DirectionsMatrixSourcesObject$`name`
      self
    }
  )
)
location-iq/locationiq-r-client documentation built on Feb. 28, 2020, 9:42 p.m.