R/name_matched_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 NameMatchedOut
#' @description NameMatchedOut Class
#' @format An \code{R6Class} generator object
#' @field id  character [optional]
#'
#' @field matchStatus  character [optional]
#'
#' @field score  numeric [optional]
#'
#'
#' @importFrom R6 R6Class
#' @importFrom jsonlite fromJSON toJSON
#' @export
NameMatchedOut <- R6::R6Class(
  'NameMatchedOut',
  public = list(
    `id` = NULL,
    `matchStatus` = NULL,
    `score` = NULL,
    initialize = function(`id`=NULL, `matchStatus`=NULL, `score`=NULL, ...){
      local.optional.var <- list(...)
      if (!is.null(`id`)) {
        stopifnot(is.character(`id`), length(`id`) == 1)
        self$`id` <- `id`
      }
      if (!is.null(`matchStatus`)) {
        stopifnot(is.character(`matchStatus`), length(`matchStatus`) == 1)
        self$`matchStatus` <- `matchStatus`
      }
      if (!is.null(`score`)) {
        stopifnot(is.numeric(`score`), length(`score`) == 1)
        self$`score` <- `score`
      }
    },
    toJSON = function() {
      NameMatchedOutObject <- list()
      if (!is.null(self$`id`)) {
        NameMatchedOutObject[['id']] <-
          self$`id`
      }
      if (!is.null(self$`matchStatus`)) {
        NameMatchedOutObject[['matchStatus']] <-
          self$`matchStatus`
      }
      if (!is.null(self$`score`)) {
        NameMatchedOutObject[['score']] <-
          self$`score`
      }

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