//
//  TSGenmojiModel.swift
//  AIEmoji
//
//  Created by 100Years on 2025/1/16.
//

import ObjectMapper
class TSGenmojiModel: TSBaseModel {
    
    enum ActionStatus:String ,Equatable {
        case success = "success"//成功
        case pending = "pending"//等待
        case running = "running"//运行
        case failed = "failed"//失败
        
        static func from(_ string: String) -> ActionStatus {
            return ActionStatus(rawValue: string) ?? .failed
        }
    }
    
    var id:Int = 0
    var actionType:String = ""
    var comments:String = ""
    var request:String = ""
    var response:TSGenmojiResponseModel = TSGenmojiResponseModel()
    var createdTimestamp:Int = 0
    var status:String = ""
    var costTime:Int = 0
    var percent:Int = 0
    var actionStatus:ActionStatus = .failed
    
    
    override func mapping(map: ObjectMapper.Map) {
        id           <- map["id"]
        actionType   <- map["actionType"]
        comments     <- map["comments"]
        request      <- map["request"]
        response           <- (map["response"],JsonStringTransform<TSGenmojiResponseModel>())
        createdTimestamp   <- map["createdTimestamp"]
        status     <- map["status"]
        costTime      <- map["costTime"]
        percent     <- map["percent"]
        actionStatus      <- map["actionStatus"]
        actionStatus = ActionStatus.from(status)
    }
}

class TSGenmojiResponseModel : TSBaseModel {
    var resultUrl:String = ""
    var vip:Bool = false
    override func mapping(map: ObjectMapper.Map) {
        resultUrl           <- map["resultUrl"]
        vip           <- map["vip"]
    }
}





