Skip to content

Commit bbec3ca

Browse files
committed
shared: Initial support for using scenarios
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
1 parent 2aa808c commit bbec3ca

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

shared/src/commonMain/kotlin/app/opass/ccip/helpers/PortalHelper.kt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,26 @@ class PortalHelper {
130130
}
131131
}
132132

133+
/**
134+
* Uses Scenario for specified event using given token from event's FastPass feature
135+
* @param eventId ID of the event
136+
* @param token Token to identify attendee
137+
* @param scenarioId ID of the scenario
138+
* @return [Attendee] on success, null otherwise
139+
*/
140+
suspend fun useScenario(
141+
eventId: String,
142+
token: String,
143+
scenarioId: String
144+
): Attendee? {
145+
val eventConfig = dbHelper.getEventConfig(eventId) ?: return null
146+
val feat = eventConfig.features.find { f -> f.type == FeatureType.FAST_PASS } ?: return null
147+
148+
return client.useScenario(feat.url!!, token, scenarioId).also {
149+
dbHelper.addAttendee(eventId, it)
150+
}
151+
}
152+
133153
/**
134154
* Deletes an attendee's information from the database
135155
*

shared/src/commonMain/kotlin/app/opass/ccip/network/PortalClient.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,11 @@ internal class PortalClient {
6666
if (token != null) parameter("token", token)
6767
}.body()
6868
}
69+
70+
suspend fun useScenario(url: String, token: String, scenarioId: String): Attendee {
71+
return universalClient.get {
72+
url("$url/use/$scenarioId")
73+
parameter("token", token)
74+
}.body()
75+
}
6976
}

0 commit comments

Comments
 (0)