/* Options: Date: 2025-09-10 19:38:45 SwiftVersion: 5.0 Version: 8.30 Tip: To override a DTO option, remove "//" prefix before updating BaseUrl: https://dev-optimization.power.dev //BaseClass: //AddModelExtensions: True //AddServiceStackTypes: True IncludeTypes: TODOptimizerRequest.* //ExcludeTypes: //ExcludeGenericBaseTypes: False //AddResponseStatus: False //AddImplicitVersion: //AddDescriptionAsComments: True //InitializeCollections: True //TreatTypesAsStrings: //DefaultImports: Foundation,ServiceStack */ import Foundation import ServiceStack // @Route("/optimizer/tod", "POST") public class TODOptimizerRequest : TodOptimizerRequestBase, IReturn { public typealias Return = TodOptimizerResponse required public init(){ super.init() } required public init(from decoder: Decoder) throws { try super.init(from: decoder) } public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) } } public class TodOptimizerResponse : Codable { public var status:ApiResponseStatus public var message:String public var apiActionId:String public var testItems:[TodOptimizerResponseItem] = [] required public init(){} } public class AnnualRateItem : Codable { public var year:Int public var value:Double required public init(){} } public class YoyFactorOptimizarItem : Codable { public var year:Int public var factor:Double required public init(){} } public class TodOptimizerRequestItem : Codable { public var year:Int public var month:Int public var hour:Int public var weekDay:Int public var energyPrice:Double public var capacityPrice:Double required public init(){} } public class TodOptimizerRequestBase : Codable { public var projectId:String public var chargeDischargeLimit:Double public var batteryCapacity:Double public var chargeEfficiency:Double public var dischargeEfficiency:Double public var paraciticLossesOperation:Double public var paraciticLossesResting:Double public var hvacLosses:Double public var acCablingLosses:Double public var transformatorLosses:Double public var thermalLosses:Double public var unavailabilityLoss:Double public var otherLosses:Double public var enableCapacity:Bool public var energySchedule:[AnnualRateItem] = [] public var capacitySchedule:[AnnualRateItem] = [] public var yoyFactors:[YoyFactorOptimizarItem] = [] public var data:[TodOptimizerRequestItem] = [] public var apiActionId:String required public init(){} } public enum ApiResponseStatus : Int, Codable { case Undefined = 0 case Success = 1 case Pending = 10 case Failed = 100 } public class TodOptimizerResponseItem : TodOptimizerRequestItem { public var chargeState:Double public var charging:Double public var loss:Double public var chargeRate:Double required public init(){ super.init() } private enum CodingKeys : String, CodingKey { case chargeState case charging case loss case chargeRate } required public init(from decoder: Decoder) throws { try super.init(from: decoder) let container = try decoder.container(keyedBy: CodingKeys.self) chargeState = try container.decodeIfPresent(Double.self, forKey: .chargeState) charging = try container.decodeIfPresent(Double.self, forKey: .charging) loss = try container.decodeIfPresent(Double.self, forKey: .loss) chargeRate = try container.decodeIfPresent(Double.self, forKey: .chargeRate) } public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) if chargeState != nil { try container.encode(chargeState, forKey: .chargeState) } if charging != nil { try container.encode(charging, forKey: .charging) } if loss != nil { try container.encode(loss, forKey: .loss) } if chargeRate != nil { try container.encode(chargeRate, forKey: .chargeRate) } } }