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


#' ResultOfMessagePushResponse Class
#'
#' @field code 
#' @field data 
#' @field errmsg 
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
ResultOfMessagePushResponse <- R6::R6Class(
  'ResultOfMessagePushResponse',
  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() {
      ResultOfMessagePushResponseObject <- list()
      if (!is.null(self$`code`)) {
        ResultOfMessagePushResponseObject[['code']] <-
          self$`code`
      }
      if (!is.null(self$`data`)) {
        ResultOfMessagePushResponseObject[['data']] <-
          self$`data`$toJSON()
      }
      if (!is.null(self$`errmsg`)) {
        ResultOfMessagePushResponseObject[['errmsg']] <-
          self$`errmsg`
      }

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