PUT,PATCH | /machines/{Id} |
---|
import Foundation
import ServiceStack
public class UpdateMachineRequest : PutPatchOperationTenanted<UpdateMachineResponse>
{
public var id:String?
public var name:String?
public var type:String?
public var manufacturedOn:Date?
public var location:String?
public var configuration:String?
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case id
case name
case type
case manufacturedOn
case location
case configuration
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
id = try container.decodeIfPresent(String.self, forKey: .id)
name = try container.decodeIfPresent(String.self, forKey: .name)
type = try container.decodeIfPresent(String.self, forKey: .type)
manufacturedOn = try container.decodeIfPresent(Date.self, forKey: .manufacturedOn)
location = try container.decodeIfPresent(String.self, forKey: .location)
configuration = try container.decodeIfPresent(String.self, forKey: .configuration)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if id != nil { try container.encode(id, forKey: .id) }
if name != nil { try container.encode(name, forKey: .name) }
if type != nil { try container.encode(type, forKey: .type) }
if manufacturedOn != nil { try container.encode(manufacturedOn, forKey: .manufacturedOn) }
if location != nil { try container.encode(location, forKey: .location) }
if configuration != nil { try container.encode(configuration, forKey: .configuration) }
}
}
public class PutPatchOperationTenanted<TResponse : Codable> : PutPatchOperationUnTenanted<TResponse>, ITenantedRequest
{
public var organisationId:String?
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case organisationId
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
organisationId = try container.decodeIfPresent(String.self, forKey: .organisationId)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if organisationId != nil { try container.encode(organisationId, forKey: .organisationId) }
}
}
public class PutPatchOperationUnTenanted<TResponse : Codable> : IPatch, IPut, Codable
{
required public init(){}
}
public class UpdateMachineResponse : Codable
{
public var responseStatus:ResponseStatus?
public var machine:Machine?
required public init(){}
}
public class Machine : IIdentifiableResource, Codable
{
public var name:String?
public var type:String?
public var manufacturedOn:Date?
public var location:String?
public var configuration:String?
public var id:String?
required public init(){}
}
Swift UpdateMachineRequest DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .json suffix or ?format=json
To embed the response in a jsonp callback, append ?callback=myCallback
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
PUT /machines/{Id} HTTP/1.1
Host: foundrystage-api-app.azurewebsites.net
Accept: application/json
Content-Type: application/json
Content-Length: length
{"id":"String","name":"String","type":"String","manufacturedOn":"0001-01-01","location":"String","configuration":"String","organisationId":"String"}
HTTP/1.1 200 OK Content-Type: application/json Content-Length: length {"responseStatus":{"errorCode":"String","message":"String","stackTrace":"String","errors":[{"errorCode":"String","fieldName":"String","message":"String","meta":{"String":"String"}}],"meta":{"String":"String"}},"machine":{"name":"String","type":"String","manufacturedOn":"0001-01-01","location":"String","configuration":"String","id":"String"}}