/* Options: Date: 2025-04-05 01:57:14 SwiftVersion: 5.0 Version: 8.23 Tip: To override a DTO option, remove "//" prefix before updating BaseUrl: https://testapi.bokamera.se //BaseClass: //AddModelExtensions: True //AddServiceStackTypes: True IncludeTypes: CreateIncentive.* //ExcludeTypes: //ExcludeGenericBaseTypes: False //AddResponseStatus: False //AddImplicitVersion: //AddDescriptionAsComments: True //InitializeCollections: True //TreatTypesAsStrings: //DefaultImports: Foundation,ServiceStack */ import Foundation import ServiceStack // @Route("/superadmin/incentives", "POST") // @ValidateRequest(Validator="IsAuthenticated") // @ApiResponse(Description="You were unauthorized to call this service", StatusCode=401) public class CreateIncentive : IReturn, Codable { public typealias Return = AdminIncentiveQueryResponse // @ApiMember(IsRequired=true) public var heading:String // @ApiMember() public var storageUrl:String // @ApiMember() public var body:String // @ApiMember(IsRequired=true) public var successButtonText:String // @ApiMember(IsRequired=true) public var actionId:Int // @ApiMember(IsRequired=true) public var frequency:IncentiveRecurrenceFrequency // @ApiMember() public var recurrenceInterval:UInt32 // @ApiMember(IsRequired=true) public var initialDelayInSeconds:Int // @ApiMember(IsRequired=true) public var maxDisplayCount:Int? // @ApiMember(IsRequired=true) public var validFrom:Date // @ApiMember(IsRequired=true) public var validTo:Date // @ApiMember() public var active:Bool // @ApiMember() public var payload:String public var companyIds:[String] = [] public var criteria:[IncentiveCriteriaDto] = [] required public init(){} } public class AdminIncentiveQueryResponse : CompanyIncentiveResponse { public var frequency:IncentiveRecurrenceFrequency public var recurrenceInterval:UInt32 public var createdDate:Date public var modifiedDate:Date public var companyIds:[String] = [] public var criteria:[IncentiveCriteria] = [] public var applyToAllCompanies:Bool required public init(){ super.init() } private enum CodingKeys : String, CodingKey { case frequency case recurrenceInterval case createdDate case modifiedDate case companyIds case criteria case applyToAllCompanies } required public init(from decoder: Decoder) throws { try super.init(from: decoder) let container = try decoder.container(keyedBy: CodingKeys.self) frequency = try container.decodeIfPresent(IncentiveRecurrenceFrequency.self, forKey: .frequency) recurrenceInterval = try container.decodeIfPresent(UInt32.self, forKey: .recurrenceInterval) createdDate = try container.decodeIfPresent(Date.self, forKey: .createdDate) modifiedDate = try container.decodeIfPresent(Date.self, forKey: .modifiedDate) companyIds = try container.decodeIfPresent([String].self, forKey: .companyIds) ?? [] criteria = try container.decodeIfPresent([IncentiveCriteria].self, forKey: .criteria) ?? [] applyToAllCompanies = try container.decodeIfPresent(Bool.self, forKey: .applyToAllCompanies) } public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) if frequency != nil { try container.encode(frequency, forKey: .frequency) } if recurrenceInterval != nil { try container.encode(recurrenceInterval, forKey: .recurrenceInterval) } if createdDate != nil { try container.encode(createdDate, forKey: .createdDate) } if modifiedDate != nil { try container.encode(modifiedDate, forKey: .modifiedDate) } if companyIds.count > 0 { try container.encode(companyIds, forKey: .companyIds) } if criteria.count > 0 { try container.encode(criteria, forKey: .criteria) } if applyToAllCompanies != nil { try container.encode(applyToAllCompanies, forKey: .applyToAllCompanies) } } } public class Country : BaseModel { // @References(typeof(Currency)) public var currencyId:String public var currencyInfo:Currency // @Required() public var name:String? public var culture:String public var timeZone:String public var modifiedDate:Date? // @Required() public var id:String? required public init(){ super.init() } private enum CodingKeys : String, CodingKey { case currencyId case currencyInfo case name case culture case timeZone case modifiedDate case id } required public init(from decoder: Decoder) throws { try super.init(from: decoder) let container = try decoder.container(keyedBy: CodingKeys.self) currencyId = try container.decodeIfPresent(String.self, forKey: .currencyId) currencyInfo = try container.decodeIfPresent(Currency.self, forKey: .currencyInfo) name = try container.decodeIfPresent(String.self, forKey: .name) culture = try container.decodeIfPresent(String.self, forKey: .culture) timeZone = try container.decodeIfPresent(String.self, forKey: .timeZone) modifiedDate = try container.decodeIfPresent(Date.self, forKey: .modifiedDate) id = try container.decodeIfPresent(String.self, forKey: .id) } public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) if currencyId != nil { try container.encode(currencyId, forKey: .currencyId) } if currencyInfo != nil { try container.encode(currencyInfo, forKey: .currencyInfo) } if name != nil { try container.encode(name, forKey: .name) } if culture != nil { try container.encode(culture, forKey: .culture) } if timeZone != nil { try container.encode(timeZone, forKey: .timeZone) } if modifiedDate != nil { try container.encode(modifiedDate, forKey: .modifiedDate) } if id != nil { try container.encode(id, forKey: .id) } } } public class Currency : BaseModel { // @Required() public var name:String? // @Required() public var currencySign:String? // @Required() public var active:Bool? public var modifiedDate:Date? // @Required() public var id:String? required public init(){ super.init() } private enum CodingKeys : String, CodingKey { case name case currencySign case active case modifiedDate case id } required public init(from decoder: Decoder) throws { try super.init(from: decoder) let container = try decoder.container(keyedBy: CodingKeys.self) name = try container.decodeIfPresent(String.self, forKey: .name) currencySign = try container.decodeIfPresent(String.self, forKey: .currencySign) active = try container.decodeIfPresent(Bool.self, forKey: .active) modifiedDate = try container.decodeIfPresent(Date.self, forKey: .modifiedDate) id = try container.decodeIfPresent(String.self, forKey: .id) } public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) if name != nil { try container.encode(name, forKey: .name) } if currencySign != nil { try container.encode(currencySign, forKey: .currencySign) } if active != nil { try container.encode(active, forKey: .active) } if modifiedDate != nil { try container.encode(modifiedDate, forKey: .modifiedDate) } if id != nil { try container.encode(id, forKey: .id) } } } public enum IncentiveRecurrenceFrequency : Int, Codable { case OneTime = 1 case Weekly = 2 case Monthly = 3 } public class IncentiveCriteriaDto : Codable { public var criteriaType:CriteriaType public var value:String public var invertCondition:Bool required public init(){} } public class LicenseTypeQueryResponse : Codable { /** * The license type id */ // @ApiMember(Description="The license type id") public var id:Int /** * The license type name */ // @ApiMember(Description="The license type name") public var name:String /** * The license type description */ // @ApiMember(Description="The license type description") public var Description:String /** * If the license type is not a standard license but instead an extra license option. An example would be sending new letter license. */ // @ApiMember(Description="If the license type is not a standard license but instead an extra license option. An example would be sending new letter license.") public var isExtraLicenseOption:Bool /** * The period of notice for the license in days. */ // @ApiMember(Description="The period of notice for the license in days.") public var periodOfNoticeDays:Int /** * The license items for the license type */ // @ApiMember(Description="The license items for the license type") public var items:[LicenseItemsResponse] = [] /** * The license prices in each country for the license type */ // @ApiMember(Description="The license prices in each country for the license type") public var prices:[LicensePriceResponse] = [] required public init(){} } public class CompanyIncentiveResponse : Codable { public var id:Int public var heading:String public var storageUrl:String public var successButtonText:String public var actionId:Int public var initialDelayInSeconds:Int public var maxDisplayCount:Int? public var validFrom:Date public var validTo:Date public var action:IncentiveActionResponse public var payload:String required public init(){} } public class IncentiveCriteria : BaseModel { public var id:Int public var incentiveId:Int public var criteriaType:CriteriaType public var value:String public var invertCondition:Bool public var createdDate:Date required public init(){ super.init() } private enum CodingKeys : String, CodingKey { case id case incentiveId case criteriaType case value case invertCondition case createdDate } required public init(from decoder: Decoder) throws { try super.init(from: decoder) let container = try decoder.container(keyedBy: CodingKeys.self) id = try container.decodeIfPresent(Int.self, forKey: .id) incentiveId = try container.decodeIfPresent(Int.self, forKey: .incentiveId) criteriaType = try container.decodeIfPresent(CriteriaType.self, forKey: .criteriaType) value = try container.decodeIfPresent(String.self, forKey: .value) invertCondition = try container.decodeIfPresent(Bool.self, forKey: .invertCondition) createdDate = try container.decodeIfPresent(Date.self, forKey: .createdDate) } public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) if id != nil { try container.encode(id, forKey: .id) } if incentiveId != nil { try container.encode(incentiveId, forKey: .incentiveId) } if criteriaType != nil { try container.encode(criteriaType, forKey: .criteriaType) } if value != nil { try container.encode(value, forKey: .value) } if invertCondition != nil { try container.encode(invertCondition, forKey: .invertCondition) } if createdDate != nil { try container.encode(createdDate, forKey: .createdDate) } } } public class IncentiveActionResponse : Codable { public var id:Int public var actionType:IncentiveActionType public var page:String public var segment:String public var element:String public var licenseTypeId:Int? public var suggestedLicenseToUpgrade:LicenseTypeQueryResponse required public init(){} } public class BaseModel : Codable { required public init(){} } public enum CriteriaType : String, Codable { case LicenseAvailability case SmsActivation case eAccountingActivation case CodeLockActivation case SocialActivation case OnlinePaymentActivation case FollowUpMessageActivation case RatingActivation } public class LicenseItemsResponse : Codable { public var id:Int public var name:String public var allowedItems:Int required public init(){} } public class LicensePriceResponse : Codable { public var licenseTypeId:Int public var countryId:String public var price:Int public var country:Country public var licensePlanId:Int required public init(){} } public enum IncentiveActionType : Int, Codable { case Upgrade = 1 case AddOn = 2 case Information = 3 } public enum Currency : Int, Codable { case SEK = 1 case EUR = 2 }