diff --git a/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/requests/invitations/InvitationsEngine.kt b/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/requests/invitations/InvitationsEngine.kt index 607229cd..af037212 100644 --- a/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/requests/invitations/InvitationsEngine.kt +++ b/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/requests/invitations/InvitationsEngine.kt @@ -8,6 +8,7 @@ import app.meetacy.sdk.engine.requests.AcceptInvitationRequest import app.meetacy.sdk.engine.requests.CancelInvitationRequest import app.meetacy.sdk.engine.requests.CreateInvitationRequest import app.meetacy.sdk.engine.requests.DenyInvitationRequest +import app.meetacy.sdk.types.invitation.Invitation import app.meetacy.sdk.types.serializable.invitation.InvitationIdSerializable import app.meetacy.sdk.types.serializable.invitation.InvitationSerializable import app.meetacy.sdk.types.serializable.invitation.serializable @@ -17,6 +18,7 @@ import app.meetacy.sdk.types.serializable.meeting.serializable import app.meetacy.sdk.types.serializable.user.UserIdSerializable import app.meetacy.sdk.types.serializable.user.serializable import app.meetacy.sdk.types.url.Url +import app.meetacy.sdk.types.user.UserId import io.ktor.client.HttpClient import io.ktor.client.call.body import io.ktor.client.request.post @@ -32,12 +34,12 @@ internal class InvitationsEngine( @Serializable private data class CreateInvitationBody( val meetingId: MeetingIdSerializable, - val userId: UserIdSerializable + val usersIds: List ) private fun CreateInvitationRequest.toBody() = CreateInvitationBody( meetingId.serializable(), - userId.serializable() + usersIds.map(UserId::serializable) ) suspend fun create( @@ -49,8 +51,8 @@ internal class InvitationsEngine( apiVersion(request.apiVersion) token(request.token) setBody(body) - }.bodyAsSuccess() - return CreateInvitationRequest.Response(response.type()) + }.bodyAsSuccess>() + return CreateInvitationRequest.Response(response.map(InvitationSerializable::type)) } @Serializable diff --git a/api/src/commonMain/kotlin/app/meetacy/sdk/engine/requests/CreateInvitationRequest.kt b/api/src/commonMain/kotlin/app/meetacy/sdk/engine/requests/CreateInvitationRequest.kt index 08e2fbc5..edf191c6 100644 --- a/api/src/commonMain/kotlin/app/meetacy/sdk/engine/requests/CreateInvitationRequest.kt +++ b/api/src/commonMain/kotlin/app/meetacy/sdk/engine/requests/CreateInvitationRequest.kt @@ -7,8 +7,8 @@ import app.meetacy.sdk.types.user.UserId public data class CreateInvitationRequest( val token: Token, - val userId: UserId, + val usersIds: List, val meetingId: MeetingId ) : MeetacyRequest { - public data class Response(val invitation: Invitation) + public data class Response(val invitations: List) } diff --git a/api/src/commonMain/kotlin/app/meetacy/sdk/invitations/AuthorizedInvitationsApi.kt b/api/src/commonMain/kotlin/app/meetacy/sdk/invitations/AuthorizedInvitationsApi.kt index f396b5fe..7c16b3ee 100644 --- a/api/src/commonMain/kotlin/app/meetacy/sdk/invitations/AuthorizedInvitationsApi.kt +++ b/api/src/commonMain/kotlin/app/meetacy/sdk/invitations/AuthorizedInvitationsApi.kt @@ -2,25 +2,21 @@ package app.meetacy.sdk.invitations import app.meetacy.sdk.AuthorizedMeetacyApi import app.meetacy.sdk.types.auth.Token -import app.meetacy.sdk.types.datetime.DateTime import app.meetacy.sdk.types.invitation.InvitationId import app.meetacy.sdk.types.meeting.MeetingId -import app.meetacy.sdk.types.user.User import app.meetacy.sdk.types.user.UserId -import app.meetacy.sdk.users.UserRepository -import kotlin.jvm.JvmName public class AuthorizedInvitationsApi(private val api: AuthorizedMeetacyApi) { public val token: Token get() = api.token public val base: InvitationsApi = api.base.invitations public suspend fun create( - userId: UserId, + usersIds: List, meetingId: MeetingId - ): AuthorizedInvitationRepository { - val invitation = base.create(token, userId, meetingId).data + ): List { + val invitations = base.create(token, usersIds, meetingId) - return AuthorizedInvitationRepository(invitation, api) + return invitations.map { AuthorizedInvitationRepository(it.data, api) } } public suspend fun accept(invitationId: InvitationId) { diff --git a/api/src/commonMain/kotlin/app/meetacy/sdk/invitations/InvitationsApi.kt b/api/src/commonMain/kotlin/app/meetacy/sdk/invitations/InvitationsApi.kt index 687a2dd0..4c14bf98 100644 --- a/api/src/commonMain/kotlin/app/meetacy/sdk/invitations/InvitationsApi.kt +++ b/api/src/commonMain/kotlin/app/meetacy/sdk/invitations/InvitationsApi.kt @@ -1,31 +1,30 @@ package app.meetacy.sdk.invitations import app.meetacy.sdk.MeetacyApi -import app.meetacy.sdk.engine.requests.* +import app.meetacy.sdk.engine.requests.AcceptInvitationRequest +import app.meetacy.sdk.engine.requests.CancelInvitationRequest +import app.meetacy.sdk.engine.requests.CreateInvitationRequest +import app.meetacy.sdk.engine.requests.DenyInvitationRequest import app.meetacy.sdk.types.auth.Token -import app.meetacy.sdk.types.datetime.DateTime import app.meetacy.sdk.types.invitation.InvitationId import app.meetacy.sdk.types.meeting.MeetingId -import app.meetacy.sdk.types.user.User import app.meetacy.sdk.types.user.UserId -import app.meetacy.sdk.users.UserRepository -import kotlin.jvm.JvmName public class InvitationsApi(private val api: MeetacyApi) { public suspend fun create( token: Token, - userId: UserId, + usersIds: List, meetingId: MeetingId - ): InvitationsRepository { - val invitation = api.engine.execute( + ): List { + val invitations = api.engine.execute( request = CreateInvitationRequest( token, - userId, + usersIds, meetingId ) - ).invitation + ).invitations - return InvitationsRepository(invitation, api) + return invitations.map { InvitationsRepository(it, api) } } public suspend fun accept( diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 06a01107..2d532636 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,7 +2,7 @@ kotlin = "1.9.0" ktor = "2.3.6" -meetacySdk = "0.0.70" +meetacySdk = "0.0.71" # kotlinx kotlinxCoroutines = "1.6.4"