import Foundation
import ServiceStack
public class JsonMetadataUploadRequest : JsonRequestDto
{
public var uploadFileName:String
public var originalFileName:String
public var templateGuid:String
public var clientIpAddress:String
public var clientGuid:String
public var clientName:String
public var clientId:String
public var clientSerialNumber:String
public var userName:String
public var userEmail:String
public var userHomeFolder:String
public var templateQuestions:[String:String] = [:]
public var globalQuestions:[String:String] = [:]
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case uploadFileName
case originalFileName
case templateGuid
case clientIpAddress
case clientGuid
case clientName
case clientId
case clientSerialNumber
case userName
case userEmail
case userHomeFolder
case templateQuestions
case globalQuestions
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
uploadFileName = try container.decodeIfPresent(String.self, forKey: .uploadFileName)
originalFileName = try container.decodeIfPresent(String.self, forKey: .originalFileName)
templateGuid = try container.decodeIfPresent(String.self, forKey: .templateGuid)
clientIpAddress = try container.decodeIfPresent(String.self, forKey: .clientIpAddress)
clientGuid = try container.decodeIfPresent(String.self, forKey: .clientGuid)
clientName = try container.decodeIfPresent(String.self, forKey: .clientName)
clientId = try container.decodeIfPresent(String.self, forKey: .clientId)
clientSerialNumber = try container.decodeIfPresent(String.self, forKey: .clientSerialNumber)
userName = try container.decodeIfPresent(String.self, forKey: .userName)
userEmail = try container.decodeIfPresent(String.self, forKey: .userEmail)
userHomeFolder = try container.decodeIfPresent(String.self, forKey: .userHomeFolder)
templateQuestions = try container.decodeIfPresent([String:String].self, forKey: .templateQuestions) ?? [:]
globalQuestions = try container.decodeIfPresent([String:String].self, forKey: .globalQuestions) ?? [:]
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if uploadFileName != nil { try container.encode(uploadFileName, forKey: .uploadFileName) }
if originalFileName != nil { try container.encode(originalFileName, forKey: .originalFileName) }
if templateGuid != nil { try container.encode(templateGuid, forKey: .templateGuid) }
if clientIpAddress != nil { try container.encode(clientIpAddress, forKey: .clientIpAddress) }
if clientGuid != nil { try container.encode(clientGuid, forKey: .clientGuid) }
if clientName != nil { try container.encode(clientName, forKey: .clientName) }
if clientId != nil { try container.encode(clientId, forKey: .clientId) }
if clientSerialNumber != nil { try container.encode(clientSerialNumber, forKey: .clientSerialNumber) }
if userName != nil { try container.encode(userName, forKey: .userName) }
if userEmail != nil { try container.encode(userEmail, forKey: .userEmail) }
if userHomeFolder != nil { try container.encode(userHomeFolder, forKey: .userHomeFolder) }
if templateQuestions.count > 0 { try container.encode(templateQuestions, forKey: .templateQuestions) }
if globalQuestions.count > 0 { try container.encode(globalQuestions, forKey: .globalQuestions) }
}
}
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 JsonMetadataUploadResponse : JsonDto
{
public var templateGuid:String
public var inError:Bool
public var errorMessage:String
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case templateGuid
case inError
case errorMessage
}
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)
inError = try container.decodeIfPresent(Bool.self, forKey: .inError)
errorMessage = try container.decodeIfPresent(String.self, forKey: .errorMessage)
}
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 inError != nil { try container.encode(inError, forKey: .inError) }
if errorMessage != nil { try container.encode(errorMessage, forKey: .errorMessage) }
}
}
Swift JsonMetadataUploadRequest 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 /jsonl/reply/JsonMetadataUploadRequest HTTP/1.1
Host: buildmax.org
Accept: text/jsonl
Content-Type: text/jsonl
Content-Length: length
{"UploadFileName":"String","OriginalFileName":"String","TemplateGuid":"String","ClientIpAddress":"String","ClientGuid":"String","ClientName":"String","ClientId":"String","ClientSerialNumber":"String","UserName":"String","UserEmail":"String","UserHomeFolder":"String","ClientCode":"String","ClientRegistrationCode":"String","Token":"String"}
HTTP/1.1 200 OK
Content-Type: text/jsonl
Content-Length: length
{"TemplateGuid":"String","InError":false,"ErrorMessage":"String"}