Required role: | Admin | Required permission: | CanAccess |
GET | /sync/products |
---|
import Foundation
import ServiceStack
/**
* Represents a service request to retrieve all products.
*/
// @Api(Description="Represents a service request to retrieve all products.")
public class RetrieveAllProducts : RetrieveAllProductsBase
{
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)
}
}
/**
* Specifies a service to retrieve all products.
*/
// @Api(Description="Specifies a service to retrieve all products.")
public class RetrieveAllProductsBase : PaginationBase, IGet
{
/**
* Should the related orders of the account be included in the retrieved products?
*/
// @ApiMember(Description="Should the related orders of the account be included in the retrieved products?")
public var includeOrders:Bool?
/**
* Specifies the number of orders to skip per product. Applicable only when 'IncludeOrders' is true.
*/
// @ApiMember(Description="Specifies the number of orders to skip per product. Applicable only when 'IncludeOrders' is true. ")
public var skipOrders:Int?
/**
* Specifies the number of orders to include per product. Applicable only when 'IncludeOrders' is true.
*/
// @ApiMember(Description="Specifies the number of orders to include per product. Applicable only when 'IncludeOrders' is true. ")
public var takeOrders:Int?
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case includeOrders
case skipOrders
case takeOrders
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
includeOrders = try container.decodeIfPresent(Bool.self, forKey: .includeOrders)
skipOrders = try container.decodeIfPresent(Int.self, forKey: .skipOrders)
takeOrders = try container.decodeIfPresent(Int.self, forKey: .takeOrders)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if includeOrders != nil { try container.encode(includeOrders, forKey: .includeOrders) }
if skipOrders != nil { try container.encode(skipOrders, forKey: .skipOrders) }
if takeOrders != nil { try container.encode(takeOrders, forKey: .takeOrders) }
}
}
/**
* The number of query results to skip.
*/
// @Api(Description="The number of query results to skip.")
public class PaginationBase : IPaginate, Codable
{
/**
* The number of query results to skip.
*/
// @ApiMember(Description="The number of query results to skip.")
public var skip:Int?
/**
* The number of query results to include.
*/
// @ApiMember(Description="The number of query results to include.")
public var take:Int?
required public init(){}
}
/**
* Represents a query response that contains a structured error information and encapsulates products.
*/
// @Api(Description="Represents a query response that contains a structured error information and encapsulates products.")
public class ProductQueryResponse : QueryResponse<Product>
{
/**
* The dictionary of orders associated with each found product.
*/
// @ApiMember(Description="The dictionary of orders associated with each found product.")
public var ordersMap:[Int:[Order]] = [:]
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case ordersMap
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
ordersMap = try container.decodeIfPresent([Int:[Order]].self, forKey: .ordersMap) ?? [:]
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if ordersMap.count > 0 { try container.encode(ordersMap, forKey: .ordersMap) }
}
}
/**
* Represents a product.
*/
// @Api(Description="Represents a product.")
public class Product : IHasName, Codable
{
/**
* The unique identifier of the product.
*/
// @ApiMember(Description="The unique identifier of the product.", IsRequired=true)
public var id:Int
/**
* The position of this instance in a collection of 'Product' instances
*/
// @ApiMember(Description="The position of this instance in a collection of 'Product' instances", IsRequired=true)
public var index:Int
/**
* The name of the product.
*/
// @ApiMember(Description="The name of the product.", IsRequired=true)
// @Validate(Validator="NotEmpty")
public var name:String
/**
* The version of the product.
*/
// @ApiMember(Description="The version of the product.", IsRequired=true)
// @Validate(Validator="NotEmpty")
public var version:String
/**
* The version of the product.
*/
// @ApiMember(Description="The version of the product.")
public var Description:String
/**
* Tags associated with the product.
*/
// @ApiMember(Description="Tags associated with the product.")
public var tags:[String] = []
required public init(){}
}
Swift RetrieveAllProducts 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 /sync/products HTTP/1.1 Host: taxfiling.pwc.de Accept: text/jsv
HTTP/1.1 200 OK Content-Type: text/jsv Content-Length: length { ordersMap: { 0: [ { id: 0, productId: 0, accountId: 0, name: String, serviceName: String, requestTimestamp: 0001-01-01, responseTimestamp: 0001-01-01, requestUri: String, requestHttpMethod: String, requestDuration: PT0S, responseStatusCode: Continue, clientIPAddress: String, unitOfMeasurement: String, processType: String, dataType: String, dataName: String, creationDate: 0001-01-01, expiryDate: 0001-01-01, isTest: False } ] }, offset: 0, total: 0, results: [ { id: 0, index: 0, name: String, version: String, description: String, tags: [ String ] } ], meta: { String: String }, responseStatus: { errorCode: String, message: String, stackTrace: String, errors: [ { errorCode: String, fieldName: String, message: String, meta: { String: String } } ], meta: { String: String } } }