Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement meeting batch inviting #102

Merged
merged 1 commit into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -32,12 +34,12 @@ internal class InvitationsEngine(
@Serializable
private data class CreateInvitationBody(
val meetingId: MeetingIdSerializable,
val userId: UserIdSerializable
val usersIds: List<UserIdSerializable>
)

private fun CreateInvitationRequest.toBody() = CreateInvitationBody(
meetingId.serializable(),
userId.serializable()
usersIds.map(UserId::serializable)
)

suspend fun create(
Expand All @@ -49,8 +51,8 @@ internal class InvitationsEngine(
apiVersion(request.apiVersion)
token(request.token)
setBody(body)
}.bodyAsSuccess<InvitationSerializable>()
return CreateInvitationRequest.Response(response.type())
}.bodyAsSuccess<List<InvitationSerializable>>()
return CreateInvitationRequest.Response(response.map(InvitationSerializable::type))
}

@Serializable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import app.meetacy.sdk.types.user.UserId

public data class CreateInvitationRequest(
val token: Token,
val userId: UserId,
val usersIds: List<UserId>,
val meetingId: MeetingId
) : MeetacyRequest<CreateInvitationRequest.Response> {
public data class Response(val invitation: Invitation)
public data class Response(val invitations: List<Invitation>)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<UserId>,
meetingId: MeetingId
): AuthorizedInvitationRepository {
val invitation = base.create(token, userId, meetingId).data
): List<AuthorizedInvitationRepository> {
val invitations = base.create(token, usersIds, meetingId)

return AuthorizedInvitationRepository(invitation, api)
return invitations.map { AuthorizedInvitationRepository(it.data, api) }
}

public suspend fun accept(invitationId: InvitationId) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
package app.meetacy.sdk.invitations

import app.meetacy.sdk.MeetacyApi
import app.meetacy.sdk.engine.requests.*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

е*ись конем, wildcard!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Постоянно их использую

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

жесть, однако. хотя может это моя последняя привычка питониста - следить чтоб не было импорта через звездочку

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

так в питоне понятно почему не надо

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<UserId>,
meetingId: MeetingId
): InvitationsRepository {
val invitation = api.engine.execute(
): List<InvitationsRepository> {
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(
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading