ScannerVision Web Server

<back to all web services

JsonRegisterClientRequest

Requires Authentication
import Foundation
import ServiceStack

public class JsonRegisterClientRequest : JsonRequestDto
{
    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 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 JsonRegisterClientResponse : JsonDto
{
    public var result:RegistrationResult
    public var errorMessage:String
    public var clientRegistrationCode:String

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

    private enum CodingKeys : String, CodingKey {
        case result
        case errorMessage
        case clientRegistrationCode
    }

    required public init(from decoder: Decoder) throws {
        try super.init(from: decoder)
        let container = try decoder.container(keyedBy: CodingKeys.self)
        result = try container.decodeIfPresent(RegistrationResult.self, forKey: .result)
        errorMessage = try container.decodeIfPresent(String.self, forKey: .errorMessage)
        clientRegistrationCode = try container.decodeIfPresent(String.self, forKey: .clientRegistrationCode)
    }

    public override func encode(to encoder: Encoder) throws {
        try super.encode(to: encoder)
        var container = encoder.container(keyedBy: CodingKeys.self)
        if result != nil { try container.encode(result, forKey: .result) }
        if errorMessage != nil { try container.encode(errorMessage, forKey: .errorMessage) }
        if clientRegistrationCode != nil { try container.encode(clientRegistrationCode, forKey: .clientRegistrationCode) }
    }
}

public enum RegistrationResult : String, Codable
{
    case Success
    case ClientCodeNotFound
    case ClientAlreadyRegistered
    case Error
}


Swift JsonRegisterClientRequest DTOs

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

HTTP + XML

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

POST /xml/reply/JsonRegisterClientRequest HTTP/1.1 
Host: buildmax.org 
Accept: application/xml
Content-Type: application/xml
Content-Length: length

<JsonRegisterClientRequest xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/ScannerVision.WebService.Json.Dto">
  <ClientCode>String</ClientCode>
  <ClientRegistrationCode>String</ClientRegistrationCode>
  <Token>String</Token>
</JsonRegisterClientRequest>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<JsonRegisterClientResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/ScannerVision.WebService.Json.Dto">
  <ClientRegistrationCode>String</ClientRegistrationCode>
  <ErrorMessage>String</ErrorMessage>
  <Result>Success</Result>
</JsonRegisterClientResponse>