Required role: | Admin | Required permissions: | CanAccess, CanAdd |
POST | /sync/products/batch |
---|
<?php namespace dtos;
use DateTime;
use Exception;
use DateInterval;
use JsonSerializable;
use ServiceStack\{IReturn,IReturnVoid,IGet,IPost,IPut,IDelete,IPatch,IMeta,IHasSessionId,IHasBearerToken,IHasVersion};
use ServiceStack\{ICrud,ICreateDb,IUpdateDb,IPatchDb,IDeleteDb,ISaveDb,AuditBase,QueryDb,QueryDb2,QueryData,QueryData2,QueryResponse};
use ServiceStack\{ResponseStatus,ResponseError,EmptyResponse,IdResponse,ArrayList,KeyValuePair2,StringResponse,StringsResponse,Tuple2,Tuple3,ByteArray};
use ServiceStack\{JsonConverters,Returns,TypeContext};
/** @description Represents a product. */
// @Api(Description="Represents a product.")
class Product implements IHasName, JsonSerializable
{
public function __construct(
/** @description The unique identifier of the product. */
// @ApiMember(Description="The unique identifier of the product.", IsRequired=true)
/** @var int */
public int $id=0,
/** @description 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)
/** @var int */
public int $index=0,
/** @description The name of the product. */
// @ApiMember(Description="The name of the product.", IsRequired=true)
// @Validate(Validator="NotEmpty")
/** @var string */
public string $name='',
/** @description The version of the product. */
// @ApiMember(Description="The version of the product.", IsRequired=true)
// @Validate(Validator="NotEmpty")
/** @var string */
public string $version='',
/** @description The version of the product. */
// @ApiMember(Description="The version of the product.")
/** @var string|null */
public ?string $description=null,
/** @description Tags associated with the product. */
// @ApiMember(Description="Tags associated with the product.")
/** @var array<string>|null */
public ?array $tags=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['id'])) $this->id = $o['id'];
if (isset($o['index'])) $this->index = $o['index'];
if (isset($o['name'])) $this->name = $o['name'];
if (isset($o['version'])) $this->version = $o['version'];
if (isset($o['description'])) $this->description = $o['description'];
if (isset($o['tags'])) $this->tags = JsonConverters::fromArray('string', $o['tags']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->id)) $o['id'] = $this->id;
if (isset($this->index)) $o['index'] = $this->index;
if (isset($this->name)) $o['name'] = $this->name;
if (isset($this->version)) $o['version'] = $this->version;
if (isset($this->description)) $o['description'] = $this->description;
if (isset($this->tags)) $o['tags'] = JsonConverters::toArray('string', $this->tags);
return empty($o) ? new class(){} : $o;
}
}
/** @description Specifies a base service request to register one or more products in a batch operation. */
// @Api(Description="Specifies a base service request to register one or more products in a batch operation.")
class BatchRegisterProductsBase implements IPost, JsonSerializable
{
public function __construct(
/** @description The products to register. */
// @ApiMember(Description="The products to register.", IsRequired=true)
/** @var array<Product>|null */
public ?array $products=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['products'])) $this->products = JsonConverters::fromArray('Product', $o['products']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->products)) $o['products'] = JsonConverters::toArray('Product', $this->products);
return empty($o) ? new class(){} : $o;
}
}
/** @description Represents a service request to register one or more products in a batch operation. */
// @Api(Description="Represents a service request to register one or more products in a batch operation.")
class BatchRegisterProducts extends BatchRegisterProductsBase implements JsonSerializable
{
/**
* @param array<Product>|null $products
*/
public function __construct(
?array $products=null
) {
parent::__construct($products);
}
/** @throws Exception */
public function fromMap($o): void {
parent::fromMap($o);
if (isset($o['products'])) $this->products = JsonConverters::fromArray('Product', $o['products']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
if (isset($this->products)) $o['products'] = JsonConverters::toArray('Product', $this->products);
return empty($o) ? new class(){} : $o;
}
}
PHP BatchRegisterProducts DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /sync/products/batch HTTP/1.1
Host: taxfiling.pwc.de
Accept: application/xml
Content-Type: application/xml
Content-Length: length
<BatchRegisterProducts xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/PwC.Metering.Core.Services.Contracts.Requests">
<Products xmlns:d2p1="http://schemas.datacontract.org/2004/07/PwC.Metering.Core.Domain.Concretes.Models">
<d2p1:Product>
<d2p1:Description>String</d2p1:Description>
<d2p1:Id>0</d2p1:Id>
<d2p1:Index>0</d2p1:Index>
<d2p1:Name>String</d2p1:Name>
<d2p1:Tags xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d4p1:string>String</d4p1:string>
</d2p1:Tags>
<d2p1:Version>String</d2p1:Version>
</d2p1:Product>
</Products>
</BatchRegisterProducts>
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: length <ArrayOfProductResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/PwC.Metering.Core.Services.Contracts.Responses"> <ProductResponse> <ResponseStatus xmlns:d3p1="http://schemas.servicestack.net/types"> <d3p1:ErrorCode>String</d3p1:ErrorCode> <d3p1:Message>String</d3p1:Message> <d3p1:StackTrace>String</d3p1:StackTrace> <d3p1:Errors> <d3p1:ResponseError> <d3p1:ErrorCode>String</d3p1:ErrorCode> <d3p1:FieldName>String</d3p1:FieldName> <d3p1:Message>String</d3p1:Message> <d3p1:Meta xmlns:d6p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays"> <d6p1:KeyValueOfstringstring> <d6p1:Key>String</d6p1:Key> <d6p1:Value>String</d6p1:Value> </d6p1:KeyValueOfstringstring> </d3p1:Meta> </d3p1:ResponseError> </d3p1:Errors> <d3p1:Meta xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays"> <d4p1:KeyValueOfstringstring> <d4p1:Key>String</d4p1:Key> <d4p1:Value>String</d4p1:Value> </d4p1:KeyValueOfstringstring> </d3p1:Meta> </ResponseStatus> <Orders xmlns:d3p1="http://schemas.datacontract.org/2004/07/PwC.Metering.Core.Domain.Concretes.Models"> <d3p1:Order> <d3p1:AccountId>0</d3p1:AccountId> <d3p1:ClientIPAddress>String</d3p1:ClientIPAddress> <d3p1:CreationDate>0001-01-01T00:00:00</d3p1:CreationDate> <d3p1:DataName>String</d3p1:DataName> <d3p1:DataType>String</d3p1:DataType> <d3p1:ExpiryDate>0001-01-01T00:00:00</d3p1:ExpiryDate> <d3p1:Id>0</d3p1:Id> <d3p1:IsTest>false</d3p1:IsTest> <d3p1:Name>String</d3p1:Name> <d3p1:ProcessType>String</d3p1:ProcessType> <d3p1:ProductId>0</d3p1:ProductId> <d3p1:RequestDuration>PT0S</d3p1:RequestDuration> <d3p1:RequestHttpMethod>String</d3p1:RequestHttpMethod> <d3p1:RequestTimestamp>0001-01-01T00:00:00</d3p1:RequestTimestamp> <d3p1:RequestUri>String</d3p1:RequestUri> <d3p1:ResponseStatusCode>Continue</d3p1:ResponseStatusCode> <d3p1:ResponseTimestamp>0001-01-01T00:00:00</d3p1:ResponseTimestamp> <d3p1:ServiceName>String</d3p1:ServiceName> <d3p1:UnitOfMeasurement>String</d3p1:UnitOfMeasurement> </d3p1:Order> </Orders> <Product xmlns:d3p1="http://schemas.datacontract.org/2004/07/PwC.Metering.Core.Domain.Concretes.Models"> <d3p1:Description>String</d3p1:Description> <d3p1:Id>0</d3p1:Id> <d3p1:Index>0</d3p1:Index> <d3p1:Name>String</d3p1:Name> <d3p1:Tags xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays"> <d4p1:string>String</d4p1:string> </d3p1:Tags> <d3p1:Version>String</d3p1:Version> </Product> </ProductResponse> </ArrayOfProductResponse>