ScannerVision Web Server

<back to all web services

JsonBrowsePicklistRequest

Requires Authentication
import Foundation
import ServiceStack

public class JsonBrowsePicklistRequest : JsonBrowseRequest
{
    public var templateGuid:String
    public var picklistGuid:String
    public var answers:[String:String] = [:]

    required public init(){ super.init() }

    private enum CodingKeys : String, CodingKey {
        case templateGuid
        case picklistGuid
        case answers
    }

    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)
        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 templateGuid != nil { try container.encode(templateGuid, forKey: .templateGuid) }
        if picklistGuid != nil { try container.encode(picklistGuid, forKey: .picklistGuid) }
        if answers.count > 0 { try container.encode(answers, forKey: .answers) }
    }
}

public class JsonBrowseRequest : JsonRequestDto
{
    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 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 JsonBrowseResponse : Codable
{
    public var path:String
    public var folders:[String] = []

    required public init(){}
}


Swift JsonBrowsePicklistRequest DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv

HTTP + JSV

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /jsv/reply/JsonBrowsePicklistRequest HTTP/1.1 
Host: buildmax.org 
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length

{
	TemplateGuid: String,
	PicklistGuid: String,
	Path: String,
	ClientCode: String,
	ClientRegistrationCode: String,
	Token: String
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	Path: String,
	Folders: 
	[
		String
	]
}