Skip to content

Commit

Permalink
fix(#86-change-requests-type): remove body at get requests
Browse files Browse the repository at this point in the history
  • Loading branch information
y9Kap committed Jan 16, 2024
1 parent 7377014 commit a945b88
Showing 1 changed file with 6 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,43 +74,31 @@ internal class MeetingsEngine(
return ListMeetingsHistoryRequest.Response(response)
}

private fun ListActiveMeetingsRequest.toBody() = ListMeetingsPagingBody(
amount.serializable(),
pagingId?.serializable()
)

suspend fun listActiveMeetings(
request: ListActiveMeetingsRequest
): ListActiveMeetingsRequest.Response {
val url = baseUrl / "history" / "active"
val body = request.toBody()

val response = httpClient.get(url.string) {
apiVersion(request.apiVersion)
token(request.token)
setBody(body)
parameter("amount", request.amount.int)
parameter("pagingId", request.pagingId?.string)
}.bodyAsSuccess<PagingResponseSerializable<MeetingSerializable>>()
.type()
.mapItems { meeting -> meeting.type() }

return ListActiveMeetingsRequest.Response(response)
}

private fun ListPastMeetingsRequest.toBody() = ListMeetingsPagingBody(
amount.serializable(),
pagingId?.serializable()
)

suspend fun listPastMeetings(
request: ListPastMeetingsRequest
): ListPastMeetingsRequest.Response {
val url = baseUrl / "history" / "past"
val body = request.toBody()

val response = httpClient.post(url.string) {
val response = httpClient.get(url.string) {
apiVersion(request.apiVersion)
token(request.token)
setBody(body)
parameter("amount", request.amount.int)
parameter("pagingId", request.pagingId?.string)
}.bodyAsSuccess<PagingResponseSerializable<MeetingSerializable>>()
.type()
.mapItems { meeting -> meeting.type() }
Expand Down Expand Up @@ -162,7 +150,7 @@ internal class MeetingsEngine(

suspend fun createMeeting(
request: CreateMeetingRequest
): CreateMeetingRequest.Response = with(request) {
): CreateMeetingRequest.Response {
val url = baseUrl / "create"
val body = request.toBody()
val response = httpClient.post(url.string) {
Expand Down

0 comments on commit a945b88

Please sign in to comment.