All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.appwrite.models.Variable.kt Maven / Gradle / Ivy

Go to download

Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Kotlin SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)

There is a newer version: 6.1.0
Show newest version
package io.appwrite.models

import com.google.gson.annotations.SerializedName
import io.appwrite.extensions.jsonCast

/**
 * Variable
 */
data class Variable(
    /**
     * Variable ID.
     */
    @SerializedName("\$id")
    val id: String,

    /**
     * Variable creation date in ISO 8601 format.
     */
    @SerializedName("\$createdAt")
    val createdAt: String,

    /**
     * Variable creation date in ISO 8601 format.
     */
    @SerializedName("\$updatedAt")
    val updatedAt: String,

    /**
     * Variable key.
     */
    @SerializedName("key")
    val key: String,

    /**
     * Variable value.
     */
    @SerializedName("value")
    val value: String,

    /**
     * Service to which the variable belongs. Possible values are "project", "function"
     */
    @SerializedName("resourceType")
    val resourceType: String,

    /**
     * ID of resource to which the variable belongs. If resourceType is "project", it is empty. If resourceType is "function", it is ID of the function.
     */
    @SerializedName("resourceId")
    val resourceId: String,

) {
    fun toMap(): Map = mapOf(
        "\$id" to id as Any,
        "\$createdAt" to createdAt as Any,
        "\$updatedAt" to updatedAt as Any,
        "key" to key as Any,
        "value" to value as Any,
        "resourceType" to resourceType as Any,
        "resourceId" to resourceId as Any,
    )

    companion object {

        @Suppress("UNCHECKED_CAST")
        fun from(
            map: Map,
        ) = Variable(
            id = map["\$id"] as String,
            createdAt = map["\$createdAt"] as String,
            updatedAt = map["\$updatedAt"] as String,
            key = map["key"] as String,
            value = map["value"] as String,
            resourceType = map["resourceType"] as String,
            resourceId = map["resourceId"] as String,
        )
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy