Skip to content

Commit

Permalink
feat(#96-add-support-quit-meeting-request): support quit meeting requ…
Browse files Browse the repository at this point in the history
…est was added
  • Loading branch information
y9Kap committed Mar 9, 2024
1 parent d0a0cea commit 0acb707
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ public class KtorMeetacyEngine(
is ListMeetingsMapRequest -> meetings.listMeetingsMap(request) as T
is CreateMeetingRequest -> meetings.createMeeting(request) as T
is ParticipateMeetingRequest -> meetings.participateMeeting(request) as T
is QuitMeetingRequest -> meetings.quitMeeting(request) as T
is GetMeetingRequest -> meetings.getMeeting(request) as T
is EditMeetingRequest -> meetings.editMeeting(request) as T
is ListMeetingParticipantsRequest -> meetings.listMeetingParticipants(request) as T
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,7 @@ import app.meetacy.sdk.engine.ktor.apiVersion
import app.meetacy.sdk.engine.ktor.response.StatusTrueResponse
import app.meetacy.sdk.engine.ktor.response.bodyAsSuccess
import app.meetacy.sdk.engine.ktor.token
import app.meetacy.sdk.engine.requests.CreateMeetingRequest
import app.meetacy.sdk.engine.requests.EditMeetingRequest
import app.meetacy.sdk.engine.requests.GetMeetingRequest
import app.meetacy.sdk.engine.requests.ListActiveMeetingsRequest
import app.meetacy.sdk.engine.requests.ListMeetingParticipantsRequest
import app.meetacy.sdk.engine.requests.ListMeetingsHistoryRequest
import app.meetacy.sdk.engine.requests.ListMeetingsMapRequest
import app.meetacy.sdk.engine.requests.ListPastMeetingsRequest
import app.meetacy.sdk.engine.requests.ParticipateMeetingRequest
import app.meetacy.sdk.engine.requests.*
import app.meetacy.sdk.types.optional.map
import app.meetacy.sdk.types.serializable.amount.AmountSerializable
import app.meetacy.sdk.types.serializable.amount.serializable
Expand All @@ -35,8 +27,8 @@ import app.meetacy.sdk.types.serializable.paging.type
import app.meetacy.sdk.types.serializable.user.UserSerializable
import app.meetacy.sdk.types.serializable.user.type
import app.meetacy.sdk.types.url.Url
import io.ktor.client.HttpClient
import io.ktor.client.call.body
import io.ktor.client.*
import io.ktor.client.call.*
import io.ktor.client.request.*
import kotlinx.serialization.Serializable

Expand Down Expand Up @@ -239,6 +231,21 @@ internal class MeetingsEngine(
}.body<StatusTrueResponse>()
}

@Serializable
private data class QuitMeetingBody(val meetingId: MeetingIdSerializable)

private fun QuitMeetingRequest.toBody() = QuitMeetingBody(meetingId.serializable())

suspend fun quitMeeting(request: QuitMeetingRequest) {
val url = baseUrl / "quit"
val body = request.toBody()
httpClient.post(url.string) {
apiVersion(request.apiVersion)
token(request.token)
setBody(body)
}.body<StatusTrueResponse>()
}

@Serializable
private data class GetMeetingBody(val meetingId: MeetingIdSerializable)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package app.meetacy.sdk.engine.requests

import app.meetacy.sdk.types.auth.Token
import app.meetacy.sdk.types.meeting.MeetingId

public data class QuitMeetingRequest(
val token: Token,
val meetingId: MeetingId
) : SimpleMeetacyRequest
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,8 @@ public class AuthorizedMeetingRepository(
public suspend fun participate() {
api.meetings.participate(data.id)
}

public suspend fun quit() {
api.meetings.quit(data.id)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ public class AuthorizedMeetingsApi(
base.participate(api.token, meetingId)
}

public suspend fun quit(meetingId: MeetingId) {
base.quit(api.token, meetingId)
}

public suspend fun get(meetingId: MeetingId): AuthorizedMeetingRepository {
val repository = base.get(api.token, meetingId)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ public class MeetingRepository(
api.meetings.participate(token, id)
}

public suspend fun quit(token: Token) {
api.meetings.quit(token, id)
}

public suspend fun updated(
token: Token
): MeetingRepository {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package app.meetacy.sdk.meetings

import app.meetacy.sdk.MeetacyApi
import app.meetacy.sdk.engine.requests.CreateMeetingRequest
import app.meetacy.sdk.engine.requests.EditMeetingRequest
import app.meetacy.sdk.engine.requests.GetMeetingRequest
import app.meetacy.sdk.engine.requests.ParticipateMeetingRequest
import app.meetacy.sdk.engine.requests.*
import app.meetacy.sdk.meetings.history.MeetingsHistoryApi
import app.meetacy.sdk.meetings.map.MeetingsMapApi
import app.meetacy.sdk.meetings.participants.MeetingParticipantsApi
Expand Down Expand Up @@ -103,6 +100,10 @@ public class MeetingsApi(private val api: MeetacyApi) {
api.engine.execute(ParticipateMeetingRequest(token, meetingId))
}

public suspend fun quit(token: Token, meetingId: MeetingId) {
api.engine.execute(QuitMeetingRequest(token, meetingId))
}

public suspend fun get(token: Token, meetingId: MeetingId): MeetingRepository {
val meeting = api.engine.execute(GetMeetingRequest(token, meetingId)).meeting

Expand Down

0 comments on commit 0acb707

Please sign in to comment.