2022-08-15 00:27:10 +08:00

307 lines
8.2 KiB
R

#' OpenAPI Petstore
#'
#' This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
#'
#' The version of the OpenAPI document: 1.0.0
#' Generated by: https://openapi-generator.tech
#'
#' @docType class
#' @title User
#' @description User Class
#' @format An \code{R6Class} generator object
#' @field id integer [optional]
#' @field username character [optional]
#' @field firstName character [optional]
#' @field lastName character [optional]
#' @field email character [optional]
#' @field password character [optional]
#' @field phone character [optional]
#' @field userStatus integer [optional]
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
User <- R6::R6Class(
"User",
public = list(
`id` = NULL,
`username` = NULL,
`firstName` = NULL,
`lastName` = NULL,
`email` = NULL,
`password` = NULL,
`phone` = NULL,
`userStatus` = NULL,
#' Initialize a new User class.
#'
#' @description
#' Initialize a new User class.
#'
#' @param id id
#' @param username username
#' @param firstName firstName
#' @param lastName lastName
#' @param email email
#' @param password password
#' @param phone phone
#' @param userStatus User Status
#' @param ... Other optional arguments.
#' @export
initialize = function(
`id` = NULL, `username` = NULL, `firstName` = NULL, `lastName` = NULL, `email` = NULL, `password` = NULL, `phone` = NULL, `userStatus` = NULL, ...
) {
if (!is.null(`id`)) {
stopifnot(is.numeric(`id`), length(`id`) == 1)
self$`id` <- `id`
}
if (!is.null(`username`)) {
stopifnot(is.character(`username`), length(`username`) == 1)
self$`username` <- `username`
}
if (!is.null(`firstName`)) {
stopifnot(is.character(`firstName`), length(`firstName`) == 1)
self$`firstName` <- `firstName`
}
if (!is.null(`lastName`)) {
stopifnot(is.character(`lastName`), length(`lastName`) == 1)
self$`lastName` <- `lastName`
}
if (!is.null(`email`)) {
stopifnot(is.character(`email`), length(`email`) == 1)
self$`email` <- `email`
}
if (!is.null(`password`)) {
stopifnot(is.character(`password`), length(`password`) == 1)
self$`password` <- `password`
}
if (!is.null(`phone`)) {
stopifnot(is.character(`phone`), length(`phone`) == 1)
self$`phone` <- `phone`
}
if (!is.null(`userStatus`)) {
stopifnot(is.numeric(`userStatus`), length(`userStatus`) == 1)
self$`userStatus` <- `userStatus`
}
},
#' To JSON string
#'
#' @description
#' To JSON String
#'
#' @return User in JSON format
#' @export
toJSON = function() {
UserObject <- list()
if (!is.null(self$`id`)) {
UserObject[["id"]] <-
self$`id`
}
if (!is.null(self$`username`)) {
UserObject[["username"]] <-
self$`username`
}
if (!is.null(self$`firstName`)) {
UserObject[["firstName"]] <-
self$`firstName`
}
if (!is.null(self$`lastName`)) {
UserObject[["lastName"]] <-
self$`lastName`
}
if (!is.null(self$`email`)) {
UserObject[["email"]] <-
self$`email`
}
if (!is.null(self$`password`)) {
UserObject[["password"]] <-
self$`password`
}
if (!is.null(self$`phone`)) {
UserObject[["phone"]] <-
self$`phone`
}
if (!is.null(self$`userStatus`)) {
UserObject[["userStatus"]] <-
self$`userStatus`
}
UserObject
},
#' Deserialize JSON string into an instance of User
#'
#' @description
#' Deserialize JSON string into an instance of User
#'
#' @param input_json the JSON input
#' @return the instance of User
#' @export
fromJSON = function(input_json) {
this_object <- jsonlite::fromJSON(input_json)
if (!is.null(this_object$`id`)) {
self$`id` <- this_object$`id`
}
if (!is.null(this_object$`username`)) {
self$`username` <- this_object$`username`
}
if (!is.null(this_object$`firstName`)) {
self$`firstName` <- this_object$`firstName`
}
if (!is.null(this_object$`lastName`)) {
self$`lastName` <- this_object$`lastName`
}
if (!is.null(this_object$`email`)) {
self$`email` <- this_object$`email`
}
if (!is.null(this_object$`password`)) {
self$`password` <- this_object$`password`
}
if (!is.null(this_object$`phone`)) {
self$`phone` <- this_object$`phone`
}
if (!is.null(this_object$`userStatus`)) {
self$`userStatus` <- this_object$`userStatus`
}
self
},
#' To JSON string
#'
#' @description
#' To JSON String
#'
#' @return User in JSON format
#' @export
toJSONString = function() {
jsoncontent <- c(
if (!is.null(self$`id`)) {
sprintf(
'"id":
%d
',
self$`id`
)
},
if (!is.null(self$`username`)) {
sprintf(
'"username":
"%s"
',
self$`username`
)
},
if (!is.null(self$`firstName`)) {
sprintf(
'"firstName":
"%s"
',
self$`firstName`
)
},
if (!is.null(self$`lastName`)) {
sprintf(
'"lastName":
"%s"
',
self$`lastName`
)
},
if (!is.null(self$`email`)) {
sprintf(
'"email":
"%s"
',
self$`email`
)
},
if (!is.null(self$`password`)) {
sprintf(
'"password":
"%s"
',
self$`password`
)
},
if (!is.null(self$`phone`)) {
sprintf(
'"phone":
"%s"
',
self$`phone`
)
},
if (!is.null(self$`userStatus`)) {
sprintf(
'"userStatus":
%d
',
self$`userStatus`
)
}
)
jsoncontent <- paste(jsoncontent, collapse = ",")
as.character(jsonlite::minify(paste("{", jsoncontent, "}", sep = "")))
},
#' Deserialize JSON string into an instance of User
#'
#' @description
#' Deserialize JSON string into an instance of User
#'
#' @param input_json the JSON input
#' @return the instance of User
#' @export
fromJSONString = function(input_json) {
this_object <- jsonlite::fromJSON(input_json)
self$`id` <- this_object$`id`
self$`username` <- this_object$`username`
self$`firstName` <- this_object$`firstName`
self$`lastName` <- this_object$`lastName`
self$`email` <- this_object$`email`
self$`password` <- this_object$`password`
self$`phone` <- this_object$`phone`
self$`userStatus` <- this_object$`userStatus`
self
},
#' Validate JSON input with respect to User
#'
#' @description
#' Validate JSON input with respect to User and throw an exception if invalid
#'
#' @param input the JSON input
#' @export
validateJSON = function(input) {
input_json <- jsonlite::fromJSON(input)
},
#' To string (JSON format)
#'
#' @description
#' To string (JSON format)
#'
#' @return String representation of User
#' @export
toString = function() {
self$toJSONString()
},
#' Return true if the values in all fields are valid.
#'
#' @description
#' Return true if the values in all fields are valid.
#'
#' @return true if the values in all fields are valid.
#' @export
isValid = function() {
TRUE
},
#' Return a list of invalid fields (if any).
#'
#' @description
#' Return a list of invalid fields (if any).
#'
#' @return A list of invalid fields (if any).
#' @export
getInvalidFields = function() {
invalid_fields <- list()
invalid_fields
}
)
)