-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(#79-support-search): support search was added
- Loading branch information
Showing
5 changed files
with
138 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
api/src/commonMain/kotlin/app/meetacy/sdk/search/AuthorizedSearchItemRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package app.meetacy.sdk.search | ||
|
||
import app.meetacy.sdk.AuthorizedMeetacyApi | ||
import app.meetacy.sdk.meetings.AuthorizedMeetingRepository | ||
import app.meetacy.sdk.types.auth.Token | ||
import app.meetacy.sdk.types.search.SearchItem | ||
import app.meetacy.sdk.users.AuthorizedUserRepository | ||
import app.meetacy.sdk.types.place.Place as PlaceData | ||
|
||
public sealed class AuthorizedSearchItemRepository { | ||
protected abstract val api: AuthorizedMeetacyApi | ||
This comment has been minimized.
Sorry, something went wrong. |
||
public abstract val data: SearchItem | ||
public abstract val base: SearchItemRepository | ||
|
||
public val token: Token get() = api.token | ||
|
||
public class Meeting( | ||
override val data: SearchItem.Meeting, | ||
override val api: AuthorizedMeetacyApi | ||
) : AuthorizedSearchItemRepository() { | ||
override val base: SearchItemRepository | ||
get() = SearchItemRepository.Meeting(data, api.base) | ||
public val meeting: AuthorizedMeetingRepository | ||
get() = AuthorizedMeetingRepository(data.meeting, api) | ||
} | ||
|
||
public class Place( | ||
override val data: SearchItem.Place, | ||
override val api: AuthorizedMeetacyApi | ||
) : AuthorizedSearchItemRepository() { | ||
override val base: SearchItemRepository | ||
get() = SearchItemRepository.Place(data) | ||
|
||
public val place: PlaceData | ||
get() = data.place | ||
} | ||
|
||
public class User( | ||
override val data: SearchItem.User, | ||
override val api: AuthorizedMeetacyApi | ||
) : AuthorizedSearchItemRepository() { | ||
|
||
override val base: SearchItemRepository | ||
get() = SearchItemRepository.User(data, api.base) | ||
public val user: AuthorizedUserRepository | ||
get() = AuthorizedUserRepository.of(data.user, api) | ||
} | ||
|
||
public companion object { | ||
public fun of(data: SearchItem, api: AuthorizedMeetacyApi): AuthorizedSearchItemRepository = | ||
when (data) { | ||
is SearchItem.Meeting -> Meeting(data, api) | ||
is SearchItem.Place -> Place(data, api) | ||
is SearchItem.User -> User(data, api) | ||
} | ||
|
||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
api/src/commonMain/kotlin/app/meetacy/sdk/search/SearchItemRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package app.meetacy.sdk.search | ||
|
||
import app.meetacy.sdk.MeetacyApi | ||
import app.meetacy.sdk.meetings.AuthorizedMeetingRepository | ||
import app.meetacy.sdk.meetings.MeetingRepository | ||
import app.meetacy.sdk.types.place.Place as PlaceData | ||
import app.meetacy.sdk.types.search.SearchItem | ||
import app.meetacy.sdk.users.UserRepository | ||
|
||
/** | ||
* When modifying this class, corresponding classes should be altered: | ||
* - [AuthorizedMeetingRepository] | ||
*/ | ||
|
||
This comment has been minimized.
Sorry, something went wrong. |
||
public sealed class SearchItemRepository { | ||
public abstract val data: SearchItem | ||
|
||
public class Meeting( | ||
override val data: SearchItem.Meeting, | ||
private val api: MeetacyApi | ||
) : SearchItemRepository() { | ||
public val meeting: MeetingRepository | ||
get() = MeetingRepository(data.meeting, api) | ||
} | ||
|
||
public class Place( | ||
override val data: SearchItem.Place | ||
) : SearchItemRepository() { | ||
public val place: PlaceData | ||
get() = data.place | ||
} | ||
|
||
public class User( | ||
override val data: SearchItem.User, | ||
private val api: MeetacyApi | ||
) : SearchItemRepository() { | ||
public val user: UserRepository | ||
get() = UserRepository.of(data.user, api) | ||
} | ||
|
||
public companion object { | ||
public fun of(data: SearchItem, api: MeetacyApi): SearchItemRepository { | ||
return when (data) { | ||
is SearchItem.Meeting -> Meeting(data, api) | ||
is SearchItem.Place -> Place(data) | ||
is SearchItem.User -> User(data, api) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Нет отступа