11import Foundation
22import JSONCodable
3+ import AppwriteEnums
34
45/// Execution
56open class Execution : Codable {
@@ -44,10 +45,10 @@ open class Execution: Codable {
4445 public let deploymentId : String
4546
4647 /// The trigger that caused the function to execute. Possible values can be: `http`, `schedule`, or `event`.
47- public let trigger : String
48+ public let trigger : AppwriteEnums . ExecutionTrigger
4849
4950 /// The status of the function execution. Possible values can be: `waiting`, `processing`, `completed`, or `failed`.
50- public let status : String
51+ public let status : AppwriteEnums . ExecutionStatus
5152
5253 /// HTTP request method type.
5354 public let requestMethod : String
@@ -87,8 +88,8 @@ open class Execution: Codable {
8788 permissions: [ String ] ,
8889 functionId: String ,
8990 deploymentId: String ,
90- trigger: String ,
91- status: String ,
91+ trigger: AppwriteEnums . ExecutionTrigger ,
92+ status: AppwriteEnums . ExecutionStatus ,
9293 requestMethod: String ,
9394 requestPath: String ,
9495 requestHeaders: [ Headers ] ,
@@ -129,8 +130,8 @@ open class Execution: Codable {
129130 self . permissions = try container. decode ( [ String ] . self, forKey: . permissions)
130131 self . functionId = try container. decode ( String . self, forKey: . functionId)
131132 self . deploymentId = try container. decode ( String . self, forKey: . deploymentId)
132- self . trigger = try container. decode ( String . self, forKey: . trigger)
133- self . status = try container. decode ( String . self, forKey: . status)
133+ self . trigger = AppwriteEnums . ExecutionTrigger ( rawValue : try container. decode ( String . self, forKey: . trigger) ) !
134+ self . status = AppwriteEnums . ExecutionStatus ( rawValue : try container. decode ( String . self, forKey: . status) ) !
134135 self . requestMethod = try container. decode ( String . self, forKey: . requestMethod)
135136 self . requestPath = try container. decode ( String . self, forKey: . requestPath)
136137 self . requestHeaders = try container. decode ( [ Headers ] . self, forKey: . requestHeaders)
@@ -152,8 +153,8 @@ open class Execution: Codable {
152153 try container. encode ( permissions, forKey: . permissions)
153154 try container. encode ( functionId, forKey: . functionId)
154155 try container. encode ( deploymentId, forKey: . deploymentId)
155- try container. encode ( trigger, forKey: . trigger)
156- try container. encode ( status, forKey: . status)
156+ try container. encode ( trigger. rawValue , forKey: . trigger)
157+ try container. encode ( status. rawValue , forKey: . status)
157158 try container. encode ( requestMethod, forKey: . requestMethod)
158159 try container. encode ( requestPath, forKey: . requestPath)
159160 try container. encode ( requestHeaders, forKey: . requestHeaders)
@@ -174,8 +175,8 @@ open class Execution: Codable {
174175 " $permissions " : permissions as Any ,
175176 " functionId " : functionId as Any ,
176177 " deploymentId " : deploymentId as Any ,
177- " trigger " : trigger as Any ,
178- " status " : status as Any ,
178+ " trigger " : trigger. rawValue as Any ,
179+ " status " : status. rawValue as Any ,
179180 " requestMethod " : requestMethod as Any ,
180181 " requestPath " : requestPath as Any ,
181182 " requestHeaders " : requestHeaders. map { $0. toMap ( ) } as Any ,
@@ -197,8 +198,8 @@ open class Execution: Codable {
197198 permissions: map [ " $permissions " ] as! [ String ] ,
198199 functionId: map [ " functionId " ] as! String ,
199200 deploymentId: map [ " deploymentId " ] as! String ,
200- trigger: map [ " trigger " ] as! String ,
201- status: map [ " status " ] as! String ,
201+ trigger: ExecutionTrigger ( rawValue : map [ " trigger " ] as! String ) ! ,
202+ status: ExecutionStatus ( rawValue : map [ " status " ] as! String ) ! ,
202203 requestMethod: map [ " requestMethod " ] as! String ,
203204 requestPath: map [ " requestPath " ] as! String ,
204205 requestHeaders: ( map [ " requestHeaders " ] as! [ [ String : Any ] ] ) . map { Headers . from ( map: $0) } ,
0 commit comments