Required role: | Admin | Required permissions: | CanAccess, CanEdit |
PUT | /async/products/{Id} |
---|
import Foundation
import ServiceStack
/**
* Represents a service request to update product data in an asynchronous operation.
*/
// @Api(Description="Represents a service request to update product data in an asynchronous operation.")
public class UpdateProductAsync : UpdateProductBase
{
/**
* The unique identifier of the product.
*/
// @ApiMember(Description="The unique identifier of the product.")
public var id:Int
/**
* The name of the product.
*/
// @ApiMember(Description="The name of the product.")
public var name:String
/**
* The description of the product.
*/
// @ApiMember(Description="The description of the product.")
public var Description:String
/**
* The version of the product.
*/
// @ApiMember(Description="The version of the product.")
public var version:String
/**
* Tags associated with the product.
*/
// @ApiMember(Description="Tags associated with the product.")
public var tags:[String] = []
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case id
case name
case Description
case version
case tags
}
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)
name = try container.decodeIfPresent(String.self, forKey: .name)
Description = try container.decodeIfPresent(String.self, forKey: .Description)
version = try container.decodeIfPresent(String.self, forKey: .version)
tags = try container.decodeIfPresent([String].self, forKey: .tags) ?? []
}
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 Description != nil { try container.encode(Description, forKey: .Description) }
if version != nil { try container.encode(version, forKey: .version) }
if tags.count > 0 { try container.encode(tags, forKey: .tags) }
}
}
/**
* Specifies a service request to update product data.
*/
// @Api(Description="Specifies a service request to update product data.")
public class UpdateProductBase : IPut, Codable
{
/**
* The unique identifier of the product.
*/
// @ApiMember(Description="The unique identifier of the product.")
public var id:Int
/**
* The name of the product.
*/
// @ApiMember(Description="The name of the product.")
public var name:String
/**
* The description of the product.
*/
// @ApiMember(Description="The description of the product.")
public var Description:String
/**
* The version of the product.
*/
// @ApiMember(Description="The version of the product.")
public var version:String
/**
* Tags associated with the product.
*/
// @ApiMember(Description="Tags associated with the product.")
public var tags:[String] = []
required public init(){}
}
/**
* Represents a service response that encapsulates product data.
*/
// @Api(Description="Represents a service response that encapsulates product data.")
public class ProductResponse : ServiceResponseBase
{
/**
* The product data of the response.
*/
// @ApiMember(Description="The product data of the response.")
public var product:Product
/**
* The list of orders associated with the encapsulated product.
*/
// @ApiMember(Description="The list of orders associated with the encapsulated product.")
public var orders:[Order] = []
/**
* Data structure that holds error information from a service operation.
*/
// @ApiMember(Description="Data structure that holds error information from a service operation.")
public var responseStatus:ResponseStatus
required public init(){ super.init() }
private enum CodingKeys : String, CodingKey {
case product
case orders
case responseStatus
}
required public init(from decoder: Decoder) throws {
try super.init(from: decoder)
let container = try decoder.container(keyedBy: CodingKeys.self)
product = try container.decodeIfPresent(Product.self, forKey: .product)
orders = try container.decodeIfPresent([Order].self, forKey: .orders) ?? []
responseStatus = try container.decodeIfPresent(ResponseStatus.self, forKey: .responseStatus)
}
public override func encode(to encoder: Encoder) throws {
try super.encode(to: encoder)
var container = encoder.container(keyedBy: CodingKeys.self)
if product != nil { try container.encode(product, forKey: .product) }
if orders.count > 0 { try container.encode(orders, forKey: .orders) }
if responseStatus != nil { try container.encode(responseStatus, forKey: .responseStatus) }
}
}
/**
* Specifies a base service response class that contains a structured error information.
*/
// @Api(Description="Specifies a base service response class that contains a structured error information.")
public class ServiceResponseBase : Codable
{
/**
* Data structure that holds error information from a service operation.
*/
// @ApiMember(Description="Data structure that holds error information from a service operation.")
public var responseStatus:ResponseStatus
required public init(){}
}
/**
* 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(){}
}
/**
* Represents a commission to consume services.
*/
// @Api(Description="Represents a commission to consume services.")
public class Order : IHasName, Codable
{
/**
* The unique identifier of the order.
*/
// @ApiMember(Description="The unique identifier of the order.", IsRequired=true)
public var id:Int
/**
* The unique identifier of the product, for which the order is made.
*/
// @ApiMember(Description="The unique identifier of the product, for which the order is made.", IsRequired=true)
public var productId:Int
/**
* The unique identifier of the user account, who placed the order.
*/
// @ApiMember(Description="The unique identifier of the user account, who placed the order.", IsRequired=true)
public var accountId:Int
/**
* A name to identify the order.
*/
// @ApiMember(Description="A name to identify the order.", IsRequired=true)
// @Validate(Validator="NotEmpty")
public var name:String
/**
* The name of the service, for which the order was made.
*/
// @ApiMember(Description="The name of the service, for which the order was made.")
public var serviceName:String
/**
* The time stamp at which the order was initiated.
*/
// @ApiMember(Description="The time stamp at which the order was initiated.")
public var requestTimestamp:Date?
/**
* The time stamp at which the order was completed.
*/
// @ApiMember(Description="The time stamp at which the order was completed.")
public var responseTimestamp:Date?
/**
* The URI from which the order was initiated.
*/
// @ApiMember(Description="The URI from which the order was initiated.")
public var requestUri:String
/**
* The HTTP method of the order request.
*/
// @ApiMember(Description="The HTTP method of the order request.")
public var requestHttpMethod:String
/**
* The duration of the order request.
*/
// @ApiMember(Description="The duration of the order request.")
@TimeSpan public var requestDuration:TimeInterval?
/**
* The HTTP status code of the order request.
*/
// @ApiMember(Description="The HTTP status code of the order request.")
public var responseStatusCode:HttpStatusCode
/**
* The IP address of client, who placed the order.
*/
// @ApiMember(Description="The IP address of client, who placed the order.")
public var clientIPAddress:String
/**
* The unit of measurement for the order.
*/
// @ApiMember(Description="The unit of measurement for the order.")
public var unitOfMeasurement:String
/**
* The type of process, for which the order is charged.
*/
// @ApiMember(Description="The type of process, for which the order is charged.")
public var processType:String
/**
* The type of data, for which the order is charged.
*/
// @ApiMember(Description="The type of data, for which the order is charged.")
public var dataType:String
/**
* The name of the data, for which the order is charged.
*/
// @ApiMember(Description="The name of the data, for which the order is charged.")
public var dataName:String
/**
* The date of creation of the order.
*/
// @ApiMember(Description="The date of creation of the order.")
public var creationDate:Date
/**
* The final date to retain the order in the records. After this date, the order is expunged from the records.
*/
// @ApiMember(Description="The final date to retain the order in the records. After this date, the order is expunged from the records.")
public var expiryDate:Date?
/**
* Indicates whether the order is simulated for test purposes. True if the order is simulated for test purposes; otherwise it is a false order for production purposes.
*/
// @ApiMember(Description="Indicates whether the order is simulated for test purposes. True if the order is simulated for test purposes; otherwise it is a false order for production purposes.")
public var isTest:Bool
required public init(){}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .csv suffix or ?format=csv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
PUT /async/products/{Id} HTTP/1.1
Host: taxfiling.staging.pwc.de
Accept: text/csv
Content-Type: text/csv
Content-Length: length
{"id":0,"name":"String","description":"String","version":"String","tags":["String"]}
HTTP/1.1 200 OK Content-Type: text/csv Content-Length: length {"product":{"id":0,"index":0,"name":"String","version":"String","description":"String","tags":["String"]},"orders":[{"id":0,"productId":0,"accountId":0,"name":"String","serviceName":"String","requestTimestamp":"\/Date(-62135596800000-0000)\/","responseTimestamp":"\/Date(-62135596800000-0000)\/","requestUri":"String","requestHttpMethod":"String","requestDuration":"PT0S","responseStatusCode":"Continue","clientIPAddress":"String","unitOfMeasurement":"String","processType":"String","dataType":"String","dataName":"String","creationDate":"\/Date(-62135596800000-0000)\/","expiryDate":"\/Date(-62135596800000-0000)\/","isTest":false}],"responseStatus":{"errorCode":"String","message":"String","stackTrace":"String","errors":[{"errorCode":"String","fieldName":"String","message":"String","meta":{"String":"String"}}],"meta":{"String":"String"}}}