-
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.
- Loading branch information
1 parent
1b01490
commit a2fffbb
Showing
13 changed files
with
67 additions
and
49 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
11 changes: 11 additions & 0 deletions
11
src/commonMain/kotlin/com/petersamokhin/notionsdk/data/mapper/IconMapper.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,11 @@ | ||
package com.petersamokhin.notionsdk.data.mapper | ||
|
||
import com.petersamokhin.notionsdk.data.model.internal.obj.Icon | ||
import com.petersamokhin.notionsdk.data.model.result.NotionIcon | ||
|
||
internal fun Icon.toDomain(): NotionIcon = | ||
when { | ||
emoji != null -> NotionIcon.Emoji(emoji) | ||
file != null -> NotionIcon.File(file.url, file.expiryTime) | ||
else -> error("$this is not a valid Notion icon") | ||
} |
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
18 changes: 18 additions & 0 deletions
18
src/commonMain/kotlin/com/petersamokhin/notionsdk/data/model/internal/obj/Icon.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,18 @@ | ||
package com.petersamokhin.notionsdk.data.model.internal.obj | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
internal data class Icon( | ||
val type: String, | ||
val emoji: String? = null, | ||
val file: File? = null, | ||
) { | ||
@Serializable | ||
data class File( | ||
val url: String, | ||
@SerialName("expiry_time") | ||
val expiryTime: String? = null, | ||
) | ||
} |
2 changes: 2 additions & 0 deletions
2
...ommonMain/kotlin/com/petersamokhin/notionsdk/data/model/internal/response/NotionObject.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 |
---|---|---|
@@ -1,10 +1,12 @@ | ||
package com.petersamokhin.notionsdk.data.model.internal.response | ||
|
||
import com.petersamokhin.notionsdk.data.model.internal.obj.Icon | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
internal data class PageObject( | ||
val id: String, | ||
val url: String, | ||
val properties: Map<String, PageProperty>, | ||
val icon: Icon? = null, | ||
) |
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
21 changes: 21 additions & 0 deletions
21
src/commonMain/kotlin/com/petersamokhin/notionsdk/data/model/result/NotionIcon.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,21 @@ | ||
package com.petersamokhin.notionsdk.data.model.result | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
public sealed class NotionIcon { | ||
@Serializable | ||
@SerialName("emoji") | ||
public data class Emoji( | ||
val emoji: String, | ||
) : NotionIcon() | ||
|
||
@Serializable | ||
@SerialName("file") | ||
public data class File( | ||
val url: String, | ||
@SerialName("expiry_time") | ||
val expiryTime: String? = null, | ||
) : NotionIcon() | ||
} |
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