| All Verbs | /{Brand}/browse/{BrowseType}/ | ||
|---|---|---|---|
| All Verbs | /{Brand}/browse/{BrowseType}/ | ||
| All Verbs | /{Brand}/browse/{BrowseType}/{Path} | ||
| All Verbs | /{Brand}/browse/{BrowseType}/{Path} |
import Foundation
import ServiceStack
public class BrowsePicklistRequest : BrowseRequest
{
public var picklistGuid:String
public var answers:[String:String] = [:]
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case picklistGuid
case answers
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
picklistGuid = try container.decodeIfPresent(String.self, forKey: .picklistGuid)
answers = try container.decodeIfPresent([String:String].self, forKey: .answers) ?? [:]
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if picklistGuid != nil { try container.encode(picklistGuid, forKey: .picklistGuid) }
if answers.count > 0 { try container.encode(answers, forKey: .answers) }
}
}
public class BrowseRequest : RequestBase
{
public var path:String
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case path
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
path = try container.decodeIfPresent(String.self, forKey: .path)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if path != nil { try container.encode(path, forKey: .path) }
}
}
public class RequestBase : DtoBase
{
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 DtoBase : Codable
{
public var brand:Brand
required public init(){}
}
public enum Brand : String, Codable
{
case Desktop
case Hp
case Kyocera
case NeaScan
case Samsung
case FujiXerox
case Ta
case Utax
case Epson
case ScanFront400
case Sharp
case Ricoh
case FujiFilm
}
Swift BrowsePicklistRequest DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /{Brand}/browse/{BrowseType}/ HTTP/1.1
Host: buildmax.org
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length
{
PicklistGuid: String,
Path: String,
Brand: Desktop
}