All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.svix.kotlin.internal.apis.AuthenticationApi.kt Maven / Gradle / Ivy

/**
* Svix API
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.1.1
* 
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package com.svix.kotlin.internal.apis

import com.svix.kotlin.models.AppPortalAccessIn
import com.svix.kotlin.models.AppPortalAccessOut
import com.svix.kotlin.models.ApplicationTokenExpireIn
import com.svix.kotlin.models.AuthTokenOut
import com.svix.kotlin.models.CreateMessageTokenIn
import com.svix.kotlin.models.DashboardAccessOut
import com.svix.kotlin.models.HTTPValidationError
import com.svix.kotlin.models.HttpErrorOut
import com.svix.kotlin.models.OneTimeTokenIn
import com.svix.kotlin.models.OneTimeTokenOut

import com.svix.kotlin.internal.infrastructure.ApiClient
import com.svix.kotlin.internal.infrastructure.ClientException
import com.svix.kotlin.internal.infrastructure.ClientError
import com.svix.kotlin.internal.infrastructure.ServerException
import com.svix.kotlin.internal.infrastructure.ServerError
import com.svix.kotlin.internal.infrastructure.MultiValueMap
import com.svix.kotlin.internal.infrastructure.RequestConfig
import com.svix.kotlin.internal.infrastructure.RequestMethod
import com.svix.kotlin.internal.infrastructure.ResponseType
import com.svix.kotlin.internal.infrastructure.Success
import com.svix.kotlin.internal.infrastructure.toMultiValue

class AuthenticationApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) {
    companion object {
        @JvmStatic
        val defaultBasePath: String by lazy {
            System.getProperties().getProperty("com.svix.kotlin.internal.baseUrl", "https://api.eu.svix.com")
        }
    }

    /**
    * Get Consumer App Portal Access
    * Use this function to get magic links (and authentication codes) for connecting your users to the Consumer Application Portal.
    * @param appId The app's ID or UID 
    * @param appPortalAccessIn  
    * @param idempotencyKey The request's idempotency key (optional)
    * @return AppPortalAccessOut
    * @throws UnsupportedOperationException If the API returns an informational or redirection response
    * @throws ClientException If the API returns a client error response
    * @throws ServerException If the API returns a server error response
    */
    @Suppress("UNCHECKED_CAST")
    @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class)
    suspend fun v1AuthenticationAppPortalAccess(appId: kotlin.String, appPortalAccessIn: AppPortalAccessIn, idempotencyKey: kotlin.String?) : AppPortalAccessOut {
        val localVariableConfig = v1AuthenticationAppPortalAccessRequestConfig(appId = appId, appPortalAccessIn = appPortalAccessIn, idempotencyKey = idempotencyKey)

        val localVarResponse = request(
            localVariableConfig
        )

        return when (localVarResponse.responseType) {
            ResponseType.Success -> (localVarResponse as Success<*>).data as AppPortalAccessOut
            ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
            ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
            ResponseType.ClientError -> {
                val localVarError = localVarResponse as ClientError<*>
                throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
            }
            ResponseType.ServerError -> {
                val localVarError = localVarResponse as ServerError<*>
                throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
            }
        }
    }

    /**
    * To obtain the request config of the operation v1AuthenticationAppPortalAccess
    *
    * @param appId The app's ID or UID 
    * @param appPortalAccessIn  
    * @param idempotencyKey The request's idempotency key (optional)
    * @return RequestConfig
    */
    fun v1AuthenticationAppPortalAccessRequestConfig(appId: kotlin.String, appPortalAccessIn: AppPortalAccessIn, idempotencyKey: kotlin.String?) : RequestConfig {
        val localVariableBody = appPortalAccessIn
        val localVariableQuery: MultiValueMap = mutableMapOf()
        val localVariableHeaders: MutableMap = mutableMapOf()
        idempotencyKey?.apply { localVariableHeaders["idempotency-key"] = this.toString() }

        return RequestConfig(
            method = RequestMethod.POST,
            path = "/api/v1/auth/app-portal-access/{app_id}".replace("{"+"app_id"+"}", "$appId"),
            query = localVariableQuery,
            headers = localVariableHeaders,
            body = localVariableBody
        )
    }

    /**
    * Create Cmg Token
    * Create a new access token that only allows creating messages inside this application.
    * @param appId The app's ID or UID 
    * @param createMessageTokenIn  
    * @param idempotencyKey The request's idempotency key (optional)
    * @return AuthTokenOut
    * @throws UnsupportedOperationException If the API returns an informational or redirection response
    * @throws ClientException If the API returns a client error response
    * @throws ServerException If the API returns a server error response
    */
    @Suppress("UNCHECKED_CAST")
    @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class)
    suspend fun v1AuthenticationCreateMessageToken(appId: kotlin.String, createMessageTokenIn: CreateMessageTokenIn, idempotencyKey: kotlin.String?) : AuthTokenOut {
        val localVariableConfig = v1AuthenticationCreateMessageTokenRequestConfig(appId = appId, createMessageTokenIn = createMessageTokenIn, idempotencyKey = idempotencyKey)

        val localVarResponse = request(
            localVariableConfig
        )

        return when (localVarResponse.responseType) {
            ResponseType.Success -> (localVarResponse as Success<*>).data as AuthTokenOut
            ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
            ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
            ResponseType.ClientError -> {
                val localVarError = localVarResponse as ClientError<*>
                throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
            }
            ResponseType.ServerError -> {
                val localVarError = localVarResponse as ServerError<*>
                throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
            }
        }
    }

    /**
    * To obtain the request config of the operation v1AuthenticationCreateMessageToken
    *
    * @param appId The app's ID or UID 
    * @param createMessageTokenIn  
    * @param idempotencyKey The request's idempotency key (optional)
    * @return RequestConfig
    */
    fun v1AuthenticationCreateMessageTokenRequestConfig(appId: kotlin.String, createMessageTokenIn: CreateMessageTokenIn, idempotencyKey: kotlin.String?) : RequestConfig {
        val localVariableBody = createMessageTokenIn
        val localVariableQuery: MultiValueMap = mutableMapOf()
        val localVariableHeaders: MutableMap = mutableMapOf()
        idempotencyKey?.apply { localVariableHeaders["idempotency-key"] = this.toString() }

        return RequestConfig(
            method = RequestMethod.POST,
            path = "/api/v1/auth/app/{app_id}/create-message-token".replace("{"+"app_id"+"}", "$appId"),
            query = localVariableQuery,
            headers = localVariableHeaders,
            body = localVariableBody
        )
    }

    /**
    * Dashboard Access
    * DEPRECATED: Please use `app-portal-access` instead.  Use this function to get magic links (and authentication codes) for connecting your users to the Consumer Application Portal.
    * @param appId The app's ID or UID 
    * @param idempotencyKey The request's idempotency key (optional)
    * @return DashboardAccessOut
    * @throws UnsupportedOperationException If the API returns an informational or redirection response
    * @throws ClientException If the API returns a client error response
    * @throws ServerException If the API returns a server error response
    */
    @Suppress("UNCHECKED_CAST")
    @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class)
    @Deprecated(message = "This operation is deprecated.")
    suspend fun v1AuthenticationDashboardAccess(appId: kotlin.String, idempotencyKey: kotlin.String?) : DashboardAccessOut {
        @Suppress("DEPRECATION")
        val localVariableConfig = v1AuthenticationDashboardAccessRequestConfig(appId = appId, idempotencyKey = idempotencyKey)

        val localVarResponse = request(
            localVariableConfig
        )

        return when (localVarResponse.responseType) {
            ResponseType.Success -> (localVarResponse as Success<*>).data as DashboardAccessOut
            ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
            ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
            ResponseType.ClientError -> {
                val localVarError = localVarResponse as ClientError<*>
                throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
            }
            ResponseType.ServerError -> {
                val localVarError = localVarResponse as ServerError<*>
                throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
            }
        }
    }

    /**
    * To obtain the request config of the operation v1AuthenticationDashboardAccess
    *
    * @param appId The app's ID or UID 
    * @param idempotencyKey The request's idempotency key (optional)
    * @return RequestConfig
    */
    @Deprecated(message = "This operation is deprecated.")
    fun v1AuthenticationDashboardAccessRequestConfig(appId: kotlin.String, idempotencyKey: kotlin.String?) : RequestConfig {
        val localVariableBody = null
        val localVariableQuery: MultiValueMap = mutableMapOf()
        val localVariableHeaders: MutableMap = mutableMapOf()
        idempotencyKey?.apply { localVariableHeaders["idempotency-key"] = this.toString() }

        return RequestConfig(
            method = RequestMethod.POST,
            path = "/api/v1/auth/dashboard-access/{app_id}".replace("{"+"app_id"+"}", "$appId"),
            query = localVariableQuery,
            headers = localVariableHeaders,
            body = localVariableBody
        )
    }

    /**
    * Exchange One Time Token
    * This is a one time token
    * @param oneTimeTokenIn  
    * @param idempotencyKey The request's idempotency key (optional)
    * @return OneTimeTokenOut
    * @throws UnsupportedOperationException If the API returns an informational or redirection response
    * @throws ClientException If the API returns a client error response
    * @throws ServerException If the API returns a server error response
    */
    @Suppress("UNCHECKED_CAST")
    @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class)
    suspend fun v1AuthenticationExchangeOneTimeToken(oneTimeTokenIn: OneTimeTokenIn, idempotencyKey: kotlin.String?) : OneTimeTokenOut {
        val localVariableConfig = v1AuthenticationExchangeOneTimeTokenRequestConfig(oneTimeTokenIn = oneTimeTokenIn, idempotencyKey = idempotencyKey)

        val localVarResponse = request(
            localVariableConfig
        )

        return when (localVarResponse.responseType) {
            ResponseType.Success -> (localVarResponse as Success<*>).data as OneTimeTokenOut
            ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
            ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
            ResponseType.ClientError -> {
                val localVarError = localVarResponse as ClientError<*>
                throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
            }
            ResponseType.ServerError -> {
                val localVarError = localVarResponse as ServerError<*>
                throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
            }
        }
    }

    /**
    * To obtain the request config of the operation v1AuthenticationExchangeOneTimeToken
    *
    * @param oneTimeTokenIn  
    * @param idempotencyKey The request's idempotency key (optional)
    * @return RequestConfig
    */
    fun v1AuthenticationExchangeOneTimeTokenRequestConfig(oneTimeTokenIn: OneTimeTokenIn, idempotencyKey: kotlin.String?) : RequestConfig {
        val localVariableBody = oneTimeTokenIn
        val localVariableQuery: MultiValueMap = mutableMapOf()
        val localVariableHeaders: MutableMap = mutableMapOf()
        idempotencyKey?.apply { localVariableHeaders["idempotency-key"] = this.toString() }

        return RequestConfig(
            method = RequestMethod.POST,
            path = "/api/v1/auth/one-time-token",
            query = localVariableQuery,
            headers = localVariableHeaders,
            body = localVariableBody
        )
    }

    /**
    * Expire All
    * Expire all of the tokens associated with a specific Application
    * @param appId The app's ID or UID 
    * @param applicationTokenExpireIn  
    * @param idempotencyKey The request's idempotency key (optional)
    * @return void
    * @throws UnsupportedOperationException If the API returns an informational or redirection response
    * @throws ClientException If the API returns a client error response
    * @throws ServerException If the API returns a server error response
    */
    @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class)
    suspend fun v1AuthenticationExpireAll(appId: kotlin.String, applicationTokenExpireIn: ApplicationTokenExpireIn, idempotencyKey: kotlin.String?) : Unit {
        val localVariableConfig = v1AuthenticationExpireAllRequestConfig(appId = appId, applicationTokenExpireIn = applicationTokenExpireIn, idempotencyKey = idempotencyKey)

        val localVarResponse = request(
            localVariableConfig
        )

        return when (localVarResponse.responseType) {
            ResponseType.Success -> Unit
            ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
            ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
            ResponseType.ClientError -> {
                val localVarError = localVarResponse as ClientError<*>
                throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
            }
            ResponseType.ServerError -> {
                val localVarError = localVarResponse as ServerError<*>
                throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
            }
        }
    }

    /**
    * To obtain the request config of the operation v1AuthenticationExpireAll
    *
    * @param appId The app's ID or UID 
    * @param applicationTokenExpireIn  
    * @param idempotencyKey The request's idempotency key (optional)
    * @return RequestConfig
    */
    fun v1AuthenticationExpireAllRequestConfig(appId: kotlin.String, applicationTokenExpireIn: ApplicationTokenExpireIn, idempotencyKey: kotlin.String?) : RequestConfig {
        val localVariableBody = applicationTokenExpireIn
        val localVariableQuery: MultiValueMap = mutableMapOf()
        val localVariableHeaders: MutableMap = mutableMapOf()
        idempotencyKey?.apply { localVariableHeaders["idempotency-key"] = this.toString() }

        return RequestConfig(
            method = RequestMethod.POST,
            path = "/api/v1/auth/app/{app_id}/expire-all".replace("{"+"app_id"+"}", "$appId"),
            query = localVariableQuery,
            headers = localVariableHeaders,
            body = localVariableBody
        )
    }

    /**
    * Logout
    * Logout an app token.  Trying to log out other tokens will fail.
    * @param idempotencyKey The request's idempotency key (optional)
    * @return void
    * @throws UnsupportedOperationException If the API returns an informational or redirection response
    * @throws ClientException If the API returns a client error response
    * @throws ServerException If the API returns a server error response
    */
    @Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class)
    suspend fun v1AuthenticationLogout(idempotencyKey: kotlin.String?) : Unit {
        val localVariableConfig = v1AuthenticationLogoutRequestConfig(idempotencyKey = idempotencyKey)

        val localVarResponse = request(
            localVariableConfig
        )

        return when (localVarResponse.responseType) {
            ResponseType.Success -> Unit
            ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
            ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
            ResponseType.ClientError -> {
                val localVarError = localVarResponse as ClientError<*>
                throw ClientException("Client error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
            }
            ResponseType.ServerError -> {
                val localVarError = localVarResponse as ServerError<*>
                throw ServerException("Server error : ${localVarError.statusCode} ${localVarError.message.orEmpty()}", localVarError.statusCode, localVarResponse)
            }
        }
    }

    /**
    * To obtain the request config of the operation v1AuthenticationLogout
    *
    * @param idempotencyKey The request's idempotency key (optional)
    * @return RequestConfig
    */
    fun v1AuthenticationLogoutRequestConfig(idempotencyKey: kotlin.String?) : RequestConfig {
        val localVariableBody = null
        val localVariableQuery: MultiValueMap = mutableMapOf()
        val localVariableHeaders: MutableMap = mutableMapOf()
        idempotencyKey?.apply { localVariableHeaders["idempotency-key"] = this.toString() }

        return RequestConfig(
            method = RequestMethod.POST,
            path = "/api/v1/auth/logout",
            query = localVariableQuery,
            headers = localVariableHeaders,
            body = localVariableBody
        )
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy