R/cache_metrics_out.R

# NamSor API v2
#
# NamSor API v2 : enpoints to process personal names (gender, cultural origin or ethnicity) in all alphabets or languages. Use GET methods for small tests, but prefer POST methods for higher throughput (batch processing of up to 100 names at a time). Need something you can't find here? We have many more features coming soon. Let us know, we'll do our best to add it! 
#
# The version of the OpenAPI document: 2.0.10
# Contact: contact@namsor.com
# Generated by: https://openapi-generator.tech

#' @docType class
#' @title CacheMetricsOut
#' @description CacheMetricsOut Class
#' @format An \code{R6Class} generator object
#' @field cacheName  character [optional]
#'
#' @field cacheStats  character [optional]
#'
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
CacheMetricsOut <- R6::R6Class(
  'CacheMetricsOut',
  public = list(
    `cacheName` = NULL,
    `cacheStats` = NULL,
    initialize = function(`cacheName`=NULL, `cacheStats`=NULL, ...){
      local.optional.var <- list(...)
      if (!is.null(`cacheName`)) {
        stopifnot(is.character(`cacheName`), length(`cacheName`) == 1)
        self$`cacheName` <- `cacheName`
      }
      if (!is.null(`cacheStats`)) {
        stopifnot(is.character(`cacheStats`), length(`cacheStats`) == 1)
        self$`cacheStats` <- `cacheStats`
      }
    },
    toJSON = function() {
      CacheMetricsOutObject <- list()
      if (!is.null(self$`cacheName`)) {
        CacheMetricsOutObject[['cacheName']] <-
          self$`cacheName`
      }
      if (!is.null(self$`cacheStats`)) {
        CacheMetricsOutObject[['cacheStats']] <-
          self$`cacheStats`
      }

      CacheMetricsOutObject
    },
    fromJSON = function(CacheMetricsOutJson) {
      CacheMetricsOutObject <- jsonlite::fromJSON(CacheMetricsOutJson)
      if (!is.null(CacheMetricsOutObject$`cacheName`)) {
        self$`cacheName` <- CacheMetricsOutObject$`cacheName`
      }
      if (!is.null(CacheMetricsOutObject$`cacheStats`)) {
        self$`cacheStats` <- CacheMetricsOutObject$`cacheStats`
      }
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`cacheName`)) {
        sprintf(
        '"cacheName":
          "%s"
                ',
        self$`cacheName`
        )},
        if (!is.null(self$`cacheStats`)) {
        sprintf(
        '"cacheStats":
          "%s"
                ',
        self$`cacheStats`
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(CacheMetricsOutJson) {
      CacheMetricsOutObject <- jsonlite::fromJSON(CacheMetricsOutJson)
      self$`cacheName` <- CacheMetricsOutObject$`cacheName`
      self$`cacheStats` <- CacheMetricsOutObject$`cacheStats`
      self
    }
  )
)
namsor/namsor-r-sdk2 documentation built on March 15, 2021, 7:12 p.m.