| POST | /{Brand}/scansettings/{TemplateGuid} |
|---|
import Foundation
import ServiceStack
public class ScanSettingsRequest : RequestBase
{
public var templateGuid:String
public var selectedColour:ScanColour
public var selectedOrientation:ScanOrientation
public var selectedResolution:ScanResolution
public var selectedSides:ScanSide
public var selectedSize:ScanSize
public var selectedSource:ScanSource
public var selectedType:ScanType
public var selectedScanContinuously:BoolSetting
public var selectedMixedSizes:BoolSetting
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case templateGuid
case selectedColour
case selectedOrientation
case selectedResolution
case selectedSides
case selectedSize
case selectedSource
case selectedType
case selectedScanContinuously
case selectedMixedSizes
}
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)
selectedColour = try container.decodeIfPresent(ScanColour.self, forKey: .selectedColour)
selectedOrientation = try container.decodeIfPresent(ScanOrientation.self, forKey: .selectedOrientation)
selectedResolution = try container.decodeIfPresent(ScanResolution.self, forKey: .selectedResolution)
selectedSides = try container.decodeIfPresent(ScanSide.self, forKey: .selectedSides)
selectedSize = try container.decodeIfPresent(ScanSize.self, forKey: .selectedSize)
selectedSource = try container.decodeIfPresent(ScanSource.self, forKey: .selectedSource)
selectedType = try container.decodeIfPresent(ScanType.self, forKey: .selectedType)
selectedScanContinuously = try container.decodeIfPresent(BoolSetting.self, forKey: .selectedScanContinuously)
selectedMixedSizes = try container.decodeIfPresent(BoolSetting.self, forKey: .selectedMixedSizes)
}
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 selectedColour != nil { try container.encode(selectedColour, forKey: .selectedColour) }
if selectedOrientation != nil { try container.encode(selectedOrientation, forKey: .selectedOrientation) }
if selectedResolution != nil { try container.encode(selectedResolution, forKey: .selectedResolution) }
if selectedSides != nil { try container.encode(selectedSides, forKey: .selectedSides) }
if selectedSize != nil { try container.encode(selectedSize, forKey: .selectedSize) }
if selectedSource != nil { try container.encode(selectedSource, forKey: .selectedSource) }
if selectedType != nil { try container.encode(selectedType, forKey: .selectedType) }
if selectedScanContinuously != nil { try container.encode(selectedScanContinuously, forKey: .selectedScanContinuously) }
if selectedMixedSizes != nil { try container.encode(selectedMixedSizes, forKey: .selectedMixedSizes) }
}
}
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 enum ScanColour : String, Codable
{
case BlackAndWhite
case Greyscale
case Colour
case Auto
}
public enum ScanOrientation : String, Codable
{
case Portrait
case Landscape
}
public enum ScanResolution : String, Codable
{
case Dpi100
case Dpi200
case Dpi300
case Dpi400
case Dpi600
}
public enum ScanSide : String, Codable
{
case Simplex
case Duplex
}
public enum ScanSize : String, Codable
{
case Auto
case A3
case A4
case A5
case B4
case B5
case Letter
case Legal
case Executive
case Folio
case AutoLong
case A4R
case A5R
case A6R
case B6R
}
public enum ScanSource : String, Codable
{
case Adf
case Glass
case Auto
}
public enum ScanType : String, Codable
{
case Text
case Photo
case TextAndPhoto
}
public enum BoolSetting : String, Codable
{
case True
case False
}
public class GetTemplateResponse : ScanResponseBase
{
public var serverAddress:String
public var serverPort:Int
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case serverAddress
case serverPort
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
serverAddress = try container.decodeIfPresent(String.self, forKey: .serverAddress)
serverPort = try container.decodeIfPresent(Int.self, forKey: .serverPort)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if serverAddress != nil { try container.encode(serverAddress, forKey: .serverAddress) }
if serverPort != nil { try container.encode(serverPort, forKey: .serverPort) }
}
}
public class ScanResponseBase : ResponseBase
{
//template:IClientTemplate ignored. Swift doesn't support interface properties
public var globalQuestions:[IClientQuestion] = []
public var canEnableScanButton:Bool
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case template
case globalQuestions
case canEnableScanButton
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
template = try container.decodeIfPresent(IClientTemplate.self, forKey: .template)
globalQuestions = try container.decodeIfPresent([IClientQuestion].self, forKey: .globalQuestions) ?? []
canEnableScanButton = try container.decodeIfPresent(Bool.self, forKey: .canEnableScanButton)
}
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) }
if globalQuestions.count > 0 { try container.encode(globalQuestions, forKey: .globalQuestions) }
if canEnableScanButton != nil { try container.encode(canEnableScanButton, forKey: .canEnableScanButton) }
}
}
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 }
}
Swift ScanSettingsRequest DTOs
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}/scansettings/{TemplateGuid} HTTP/1.1
Host: buildmax.org
Accept: text/jsonl
Content-Type: text/jsonl
Content-Length: length
{"TemplateGuid":"String","SelectedColour":"BlackAndWhite","SelectedOrientation":"Portrait","SelectedResolution":"Dpi100","SelectedSides":"Simplex","SelectedSize":"Auto","SelectedSource":"Adf","SelectedType":"Text","SelectedScanContinuously":"True","SelectedMixedSizes":"True","Brand":"Desktop"}
HTTP/1.1 200 OK
Content-Type: text/jsonl
Content-Length: length
{Unable to show example output for type 'GetTemplateResponse' using the custom 'other' filter}No parameterless constructor defined for this object.