import Foundation
import ServiceStack
public class JsonVpdLicensedRequest : JsonRequestDto
{
public var clientHostName:String
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case clientHostName
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
clientHostName = try container.decodeIfPresent(String.self, forKey: .clientHostName)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if clientHostName != nil { try container.encode(clientHostName, forKey: .clientHostName) }
}
}
public class JsonRequestDto : JsonDto
{
public var clientCode:String
public var clientRegistrationCode:String
public var token:String
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case clientCode
case clientRegistrationCode
case token
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
clientCode = try container.decodeIfPresent(String.self, forKey: .clientCode)
clientRegistrationCode = try container.decodeIfPresent(String.self, forKey: .clientRegistrationCode)
token = try container.decodeIfPresent(String.self, forKey: .token)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if clientCode != nil { try container.encode(clientCode, forKey: .clientCode) }
if clientRegistrationCode != nil { try container.encode(clientRegistrationCode, forKey: .clientRegistrationCode) }
if token != nil { try container.encode(token, forKey: .token) }
}
}
public class JsonDto : Codable
{
required public init(){}
}
public class JsonVpdLicensedResponse : JsonDto
{
public var isLicensed:Bool
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case isLicensed
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
isLicensed = try container.decodeIfPresent(Bool.self, forKey: .isLicensed)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if isLicensed != nil { try container.encode(isLicensed, forKey: .isLicensed) }
}
}
Swift JsonVpdLicensedRequest DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .csv suffix or ?format=csv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /csv/reply/JsonVpdLicensedRequest HTTP/1.1
Host: buildmax.org
Accept: text/csv
Content-Type: text/csv
Content-Length: length
{"ClientHostName":"String","ClientCode":"String","ClientRegistrationCode":"String","Token":"String"}
HTTP/1.1 200 OK
Content-Type: text/csv
Content-Length: length
{"IsLicensed":false}