R/openapi/organization_invitation_api.R

#' Jaqpot API
#'
#' A modern RESTful API for model management and prediction services, built using Spring Boot and Kotlin. Supports seamless integration with machine learning workflows.
#'
#' The version of the OpenAPI document: 1.0.0
#' Contact: upci.ntua@gmail.com
#' Generated by: https://openapi-generator.tech
#'
#' @docType class
#' @title OrganizationInvitation operations
#' @description OrganizationInvitationApi
#' @format An \code{R6Class} generator object
#' @field api_client Handles the client-server communication.
#'
#' @examples
#' \dontrun{
#' ####################  CreateInvitations  ####################
#'
#' library(openapi)
#' var_org_name <- "org_name_example" # character | Name of the organization
#' var_create_invitations_request <- createInvitations_request$new(c("emails_example")) # CreateInvitationsRequest | Invitation request payload
#'
#' #Create new invitations for an organization
#' api_instance <- OrganizationInvitationApi$new()
#'
#' # Configure HTTP bearer authorization: bearerAuth
#' api_instance$api_client$bearer_token <- Sys.getenv("BEARER_TOKEN")
#'
#' api_instance$CreateInvitations(var_org_name, var_create_invitations_request)
#'
#'
#' ####################  GetAllInvitations  ####################
#'
#' library(openapi)
#' var_org_name <- "org_name_example" # character | Name of the organization
#'
#' #Get all invitations for an organization
#' api_instance <- OrganizationInvitationApi$new()
#'
#' # Configure HTTP bearer authorization: bearerAuth
#' api_instance$api_client$bearer_token <- Sys.getenv("BEARER_TOKEN")
#'
#' # to save the result into a file, simply add the optional `data_file` parameter, e.g.
#' # result <- api_instance$GetAllInvitations(var_org_namedata_file = "result.txt")
#' result <- api_instance$GetAllInvitations(var_org_name)
#' dput(result)
#'
#'
#' ####################  GetInvitation  ####################
#'
#' library(openapi)
#' var_name <- "name_example" # character | Name of the organization
#' var_uuid <- "uuid_example" # character | UUID of the invitation
#'
#' #Get the status of an invitation
#' api_instance <- OrganizationInvitationApi$new()
#'
#' # Configure HTTP bearer authorization: bearerAuth
#' api_instance$api_client$bearer_token <- Sys.getenv("BEARER_TOKEN")
#'
#' # to save the result into a file, simply add the optional `data_file` parameter, e.g.
#' # result <- api_instance$GetInvitation(var_name, var_uuiddata_file = "result.txt")
#' result <- api_instance$GetInvitation(var_name, var_uuid)
#' dput(result)
#'
#'
#' ####################  ResendInvitation  ####################
#'
#' library(openapi)
#' var_org_id <- 56 # integer | ID of the organization
#' var_id <- "id_example" # character | ID of the invitation
#'
#' #Resend an invitation email
#' api_instance <- OrganizationInvitationApi$new()
#'
#' # Configure HTTP bearer authorization: bearerAuth
#' api_instance$api_client$bearer_token <- Sys.getenv("BEARER_TOKEN")
#'
#' api_instance$ResendInvitation(var_org_id, var_id)
#'
#'
#' ####################  UpdateInvitation  ####################
#'
#' library(openapi)
#' var_name <- "name_example" # character | Name of the organization
#' var_uuid <- "uuid_example" # character | UUID of the invitation
#' var_organization_invitation <- OrganizationInvitation$new("userEmail_example", "PENDING", "expirationDate_example", "id_example", "userId_example") # OrganizationInvitation | Invitation status update payload
#'
#' #Update the status of an invitation
#' api_instance <- OrganizationInvitationApi$new()
#'
#' # Configure HTTP bearer authorization: bearerAuth
#' api_instance$api_client$bearer_token <- Sys.getenv("BEARER_TOKEN")
#'
#' # to save the result into a file, simply add the optional `data_file` parameter, e.g.
#' # result <- api_instance$UpdateInvitation(var_name, var_uuid, var_organization_invitationdata_file = "result.txt")
#' result <- api_instance$UpdateInvitation(var_name, var_uuid, var_organization_invitation)
#' dput(result)
#'
#'
#' }
#' @importFrom R6 R6Class
#' @importFrom base64enc base64encode
#' @keywords internal
OrganizationInvitationApi <- R6::R6Class(
  "OrganizationInvitationApi",
  public = list(
    api_client = NULL,

    #' @description
    #' Initialize a new OrganizationInvitationApi.
    #'
    #' @param api_client An instance of API client.
    initialize = function(api_client) {
      if (!missing(api_client)) {
        self$api_client <- api_client
      } else {
        self$api_client <- ApiClient$new()
      }
    },

    #' @description
    #' Create new invitations for an organization
    #'
    #' @param org_name Name of the organization
    #' @param create_invitations_request Invitation request payload
    #' @param ... Other optional arguments
    #'
    #' @return void
    CreateInvitations = function(org_name, create_invitations_request, ...) {
      local_var_response <- self$CreateInvitationsWithHttpInfo(org_name, create_invitations_request, ...)
      if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) {
        local_var_response$content
      } else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) {
        local_var_response
      } else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) {
        local_var_response
      } else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) {
        local_var_response
      }
    },

    #' @description
    #' Create new invitations for an organization
    #'
    #' @param org_name Name of the organization
    #' @param create_invitations_request Invitation request payload
    #' @param ... Other optional arguments
    #'
    #' @return API response (void) with additional information such as HTTP status code, headers
    CreateInvitationsWithHttpInfo = function(org_name, create_invitations_request, ...) {
      args <- list(...)
      query_params <- list()
      header_params <- c()
      form_params <- list()
      file_params <- list()
      local_var_body <- NULL
      oauth_scopes <- NULL
      is_oauth <- FALSE

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

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



      if (!is.null(`create_invitations_request`)) {
        local_var_body <- `create_invitations_request`$toJSONString()
      } else {
        body <- NULL
      }

      local_var_url_path <- "/v1/organizations/{orgName}/invitations"
      if (!missing(`org_name`)) {
        local_var_url_path <- gsub("\\{orgName\\}", URLencode(as.character(`org_name`), reserved = TRUE), local_var_url_path)
      }

      # Bearer token
      if (!is.null(self$api_client$bearer_token)) {
        header_params["Authorization"] <- paste("Bearer", self$api_client$bearer_token, sep = " ")
      }

      # The Accept request HTTP header
      local_var_accepts <- list()

      # The Content-Type representation header
      local_var_content_types <- list("application/json")

      local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path),
                                 method = "POST",
                                 query_params = query_params,
                                 header_params = header_params,
                                 form_params = form_params,
                                 file_params = file_params,
                                 accepts = local_var_accepts,
                                 content_types = local_var_content_types,
                                 body = local_var_body,
                                 is_oauth = is_oauth,
                                 oauth_scopes = oauth_scopes,
                                 ...)

      if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) {
        local_var_resp$content <- NULL
        local_var_resp
      } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) {
        ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp)
      } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) {
        ApiResponse$new("API client error", local_var_resp)
      } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) {
        if (is.null(local_var_resp$response) || local_var_resp$response == "") {
          local_var_resp$response <- "API server error"
        }
        local_var_resp
      }
    },

    #' @description
    #' Get all invitations for an organization
    #'
    #' @param org_name Name of the organization
    #' @param data_file (optional) name of the data file to save the result
    #' @param ... Other optional arguments
    #'
    #' @return array[OrganizationInvitation]
    GetAllInvitations = function(org_name, data_file = NULL, ...) {
      local_var_response <- self$GetAllInvitationsWithHttpInfo(org_name, data_file = data_file, ...)
      if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) {
        local_var_response$content
      } else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) {
        local_var_response
      } else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) {
        local_var_response
      } else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) {
        local_var_response
      }
    },

    #' @description
    #' Get all invitations for an organization
    #'
    #' @param org_name Name of the organization
    #' @param data_file (optional) name of the data file to save the result
    #' @param ... Other optional arguments
    #'
    #' @return API response (array[OrganizationInvitation]) with additional information such as HTTP status code, headers
    GetAllInvitationsWithHttpInfo = function(org_name, data_file = NULL, ...) {
      args <- list(...)
      query_params <- list()
      header_params <- c()
      form_params <- list()
      file_params <- list()
      local_var_body <- NULL
      oauth_scopes <- NULL
      is_oauth <- FALSE

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


      local_var_url_path <- "/v1/organizations/{orgName}/invitations"
      if (!missing(`org_name`)) {
        local_var_url_path <- gsub("\\{orgName\\}", URLencode(as.character(`org_name`), reserved = TRUE), local_var_url_path)
      }

      # Bearer token
      if (!is.null(self$api_client$bearer_token)) {
        header_params["Authorization"] <- paste("Bearer", self$api_client$bearer_token, sep = " ")
      }

      # The Accept request HTTP header
      local_var_accepts <- list("application/json")

      # The Content-Type representation header
      local_var_content_types <- list()

      local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path),
                                 method = "GET",
                                 query_params = query_params,
                                 header_params = header_params,
                                 form_params = form_params,
                                 file_params = file_params,
                                 accepts = local_var_accepts,
                                 content_types = local_var_content_types,
                                 body = local_var_body,
                                 is_oauth = is_oauth,
                                 oauth_scopes = oauth_scopes,
                                 ...)

      if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) {
        # save response in a file
        if (!is.null(data_file)) {
          write(local_var_resp$response, data_file)
        }

        deserialized_resp_obj <- tryCatch(
          self$api_client$deserialize(local_var_resp$response_as_text(), "array[OrganizationInvitation]", loadNamespace("openapi")),
          error = function(e) {
            stop("Failed to deserialize response")
          }
        )
        local_var_resp$content <- deserialized_resp_obj
        local_var_resp
      } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) {
        ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp)
      } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) {
        ApiResponse$new("API client error", local_var_resp)
      } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) {
        if (is.null(local_var_resp$response) || local_var_resp$response == "") {
          local_var_resp$response <- "API server error"
        }
        local_var_resp
      }
    },

    #' @description
    #' Get the status of an invitation
    #'
    #' @param name Name of the organization
    #' @param uuid UUID of the invitation
    #' @param data_file (optional) name of the data file to save the result
    #' @param ... Other optional arguments
    #'
    #' @return OrganizationInvitation
    GetInvitation = function(name, uuid, data_file = NULL, ...) {
      local_var_response <- self$GetInvitationWithHttpInfo(name, uuid, data_file = data_file, ...)
      if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) {
        local_var_response$content
      } else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) {
        local_var_response
      } else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) {
        local_var_response
      } else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) {
        local_var_response
      }
    },

    #' @description
    #' Get the status of an invitation
    #'
    #' @param name Name of the organization
    #' @param uuid UUID of the invitation
    #' @param data_file (optional) name of the data file to save the result
    #' @param ... Other optional arguments
    #'
    #' @return API response (OrganizationInvitation) with additional information such as HTTP status code, headers
    GetInvitationWithHttpInfo = function(name, uuid, data_file = NULL, ...) {
      args <- list(...)
      query_params <- list()
      header_params <- c()
      form_params <- list()
      file_params <- list()
      local_var_body <- NULL
      oauth_scopes <- NULL
      is_oauth <- FALSE

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

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



      local_var_url_path <- "/v1/organizations/{name}/invitations/{uuid}"
      if (!missing(`name`)) {
        local_var_url_path <- gsub("\\{name\\}", URLencode(as.character(`name`), reserved = TRUE), local_var_url_path)
      }

      if (!missing(`uuid`)) {
        local_var_url_path <- gsub("\\{uuid\\}", URLencode(as.character(`uuid`), reserved = TRUE), local_var_url_path)
      }

      # Bearer token
      if (!is.null(self$api_client$bearer_token)) {
        header_params["Authorization"] <- paste("Bearer", self$api_client$bearer_token, sep = " ")
      }

      # The Accept request HTTP header
      local_var_accepts <- list("application/json")

      # The Content-Type representation header
      local_var_content_types <- list()

      local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path),
                                 method = "GET",
                                 query_params = query_params,
                                 header_params = header_params,
                                 form_params = form_params,
                                 file_params = file_params,
                                 accepts = local_var_accepts,
                                 content_types = local_var_content_types,
                                 body = local_var_body,
                                 is_oauth = is_oauth,
                                 oauth_scopes = oauth_scopes,
                                 ...)

      if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) {
        # save response in a file
        if (!is.null(data_file)) {
          write(local_var_resp$response, data_file)
        }

        deserialized_resp_obj <- tryCatch(
          self$api_client$deserialize(local_var_resp$response_as_text(), "OrganizationInvitation", loadNamespace("openapi")),
          error = function(e) {
            stop("Failed to deserialize response")
          }
        )
        local_var_resp$content <- deserialized_resp_obj
        local_var_resp
      } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) {
        ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp)
      } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) {
        ApiResponse$new("API client error", local_var_resp)
      } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) {
        if (is.null(local_var_resp$response) || local_var_resp$response == "") {
          local_var_resp$response <- "API server error"
        }
        local_var_resp
      }
    },

    #' @description
    #' Resend an invitation email
    #'
    #' @param org_id ID of the organization
    #' @param id ID of the invitation
    #' @param ... Other optional arguments
    #'
    #' @return void
    ResendInvitation = function(org_id, id, ...) {
      local_var_response <- self$ResendInvitationWithHttpInfo(org_id, id, ...)
      if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) {
        local_var_response$content
      } else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) {
        local_var_response
      } else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) {
        local_var_response
      } else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) {
        local_var_response
      }
    },

    #' @description
    #' Resend an invitation email
    #'
    #' @param org_id ID of the organization
    #' @param id ID of the invitation
    #' @param ... Other optional arguments
    #'
    #' @return API response (void) with additional information such as HTTP status code, headers
    ResendInvitationWithHttpInfo = function(org_id, id, ...) {
      args <- list(...)
      query_params <- list()
      header_params <- c()
      form_params <- list()
      file_params <- list()
      local_var_body <- NULL
      oauth_scopes <- NULL
      is_oauth <- FALSE

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

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



      local_var_url_path <- "/v1/organizations/{orgId}/invitations/{id}/resend"
      if (!missing(`org_id`)) {
        local_var_url_path <- gsub("\\{orgId\\}", URLencode(as.character(`org_id`), reserved = TRUE), local_var_url_path)
      }

      if (!missing(`id`)) {
        local_var_url_path <- gsub("\\{id\\}", URLencode(as.character(`id`), reserved = TRUE), local_var_url_path)
      }

      # Bearer token
      if (!is.null(self$api_client$bearer_token)) {
        header_params["Authorization"] <- paste("Bearer", self$api_client$bearer_token, sep = " ")
      }

      # The Accept request HTTP header
      local_var_accepts <- list("application/json")

      # The Content-Type representation header
      local_var_content_types <- list()

      local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path),
                                 method = "POST",
                                 query_params = query_params,
                                 header_params = header_params,
                                 form_params = form_params,
                                 file_params = file_params,
                                 accepts = local_var_accepts,
                                 content_types = local_var_content_types,
                                 body = local_var_body,
                                 is_oauth = is_oauth,
                                 oauth_scopes = oauth_scopes,
                                 ...)

      if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) {
        local_var_resp$content <- NULL
        local_var_resp
      } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) {
        ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp)
      } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) {
        ApiResponse$new("API client error", local_var_resp)
      } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) {
        if (is.null(local_var_resp$response) || local_var_resp$response == "") {
          local_var_resp$response <- "API server error"
        }
        local_var_resp
      }
    },

    #' @description
    #' Update the status of an invitation
    #'
    #' @param name Name of the organization
    #' @param uuid UUID of the invitation
    #' @param organization_invitation Invitation status update payload
    #' @param data_file (optional) name of the data file to save the result
    #' @param ... Other optional arguments
    #'
    #' @return OrganizationInvitation
    UpdateInvitation = function(name, uuid, organization_invitation, data_file = NULL, ...) {
      local_var_response <- self$UpdateInvitationWithHttpInfo(name, uuid, organization_invitation, data_file = data_file, ...)
      if (local_var_response$status_code >= 200 && local_var_response$status_code <= 299) {
        local_var_response$content
      } else if (local_var_response$status_code >= 300 && local_var_response$status_code <= 399) {
        local_var_response
      } else if (local_var_response$status_code >= 400 && local_var_response$status_code <= 499) {
        local_var_response
      } else if (local_var_response$status_code >= 500 && local_var_response$status_code <= 599) {
        local_var_response
      }
    },

    #' @description
    #' Update the status of an invitation
    #'
    #' @param name Name of the organization
    #' @param uuid UUID of the invitation
    #' @param organization_invitation Invitation status update payload
    #' @param data_file (optional) name of the data file to save the result
    #' @param ... Other optional arguments
    #'
    #' @return API response (OrganizationInvitation) with additional information such as HTTP status code, headers
    UpdateInvitationWithHttpInfo = function(name, uuid, organization_invitation, data_file = NULL, ...) {
      args <- list(...)
      query_params <- list()
      header_params <- c()
      form_params <- list()
      file_params <- list()
      local_var_body <- NULL
      oauth_scopes <- NULL
      is_oauth <- FALSE

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

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

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




      if (!is.null(`organization_invitation`)) {
        local_var_body <- `organization_invitation`$toJSONString()
      } else {
        body <- NULL
      }

      local_var_url_path <- "/v1/organizations/{name}/invitations/{uuid}"
      if (!missing(`name`)) {
        local_var_url_path <- gsub("\\{name\\}", URLencode(as.character(`name`), reserved = TRUE), local_var_url_path)
      }

      if (!missing(`uuid`)) {
        local_var_url_path <- gsub("\\{uuid\\}", URLencode(as.character(`uuid`), reserved = TRUE), local_var_url_path)
      }

      # Bearer token
      if (!is.null(self$api_client$bearer_token)) {
        header_params["Authorization"] <- paste("Bearer", self$api_client$bearer_token, sep = " ")
      }

      # The Accept request HTTP header
      local_var_accepts <- list("application/json")

      # The Content-Type representation header
      local_var_content_types <- list("application/json")

      local_var_resp <- self$api_client$CallApi(url = paste0(self$api_client$base_path, local_var_url_path),
                                 method = "PUT",
                                 query_params = query_params,
                                 header_params = header_params,
                                 form_params = form_params,
                                 file_params = file_params,
                                 accepts = local_var_accepts,
                                 content_types = local_var_content_types,
                                 body = local_var_body,
                                 is_oauth = is_oauth,
                                 oauth_scopes = oauth_scopes,
                                 ...)

      if (local_var_resp$status_code >= 200 && local_var_resp$status_code <= 299) {
        # save response in a file
        if (!is.null(data_file)) {
          write(local_var_resp$response, data_file)
        }

        deserialized_resp_obj <- tryCatch(
          self$api_client$deserialize(local_var_resp$response_as_text(), "OrganizationInvitation", loadNamespace("openapi")),
          error = function(e) {
            stop("Failed to deserialize response")
          }
        )
        local_var_resp$content <- deserialized_resp_obj
        local_var_resp
      } else if (local_var_resp$status_code >= 300 && local_var_resp$status_code <= 399) {
        ApiResponse$new(paste("Server returned ", local_var_resp$status_code, " response status code."), local_var_resp)
      } else if (local_var_resp$status_code >= 400 && local_var_resp$status_code <= 499) {
        ApiResponse$new("API client error", local_var_resp)
      } else if (local_var_resp$status_code >= 500 && local_var_resp$status_code <= 599) {
        if (is.null(local_var_resp$response) || local_var_resp$response == "") {
          local_var_resp$response <- "API server error"
        }
        local_var_resp
      }
    }
  )
)
KinkyDesign/jaqpotr documentation built on Nov. 27, 2024, 1:20 a.m.