add properties to typeResponse
This commit is contained in:
1 parent
4cf6073fbe
commit
99a494608f
7 files changed
+76
No files matched your search
@@ -2,8 +2,10 @@ package ch.ergon.anytask.api
|
||||
|
||||
import ch.ergon.anytask.api.dto.CreateObjectRequest
|
||||
import ch.ergon.anytask.api.dto.CreateObjectResponse
|
||||
import ch.ergon.anytask.api.dto.ObjectType
|
||||
import ch.ergon.anytask.api.dto.Space
|
||||
import ch.ergon.anytask.api.dto.SpacesResponse
|
||||
import ch.ergon.anytask.api.dto.TypesResponse
|
||||
import io.ktor.client.*
|
||||
import io.ktor.client.call.*
|
||||
import io.ktor.client.engine.cio.*
|
||||
@@ -60,6 +62,15 @@ class AnyTypeApi(
|
||||
response.body<SpacesResponse>().data
|
||||
}
|
||||
|
||||
suspend fun getTypes(): Result<List<ObjectType>> =
|
||||
runCatching {
|
||||
val response = http.get("$baseUrl/v1/spaces/$spaceId/types") {
|
||||
header("Anytype-Version", "0.1")
|
||||
bearerAuth(apiKey)
|
||||
}
|
||||
response.body<TypesResponse>().data
|
||||
}
|
||||
|
||||
suspend fun createTask(title: String, details: String = ""): Result<String> =
|
||||
runCatching {
|
||||
val response = http.post("$baseUrl/v1/spaces/$spaceId/objects") {
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package ch.ergon.anytask.api.dto
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class Icon(
|
||||
val format: String = "",
|
||||
val emoji: String = "",
|
||||
val file: String = "",
|
||||
val name: String = "",
|
||||
val color: String = "",
|
||||
)
|
||||
@@ -0,0 +1,16 @@
|
||||
package ch.ergon.anytask.api.dto
|
||||
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class ObjectType(
|
||||
val id: String,
|
||||
val key: String = "",
|
||||
val name: String,
|
||||
val icon: Icon = Icon(),
|
||||
val layout: String = "",
|
||||
val archived: Boolean = false,
|
||||
@SerialName("plural_name") val pluralName: String = "",
|
||||
val properties: List<Property> = emptyList(),
|
||||
)
|
||||
@@ -0,0 +1,12 @@
|
||||
package ch.ergon.anytask.api.dto
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class Property(
|
||||
val id: String,
|
||||
val key: String = "",
|
||||
val name: String,
|
||||
val format: String = "",
|
||||
val `object`: String = "",
|
||||
)
|
||||
@@ -0,0 +1,8 @@
|
||||
package ch.ergon.anytask.api.dto
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class TypesResponse(
|
||||
val data: List<ObjectType>,
|
||||
)
|
||||