R/admin_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 Admin operations
#' @description namsor.Admin
#'
#' @field path Stores url path of the request.
#' @field apiClient Handles the client-server communication.
#'
#' @importFrom R6 R6Class
#'
#' @section Methods:
#' \describe{
#'
#' ApiUsage Print current API usage.
#'
#'
#' ApiUsageHistory Print historical API usage.
#'
#'
#' ApiUsageHistoryAggregate Print historical API usage (in an aggregated view, by service, by day/hour/min).
#'
#'
#' AvailablePlans List all available plans in the default currency (usd).
#'
#'
#' AvailablePlans1 List all available plans in the user's preferred currency.
#'
#'
#' AvailableServices List of API services and usage cost in Units (default is 1=ONE Unit).
#'
#'
#' BillingCurrencies List possible currency options for billing (USD, EUR, GBP, ...)
#'
#'
#' BillingHistory Read the history billing information (invoices paid via Stripe or manually).
#'
#'
#' BillingInfo Read the billing information (company name, address, phone, vat ID)
#'
#'
#' Charge Create a Stripe Customer, based on a payment card token (from secure StripeJS) and email.
#'
#'
#' CorporateKey Setting an API Key to a corporate status.
#'
#'
#' DebugLevel Update debug level for a classifier
#'
#'
#' InvalidateCache Invalidate system caches.
#'
#'
#' NamsorCounter Get the overall API counter
#'
#'
#' PaymentInfo Get the Stripe payment information associated with the current google auth session token.
#'
#'
#' ProcureKey Procure an API Key (sent via Email), based on an auth token. Keep your API Key secret.
#'
#'
#' RedeployUI Redeploy UI from current dev branch.
#'
#'
#' RedeployUI1 Redeploy UI from current dev branch.
#'
#'
#' RemoveUserAccount Subscribe to a give API plan, using the user's preferred or default currency.
#'
#'
#' Shutdown Stop learning and shutdown system.
#'
#'
#' SoftwareVersion Get the current software version
#'
#'
#' SourceStats Print basic source statistics.
#'
#'
#' Stats Print basic system statistics.
#'
#'
#' StripeConnect Connects a Stripe Account.
#'
#'
#' SubscribePlan Subscribe to a give API plan, using the user's preferred or default currency.
#'
#'
#' UpdateBillingInfo Sets or update the billing information (company name, address, phone, vat ID)
#'
#'
#' UpdateLimit Modifies the hard/soft limit on the API plan's overages (default is 0$ soft limit).
#'
#'
#' UpdatePaymentDefault Update the default Stripe card associated with the current google auth session token.
#'
#'
#' UserInfo Get the user profile associated with the current google auth session token.
#'
#'
#' VerifyEmail Verifies an email, based on token sent to that email
#'
#'
#' VerifyRemoveEmail Verifies an email, based on token sent to that email
#'
#'
#' Vet Vetting of a source.
#'
#' }
#'
#' @importFrom jsonlite base64_enc
#' @export
AdminApi <- R6::R6Class(
  'AdminApi',
  public = list(
    apiClient = NULL,
    initialize = function(apiClient){
      if (!missing(apiClient)) {
        self$apiClient <- apiClient
      }
      else {
        self$apiClient <- ApiClient$new()
      }
    },
    ApiUsage = function(...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      urlPath <- "/api2/json/apiUsage"
      # 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) {
        APIPeriodUsageOut$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)
      }

    },
    ApiUsageHistory = function(...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      urlPath <- "/api2/json/apiUsageHistory"
      # 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) {
        APIPeriodUsageOut$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)
      }

    },
    ApiUsageHistoryAggregate = function(...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      urlPath <- "/api2/json/apiUsageHistoryAggregate"
      # 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) {
        APIPeriodUsageOut$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)
      }

    },
    AvailablePlans = function(...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      urlPath <- "/api2/json/availablePlans"
      # 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) {
        APIPlansOut$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)
      }

    },
    AvailablePlans1 = function(token, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

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

      urlPath <- "/api2/json/availablePlans/{token}"
      if (!missing(`token`)) {
        urlPath <- gsub(paste0("\\{", "token", "\\}"), `token`, 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) {
        APIPlansOut$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)
      }

    },
    AvailableServices = function(...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      urlPath <- "/api2/json/apiServices"
      # 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) {
        APIPlansOut$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)
      }

    },
    BillingCurrencies = function(...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      urlPath <- "/api2/json/billingCurrencies"
      # 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) {
        CurrenciesOut$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)
      }

    },
    BillingHistory = function(token, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

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

      urlPath <- "/api2/json/billingHistory/{token}"
      if (!missing(`token`)) {
        urlPath <- gsub(paste0("\\{", "token", "\\}"), `token`, 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) {
        BillingHistoryOut$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)
      }

    },
    BillingInfo = function(token, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

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

      urlPath <- "/api2/json/billingInfo/{token}"
      if (!missing(`token`)) {
        urlPath <- gsub(paste0("\\{", "token", "\\}"), `token`, 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) {
        BillingInfoInOut$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)
      }

    },
    Charge = function(inline.object=NULL, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      if (!missing(`inline.object`)) {
        body <- `inline.object`$toJSONString()
      } else {
        body <- NULL
      }

      urlPath <- "/api2/json/charge"
      # 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) {
        APIKeyOut$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)
      }

    },
    CorporateKey = function(api.key, corporate, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      if (missing(`api.key`)) {
        stop("Missing required parameter `api.key`.")
      }

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

      urlPath <- "/api2/json/corporateKey/{apiKey}/{corporate}"
      if (!missing(`api.key`)) {
        urlPath <- gsub(paste0("\\{", "apiKey", "\\}"), `api.key`, urlPath)
      }

      if (!missing(`corporate`)) {
        urlPath <- gsub(paste0("\\{", "corporate", "\\}"), `corporate`, 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) {
        # void response, no need to return anything
      } 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)
      }

    },
    DebugLevel = function(logger, level, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

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

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

      urlPath <- "/api2/json/debugLevel/{logger}/{level}"
      if (!missing(`logger`)) {
        urlPath <- gsub(paste0("\\{", "logger", "\\}"), `logger`, urlPath)
      }

      if (!missing(`level`)) {
        urlPath <- gsub(paste0("\\{", "level", "\\}"), `level`, 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) {
        # void response, no need to return anything
      } 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)
      }

    },
    InvalidateCache = function(...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      urlPath <- "/api2/json/invalidateCache"
      # 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) {
        # void response, no need to return anything
      } 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)
      }

    },
    NamsorCounter = function(...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      urlPath <- "/api2/json/namsorCounter"
      # 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) {
        SoftwareVersionOut$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)
      }

    },
    PaymentInfo = function(token, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

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

      urlPath <- "/api2/json/paymentInfo/{token}"
      if (!missing(`token`)) {
        urlPath <- gsub(paste0("\\{", "token", "\\}"), `token`, 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) {
        APIKeyOut$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)
      }

    },
    ProcureKey = function(token, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

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

      urlPath <- "/api2/json/procureKey/{token}"
      if (!missing(`token`)) {
        urlPath <- gsub(paste0("\\{", "token", "\\}"), `token`, 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) {
        APIKeyOut$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)
      }

    },
    RedeployUI = function(...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      urlPath <- "/api2/json/redeployUI"
      # 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) {
        # void response, no need to return anything
      } 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)
      }

    },
    RedeployUI1 = function(live, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

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

      urlPath <- "/api2/json/redeployUI/{live}"
      if (!missing(`live`)) {
        urlPath <- gsub(paste0("\\{", "live", "\\}"), `live`, 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) {
        # void response, no need to return anything
      } 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)
      }

    },
    RemoveUserAccount = function(token, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

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

      urlPath <- "/api2/json/removeUserAccount/{token}"
      if (!missing(`token`)) {
        urlPath <- gsub(paste0("\\{", "token", "\\}"), `token`, 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) {
        APIPlanSubscriptionOut$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)
      }

    },
    Shutdown = function(...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      urlPath <- "/api2/json/shutdown"
      # 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) {
        # void response, no need to return anything
      } 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)
      }

    },
    SoftwareVersion = function(...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      urlPath <- "/api2/json/softwareVersion"
      # 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) {
        SoftwareVersionOut$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)
      }

    },
    SourceStats = function(source, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

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

      urlPath <- "/api2/json/sourceStats/{source}"
      if (!missing(`source`)) {
        urlPath <- gsub(paste0("\\{", "source", "\\}"), `source`, 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) {
        SystemMetricsOut$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)
      }

    },
    Stats = function(...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      urlPath <- "/api2/json/stats"
      # 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) {
        SystemMetricsOut$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)
      }

    },
    StripeConnect = function(scope=NULL, code=NULL, error=NULL, error.description=NULL, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      queryParams['scope'] <- scope

      queryParams['code'] <- code

      queryParams['error'] <- error

      queryParams['error_description'] <- error.description

      urlPath <- "/api2/json/stripeConnect"
      # 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) {
        # void response, no need to return anything
      } 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)
      }

    },
    SubscribePlan = function(plan.name, token, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

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

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

      urlPath <- "/api2/json/subscribePlan/{planName}/{token}"
      if (!missing(`plan.name`)) {
        urlPath <- gsub(paste0("\\{", "planName", "\\}"), `plan.name`, urlPath)
      }

      if (!missing(`token`)) {
        urlPath <- gsub(paste0("\\{", "token", "\\}"), `token`, 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) {
        APIPlanSubscriptionOut$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)
      }

    },
    UpdateBillingInfo = function(token, billing.info.in.out=NULL, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

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

      if (!missing(`billing.info.in.out`)) {
        body <- `billing.info.in.out`$toJSONString()
      } else {
        body <- NULL
      }

      urlPath <- "/api2/json/updateBillingInfo/{token}"
      if (!missing(`token`)) {
        urlPath <- gsub(paste0("\\{", "token", "\\}"), `token`, 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 = "POST",
                                 queryParams = queryParams,
                                 headerParams = headerParams,
                                 body = body,
                                 ...)

      if (httr::status_code(resp) >= 200 && httr::status_code(resp) <= 299) {
        BillingInfoInOut$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)
      }

    },
    UpdateLimit = function(usage.limit, hard.or.soft, token, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      if (missing(`usage.limit`)) {
        stop("Missing required parameter `usage.limit`.")
      }

      if (missing(`hard.or.soft`)) {
        stop("Missing required parameter `hard.or.soft`.")
      }

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

      urlPath <- "/api2/json/updateLimit/{usageLimit}/{hardOrSoft}/{token}"
      if (!missing(`usage.limit`)) {
        urlPath <- gsub(paste0("\\{", "usageLimit", "\\}"), `usage.limit`, urlPath)
      }

      if (!missing(`hard.or.soft`)) {
        urlPath <- gsub(paste0("\\{", "hardOrSoft", "\\}"), `hard.or.soft`, urlPath)
      }

      if (!missing(`token`)) {
        urlPath <- gsub(paste0("\\{", "token", "\\}"), `token`, 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) {
        APIPeriodUsageOut$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)
      }

    },
    UpdatePaymentDefault = function(defaut.source.id, token, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      if (missing(`defaut.source.id`)) {
        stop("Missing required parameter `defaut.source.id`.")
      }

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

      urlPath <- "/api2/json/updatePaymentDefault/{defautSourceId}/{token}"
      if (!missing(`defaut.source.id`)) {
        urlPath <- gsub(paste0("\\{", "defautSourceId", "\\}"), `defaut.source.id`, urlPath)
      }

      if (!missing(`token`)) {
        urlPath <- gsub(paste0("\\{", "token", "\\}"), `token`, 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) {
        APIKeyOut$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)
      }

    },
    UserInfo = function(token, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

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

      urlPath <- "/api2/json/userInfo/{token}"
      if (!missing(`token`)) {
        urlPath <- gsub(paste0("\\{", "token", "\\}"), `token`, 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) {
        APIKeyOut$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)
      }

    },
    VerifyEmail = function(email.token, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      if (missing(`email.token`)) {
        stop("Missing required parameter `email.token`.")
      }

      urlPath <- "/api2/json/verifyEmail/{emailToken}"
      if (!missing(`email.token`)) {
        urlPath <- gsub(paste0("\\{", "emailToken", "\\}"), `email.token`, 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) {
        APIKeyOut$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)
      }

    },
    VerifyRemoveEmail = function(email.token, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

      if (missing(`email.token`)) {
        stop("Missing required parameter `email.token`.")
      }

      urlPath <- "/api2/json/verifyRemoveEmail/{emailToken}"
      if (!missing(`email.token`)) {
        urlPath <- gsub(paste0("\\{", "emailToken", "\\}"), `email.token`, 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) {
        APIKeyOut$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)
      }

    },
    Vet = function(source, vetted, ...){
      args <- list(...)
      queryParams <- list()
      headerParams <- c()

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

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

      urlPath <- "/api2/json/vetting/{source}/{vetted}"
      if (!missing(`source`)) {
        urlPath <- gsub(paste0("\\{", "source", "\\}"), `source`, urlPath)
      }

      if (!missing(`vetted`)) {
        urlPath <- gsub(paste0("\\{", "vetted", "\\}"), `vetted`, 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) {
        # void response, no need to return anything
      } 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.