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

commonMain.com.xebia.functional.openai.generated.api.Invites.kt Maven / Gradle / Ivy

There is a newer version: 0.0.5-alpha.119
Show newest version
/**
 *
 * Please note:
 * This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * Do not edit this file manually.
 *
 */

@file:Suppress(
    "ArrayInDataClass",
    "EnumEntryName",
    "RemoveRedundantQualifierName",
    "UnusedImport"
)

package com.xebia.functional.openai.generated.api

import com.xebia.functional.openai.generated.model.Invite
import com.xebia.functional.openai.generated.model.InviteDeleteResponse
import com.xebia.functional.openai.generated.model.InviteListResponse
import com.xebia.functional.openai.generated.model.InviteRequest
import com.xebia.functional.openai.Config
import com.xebia.functional.openai.UploadFile
import com.xebia.functional.openai.appendGen
import com.xebia.functional.openai.generated.api.Invites.*
import com.xebia.functional.openai.streamEvents
import com.xebia.functional.openai.errors.serializeOrThrowWithResponseInfo
import io.ktor.client.HttpClient
import io.ktor.client.call.body
import io.ktor.client.plugins.timeout
import io.ktor.client.request.HttpRequestBuilder
import io.ktor.client.request.accept
import io.ktor.client.request.header
import io.ktor.client.request.forms.formData
import io.ktor.client.request.parameter
import io.ktor.client.request.prepareRequest
import io.ktor.client.request.request
import io.ktor.client.request.setBody
import io.ktor.client.statement.HttpResponse
import io.ktor.client.statement.HttpStatement
import io.ktor.http.ContentType
import io.ktor.http.HttpHeaders
import io.ktor.http.HttpMethod
import io.ktor.http.contentType
import io.ktor.http.path
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import kotlinx.serialization.*
import kotlinx.serialization.descriptors.*
import kotlinx.serialization.encoding.*
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.jsonObject
import kotlinx.serialization.json.JsonPrimitive
import kotlin.time.Duration.Companion.seconds
import kotlin.time.DurationUnit

/**
  *
  */
interface Invites {

    /**
    * Delete an invite. If the invite has already been accepted, it cannot be deleted.
    * 
     * @param inviteId The ID of the invite to delete.
     * @param configure optional configuration for the request, allows overriding the default configuration.
    * @return InviteDeleteResponse
    */
    suspend fun deleteInvite(inviteId: kotlin.String, configure: HttpRequestBuilder.() -> Unit = {}): InviteDeleteResponse


    /**
    * Create an invite for a user to the organization. The invite must be accepted by the user before they have access to the organization.
    * 
     * @param inviteRequest The invite request payload.
     * @param configure optional configuration for the request, allows overriding the default configuration.
    * @return Invite
    */
    suspend fun inviteUser(inviteRequest: InviteRequest, configure: HttpRequestBuilder.() -> Unit = {}): Invite


    /**
    * Returns a list of invites in the organization.
    * 
     * @param limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 20.  (optional, default to 20)
     * @param after A cursor for use in pagination. `after` is an object ID that defines your place in the list. For instance, if you make a list request and receive 100 objects, ending with obj_foo, your subsequent call can include after=obj_foo in order to fetch the next page of the list.  (optional)
     * @param configure optional configuration for the request, allows overriding the default configuration.
    * @return InviteListResponse
    */
    suspend fun listInvites(limit: kotlin.Int? = 20, after: kotlin.String? = null, configure: HttpRequestBuilder.() -> Unit = {}): InviteListResponse


    /**
    * Retrieves an invite.
    * 
     * @param inviteId The ID of the invite to retrieve.
     * @param configure optional configuration for the request, allows overriding the default configuration.
    * @return Invite
    */
    suspend fun retrieveInvite(inviteId: kotlin.String, configure: HttpRequestBuilder.() -> Unit = {}): Invite

}

fun Invites(client: HttpClient, config: Config): com.xebia.functional.openai.generated.api.Invites = object : com.xebia.functional.openai.generated.api.Invites {
    override suspend fun deleteInvite(inviteId: kotlin.String, configure: HttpRequestBuilder.() -> Unit): InviteDeleteResponse =
      client.request {
        configure()
        method = HttpMethod.Delete
        contentType(ContentType.Application.Json)
        url { path("organization/invites/{invite_id}".replace("{" + "invite_id" + "}", "$inviteId")) }
        setBody(
                io.ktor.client.utils.EmptyContent
        )
      }.serializeOrThrowWithResponseInfo()

    override suspend fun inviteUser(inviteRequest: InviteRequest, configure: HttpRequestBuilder.() -> Unit): Invite =
      client.request {
        configure()
        method = HttpMethod.Post
        contentType(ContentType.Application.Json)
        url { path("organization/invites") }
        setBody(inviteRequest
)
      }.serializeOrThrowWithResponseInfo()

    override suspend fun listInvites(limit: kotlin.Int?,after: kotlin.String?, configure: HttpRequestBuilder.() -> Unit): InviteListResponse =
      client.request {
        configure()
        method = HttpMethod.Get
        contentType(ContentType.Application.Json)
            parameter("limit", limit)
            parameter("after", after)
        url { path("organization/invites") }
        setBody(
                io.ktor.client.utils.EmptyContent
        )
      }.serializeOrThrowWithResponseInfo()

    override suspend fun retrieveInvite(inviteId: kotlin.String, configure: HttpRequestBuilder.() -> Unit): Invite =
      client.request {
        configure()
        method = HttpMethod.Get
        contentType(ContentType.Application.Json)
        url { path("organization/invites/{invite_id}".replace("{" + "invite_id" + "}", "$inviteId")) }
        setBody(
                io.ktor.client.utils.EmptyContent
        )
      }.serializeOrThrowWithResponseInfo()

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy