import Foundation
import ServiceStack
public class GetJsonTemplateInfos : JsonDto
{
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 JsonDto : Codable
{
required public init(){}
}
public class GetJsonTemplateInfosResponse : JsonDto
{
public var templateInfos:[JsonTemplateInfo] = []
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case templateInfos
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
templateInfos = try container.decodeIfPresent([JsonTemplateInfo].self, forKey: .templateInfos) ?? []
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if templateInfos.count > 0 { try container.encode(templateInfos, forKey: .templateInfos) }
}
}
public class JsonTemplateInfo : Codable
{
public var guid:String
public var templateModificationDate:Date
public var iconModificationDate:Date
required public init(){}
}
Swift GetJsonTemplateInfos DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .json suffix or ?format=json
To embed the response in a jsonp callback, append ?callback=myCallback
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /json/reply/GetJsonTemplateInfos HTTP/1.1
Host: buildmax.org
Accept: application/json
Content-Type: application/json
Content-Length: length
{}
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length
{"TemplateInfos":[{"Guid":"String","TemplateModificationDate":"\/Date(-62135596800000-0000)\/","IconModificationDate":"\/Date(-62135596800000-0000)\/"}]}