-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(openplanner): add compatibility with OpenPlanner.fr.
Closes #60
- Loading branch information
1 parent
ac1ab62
commit 472258a
Showing
14 changed files
with
305 additions
and
9 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
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
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
47 changes: 47 additions & 0 deletions
47
...nd/src/main/java/org/gdglille/devfest/backend/third/parties/openplanner/OpenPlannerApi.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,47 @@ | ||
package org.gdglille.devfest.backend.third.parties.openplanner | ||
|
||
import io.ktor.client.HttpClient | ||
import io.ktor.client.call.body | ||
import io.ktor.client.engine.java.Java | ||
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation | ||
import io.ktor.client.plugins.logging.DEFAULT | ||
import io.ktor.client.plugins.logging.LogLevel | ||
import io.ktor.client.plugins.logging.Logger | ||
import io.ktor.client.plugins.logging.Logging | ||
import io.ktor.client.request.get | ||
import io.ktor.serialization.kotlinx.json.json | ||
import kotlinx.datetime.Clock | ||
import kotlinx.serialization.json.Json | ||
|
||
class OpenPlannerApi( | ||
private val client: HttpClient, | ||
private val baseUrl: String = "https://storage.googleapis.com/conferencecenterr.appspot.com" | ||
) { | ||
suspend fun fetchPrivateJson(eventId: String, privateId: String): OpenPlanner = | ||
client.get("$baseUrl/events/$eventId/$privateId.json?t=${Clock.System.now().epochSeconds}") | ||
.body<OpenPlanner>() | ||
|
||
object Factory { | ||
fun create(enableNetworkLogs: Boolean): OpenPlannerApi = | ||
OpenPlannerApi( | ||
client = HttpClient(Java.create()) { | ||
install(ContentNegotiation) { | ||
json( | ||
Json { | ||
isLenient = true | ||
ignoreUnknownKeys = true | ||
} | ||
) | ||
} | ||
if (enableNetworkLogs) { | ||
install( | ||
Logging | ||
) { | ||
logger = Logger.DEFAULT | ||
level = LogLevel.INFO | ||
} | ||
} | ||
} | ||
) | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
...rc/main/java/org/gdglille/devfest/backend/third/parties/openplanner/OpenPlannerMappers.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,64 @@ | ||
package org.gdglille.devfest.backend.third.parties.openplanner | ||
|
||
import org.gdglille.devfest.backend.categories.CategoryDb | ||
import org.gdglille.devfest.backend.formats.FormatDb | ||
import org.gdglille.devfest.backend.schedulers.ScheduleDb | ||
import org.gdglille.devfest.backend.speakers.SpeakerDb | ||
import org.gdglille.devfest.backend.talks.TalkDb | ||
|
||
fun CategoryOP.convertToDb() = CategoryDb( | ||
id = id, | ||
name = name, | ||
color = color, | ||
icon = "" | ||
) | ||
|
||
fun FormatOP.convertToDb() = FormatDb( | ||
id = id, | ||
name = name, | ||
time = durationMinutes | ||
) | ||
|
||
fun SpeakerOP.convertToDb(): SpeakerDb { | ||
val twitter = socials.find { it.name == "Twitter" }?.link | ||
val github = socials.find { it.name == "GitHub" }?.link | ||
return SpeakerDb( | ||
id = id, | ||
displayName = name, | ||
pronouns = null, | ||
bio = bio ?: "", | ||
jobTitle = jobTitle, | ||
company = company, | ||
photoUrl = photoUrl ?: "", | ||
website = null, | ||
twitter = if (twitter?.contains("twitter.com") == true) twitter | ||
else "https://twitter.com/$twitter", | ||
mastodon = null, | ||
github = if (github?.contains("github.com") == true) github | ||
else "https://github.com/$github", | ||
linkedin = null | ||
) | ||
} | ||
|
||
fun SessionOP.convertToTalkDb() = TalkDb( | ||
id = id, | ||
title = title, | ||
level = level, | ||
abstract = abstract, | ||
category = categoryId, | ||
format = formatId, | ||
language = language, | ||
speakerIds = speakerIds, | ||
linkSlides = null, | ||
linkReplay = null | ||
) | ||
|
||
fun SessionOP.convertToScheduleDb(order: Int) = ScheduleDb( | ||
order = order, | ||
startTime = dateStart?.split("+")?.first() | ||
?: error("Can't schedule a talk without a start time"), | ||
endTime = dateEnd?.split("+")?.first() | ||
?: error("Can't schedule a talk without a end time"), | ||
room = trackId ?: error("Can't schedule a talk without a room"), | ||
talkId = id | ||
) |
81 changes: 81 additions & 0 deletions
81
...nd/src/main/java/org/gdglille/devfest/backend/third/parties/openplanner/OpenPlannerNet.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,81 @@ | ||
package org.gdglille.devfest.backend.third.parties.openplanner | ||
|
||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class OpenPlanner( | ||
val generatedAt: String, | ||
val event: EventOP, | ||
val speakers: List<SpeakerOP>, | ||
val sessions: List<SessionOP> | ||
) | ||
|
||
@Serializable | ||
data class EventOP( | ||
val id: String, | ||
val name: String, | ||
val scheduleVisible: Boolean, | ||
val dateStart: String, | ||
val dateEnd: String, | ||
val formats: List<FormatOP>, | ||
val categories: List<CategoryOP>, | ||
val tracks: List<TrackOP> | ||
) | ||
|
||
@Serializable | ||
data class FormatOP( | ||
val id: String, | ||
val name: String, | ||
val description: String? = null, | ||
val durationMinutes: Int | ||
) | ||
|
||
@Serializable | ||
data class CategoryOP( | ||
val id: String, | ||
val name: String, | ||
val color: String | ||
) | ||
|
||
@Serializable | ||
data class TrackOP( | ||
val id: String, | ||
val name: String | ||
) | ||
|
||
@Serializable | ||
data class SpeakerOP( | ||
val id: String, | ||
val name: String, | ||
val bio: String?, | ||
val photoUrl: String?, | ||
val email: String, | ||
val phone: String?, | ||
val company: String?, | ||
val geolocation: String?, | ||
val jobTitle: String?, | ||
val socials: List<SocialOP> | ||
) | ||
|
||
@Serializable | ||
data class SocialOP( | ||
val link: String, | ||
val icon: String, | ||
val name: String | ||
) | ||
|
||
@Serializable | ||
data class SessionOP( | ||
val id: String, | ||
val title: String, | ||
val abstract: String, | ||
val dateStart: String? = null, | ||
val dateEnd: String? = null, | ||
val durationMinutes: Int, | ||
val speakerIds: List<String>, | ||
val trackId: String?, | ||
val language: String, | ||
val level: String, | ||
val formatId: String, | ||
val categoryId: String, | ||
) |
Oops, something went wrong.