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

com.svix.kotlin.internal.apis.MessageApi.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.HTTPValidationError
import com.svix.kotlin.models.HttpErrorOut
import com.svix.kotlin.models.ListResponseMessageOut
import com.svix.kotlin.models.MessageAttemptOut
import com.svix.kotlin.models.MessageEventsOut
import com.svix.kotlin.models.MessageIn
import com.svix.kotlin.models.MessageOut
import com.svix.kotlin.models.MessageRawPayloadOut
import com.svix.kotlin.models.MessageSubscriberAuthTokenOut

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 MessageApi(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")
        }
    }

    /**
    * Create Message Attempt For Endpoint
    * Creates and sends a message to the specified endpoint. The message attempt and response from the endpoint is returned. FIXME: use MessageIn for expediency, even though the `application` parameter is unused. Since this endpoint isn't publicly documented anyway, it should be fine
    * @param appId The app's ID or UID 
    * @param endpointId The ep's ID or UID 
    * @param messageIn  
    * @param idempotencyKey The request's idempotency key (optional)
    * @return MessageAttemptOut
    * @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 createMessageAttemptForEndpoint(appId: kotlin.String, endpointId: kotlin.String, messageIn: MessageIn, idempotencyKey: kotlin.String?) : MessageAttemptOut {
        val localVariableConfig = createMessageAttemptForEndpointRequestConfig(appId = appId, endpointId = endpointId, messageIn = messageIn, idempotencyKey = idempotencyKey)

        val localVarResponse = request(
            localVariableConfig
        )

        return when (localVarResponse.responseType) {
            ResponseType.Success -> (localVarResponse as Success<*>).data as MessageAttemptOut
            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 createMessageAttemptForEndpoint
    *
    * @param appId The app's ID or UID 
    * @param endpointId The ep's ID or UID 
    * @param messageIn  
    * @param idempotencyKey The request's idempotency key (optional)
    * @return RequestConfig
    */
    fun createMessageAttemptForEndpointRequestConfig(appId: kotlin.String, endpointId: kotlin.String, messageIn: MessageIn, idempotencyKey: kotlin.String?) : RequestConfig {
        val localVariableBody = messageIn
        val localVariableQuery: MultiValueMap = mutableMapOf()
        val localVariableHeaders: MutableMap = mutableMapOf()
        idempotencyKey?.apply { localVariableHeaders["idempotency-key"] = this.toString() }

        return RequestConfig(
            method = RequestMethod.POST,
            path = "/api/v1/app/{app_id}/endpoint/{endpoint_id}/msg/test-attempt".replace("{"+"app_id"+"}", "$appId").replace("{"+"endpoint_id"+"}", "$endpointId"),
            query = localVariableQuery,
            headers = localVariableHeaders,
            body = localVariableBody
        )
    }

    /**
    * Create Message
    * Creates a new message and dispatches it to all of the application's endpoints.  The `eventId` is an optional custom unique ID. It's verified to be unique only up to a day, after that no verification will be made. If a message with the same `eventId` already exists for the application, a 409 conflict error will be returned.  The `eventType` indicates the type and schema of the event. All messages of a certain `eventType` are expected to have the same schema. Endpoints can choose to only listen to specific event types. Messages can also have `channels`, which similar to event types let endpoints filter by them. Unlike event types, messages can have multiple channels, and channels don't imply a specific message content or schema.  The `payload` property is the webhook's body (the actual webhook message). Svix supports payload sizes of up to ~350kb, though it's generally a good idea to keep webhook payloads small, probably no larger than 40kb.
    * @param appId The app's ID or UID 
    * @param messageIn  
    * @param withContent When `true` message payloads are included in the response (optional, default to true)
    * @param idempotencyKey The request's idempotency key (optional)
    * @return MessageOut
    * @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 v1MessageCreate(appId: kotlin.String, messageIn: MessageIn, withContent: kotlin.Boolean?, idempotencyKey: kotlin.String?) : MessageOut {
        val localVariableConfig = v1MessageCreateRequestConfig(appId = appId, messageIn = messageIn, withContent = withContent, idempotencyKey = idempotencyKey)

        val localVarResponse = request(
            localVariableConfig
        )

        return when (localVarResponse.responseType) {
            ResponseType.Success -> (localVarResponse as Success<*>).data as MessageOut
            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 v1MessageCreate
    *
    * @param appId The app's ID or UID 
    * @param messageIn  
    * @param withContent When `true` message payloads are included in the response (optional, default to true)
    * @param idempotencyKey The request's idempotency key (optional)
    * @return RequestConfig
    */
    fun v1MessageCreateRequestConfig(appId: kotlin.String, messageIn: MessageIn, withContent: kotlin.Boolean?, idempotencyKey: kotlin.String?) : RequestConfig {
        val localVariableBody = messageIn
        val localVariableQuery: MultiValueMap = mutableMapOf>()
            .apply {
                if (withContent != null) {
                    put("with_content", listOf(withContent.toString()))
                }
            }
        val localVariableHeaders: MutableMap = mutableMapOf()
        idempotencyKey?.apply { localVariableHeaders["idempotency-key"] = this.toString() }

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

    /**
    * Message Events
    * Reads the stream of created messages for an application
    * @param appId The app's ID or UID 
    * @param limit Limit the number of returned items (optional)
    * @param iterator The iterator returned from a prior invocation (optional)
    * @param eventTypes Filter response based on the event type (optional)
    * @param channels Filter response based on the event type (optional)
    * @param after  (optional)
    * @return MessageEventsOut
    * @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 v1MessageEvents(appId: kotlin.String, limit: kotlin.Int?, iterator: kotlin.String?, eventTypes: kotlin.collections.Set?, channels: kotlin.collections.Set?, after: java.time.OffsetDateTime?) : MessageEventsOut {
        val localVariableConfig = v1MessageEventsRequestConfig(appId = appId, limit = limit, iterator = iterator, eventTypes = eventTypes, channels = channels, after = after)

        val localVarResponse = request(
            localVariableConfig
        )

        return when (localVarResponse.responseType) {
            ResponseType.Success -> (localVarResponse as Success<*>).data as MessageEventsOut
            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 v1MessageEvents
    *
    * @param appId The app's ID or UID 
    * @param limit Limit the number of returned items (optional)
    * @param iterator The iterator returned from a prior invocation (optional)
    * @param eventTypes Filter response based on the event type (optional)
    * @param channels Filter response based on the event type (optional)
    * @param after  (optional)
    * @return RequestConfig
    */
    fun v1MessageEventsRequestConfig(appId: kotlin.String, limit: kotlin.Int?, iterator: kotlin.String?, eventTypes: kotlin.collections.Set?, channels: kotlin.collections.Set?, after: java.time.OffsetDateTime?) : RequestConfig {
        val localVariableBody = null
        val localVariableQuery: MultiValueMap = mutableMapOf>()
            .apply {
                if (limit != null) {
                    put("limit", listOf(limit.toString()))
                }
                if (iterator != null) {
                    put("iterator", listOf(iterator.toString()))
                }
                if (eventTypes != null) {
                    put("event_types", toMultiValue(eventTypes.toList(), "multi"))
                }
                if (channels != null) {
                    put("channels", toMultiValue(channels.toList(), "multi"))
                }
                if (after != null) {
                    put("after", listOf(parseDateToQueryString(after)))
                }
            }
        val localVariableHeaders: MutableMap = mutableMapOf()

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

    /**
    * Message Events Subscription
    * Reads the stream of created messages for an application, but using server-managed iterator tracking.
    * @param appId The app's ID or UID 
    * @param subscriptionId The esub's ID or UID 
    * @param limit Limit the number of returned items (optional)
    * @param iterator The iterator returned from a prior invocation (optional)
    * @param eventTypes Filter response based on the event type (optional)
    * @param channels Filter response based on the event type (optional)
    * @param after  (optional)
    * @return MessageEventsOut
    * @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 v1MessageEventsSubscription(appId: kotlin.String, subscriptionId: kotlin.String, limit: kotlin.Int?, iterator: kotlin.String?, eventTypes: kotlin.collections.Set?, channels: kotlin.collections.Set?, after: java.time.OffsetDateTime?) : MessageEventsOut {
        val localVariableConfig = v1MessageEventsSubscriptionRequestConfig(appId = appId, subscriptionId = subscriptionId, limit = limit, iterator = iterator, eventTypes = eventTypes, channels = channels, after = after)

        val localVarResponse = request(
            localVariableConfig
        )

        return when (localVarResponse.responseType) {
            ResponseType.Success -> (localVarResponse as Success<*>).data as MessageEventsOut
            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 v1MessageEventsSubscription
    *
    * @param appId The app's ID or UID 
    * @param subscriptionId The esub's ID or UID 
    * @param limit Limit the number of returned items (optional)
    * @param iterator The iterator returned from a prior invocation (optional)
    * @param eventTypes Filter response based on the event type (optional)
    * @param channels Filter response based on the event type (optional)
    * @param after  (optional)
    * @return RequestConfig
    */
    fun v1MessageEventsSubscriptionRequestConfig(appId: kotlin.String, subscriptionId: kotlin.String, limit: kotlin.Int?, iterator: kotlin.String?, eventTypes: kotlin.collections.Set?, channels: kotlin.collections.Set?, after: java.time.OffsetDateTime?) : RequestConfig {
        val localVariableBody = null
        val localVariableQuery: MultiValueMap = mutableMapOf>()
            .apply {
                if (limit != null) {
                    put("limit", listOf(limit.toString()))
                }
                if (iterator != null) {
                    put("iterator", listOf(iterator.toString()))
                }
                if (eventTypes != null) {
                    put("event_types", toMultiValue(eventTypes.toList(), "multi"))
                }
                if (channels != null) {
                    put("channels", toMultiValue(channels.toList(), "multi"))
                }
                if (after != null) {
                    put("after", listOf(parseDateToQueryString(after)))
                }
            }
        val localVariableHeaders: MutableMap = mutableMapOf()

        return RequestConfig(
            method = RequestMethod.GET,
            path = "/api/v1/app/{app_id}/events/subscription/{subscription_id}".replace("{"+"app_id"+"}", "$appId").replace("{"+"subscription_id"+"}", "$subscriptionId"),
            query = localVariableQuery,
            headers = localVariableHeaders,
            body = localVariableBody
        )
    }

    /**
    * Message Events Create Token
    * Creates an auth token that can be used with the `v1.message.events-subscription` endpoint
    * @param appId The app's ID or UID 
    * @param subscriptionId The esub's ID or UID 
    * @param idempotencyKey The request's idempotency key (optional)
    * @return MessageSubscriberAuthTokenOut
    * @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 v1MessageEventsSubscriptionCreateToken(appId: kotlin.String, subscriptionId: kotlin.String, idempotencyKey: kotlin.String?) : MessageSubscriberAuthTokenOut {
        val localVariableConfig = v1MessageEventsSubscriptionCreateTokenRequestConfig(appId = appId, subscriptionId = subscriptionId, idempotencyKey = idempotencyKey)

        val localVarResponse = request(
            localVariableConfig
        )

        return when (localVarResponse.responseType) {
            ResponseType.Success -> (localVarResponse as Success<*>).data as MessageSubscriberAuthTokenOut
            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 v1MessageEventsSubscriptionCreateToken
    *
    * @param appId The app's ID or UID 
    * @param subscriptionId The esub's ID or UID 
    * @param idempotencyKey The request's idempotency key (optional)
    * @return RequestConfig
    */
    fun v1MessageEventsSubscriptionCreateTokenRequestConfig(appId: kotlin.String, subscriptionId: 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/app/{app_id}/events/subscription/{subscription_id}/create-token".replace("{"+"app_id"+"}", "$appId").replace("{"+"subscription_id"+"}", "$subscriptionId"),
            query = localVariableQuery,
            headers = localVariableHeaders,
            body = localVariableBody
        )
    }

    /**
    * Delete message payload
    * Delete the given message's payload. Useful in cases when a message was accidentally sent with sensitive content.  The message can't be replayed or resent once its payload has been deleted or expired.
    * @param appId The app's ID or UID 
    * @param msgId The msg's ID or UID 
    * @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 v1MessageExpungeContent(appId: kotlin.String, msgId: kotlin.String) : Unit {
        val localVariableConfig = v1MessageExpungeContentRequestConfig(appId = appId, msgId = msgId)

        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 v1MessageExpungeContent
    *
    * @param appId The app's ID or UID 
    * @param msgId The msg's ID or UID 
    * @return RequestConfig
    */
    fun v1MessageExpungeContentRequestConfig(appId: kotlin.String, msgId: kotlin.String) : RequestConfig {
        val localVariableBody = null
        val localVariableQuery: MultiValueMap = mutableMapOf()
        val localVariableHeaders: MutableMap = mutableMapOf()

        return RequestConfig(
            method = RequestMethod.DELETE,
            path = "/api/v1/app/{app_id}/msg/{msg_id}/content".replace("{"+"app_id"+"}", "$appId").replace("{"+"msg_id"+"}", "$msgId"),
            query = localVariableQuery,
            headers = localVariableHeaders,
            body = localVariableBody
        )
    }

    /**
    * Get Message
    * Get a message by its ID or eventID.
    * @param appId The app's ID or UID 
    * @param msgId The msg's ID or UID 
    * @param withContent When `true` message payloads are included in the response (optional, default to true)
    * @return MessageOut
    * @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 v1MessageGet(appId: kotlin.String, msgId: kotlin.String, withContent: kotlin.Boolean?) : MessageOut {
        val localVariableConfig = v1MessageGetRequestConfig(appId = appId, msgId = msgId, withContent = withContent)

        val localVarResponse = request(
            localVariableConfig
        )

        return when (localVarResponse.responseType) {
            ResponseType.Success -> (localVarResponse as Success<*>).data as MessageOut
            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 v1MessageGet
    *
    * @param appId The app's ID or UID 
    * @param msgId The msg's ID or UID 
    * @param withContent When `true` message payloads are included in the response (optional, default to true)
    * @return RequestConfig
    */
    fun v1MessageGetRequestConfig(appId: kotlin.String, msgId: kotlin.String, withContent: kotlin.Boolean?) : RequestConfig {
        val localVariableBody = null
        val localVariableQuery: MultiValueMap = mutableMapOf>()
            .apply {
                if (withContent != null) {
                    put("with_content", listOf(withContent.toString()))
                }
            }
        val localVariableHeaders: MutableMap = mutableMapOf()

        return RequestConfig(
            method = RequestMethod.GET,
            path = "/api/v1/app/{app_id}/msg/{msg_id}".replace("{"+"app_id"+"}", "$appId").replace("{"+"msg_id"+"}", "$msgId"),
            query = localVariableQuery,
            headers = localVariableHeaders,
            body = localVariableBody
        )
    }

    /**
    * Get Raw Message Payload
    * Get a message raw payload by its ID or eventID.
    * @param appId The app's ID or UID 
    * @param msgId The msg's ID or UID 
    * @return MessageRawPayloadOut
    * @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 v1MessageGetRawPayload(appId: kotlin.String, msgId: kotlin.String) : MessageRawPayloadOut {
        val localVariableConfig = v1MessageGetRawPayloadRequestConfig(appId = appId, msgId = msgId)

        val localVarResponse = request(
            localVariableConfig
        )

        return when (localVarResponse.responseType) {
            ResponseType.Success -> (localVarResponse as Success<*>).data as MessageRawPayloadOut
            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 v1MessageGetRawPayload
    *
    * @param appId The app's ID or UID 
    * @param msgId The msg's ID or UID 
    * @return RequestConfig
    */
    fun v1MessageGetRawPayloadRequestConfig(appId: kotlin.String, msgId: kotlin.String) : RequestConfig {
        val localVariableBody = null
        val localVariableQuery: MultiValueMap = mutableMapOf()
        val localVariableHeaders: MutableMap = mutableMapOf()

        return RequestConfig(
            method = RequestMethod.GET,
            path = "/api/v1/app/{app_id}/msg/{msg_id}/raw".replace("{"+"app_id"+"}", "$appId").replace("{"+"msg_id"+"}", "$msgId"),
            query = localVariableQuery,
            headers = localVariableHeaders,
            body = localVariableBody
        )
    }

    /**
    * List Messages
    * List all of the application's messages.  The `before` and `after` parameters let you filter all items created before or after a certain date. These can be used alongside an iterator to paginate over results within a certain window.  Note that by default this endpoint is limited to retrieving 90 days' worth of data relative to now or, if an iterator is provided, 90 days before/after the time indicated by the iterator ID. If you require data beyond those time ranges, you will need to explicitly set the `before` or `after` parameter as appropriate. 
    * @param appId The app's ID or UID 
    * @param limit Limit the number of returned items (optional)
    * @param iterator The iterator returned from a prior invocation (optional)
    * @param channel Filter response based on the channel (optional)
    * @param before Only include items created before a certain date (optional)
    * @param after Only include items created after a certain date (optional)
    * @param withContent When `true` message payloads are included in the response (optional, default to true)
    * @param tag Filter messages matching the provided tag (optional)
    * @param eventTypes Filter response based on the event type (optional)
    * @return ListResponseMessageOut
    * @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 v1MessageList(appId: kotlin.String, limit: kotlin.Int?, iterator: kotlin.String?, channel: kotlin.String?, before: java.time.OffsetDateTime?, after: java.time.OffsetDateTime?, withContent: kotlin.Boolean?, tag: kotlin.String?, eventTypes: kotlin.collections.Set?) : ListResponseMessageOut {
        val localVariableConfig = v1MessageListRequestConfig(appId = appId, limit = limit, iterator = iterator, channel = channel, before = before, after = after, withContent = withContent, tag = tag, eventTypes = eventTypes)

        val localVarResponse = request(
            localVariableConfig
        )

        return when (localVarResponse.responseType) {
            ResponseType.Success -> (localVarResponse as Success<*>).data as ListResponseMessageOut
            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 v1MessageList
    *
    * @param appId The app's ID or UID 
    * @param limit Limit the number of returned items (optional)
    * @param iterator The iterator returned from a prior invocation (optional)
    * @param channel Filter response based on the channel (optional)
    * @param before Only include items created before a certain date (optional)
    * @param after Only include items created after a certain date (optional)
    * @param withContent When `true` message payloads are included in the response (optional, default to true)
    * @param tag Filter messages matching the provided tag (optional)
    * @param eventTypes Filter response based on the event type (optional)
    * @return RequestConfig
    */
    fun v1MessageListRequestConfig(appId: kotlin.String, limit: kotlin.Int?, iterator: kotlin.String?, channel: kotlin.String?, before: java.time.OffsetDateTime?, after: java.time.OffsetDateTime?, withContent: kotlin.Boolean?, tag: kotlin.String?, eventTypes: kotlin.collections.Set?) : RequestConfig {
        val localVariableBody = null
        val localVariableQuery: MultiValueMap = mutableMapOf>()
            .apply {
                if (limit != null) {
                    put("limit", listOf(limit.toString()))
                }
                if (iterator != null) {
                    put("iterator", listOf(iterator.toString()))
                }
                if (channel != null) {
                    put("channel", listOf(channel.toString()))
                }
                if (before != null) {
                    put("before", listOf(parseDateToQueryString(before)))
                }
                if (after != null) {
                    put("after", listOf(parseDateToQueryString(after)))
                }
                if (withContent != null) {
                    put("with_content", listOf(withContent.toString()))
                }
                if (tag != null) {
                    put("tag", listOf(tag.toString()))
                }
                if (eventTypes != null) {
                    put("event_types", toMultiValue(eventTypes.toList(), "multi"))
                }
            }
        val localVariableHeaders: MutableMap = mutableMapOf()

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

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy