From b8067e4874a836205038d470e2732c85034eb211 Mon Sep 17 00:00:00 2001 From: y9Kap Date: Fri, 8 Mar 2024 00:32:36 +0300 Subject: [PATCH] fix(#93-add-getSubscriptions-and-getSubscribers-methods): change user type to UserDetails --- .../ktor/requests/friends/FriendsEngine.kt | 15 +++++-------- .../engine/requests/GetSubscribersRequest.kt | 4 ++-- .../requests/GetSubscriptionsRequest.kt | 4 ++-- .../sdk/friends/AuthorizedFriendsApi.kt | 22 +++++++++---------- .../app/meetacy/sdk/friends/FriendsApi.kt | 19 +++++++++------- 5 files changed, 31 insertions(+), 33 deletions(-) diff --git a/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/requests/friends/FriendsEngine.kt b/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/requests/friends/FriendsEngine.kt index d846334..660af3d 100644 --- a/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/requests/friends/FriendsEngine.kt +++ b/api/api-ktor/src/commonMain/kotlin/app/meetacy/sdk/engine/ktor/requests/friends/FriendsEngine.kt @@ -11,18 +11,15 @@ import app.meetacy.sdk.engine.requests.* import app.meetacy.sdk.types.annotation.UnsafeConstructor import app.meetacy.sdk.types.datetime.DateTime import app.meetacy.sdk.types.location.Location -import app.meetacy.sdk.types.serializable.paging.PagingResponseSerializable import app.meetacy.sdk.types.serializable.amount.AmountSerializable import app.meetacy.sdk.types.serializable.amount.serializable import app.meetacy.sdk.types.serializable.location.LocationSerializable import app.meetacy.sdk.types.serializable.location.type import app.meetacy.sdk.types.serializable.paging.PagingIdSerializable +import app.meetacy.sdk.types.serializable.paging.PagingResponseSerializable import app.meetacy.sdk.types.serializable.paging.serializable import app.meetacy.sdk.types.serializable.paging.type -import app.meetacy.sdk.types.serializable.user.UserIdSerializable -import app.meetacy.sdk.types.serializable.user.UserSerializable -import app.meetacy.sdk.types.serializable.user.serializable -import app.meetacy.sdk.types.serializable.user.type +import app.meetacy.sdk.types.serializable.user.* import app.meetacy.sdk.types.url.Url import app.meetacy.sdk.types.user.RegularUser import app.meetacy.sdk.types.user.UserLocationSnapshot @@ -108,9 +105,9 @@ internal class FriendsEngine( parameter("id", request.userId?.string) parameter("amount", request.amount.int) parameter("pagingId", request.pagingId?.string) - }.bodyAsSuccess>() + }.bodyAsSuccess>() .type() - .mapItems { user -> user.type() as RegularUser } + .mapItems { userDetails -> userDetails.type() } return GetSubscriptionsRequest.Response(response) } @@ -124,9 +121,9 @@ internal class FriendsEngine( parameter("id", request.userId?.string) parameter("amount", request.amount.int) parameter("pagingId", request.pagingId?.string) - }.bodyAsSuccess>() + }.bodyAsSuccess>() .type() - .mapItems { user -> user.type() as RegularUser } + .mapItems { userDetails -> userDetails.type() } return GetSubscribersRequest.Response(response) } diff --git a/api/src/commonMain/kotlin/app/meetacy/sdk/engine/requests/GetSubscribersRequest.kt b/api/src/commonMain/kotlin/app/meetacy/sdk/engine/requests/GetSubscribersRequest.kt index 901a178..d011f54 100644 --- a/api/src/commonMain/kotlin/app/meetacy/sdk/engine/requests/GetSubscribersRequest.kt +++ b/api/src/commonMain/kotlin/app/meetacy/sdk/engine/requests/GetSubscribersRequest.kt @@ -4,7 +4,7 @@ import app.meetacy.sdk.types.amount.Amount import app.meetacy.sdk.types.auth.Token import app.meetacy.sdk.types.paging.PagingId import app.meetacy.sdk.types.paging.PagingResponse -import app.meetacy.sdk.types.user.RegularUser +import app.meetacy.sdk.types.user.UserDetails import app.meetacy.sdk.types.user.UserId public data class GetSubscribersRequest( @@ -13,5 +13,5 @@ public data class GetSubscribersRequest( val pagingId: PagingId?, val userId: UserId?, ) : MeetacyRequest { - public data class Response(val paging: PagingResponse) + public data class Response(val paging: PagingResponse) } diff --git a/api/src/commonMain/kotlin/app/meetacy/sdk/engine/requests/GetSubscriptionsRequest.kt b/api/src/commonMain/kotlin/app/meetacy/sdk/engine/requests/GetSubscriptionsRequest.kt index 639ac56..63e6ec8 100644 --- a/api/src/commonMain/kotlin/app/meetacy/sdk/engine/requests/GetSubscriptionsRequest.kt +++ b/api/src/commonMain/kotlin/app/meetacy/sdk/engine/requests/GetSubscriptionsRequest.kt @@ -4,7 +4,7 @@ import app.meetacy.sdk.types.amount.Amount import app.meetacy.sdk.types.auth.Token import app.meetacy.sdk.types.paging.PagingId import app.meetacy.sdk.types.paging.PagingResponse -import app.meetacy.sdk.types.user.RegularUser +import app.meetacy.sdk.types.user.UserDetails import app.meetacy.sdk.types.user.UserId public data class GetSubscriptionsRequest( @@ -13,5 +13,5 @@ public data class GetSubscriptionsRequest( val pagingId: PagingId?, val userId: UserId?, ) : MeetacyRequest { - public data class Response(val paging: PagingResponse) + public data class Response(val paging: PagingResponse) } diff --git a/api/src/commonMain/kotlin/app/meetacy/sdk/friends/AuthorizedFriendsApi.kt b/api/src/commonMain/kotlin/app/meetacy/sdk/friends/AuthorizedFriendsApi.kt index 5b8b959..c5ebb73 100644 --- a/api/src/commonMain/kotlin/app/meetacy/sdk/friends/AuthorizedFriendsApi.kt +++ b/api/src/commonMain/kotlin/app/meetacy/sdk/friends/AuthorizedFriendsApi.kt @@ -4,9 +4,13 @@ import app.meetacy.sdk.AuthorizedMeetacyApi import app.meetacy.sdk.friends.location.AuthorizedFriendsLocationApi import app.meetacy.sdk.types.amount.Amount import app.meetacy.sdk.types.auth.Token -import app.meetacy.sdk.types.paging.* +import app.meetacy.sdk.types.paging.PagingId +import app.meetacy.sdk.types.paging.PagingRepository +import app.meetacy.sdk.types.paging.PagingSource +import app.meetacy.sdk.types.paging.mapItems import app.meetacy.sdk.types.user.UserId import app.meetacy.sdk.users.AuthorizedRegularUserRepository +import app.meetacy.sdk.users.AuthorizedUserDetailsRepository /** * When modifying this class, corresponding classes should be altered: @@ -40,24 +44,18 @@ public class AuthorizedFriendsApi(private val api: AuthorizedMeetacyApi) { amount: Amount, pagingId: PagingId? = null, userId: UserId? = null - ): PagingRepository = + ): PagingRepository = base.subscriptions(token, amount, pagingId, userId).mapItems { user -> - AuthorizedRegularUserRepository( - data = user.data, - api = api - ) + AuthorizedUserDetailsRepository.of(user.data, api) } public suspend fun subscribers( amount: Amount, pagingId: PagingId? = null, userId: UserId? = null - ): PagingRepository = - base.subscribers(token, amount, pagingId, userId).mapItems { user -> - AuthorizedRegularUserRepository( - data = user.data, - api = api - ) + ): PagingRepository = + base.subscriptions(token, amount, pagingId, userId).mapItems { user -> + AuthorizedUserDetailsRepository.of(user.data, api) } public fun paging( diff --git a/api/src/commonMain/kotlin/app/meetacy/sdk/friends/FriendsApi.kt b/api/src/commonMain/kotlin/app/meetacy/sdk/friends/FriendsApi.kt index dbaebae..3798712 100644 --- a/api/src/commonMain/kotlin/app/meetacy/sdk/friends/FriendsApi.kt +++ b/api/src/commonMain/kotlin/app/meetacy/sdk/friends/FriendsApi.kt @@ -3,11 +3,14 @@ package app.meetacy.sdk.friends import app.meetacy.sdk.MeetacyApi import app.meetacy.sdk.engine.requests.* import app.meetacy.sdk.friends.location.FriendsLocationApi -import app.meetacy.sdk.users.RegularUserRepository import app.meetacy.sdk.types.amount.Amount import app.meetacy.sdk.types.auth.Token -import app.meetacy.sdk.types.paging.* +import app.meetacy.sdk.types.paging.PagingId +import app.meetacy.sdk.types.paging.PagingRepository +import app.meetacy.sdk.types.paging.PagingSource import app.meetacy.sdk.types.user.UserId +import app.meetacy.sdk.users.RegularUserRepository +import app.meetacy.sdk.users.UserDetailsRepository /** * When modifying this class, corresponding classes should be altered: @@ -47,7 +50,7 @@ public class FriendsApi(private val api: MeetacyApi) { amount: Amount, pagingId: PagingId? = null, userId: UserId? = null - ): PagingRepository = PagingRepository( + ): PagingRepository = PagingRepository( amount = amount, startPagingId = pagingId ) { currentAmount, currentPagingId -> @@ -58,8 +61,8 @@ public class FriendsApi(private val api: MeetacyApi) { amount = currentAmount, pagingId = currentPagingId ) - ).paging.mapItems { regularUser -> - RegularUserRepository(regularUser, api) + ).paging.mapItems { userDetails -> + UserDetailsRepository.of(userDetails, api) } } @@ -68,7 +71,7 @@ public class FriendsApi(private val api: MeetacyApi) { amount: Amount, pagingId: PagingId? = null, userId: UserId? = null, - ): PagingRepository = PagingRepository( + ): PagingRepository = PagingRepository( amount = amount, startPagingId = pagingId ) { currentAmount, currentPagingId -> @@ -79,8 +82,8 @@ public class FriendsApi(private val api: MeetacyApi) { amount = currentAmount, pagingId = currentPagingId ) - ).paging.mapItems { regularUser -> - RegularUserRepository(regularUser, api) + ).paging.mapItems { userDetails -> + UserDetailsRepository.of(userDetails, api) } }