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

commonMain.net.folivo.trixnity.clientserverapi.model.rooms.CreateRoom.kt Maven / Gradle / Ivy

There is a newer version: 4.7.1
Show newest version
package net.folivo.trixnity.clientserverapi.model.rooms

import io.ktor.resources.*
import kotlinx.serialization.Contextual
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import net.folivo.trixnity.core.HttpMethod
import net.folivo.trixnity.core.HttpMethodType.POST
import net.folivo.trixnity.core.MatrixEndpoint
import net.folivo.trixnity.core.model.RoomId
import net.folivo.trixnity.core.model.UserId
import net.folivo.trixnity.core.model.events.InitialStateEvent
import net.folivo.trixnity.core.model.events.m.room.CreateEventContent
import net.folivo.trixnity.core.model.events.m.room.PowerLevelsEventContent

/**
 * @see matrix spec
 */
@Serializable
@Resource("/_matrix/client/v3/createRoom")
@HttpMethod(POST)
data class CreateRoom(
    @SerialName("user_id") val asUserId: UserId? = null
) : MatrixEndpoint {

    @Serializable
    data class Request(
        @SerialName("visibility") val visibility: DirectoryVisibility,
        @SerialName("room_alias_name") val roomAliasLocalPart: String?,
        @SerialName("name") val name: String?,
        @SerialName("topic") val topic: String?,
        @SerialName("invite") val invite: Set?,
        @SerialName("invite_3pid") val inviteThirdPid: Set?,
        @SerialName("room_version") val roomVersion: String?,
        @SerialName("creation_content") val creationContent: CreateEventContent?,
        @SerialName("initial_state") val initialState: List<@Contextual InitialStateEvent<*>>?,
        @SerialName("preset") val preset: Preset?,
        @SerialName("is_direct") val isDirect: Boolean?,
        @SerialName("power_level_content_override") val powerLevelContentOverride: PowerLevelsEventContent?,
    ) {
        @Serializable
        data class InviteThirdPid(
            @SerialName("id_server") val identityServer: String,
            @SerialName("id_access_token") val identityServerAccessToken: String,
            @SerialName("medium") val medium: String,
            @SerialName("address") val address: String
        )

        @Serializable
        enum class Preset {
            @SerialName("private_chat")
            PRIVATE,

            @SerialName("public_chat")
            PUBLIC,

            @SerialName("trusted_private_chat")
            TRUSTED_PRIVATE
        }
    }

    @Serializable
    data class Response(
        @SerialName("room_id") val roomId: RoomId
    )
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy