/* Options: Date: 2024-11-21 12:00:59 SwiftVersion: 5.0 Version: 8.23 Tip: To override a DTO option, remove "//" prefix before updating BaseUrl: https://api.bokamera.se //BaseClass: //AddModelExtensions: True //AddServiceStackTypes: True IncludeTypes: NewsItemQuery.* //ExcludeTypes: //ExcludeGenericBaseTypes: False //AddResponseStatus: False //AddImplicitVersion: //AddDescriptionAsComments: True //InitializeCollections: True //TreatTypesAsStrings: //DefaultImports: Foundation,ServiceStack */ import Foundation import ServiceStack // @Route("/news", "GET") public class NewsItemQuery : QueryDb2, IReturn { public typealias Return = QueryResponse /** * Enter the company you want to see news for, if blank and you are an admin, your company id will be used */ // @ApiMember(Description="Enter the company you want to see news for, if blank and you are an admin, your company id will be used", ParameterType="query") public var companyId:String? /** * Enter the From Date you want to see news from, only allowed if admin */ // @ApiMember(DataType="dateTime", Description="Enter the From Date you want to see news from, only allowed if admin", ParameterType="query") public var from:Date? /** * Enter the To Date you want to see news to, only allowed if admin */ // @ApiMember(DataType="dateTime", Description="Enter the To Date you want to see news to, only allowed if admin", ParameterType="query") public var to:Date? /** * Use this parameter if you want to only show active news */ // @ApiMember(DataType="boolean", Description="Use this parameter if you want to only show active news") public var active:Bool? /** * The homeage sitepath. */ // @ApiMember(Description="The homeage sitepath.") public var sitePath:String /** * If you want to remove Html tags from newsbody and show as plain text. */ // @ApiMember(Description="If you want to remove Html tags from newsbody and show as plain text.") public var plainText:Bool required public init(){ super.init() } private enum CodingKeys : String, CodingKey { case companyId case from case to case active case sitePath case plainText } required public init(from decoder: Decoder) throws { try super.init(from: decoder) let container = try decoder.container(keyedBy: CodingKeys.self) companyId = try container.decodeIfPresent(String.self, forKey: .companyId) from = try container.decodeIfPresent(Date.self, forKey: .from) to = try container.decodeIfPresent(Date.self, forKey: .to) active = try container.decodeIfPresent(Bool.self, forKey: .active) sitePath = try container.decodeIfPresent(String.self, forKey: .sitePath) plainText = try container.decodeIfPresent(Bool.self, forKey: .plainText) } public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) if companyId != nil { try container.encode(companyId, forKey: .companyId) } if from != nil { try container.encode(from, forKey: .from) } if to != nil { try container.encode(to, forKey: .to) } if active != nil { try container.encode(active, forKey: .active) } if sitePath != nil { try container.encode(sitePath, forKey: .sitePath) } if plainText != nil { try container.encode(plainText, forKey: .plainText) } } } public protocol IInterval { var from:Date { get set } var to:Date { get set } } public class NewsItem : BaseModel, IInterval { // @Ignore() public var active:Bool // @Required() public var companyId:String? public var id:Int // @Required() public var heading:String? // @Required() public var body:String? public var imageUrl:String // @Required() public var updated:Date? // @Required() public var created:Date? public var modifiedDate:Date? // @Required() public var from:Date? // @Required() public var to:Date? required public init(){ super.init() } private enum CodingKeys : String, CodingKey { case active case companyId case id case heading case body case imageUrl case updated case created case modifiedDate case from case to } required public init(from decoder: Decoder) throws { try super.init(from: decoder) let container = try decoder.container(keyedBy: CodingKeys.self) active = try container.decodeIfPresent(Bool.self, forKey: .active) companyId = try container.decodeIfPresent(String.self, forKey: .companyId) id = try container.decodeIfPresent(Int.self, forKey: .id) heading = try container.decodeIfPresent(String.self, forKey: .heading) body = try container.decodeIfPresent(String.self, forKey: .body) imageUrl = try container.decodeIfPresent(String.self, forKey: .imageUrl) updated = try container.decodeIfPresent(Date.self, forKey: .updated) created = try container.decodeIfPresent(Date.self, forKey: .created) modifiedDate = try container.decodeIfPresent(Date.self, forKey: .modifiedDate) from = try container.decodeIfPresent(Date.self, forKey: .from) to = try container.decodeIfPresent(Date.self, forKey: .to) } public override func encode(to encoder: Encoder) throws { try super.encode(to: encoder) var container = encoder.container(keyedBy: CodingKeys.self) if active != nil { try container.encode(active, forKey: .active) } if companyId != nil { try container.encode(companyId, forKey: .companyId) } if id != nil { try container.encode(id, forKey: .id) } if heading != nil { try container.encode(heading, forKey: .heading) } if body != nil { try container.encode(body, forKey: .body) } if imageUrl != nil { try container.encode(imageUrl, forKey: .imageUrl) } if updated != nil { try container.encode(updated, forKey: .updated) } if created != nil { try container.encode(created, forKey: .created) } if modifiedDate != nil { try container.encode(modifiedDate, forKey: .modifiedDate) } if from != nil { try container.encode(from, forKey: .from) } if to != nil { try container.encode(to, forKey: .to) } } } public class BaseModel : Codable { required public init(){} } public class NewsItemQueryResponse : Codable { /** * The news item id */ // @ApiMember(Description="The news item id") public var id:Int /** * Heading of the news item */ // @ApiMember(Description="Heading of the news item") public var heading:String /** * Body of the news item */ // @ApiMember(Description="Body of the news item") public var body:String /** * Url to a image associated with the news */ // @ApiMember(Description="Url to a image associated with the news") public var imageUrl:Uri /** * The timestamp from which the newsitem should be visible from */ // @ApiMember(Description="The timestamp from which the newsitem should be visible from", IsRequired=true) public var from:Date /** * The timestamp to which the newsitem should be visible to */ // @ApiMember(Description="The timestamp to which the newsitem should be visible to", IsRequired=true) public var to:Date /** * The timestamp when news was created */ // @ApiMember(Description="The timestamp when news was created", IsRequired=true) public var created:Date public var responseStatus:ResponseStatus required public init(){} }