-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
shared: Add method to get attendee for event
Signed-off-by: Aayush Gupta <[email protected]>
- Loading branch information
1 parent
d8ea4c4
commit f97c69d
Showing
7 changed files
with
197 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
23 changes: 23 additions & 0 deletions
23
shared/src/commonMain/kotlin/app/opass/ccip/extensions/AttendeeTable.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,23 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 OPass | ||
* SPDX-License-Identifier: GPL-3.0-only | ||
*/ | ||
|
||
package app.opass.ccip.extensions | ||
|
||
import app.opass.ccip.database.AttendeeTable | ||
import app.opass.ccip.network.models.fastpass.Attendee | ||
import app.opass.ccip.network.models.fastpass.Scenario | ||
import kotlinx.serialization.json.Json | ||
|
||
internal fun AttendeeTable.toAttendee(): Attendee { | ||
return Attendee( | ||
attr = Json.decodeFromString<Map<String, String>>(this.attr), | ||
eventId = this.eventId, | ||
firstUse = this.firstUse, | ||
role = this.role, | ||
scenarios = Json.decodeFromString<List<Scenario>>(this.scenarios), | ||
token = this.token, | ||
userId = this.eventId, | ||
) | ||
} |
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
27 changes: 27 additions & 0 deletions
27
shared/src/commonMain/kotlin/app/opass/ccip/network/models/fastpass/Attendee.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,27 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 OPass | ||
* SPDX-License-Identifier: GPL-3.0-only | ||
*/ | ||
|
||
package app.opass.ccip.network.models.fastpass | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class Attendee( | ||
val attr: Map<String, String> = emptyMap(), | ||
|
||
@SerialName("event_id") | ||
val eventId: String, | ||
|
||
@SerialName("first_use") | ||
val firstUse: Long, | ||
|
||
val role: String, | ||
val scenarios: List<Scenario>, | ||
val token: String, | ||
|
||
@SerialName("user_id") | ||
val userId: String | ||
) |
44 changes: 44 additions & 0 deletions
44
shared/src/commonMain/kotlin/app/opass/ccip/network/models/fastpass/Scenario.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,44 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 OPass | ||
* SPDX-License-Identifier: GPL-3.0-only | ||
*/ | ||
|
||
package app.opass.ccip.network.models.fastpass | ||
|
||
import app.opass.ccip.extensions.localized | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class Scenario( | ||
val attr: Map<String, String> = emptyMap(), | ||
|
||
@SerialName("available_time") | ||
val availableTime: Long, | ||
|
||
val countdown: Int, | ||
|
||
@SerialName("display_text") | ||
val _displayText: Localized, | ||
|
||
@SerialName("expire_time") | ||
val expireTime: Long, | ||
|
||
val disabled: String, | ||
|
||
val id: String, | ||
val order: Int, | ||
val used: Int | ||
) { | ||
val displayText: String | ||
get() = localized(_displayText.en, _displayText.zh) | ||
|
||
@Serializable | ||
data class Localized( | ||
@SerialName("en-US") | ||
val en: String, | ||
|
||
@SerialName("zh-TW") | ||
val zh: String | ||
) | ||
} |
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