ScannerVision Web Server

<back to all web services

GetJsonPicklistItems

Requires Authentication
import Foundation
import ServiceStack

public class GetJsonPicklistItems : JsonDto
{
    public var templateGuid:String
    public var guid:String
    public var answers:[String:String] = [:]

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

    private enum CodingKeys : String, CodingKey {
        case templateGuid
        case guid
        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)
        guid = try container.decodeIfPresent(String.self, forKey: .guid)
        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 guid != nil { try container.encode(guid, forKey: .guid) }
        if answers.count > 0 { try container.encode(answers, forKey: .answers) }
    }
}

public class JsonDto : Codable
{
    required public init(){}
}

public class JsonPicklistItemsResponse : JsonDto
{
    public var guid:String
    public var items:[JsonPicklistItem] = []

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

    private enum CodingKeys : String, CodingKey {
        case guid
        case items
    }

    required public init(from decoder: Decoder) throws {
        try super.init(from: decoder)
        let container = try decoder.container(keyedBy: CodingKeys.self)
        guid = try container.decodeIfPresent(String.self, forKey: .guid)
        items = try container.decodeIfPresent([JsonPicklistItem].self, forKey: .items) ?? []
    }

    public override func encode(to encoder: Encoder) throws {
        try super.encode(to: encoder)
        var container = encoder.container(keyedBy: CodingKeys.self)
        if guid != nil { try container.encode(guid, forKey: .guid) }
        if items.count > 0 { try container.encode(items, forKey: .items) }
    }
}

public class JsonPicklistItem : Codable
{
    public var key:String
    public var value:String

    required public init(){}
}


Swift GetJsonPicklistItems DTOs

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

HTTP + CSV

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

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

{"TemplateGuid":"String","Guid":"String"}
HTTP/1.1 200 OK
Content-Type: text/csv
Content-Length: length

{Unable to show example output for type 'JsonPicklistItemsResponse' using the custom 'csv' filter}No parameterless constructor defined for this object.