R/result_of_message_object.R

# DaDaPush Public API
#
# DaDaPush: Real-time Notifications App Send real-time notifications through our API without coding and maintaining your own app for iOS or Android devices.
#
# The version of the OpenAPI document: v1
# Contact: contacts@dadapush.com
# Generated by: https://openapi-generator.tech


#' ResultOfMessageObject Class
#'
#' @field code 
#' @field data 
#' @field errmsg 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
ResultOfMessageObject <- R6::R6Class(
  'ResultOfMessageObject',
  public = list(
    `code` = NULL,
    `data` = NULL,
    `errmsg` = NULL,
    initialize = function(`code`, `errmsg`, `data`=NULL, ...){
      local.optional.var <- list(...)
      if (!missing(`code`)) {
        stopifnot(is.numeric(`code`), length(`code`) == 1)
        self$`code` <- `code`
      }
      if (!missing(`errmsg`)) {
        stopifnot(is.character(`errmsg`), length(`errmsg`) == 1)
        self$`errmsg` <- `errmsg`
      }
      if (!is.null(`data`)) {
        stopifnot(R6::is.R6(`data`))
        self$`data` <- `data`
      }
    },
    toJSON = function() {
      ResultOfMessageObjectObject <- list()
      if (!is.null(self$`code`)) {
        ResultOfMessageObjectObject[['code']] <-
          self$`code`
      }
      if (!is.null(self$`data`)) {
        ResultOfMessageObjectObject[['data']] <-
          self$`data`$toJSON()
      }
      if (!is.null(self$`errmsg`)) {
        ResultOfMessageObjectObject[['errmsg']] <-
          self$`errmsg`
      }

      ResultOfMessageObjectObject
    },
    fromJSON = function(ResultOfMessageObjectJson) {
      ResultOfMessageObjectObject <- jsonlite::fromJSON(ResultOfMessageObjectJson)
      if (!is.null(ResultOfMessageObjectObject$`code`)) {
        self$`code` <- ResultOfMessageObjectObject$`code`
      }
      if (!is.null(ResultOfMessageObjectObject$`data`)) {
        dataObject <- MessageObject$new()
        dataObject$fromJSON(jsonlite::toJSON(ResultOfMessageObjectObject$data, auto_unbox = TRUE))
        self$`data` <- dataObject
      }
      if (!is.null(ResultOfMessageObjectObject$`errmsg`)) {
        self$`errmsg` <- ResultOfMessageObjectObject$`errmsg`
      }
    },
    toJSONString = function() {
      sprintf(
        '{
           "code":
             %d,
           "data":
             %s,
           "errmsg":
             "%s"
        }',
        self$`code`,
        jsonlite::toJSON(self$`data`$toJSON(), auto_unbox=TRUE),
        self$`errmsg`
      )
    },
    fromJSONString = function(ResultOfMessageObjectJson) {
      ResultOfMessageObjectObject <- jsonlite::fromJSON(ResultOfMessageObjectJson)
      self$`code` <- ResultOfMessageObjectObject$`code`
      self$`data` <- MessageObject$new()$fromJSON(jsonlite::toJSON(ResultOfMessageObjectObject$data, auto_unbox = TRUE))
      self$`errmsg` <- ResultOfMessageObjectObject$`errmsg`
      self
    }
  )
)
dadapush/dadapush-r-client documentation built on Nov. 4, 2019, 9:36 a.m.