GET | /user/{supplieruserid}/purchaseorder/{purchaseorderid} |
---|
import Foundation
import ServiceStack
public class BrowsePurchaseOrder : PurchaseOrderBase, IGet
{
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 PurchaseOrderBase : Codable
{
public var purchaseOrderId:Int
public var supplierUserId:Int
required public init(){}
}
public class BrowsePurchaseOrderResponse : ResponseBase
{
public var purchaseOrder:PurchaseOrderDetails
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case purchaseOrder
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
purchaseOrder = try container.decodeIfPresent(PurchaseOrderDetails.self, forKey: .purchaseOrder)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if purchaseOrder != nil { try container.encode(purchaseOrder, forKey: .purchaseOrder) }
}
}
public class ResponseBase : Codable
{
public var responseStatus:ResponseStatus
required public init(){}
}
public class PurchaseOrderDetails : ModifyPurchaseOrderBase
{
public var id:Int
public var cancellationDateTime:Date?
public var isCancelled:Bool
public var meta:[String:String] = [:]
public var tenderUserId:Int?
public var tenderId:Int?
public var userId:Int?
public var purchaseOrderVersions:[PurchaseOrderVersionSimple] = []
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case id
case cancellationDateTime
case isCancelled
case meta
case tenderUserId
case tenderId
case userId
case purchaseOrderVersions
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
id = try container.decodeIfPresent(Int.self, forKey: .id)
cancellationDateTime = try container.decodeIfPresent(Date.self, forKey: .cancellationDateTime)
isCancelled = try container.decodeIfPresent(Bool.self, forKey: .isCancelled)
meta = try container.decodeIfPresent([String:String].self, forKey: .meta) ?? [:]
tenderUserId = try container.decodeIfPresent(Int.self, forKey: .tenderUserId)
tenderId = try container.decodeIfPresent(Int.self, forKey: .tenderId)
userId = try container.decodeIfPresent(Int.self, forKey: .userId)
purchaseOrderVersions = try container.decodeIfPresent([PurchaseOrderVersionSimple].self, forKey: .purchaseOrderVersions) ?? []
}
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 cancellationDateTime != nil { try container.encode(cancellationDateTime, forKey: .cancellationDateTime) }
if isCancelled != nil { try container.encode(isCancelled, forKey: .isCancelled) }
if meta.count > 0 { try container.encode(meta, forKey: .meta) }
if tenderUserId != nil { try container.encode(tenderUserId, forKey: .tenderUserId) }
if tenderId != nil { try container.encode(tenderId, forKey: .tenderId) }
if userId != nil { try container.encode(userId, forKey: .userId) }
if purchaseOrderVersions.count > 0 { try container.encode(purchaseOrderVersions, forKey: .purchaseOrderVersions) }
}
}
public class ModifyPurchaseOrderBase : ModifyRequestBase
{
public var purchaseOrderIdentifier:String
public var tenderUserId:Int?
public var supplierUserId:Int
public var buyer:String
public var subject:String
public var confirmationDeadline:Date
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case purchaseOrderIdentifier
case tenderUserId
case supplierUserId
case buyer
case subject
case confirmationDeadline
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
purchaseOrderIdentifier = try container.decodeIfPresent(String.self, forKey: .purchaseOrderIdentifier)
tenderUserId = try container.decodeIfPresent(Int.self, forKey: .tenderUserId)
supplierUserId = try container.decodeIfPresent(Int.self, forKey: .supplierUserId)
buyer = try container.decodeIfPresent(String.self, forKey: .buyer)
subject = try container.decodeIfPresent(String.self, forKey: .subject)
confirmationDeadline = try container.decodeIfPresent(Date.self, forKey: .confirmationDeadline)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if purchaseOrderIdentifier != nil { try container.encode(purchaseOrderIdentifier, forKey: .purchaseOrderIdentifier) }
if tenderUserId != nil { try container.encode(tenderUserId, forKey: .tenderUserId) }
if supplierUserId != nil { try container.encode(supplierUserId, forKey: .supplierUserId) }
if buyer != nil { try container.encode(buyer, forKey: .buyer) }
if subject != nil { try container.encode(subject, forKey: .subject) }
if confirmationDeadline != nil { try container.encode(confirmationDeadline, forKey: .confirmationDeadline) }
}
}
public class ModifyRequestBase : IConcurrencyStamp, Codable
{
public var concurrencyStamp:String
required public init(){}
}
public class PurchaseOrderVersionSimple : Codable
{
public var id:Int
public var purchaseOrderId:Int
public var supplierUserId:Int
public var version:Int
public var isViewed:Bool
public var status:ReviewStatus
required public init(){}
}
public enum ReviewStatus : Int, Codable
{
case Draft = 0
case Commented = 1
case Accepted = 2
}
Swift BrowsePurchaseOrder DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
GET /user/{supplieruserid}/purchaseorder/{purchaseorderid} HTTP/1.1 Host: szallitoiportal-be.veolia.hu Accept: text/jsv
HTTP/1.1 200 OK Content-Type: text/jsv Content-Length: length { PurchaseOrder: { Id: 0, CancellationDateTime: 0001-01-01, IsCancelled: False, Meta: { String: String }, TenderUserId: 0, TenderId: 0, UserId: 0, PurchaseOrderVersions: [ { Id: 0, PurchaseOrderId: 0, SupplierUserId: 0, Version: 0, IsViewed: False, Status: 0 } ], PurchaseOrderIdentifier: String, SupplierUserId: 0, Buyer: String, Subject: String, ConfirmationDeadline: 0001-01-01, ConcurrencyStamp: String }, ResponseStatus: { ErrorCode: String, Message: String, StackTrace: String, Errors: [ { ErrorCode: String, FieldName: String, Message: String, Meta: { String: String } } ], Meta: { String: String } } }