@@ -2,6 +2,8 @@ package io.appwrite.models
22
33import com.google.gson.annotations.SerializedName
44import io.appwrite.extensions.jsonCast
5+ import io.appwrite.enums.ExecutionTrigger
6+ import io.appwrite.enums.ExecutionStatus
57
68/* *
79 * Execution
@@ -47,13 +49,13 @@ data class Execution(
4749 * The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`.
4850 */
4951 @SerializedName(" trigger" )
50- val trigger : String ,
52+ val trigger : ExecutionTrigger ,
5153
5254 /* *
5355 * The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, or `failed`.
5456 */
5557 @SerializedName(" status" )
56- val status : String ,
58+ val status : ExecutionStatus ,
5759
5860 /* *
5961 * HTTP request method type.
@@ -123,8 +125,8 @@ data class Execution(
123125 " \$ permissions" to permissions as Any ,
124126 " functionId" to functionId as Any ,
125127 " deploymentId" to deploymentId as Any ,
126- " trigger" to trigger as Any ,
127- " status" to status as Any ,
128+ " trigger" to trigger.value as Any ,
129+ " status" to status.value as Any ,
128130 " requestMethod" to requestMethod as Any ,
129131 " requestPath" to requestPath as Any ,
130132 " requestHeaders" to requestHeaders.map { it.toMap() } as Any ,
@@ -149,8 +151,8 @@ data class Execution(
149151 permissions = map[" \$ permissions" ] as List <String >,
150152 functionId = map[" functionId" ] as String ,
151153 deploymentId = map[" deploymentId" ] as String ,
152- trigger = map[" trigger" ] as String ,
153- status = map[" status" ] as String ,
154+ trigger = ExecutionTrigger .values().find { it.value == map[" trigger" ] as String } !! ,
155+ status = ExecutionStatus .values().find { it.value == map[" status" ] as String } !! ,
154156 requestMethod = map[" requestMethod" ] as String ,
155157 requestPath = map[" requestPath" ] as String ,
156158 requestHeaders = (map[" requestHeaders" ] as List <Map <String , Any >>).map { Headers .from(map = it) },
@@ -160,7 +162,7 @@ data class Execution(
160162 logs = map[" logs" ] as String ,
161163 errors = map[" errors" ] as String ,
162164 duration = (map[" duration" ] as Number ).toDouble(),
163- scheduledAt = map[" scheduledAt" ] as ? String? ,
165+ scheduledAt = map[" scheduledAt" ] as ? String ,
164166 )
165167 }
166168}
0 commit comments