| GET | /{Brand}/browse/{TemplateGuid}/{QuestionGuid}/{PicklistGuid}/ | ||
|---|---|---|---|
| GET | /{Brand}/browse/{TemplateGuid}/{QuestionGuid}/{PicklistGuid}/search/{SearchTerm} | ||
| GET | /{Brand}/browse/{TemplateGuid}/{QuestionGuid}/{PicklistGuid}/{Path} | ||
| GET | /{Brand}/browse/{TemplateGuid}/{QuestionGuid}/{PicklistGuid}/{Path}/search/{SearchTerm} | ||
| 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 WebClientPicklistRequest : BrowsePicklistRequest
{
public var templateGuid:String
public var questionGuid:String
public var searchTerm:String
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case templateGuid
case questionGuid
case searchTerm
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
templateGuid = try container.decodeIfPresent(String.self, forKey: .templateGuid)
questionGuid = try container.decodeIfPresent(String.self, forKey: .questionGuid)
searchTerm = try container.decodeIfPresent(String.self, forKey: .searchTerm)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if templateGuid != nil { try container.encode(templateGuid, forKey: .templateGuid) }
if questionGuid != nil { try container.encode(questionGuid, forKey: .questionGuid) }
if searchTerm != nil { try container.encode(searchTerm, forKey: .searchTerm) }
}
}
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 WebClientPicklistRequest 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 /{Brand}/browse/{BrowseType}/ HTTP/1.1
Host: buildmax.org
Accept: application/json
Content-Type: application/json
Content-Length: length
{"TemplateGuid":"String","QuestionGuid":"String","SearchTerm":"String","PicklistGuid":"String","Path":"String","Brand":"Desktop"}