R/consent.R

# FireCloud
#
# FireCloud API 
#
# The version of the OpenAPI document: 0.1
# 
# Generated by: https://openapi-generator.tech

#' @docType class
#' @title Consent
#'
#' @description Consent Class
#'
#' @format An \code{R6Class} generator object
#'
#' @field consentId  character [optional]
#'
#' @field name  character [optional]
#'
#' @field createDate  integer [optional]
#'
#' @field lastUpdate  integer [optional]
#'
#' @field sortDate  integer [optional]
#'
#' @field requiresManualReview  character [optional]
#'
#' @field dataUseLetter  character [optional]
#'
#' @field useRestriction  named list( object ) [optional]
#'
#' @field dulName  character [optional]
#'
#' @field translatedUseRestriction  character [optional]
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
Consent <- R6::R6Class(
  'Consent',
  public = list(
    `consentId` = NULL,
    `name` = NULL,
    `createDate` = NULL,
    `lastUpdate` = NULL,
    `sortDate` = NULL,
    `requiresManualReview` = NULL,
    `dataUseLetter` = NULL,
    `useRestriction` = NULL,
    `dulName` = NULL,
    `translatedUseRestriction` = NULL,
    initialize = function(
        `consentId`=NULL, `name`=NULL, `createDate`=NULL, `lastUpdate`=NULL, `sortDate`=NULL, `requiresManualReview`=NULL, `dataUseLetter`=NULL, `useRestriction`=NULL, `dulName`=NULL, `translatedUseRestriction`=NULL, ...
    ) {
      local.optional.var <- list(...)
      if (!is.null(`consentId`)) {
        stopifnot(is.character(`consentId`), length(`consentId`) == 1)
        self$`consentId` <- `consentId`
      }
      if (!is.null(`name`)) {
        stopifnot(is.character(`name`), length(`name`) == 1)
        self$`name` <- `name`
      }
      if (!is.null(`createDate`)) {
        stopifnot(is.numeric(`createDate`), length(`createDate`) == 1)
        self$`createDate` <- `createDate`
      }
      if (!is.null(`lastUpdate`)) {
        stopifnot(is.numeric(`lastUpdate`), length(`lastUpdate`) == 1)
        self$`lastUpdate` <- `lastUpdate`
      }
      if (!is.null(`sortDate`)) {
        stopifnot(is.numeric(`sortDate`), length(`sortDate`) == 1)
        self$`sortDate` <- `sortDate`
      }
      if (!is.null(`requiresManualReview`)) {
        self$`requiresManualReview` <- `requiresManualReview`
      }
      if (!is.null(`dataUseLetter`)) {
        stopifnot(is.character(`dataUseLetter`), length(`dataUseLetter`) == 1)
        self$`dataUseLetter` <- `dataUseLetter`
      }
      if (!is.null(`useRestriction`)) {
        stopifnot(is.vector(`useRestriction`), length(`useRestriction`) != 0)
        sapply(`useRestriction`, function(x) stopifnot(is.character(x)))
        self$`useRestriction` <- `useRestriction`
      }
      if (!is.null(`dulName`)) {
        stopifnot(is.character(`dulName`), length(`dulName`) == 1)
        self$`dulName` <- `dulName`
      }
      if (!is.null(`translatedUseRestriction`)) {
        stopifnot(is.character(`translatedUseRestriction`), length(`translatedUseRestriction`) == 1)
        self$`translatedUseRestriction` <- `translatedUseRestriction`
      }
    },
    toJSON = function() {
      ConsentObject <- list()
      if (!is.null(self$`consentId`)) {
        ConsentObject[['consentId']] <-
          self$`consentId`
      }
      if (!is.null(self$`name`)) {
        ConsentObject[['name']] <-
          self$`name`
      }
      if (!is.null(self$`createDate`)) {
        ConsentObject[['createDate']] <-
          self$`createDate`
      }
      if (!is.null(self$`lastUpdate`)) {
        ConsentObject[['lastUpdate']] <-
          self$`lastUpdate`
      }
      if (!is.null(self$`sortDate`)) {
        ConsentObject[['sortDate']] <-
          self$`sortDate`
      }
      if (!is.null(self$`requiresManualReview`)) {
        ConsentObject[['requiresManualReview']] <-
          self$`requiresManualReview`
      }
      if (!is.null(self$`dataUseLetter`)) {
        ConsentObject[['dataUseLetter']] <-
          self$`dataUseLetter`
      }
      if (!is.null(self$`useRestriction`)) {
        ConsentObject[['useRestriction']] <-
          self$`useRestriction`
      }
      if (!is.null(self$`dulName`)) {
        ConsentObject[['dulName']] <-
          self$`dulName`
      }
      if (!is.null(self$`translatedUseRestriction`)) {
        ConsentObject[['translatedUseRestriction']] <-
          self$`translatedUseRestriction`
      }

      ConsentObject
    },
    fromJSON = function(ConsentJson) {
      ConsentObject <- jsonlite::fromJSON(ConsentJson)
      if (!is.null(ConsentObject$`consentId`)) {
        self$`consentId` <- ConsentObject$`consentId`
      }
      if (!is.null(ConsentObject$`name`)) {
        self$`name` <- ConsentObject$`name`
      }
      if (!is.null(ConsentObject$`createDate`)) {
        self$`createDate` <- ConsentObject$`createDate`
      }
      if (!is.null(ConsentObject$`lastUpdate`)) {
        self$`lastUpdate` <- ConsentObject$`lastUpdate`
      }
      if (!is.null(ConsentObject$`sortDate`)) {
        self$`sortDate` <- ConsentObject$`sortDate`
      }
      if (!is.null(ConsentObject$`requiresManualReview`)) {
        self$`requiresManualReview` <- ConsentObject$`requiresManualReview`
      }
      if (!is.null(ConsentObject$`dataUseLetter`)) {
        self$`dataUseLetter` <- ConsentObject$`dataUseLetter`
      }
      if (!is.null(ConsentObject$`useRestriction`)) {
        self$`useRestriction` <- ApiClient$new()$deserializeObj(ConsentObject$`useRestriction`, "map(object)", loadNamespace("openapi"))
      }
      if (!is.null(ConsentObject$`dulName`)) {
        self$`dulName` <- ConsentObject$`dulName`
      }
      if (!is.null(ConsentObject$`translatedUseRestriction`)) {
        self$`translatedUseRestriction` <- ConsentObject$`translatedUseRestriction`
      }
      self
    },
    toJSONString = function() {
      jsoncontent <- c(
        if (!is.null(self$`consentId`)) {
        sprintf(
        '"consentId":
          "%s"
                ',
        self$`consentId`
        )},
        if (!is.null(self$`name`)) {
        sprintf(
        '"name":
          "%s"
                ',
        self$`name`
        )},
        if (!is.null(self$`createDate`)) {
        sprintf(
        '"createDate":
          %d
                ',
        self$`createDate`
        )},
        if (!is.null(self$`lastUpdate`)) {
        sprintf(
        '"lastUpdate":
          %d
                ',
        self$`lastUpdate`
        )},
        if (!is.null(self$`sortDate`)) {
        sprintf(
        '"sortDate":
          %d
                ',
        self$`sortDate`
        )},
        if (!is.null(self$`requiresManualReview`)) {
        sprintf(
        '"requiresManualReview":
          "%s"
                ',
        self$`requiresManualReview`
        )},
        if (!is.null(self$`dataUseLetter`)) {
        sprintf(
        '"dataUseLetter":
          "%s"
                ',
        self$`dataUseLetter`
        )},
        if (!is.null(self$`useRestriction`)) {
        sprintf(
        '"useRestriction":
          "%s"
        ',
        jsonlite::toJSON(lapply(self$`useRestriction`, function(x){ x }), auto_unbox = TRUE, digits=NA)
        )},
        if (!is.null(self$`dulName`)) {
        sprintf(
        '"dulName":
          "%s"
                ',
        self$`dulName`
        )},
        if (!is.null(self$`translatedUseRestriction`)) {
        sprintf(
        '"translatedUseRestriction":
          "%s"
                ',
        self$`translatedUseRestriction`
        )}
      )
      jsoncontent <- paste(jsoncontent, collapse = ",")
      paste('{', jsoncontent, '}', sep = "")
    },
    fromJSONString = function(ConsentJson) {
      ConsentObject <- jsonlite::fromJSON(ConsentJson)
      self$`consentId` <- ConsentObject$`consentId`
      self$`name` <- ConsentObject$`name`
      self$`createDate` <- ConsentObject$`createDate`
      self$`lastUpdate` <- ConsentObject$`lastUpdate`
      self$`sortDate` <- ConsentObject$`sortDate`
      self$`requiresManualReview` <- ConsentObject$`requiresManualReview`
      self$`dataUseLetter` <- ConsentObject$`dataUseLetter`
      self$`useRestriction` <- ApiClient$new()$deserializeObj(ConsentObject$`useRestriction`, "map(object)", loadNamespace("openapi"))
      self$`dulName` <- ConsentObject$`dulName`
      self$`translatedUseRestriction` <- ConsentObject$`translatedUseRestriction`
      self
    }
  )
)
vjcitn/terraClientR documentation built on Dec. 23, 2021, 4:07 p.m.