| GET, POST | /{Brand}/templates | ||
|---|---|---|---|
| All Verbs | /kyocera/{Template*} | ||
| All Verbs | /ta/{Template*} | ||
| All Verbs | /utax/{Template*} |
import Foundation
import ServiceStack
public class GetTemplates : RequestBase
{
public var template:String
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case template
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
template = try container.decodeIfPresent(String.self, forKey: .template)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if template != nil { try container.encode(template, forKey: .template) }
}
}
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
}
public class GetTemplatesResponse : ResponseBase
{
public var templates:IList<IClientTemplate>
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case templates
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
templates = try container.decodeIfPresent(IList<IClientTemplate>.self, forKey: .templates)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if templates != nil { try container.encode(templates, forKey: .templates) }
}
}
public class ResponseBase : DtoBase
{
public var selectedUiLanguage:String
public var svSession:String
public var title:String
public var pageTip:String
public var newBrowser:Bool
public var scanFront400TA:Bool
public var scanFront400UTAX:Bool
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case selectedUiLanguage
case svSession
case title
case pageTip
case newBrowser
case scanFront400TA
case scanFront400UTAX
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
selectedUiLanguage = try container.decodeIfPresent(String.self, forKey: .selectedUiLanguage)
svSession = try container.decodeIfPresent(String.self, forKey: .svSession)
title = try container.decodeIfPresent(String.self, forKey: .title)
pageTip = try container.decodeIfPresent(String.self, forKey: .pageTip)
newBrowser = try container.decodeIfPresent(Bool.self, forKey: .newBrowser)
scanFront400TA = try container.decodeIfPresent(Bool.self, forKey: .scanFront400TA)
scanFront400UTAX = try container.decodeIfPresent(Bool.self, forKey: .scanFront400UTAX)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if selectedUiLanguage != nil { try container.encode(selectedUiLanguage, forKey: .selectedUiLanguage) }
if svSession != nil { try container.encode(svSession, forKey: .svSession) }
if title != nil { try container.encode(title, forKey: .title) }
if pageTip != nil { try container.encode(pageTip, forKey: .pageTip) }
if newBrowser != nil { try container.encode(newBrowser, forKey: .newBrowser) }
if scanFront400TA != nil { try container.encode(scanFront400TA, forKey: .scanFront400TA) }
if scanFront400UTAX != nil { try container.encode(scanFront400UTAX, forKey: .scanFront400UTAX) }
}
}
public protocol IClientTemplate
{
var Description:String { get set }
var icon:[UInt8] { get set }
//modificationInfo:ITemplateModificationInfo ignored. Swift doesn't support interface properties
var name:String { get set }
var questions:[IClientQuestion] { get set }
//template:ITemplate ignored. Swift doesn't support interface properties
var templateGuid:String { get set }
}
public protocol ITemplateModificationInfo
{
var guid:String { get set }
var templateModificationDateTime:Date { get set }
var iconModificationDateTime:Date { get set }
}
public protocol IClientQuestion : ITemplateQuestion
{
var questionGuid:String { get set }
var valueDisplayed:String { get set }
var valueReturned:String { get set }
var answered:Bool { get set }
var regexMatches:Bool { get set }
var regexHint:String { get set }
}
public protocol ITemplate : IStatus
{
var templateVersion:String { get set }
var scannerVisionVersion:String { get set }
var guid:String { get set }
var beginScript:String { get set }
var endScript:String { get set }
var templateType:TemplateType { get set }
//general:IGeneral ignored. Swift doesn't support interface properties
//capture:ICapture ignored. Swift doesn't support interface properties
//xmlMetadataImport:IXmlMetadataImport ignored. Swift doesn't support interface properties
//notifications:INotifications ignored. Swift doesn't support interface properties
//validator:IValidator ignored. Swift doesn't support interface properties
}
public enum TemplateType : String, Codable
{
case Workflow
case FreeForm
}
public protocol IGeneral : IInterface
{
var name:String { get set }
var Description:String { get set }
var icon:String { get set }
//schedule:ITemplateSchedule ignored. Swift doesn't support interface properties
//rejection:IRejection ignored. Swift doesn't support interface properties
//badDocumentRejection:IBadDocumentRejection ignored. Swift doesn't support interface properties
var pdfLoadResolution:PdfLoadResolution? { get set }
}
public protocol ITemplateSchedule : IInterface
{
var time:TimeInterval? { get set }
var endTime:TimeInterval? { get set }
var noEndTime:Bool? { get set }
var type:TemplateScheduleType? { get set }
}
public enum TemplateScheduleType : String, Codable
{
case Interval
case Fixed
}
public protocol IRejection
{
var rejectAfter:Int? { get set }
var rejectionPath:String { get set }
//shareCredentials:ICredentials ignored. Swift doesn't support interface properties
}
public protocol ICredentials : IInterface
{
var username:String { get set }
var password:String { get set }
}
public protocol IBadDocumentRejection : IStatus
{
var rejectionPath:String { get set }
//shareCredentials:ICredentials ignored. Swift doesn't support interface properties
}
public enum PdfLoadResolution : String, Codable
{
case Default
case Dpi100
case Dpi150
case Dpi200
case Dpi300
case Dpi400
case Dpi500
case Dpi600
}
public protocol ICapture : IInterface
{
var captureSources:ReadOnlyCollection<ICaptureSource> { get set }
}
public protocol ICaptureSource : IStatus
{
}
public protocol IXmlMetadataImport : IStatus
{
var sampleDocumentName:String { get set }
var tagMappings:ReadOnlyCollection<IXmlMetadataImportTagMapping> { get set }
var namespaceMappings:ReadOnlyCollection<IXmlMetadataImportNamespaceMapping> { get set }
}
public protocol IXmlMetadataImportTagMapping : IInterface
{
var xPathExpression:String { get set }
//metadata:IStringMetadata ignored. Swift doesn't support interface properties
}
public protocol IStringMetadata : IMetadata
{
var isSecure:Bool? { get set }
var sampleValue:String { get set }
var value:String { get set }
}
public protocol IXmlMetadataImportNamespaceMapping : IInterface
{
var `prefix`:String { get set }
var name:String { get set }
}
public protocol INotifications : IStatus
{
var notifications:ReadOnlyCollection<INotification> { get set }
}
public protocol INotification : IStatus
{
var Description:String { get set }
var to:String { get set }
var subject:String { get set }
var body:String { get set }
var cc:String { get set }
var bcc:String { get set }
var notificationType:NotificationType? { get set }
}
public enum NotificationType : String, Codable
{
case FailureOnly
case SuccessOnly
case Always
}
public protocol IValidator
{
//validationErrors:IValidationErrors ignored. Swift doesn't support interface properties
var isValid:Bool { get set }
}
public protocol IValidationErrors
{
var errors:ReadOnlyCollection<IValidationError> { get set }
}
public protocol IValidationError
{
var property:String { get set }
var errorMessage:String { get set }
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .other suffix or ?format=other
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /{Brand}/templates HTTP/1.1
Host: buildmax.org
Accept: text/jsonl
Content-Type: text/jsonl
Content-Length: length
{"Template":"String","Brand":"Desktop"}
HTTP/1.1 200 OK
Content-Type: text/jsonl
Content-Length: length
{Unable to show example output for type 'GetTemplatesResponse' using the custom 'other' filter}No parameterless constructor defined for this object.