R/personal_api.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 1000 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! 
#
# OpenAPI spec version: 2.0.2-beta
# Contact: contact@namsor.com
# Generated by: https://openapi-generator.tech

#' @title Personal operations
#' @description namsor.Personal
#'
#' @field path Stores url path of the request.
#' @field apiClient Handles the client-server communication.
#'
#' @importFrom R6 R6Class
#'
#' @section Methods:
#' \describe{
#'
#' Country [USES 10 UNITS] Infer the likely country of residence of a personal full name, or one surname. Assumes names as they are in the country of residence OR the country of origin.
#'
#'
#' CountryBatch [USES 10 UNITS] Infer the likely country of residence of up to 1000 personal full names, or surnames. Assumes names as they are in the country of residence OR the country of origin.
#'
#'
#' Diaspora [USES 20 UNITS] Infer the likely ethnicity/diaspora of a personal name, given a country of residence ISO2 code (ex. US, CA, AU, NZ etc.)
#'
#'
#' DiasporaBatch [USES 20 UNITS] Infer the likely ethnicity/diaspora of up to 1000 personal names, given a country of residence ISO2 code (ex. US, CA, AU, NZ etc.)
#'
#'
#' Gender Infer the likely gender of a name.
#'
#'
#' GenderBatch Infer the likely gender of up to 1000 names, detecting automatically the cultural context.
#'
#'
#' GenderFull Infer the likely gender of a full name, ex. John H. Smith
#'
#'
#' GenderFullBatch Infer the likely gender of up to 1000 full names, detecting automatically the cultural context.
#'
#'
#' GenderFullGeo Infer the likely gender of a full name, given a local context (ISO2 country code).
#'
#'
#' GenderFullGeoBatch Infer the likely gender of up to 1000 full names, with a given cultural context (country ISO2 code).
#'
#'
#' GenderGeo Infer the likely gender of a name, given a local context (ISO2 country code).
#'
#'
#' GenderGeoBatch Infer the likely gender of up to 1000 names, each given a local context (ISO2 country code).
#'
#'
#' Origin [USES 10 UNITS] Infer the likely country of origin of a personal name. Assumes names as they are in the country of origin. For US, CA, AU, NZ and other melting-pots : use 'diaspora' instead.
#'
#'
#' OriginBatch [USES 10 UNITS] Infer the likely country of origin of up to 1000 names, detecting automatically the cultural context.
#'
#'
#' ParsedGenderBatch Infer the likely gender of up to 1000 fully parsed names, detecting automatically the cultural context.
#'
#'
#' ParsedGenderGeoBatch Infer the likely gender of up to 1000 fully parsed names, detecting automatically the cultural context.
#'
#'
#' UsRaceEthnicity [USES 10 UNITS] Infer a US resident's likely race/ethnicity according to US Census taxonomy.
#'
#'
#' UsRaceEthnicityBatch [USES 10 UNITS] Infer up-to 1000 US resident's likely race/ethnicity according to US Census taxonomy.
#'
#'
#' UsRaceEthnicityZIP5 [USES 10 UNITS] Infer a US resident's likely race/ethnicity according to US Census taxonomy, using (optional) ZIP5 code info.
#'
#'
#' UsZipRaceEthnicityBatch [USES 10 UNITS] Infer up-to 1000 US resident's likely race/ethnicity according to US Census taxonomy, with (optional) ZIP code.
#'
#' }
#'
#' @importFrom jsonlite base64_enc
#' @export
PersonalApi <- R6::R6Class(
  'PersonalApi',
  public = list(
    apiClient = NULL,
    initialize = function(apiClient){
      if (!missing(apiClient)) {
        self$apiClient <- apiClient
      }
      else {
        self$apiClient <- ApiClient$new()
      }
    },
    Country = function(personal.name.full, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      if (missing(`personal.name.full`)) {
        stop("Missing required parameter `personal.name.full`.")
      }

      urlPath <- "/api2/json/country/{personalNameFull}"
      if (!missing(`personal.name.full`)) {
        urlPath <- gsub(paste0("\\{", "personalNameFull", "\\}"), `personal.name.full`, urlPath)
      }

      # API key authentication
      if ("X-API-KEY" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["X-API-KEY"]) > 0) {
        headerParams['X-API-KEY'] <- paste(unlist(self$apiClient$apiKeys["X-API-KEY"]), collapse='')
      }

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "GET",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        PersonalNameGeoOut$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }

    },
    CountryBatch = function(batch.personal.name.in=NULL, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      if (!missing(`batch.personal.name.in`)) {
        body <- `batch.personal.name.in`$toJSONString()
      } else {
        body <- NULL
      }

      urlPath <- "/api2/json/countryBatch"
      # API key authentication
      if ("X-API-KEY" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["X-API-KEY"]) > 0) {
        headerParams['X-API-KEY'] <- paste(unlist(self$apiClient$apiKeys["X-API-KEY"]), collapse='')
      }

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "POST",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        BatchPersonalNameGeoOut$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }

    },
    Diaspora = function(country.iso2, first.name, last.name, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      if (missing(`country.iso2`)) {
        stop("Missing required parameter `country.iso2`.")
      }

      if (missing(`first.name`)) {
        stop("Missing required parameter `first.name`.")
      }

      if (missing(`last.name`)) {
        stop("Missing required parameter `last.name`.")
      }

      urlPath <- "/api2/json/diaspora/{countryIso2}/{firstName}/{lastName}"
      if (!missing(`country.iso2`)) {
        urlPath <- gsub(paste0("\\{", "countryIso2", "\\}"), `country.iso2`, urlPath)
      }

      if (!missing(`first.name`)) {
        urlPath <- gsub(paste0("\\{", "firstName", "\\}"), `first.name`, urlPath)
      }

      if (!missing(`last.name`)) {
        urlPath <- gsub(paste0("\\{", "lastName", "\\}"), `last.name`, urlPath)
      }

      # API key authentication
      if ("X-API-KEY" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["X-API-KEY"]) > 0) {
        headerParams['X-API-KEY'] <- paste(unlist(self$apiClient$apiKeys["X-API-KEY"]), collapse='')
      }

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "GET",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        FirstLastNameDiasporaedOut$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }

    },
    DiasporaBatch = function(batch.first.last.name.geo.in=NULL, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      if (!missing(`batch.first.last.name.geo.in`)) {
        body <- `batch.first.last.name.geo.in`$toJSONString()
      } else {
        body <- NULL
      }

      urlPath <- "/api2/json/diasporaBatch"
      # API key authentication
      if ("X-API-KEY" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["X-API-KEY"]) > 0) {
        headerParams['X-API-KEY'] <- paste(unlist(self$apiClient$apiKeys["X-API-KEY"]), collapse='')
      }

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "POST",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        BatchFirstLastNameDiasporaedOut$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }

    },
    Gender = function(first.name, last.name, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      if (missing(`first.name`)) {
        stop("Missing required parameter `first.name`.")
      }

      if (missing(`last.name`)) {
        stop("Missing required parameter `last.name`.")
      }

      urlPath <- "/api2/json/gender/{firstName}/{lastName}"
      if (!missing(`first.name`)) {
        urlPath <- gsub(paste0("\\{", "firstName", "\\}"), `first.name`, urlPath)
      }

      if (!missing(`last.name`)) {
        urlPath <- gsub(paste0("\\{", "lastName", "\\}"), `last.name`, urlPath)
      }

      # API key authentication
      if ("X-API-KEY" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["X-API-KEY"]) > 0) {
        headerParams['X-API-KEY'] <- paste(unlist(self$apiClient$apiKeys["X-API-KEY"]), collapse='')
      }

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "GET",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        FirstLastNameGenderedOut$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }

    },
    GenderBatch = function(batch.first.last.name.in=NULL, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      if (!missing(`batch.first.last.name.in`)) {
        body <- `batch.first.last.name.in`$toJSONString()
      } else {
        body <- NULL
      }

      urlPath <- "/api2/json/genderBatch"
      # API key authentication
      if ("X-API-KEY" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["X-API-KEY"]) > 0) {
        headerParams['X-API-KEY'] <- paste(unlist(self$apiClient$apiKeys["X-API-KEY"]), collapse='')
      }

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "POST",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        BatchFirstLastNameGenderedOut$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }

    },
    GenderFull = function(full.name, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      if (missing(`full.name`)) {
        stop("Missing required parameter `full.name`.")
      }

      urlPath <- "/api2/json/genderFull/{fullName}"
      if (!missing(`full.name`)) {
        urlPath <- gsub(paste0("\\{", "fullName", "\\}"), `full.name`, urlPath)
      }

      # API key authentication
      if ("X-API-KEY" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["X-API-KEY"]) > 0) {
        headerParams['X-API-KEY'] <- paste(unlist(self$apiClient$apiKeys["X-API-KEY"]), collapse='')
      }

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "GET",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        FirstLastNameGenderedOut$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }

    },
    GenderFullBatch = function(batch.personal.name.in=NULL, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      if (!missing(`batch.personal.name.in`)) {
        body <- `batch.personal.name.in`$toJSONString()
      } else {
        body <- NULL
      }

      urlPath <- "/api2/json/genderFullBatch"
      # API key authentication
      if ("X-API-KEY" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["X-API-KEY"]) > 0) {
        headerParams['X-API-KEY'] <- paste(unlist(self$apiClient$apiKeys["X-API-KEY"]), collapse='')
      }

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "POST",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        BatchPersonalNameGenderedOut$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }

    },
    GenderFullGeo = function(full.name, country.iso2, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      if (missing(`full.name`)) {
        stop("Missing required parameter `full.name`.")
      }

      if (missing(`country.iso2`)) {
        stop("Missing required parameter `country.iso2`.")
      }

      urlPath <- "/api2/json/genderFullGeo/{fullName}/{countryIso2}"
      if (!missing(`full.name`)) {
        urlPath <- gsub(paste0("\\{", "fullName", "\\}"), `full.name`, urlPath)
      }

      if (!missing(`country.iso2`)) {
        urlPath <- gsub(paste0("\\{", "countryIso2", "\\}"), `country.iso2`, urlPath)
      }

      # API key authentication
      if ("X-API-KEY" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["X-API-KEY"]) > 0) {
        headerParams['X-API-KEY'] <- paste(unlist(self$apiClient$apiKeys["X-API-KEY"]), collapse='')
      }

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "GET",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        FirstLastNameGenderedOut$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }

    },
    GenderFullGeoBatch = function(batch.personal.name.geo.in=NULL, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      if (!missing(`batch.personal.name.geo.in`)) {
        body <- `batch.personal.name.geo.in`$toJSONString()
      } else {
        body <- NULL
      }

      urlPath <- "/api2/json/genderFullGeoBatch"
      # API key authentication
      if ("X-API-KEY" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["X-API-KEY"]) > 0) {
        headerParams['X-API-KEY'] <- paste(unlist(self$apiClient$apiKeys["X-API-KEY"]), collapse='')
      }

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "POST",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        BatchPersonalNameGenderedOut$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }

    },
    GenderGeo = function(first.name, last.name, country.iso2, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      if (missing(`first.name`)) {
        stop("Missing required parameter `first.name`.")
      }

      if (missing(`last.name`)) {
        stop("Missing required parameter `last.name`.")
      }

      if (missing(`country.iso2`)) {
        stop("Missing required parameter `country.iso2`.")
      }

      urlPath <- "/api2/json/genderGeo/{firstName}/{lastName}/{countryIso2}"
      if (!missing(`first.name`)) {
        urlPath <- gsub(paste0("\\{", "firstName", "\\}"), `first.name`, urlPath)
      }

      if (!missing(`last.name`)) {
        urlPath <- gsub(paste0("\\{", "lastName", "\\}"), `last.name`, urlPath)
      }

      if (!missing(`country.iso2`)) {
        urlPath <- gsub(paste0("\\{", "countryIso2", "\\}"), `country.iso2`, urlPath)
      }

      # API key authentication
      if ("X-API-KEY" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["X-API-KEY"]) > 0) {
        headerParams['X-API-KEY'] <- paste(unlist(self$apiClient$apiKeys["X-API-KEY"]), collapse='')
      }

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "GET",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        FirstLastNameGenderedOut$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }

    },
    GenderGeoBatch = function(batch.first.last.name.geo.in=NULL, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      if (!missing(`batch.first.last.name.geo.in`)) {
        body <- `batch.first.last.name.geo.in`$toJSONString()
      } else {
        body <- NULL
      }

      urlPath <- "/api2/json/genderGeoBatch"
      # API key authentication
      if ("X-API-KEY" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["X-API-KEY"]) > 0) {
        headerParams['X-API-KEY'] <- paste(unlist(self$apiClient$apiKeys["X-API-KEY"]), collapse='')
      }

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "POST",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        BatchFirstLastNameGenderedOut$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }

    },
    Origin = function(first.name, last.name, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      if (missing(`first.name`)) {
        stop("Missing required parameter `first.name`.")
      }

      if (missing(`last.name`)) {
        stop("Missing required parameter `last.name`.")
      }

      urlPath <- "/api2/json/origin/{firstName}/{lastName}"
      if (!missing(`first.name`)) {
        urlPath <- gsub(paste0("\\{", "firstName", "\\}"), `first.name`, urlPath)
      }

      if (!missing(`last.name`)) {
        urlPath <- gsub(paste0("\\{", "lastName", "\\}"), `last.name`, urlPath)
      }

      # API key authentication
      if ("X-API-KEY" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["X-API-KEY"]) > 0) {
        headerParams['X-API-KEY'] <- paste(unlist(self$apiClient$apiKeys["X-API-KEY"]), collapse='')
      }

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "GET",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        FirstLastNameOriginedOut$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }

    },
    OriginBatch = function(batch.first.last.name.in=NULL, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      if (!missing(`batch.first.last.name.in`)) {
        body <- `batch.first.last.name.in`$toJSONString()
      } else {
        body <- NULL
      }

      urlPath <- "/api2/json/originBatch"
      # API key authentication
      if ("X-API-KEY" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["X-API-KEY"]) > 0) {
        headerParams['X-API-KEY'] <- paste(unlist(self$apiClient$apiKeys["X-API-KEY"]), collapse='')
      }

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "POST",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        BatchFirstLastNameOriginedOut$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }

    },
    ParsedGenderBatch = function(batch.parsed.full.name.in=NULL, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      if (!missing(`batch.parsed.full.name.in`)) {
        body <- `batch.parsed.full.name.in`$toJSONString()
      } else {
        body <- NULL
      }

      urlPath <- "/api2/json/parsedGenderBatch"
      # API key authentication
      if ("X-API-KEY" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["X-API-KEY"]) > 0) {
        headerParams['X-API-KEY'] <- paste(unlist(self$apiClient$apiKeys["X-API-KEY"]), collapse='')
      }

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "POST",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        BatchFirstLastNameGenderedOut$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }

    },
    ParsedGenderGeoBatch = function(batch.parsed.full.name.geo.in=NULL, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      if (!missing(`batch.parsed.full.name.geo.in`)) {
        body <- `batch.parsed.full.name.geo.in`$toJSONString()
      } else {
        body <- NULL
      }

      urlPath <- "/api2/json/parsedGenderGeoBatch"
      # API key authentication
      if ("X-API-KEY" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["X-API-KEY"]) > 0) {
        headerParams['X-API-KEY'] <- paste(unlist(self$apiClient$apiKeys["X-API-KEY"]), collapse='')
      }

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "POST",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        BatchFirstLastNameGenderedOut$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }

    },
    UsRaceEthnicity = function(first.name, last.name, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      if (missing(`first.name`)) {
        stop("Missing required parameter `first.name`.")
      }

      if (missing(`last.name`)) {
        stop("Missing required parameter `last.name`.")
      }

      urlPath <- "/api2/json/usRaceEthnicity/{firstName}/{lastName}"
      if (!missing(`first.name`)) {
        urlPath <- gsub(paste0("\\{", "firstName", "\\}"), `first.name`, urlPath)
      }

      if (!missing(`last.name`)) {
        urlPath <- gsub(paste0("\\{", "lastName", "\\}"), `last.name`, urlPath)
      }

      # API key authentication
      if ("X-API-KEY" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["X-API-KEY"]) > 0) {
        headerParams['X-API-KEY'] <- paste(unlist(self$apiClient$apiKeys["X-API-KEY"]), collapse='')
      }

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "GET",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        FirstLastNameUSRaceEthnicityOut$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }

    },
    UsRaceEthnicityBatch = function(batch.first.last.name.geo.in=NULL, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      if (!missing(`batch.first.last.name.geo.in`)) {
        body <- `batch.first.last.name.geo.in`$toJSONString()
      } else {
        body <- NULL
      }

      urlPath <- "/api2/json/usRaceEthnicityBatch"
      # API key authentication
      if ("X-API-KEY" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["X-API-KEY"]) > 0) {
        headerParams['X-API-KEY'] <- paste(unlist(self$apiClient$apiKeys["X-API-KEY"]), collapse='')
      }

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "POST",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        BatchFirstLastNameUSRaceEthnicityOut$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }

    },
    UsRaceEthnicityZIP5 = function(first.name, last.name, zip5.code, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      if (missing(`first.name`)) {
        stop("Missing required parameter `first.name`.")
      }

      if (missing(`last.name`)) {
        stop("Missing required parameter `last.name`.")
      }

      if (missing(`zip5.code`)) {
        stop("Missing required parameter `zip5.code`.")
      }

      urlPath <- "/api2/json/usRaceEthnicityZIP5/{firstName}/{lastName}/{zip5Code}"
      if (!missing(`first.name`)) {
        urlPath <- gsub(paste0("\\{", "firstName", "\\}"), `first.name`, urlPath)
      }

      if (!missing(`last.name`)) {
        urlPath <- gsub(paste0("\\{", "lastName", "\\}"), `last.name`, urlPath)
      }

      if (!missing(`zip5.code`)) {
        urlPath <- gsub(paste0("\\{", "zip5Code", "\\}"), `zip5.code`, urlPath)
      }

      # API key authentication
      if ("X-API-KEY" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["X-API-KEY"]) > 0) {
        headerParams['X-API-KEY'] <- paste(unlist(self$apiClient$apiKeys["X-API-KEY"]), collapse='')
      }

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "GET",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        FirstLastNameUSRaceEthnicityOut$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }

    },
    UsZipRaceEthnicityBatch = function(batch.first.last.name.geo.zipped.in=NULL, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      if (!missing(`batch.first.last.name.geo.zipped.in`)) {
        body <- `batch.first.last.name.geo.zipped.in`$toJSONString()
      } else {
        body <- NULL
      }

      urlPath <- "/api2/json/usZipRaceEthnicityBatch"
      # API key authentication
      if ("X-API-KEY" %in% names(self$apiClient$apiKeys) && nchar(self$apiClient$apiKeys["X-API-KEY"]) > 0) {
        headerParams['X-API-KEY'] <- paste(unlist(self$apiClient$apiKeys["X-API-KEY"]), collapse='')
      }

      resp <- self$apiClient$CallApi(url = paste0(self$apiClient$basePath, urlPath),
                                 method = "POST",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        BatchFirstLastNameUSRaceEthnicityOut$new()$fromJSONString(httr::content(resp, "text", encoding = "UTF-8"))
      } else if (httr::status_code(resp) >= 400 && httr::status_code(resp) <= 499) {
        ApiResponse$new("API client error", resp)
      } else if (httr::status_code(resp) >= 500 && httr::status_code(resp) <= 599) {
        ApiResponse$new("API server error", resp)
      }

    }
  )
)
wing328/namsor-r-client documentation built on May 26, 2019, 7:01 p.m.