GET | /eaccounting/articles |
---|
<?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};
class BaseArticleDto implements JsonSerializable
{
public function __construct(
/** @var string */
public string $ArticleId='',
/** @var float */
public float $ArticlePrice=0.0,
/** @var string|null */
public ?string $ArticleName=null,
/** @var DateTime */
public DateTime $CreatedDate=new DateTime()
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['ArticleId'])) $this->ArticleId = $o['ArticleId'];
if (isset($o['ArticlePrice'])) $this->ArticlePrice = $o['ArticlePrice'];
if (isset($o['ArticleName'])) $this->ArticleName = $o['ArticleName'];
if (isset($o['CreatedDate'])) $this->CreatedDate = JsonConverters::from('DateTime', $o['CreatedDate']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->ArticleId)) $o['ArticleId'] = $this->ArticleId;
if (isset($this->ArticlePrice)) $o['ArticlePrice'] = $this->ArticlePrice;
if (isset($this->ArticleName)) $o['ArticleName'] = $this->ArticleName;
if (isset($this->CreatedDate)) $o['CreatedDate'] = JsonConverters::to('DateTime', $this->CreatedDate);
return empty($o) ? new class(){} : $o;
}
}
class EAccountingArticleQueryResponse extends BaseArticleDto implements JsonSerializable
{
/**
* @param string $ArticleId
* @param float $ArticlePrice
* @param string|null $ArticleName
* @param DateTime $CreatedDate
*/
public function __construct(
string $ArticleId='',
float $ArticlePrice=0.0,
?string $ArticleName=null,
DateTime $CreatedDate=new DateTime(),
/** @var string|null */
public ?string $UnitId=null,
/** @var string|null */
public ?string $CodingId=null,
/** @var string|null */
public ?string $VatRate=null,
/** @var string|null */
public ?string $VatRatePercent=null,
/** @var string|null */
public ?string $CurrencySign=null
) {
parent::__construct($ArticleId,$ArticlePrice,$ArticleName,$CreatedDate);
}
/** @throws Exception */
public function fromMap($o): void {
parent::fromMap($o);
if (isset($o['UnitId'])) $this->UnitId = $o['UnitId'];
if (isset($o['CodingId'])) $this->CodingId = $o['CodingId'];
if (isset($o['VatRate'])) $this->VatRate = $o['VatRate'];
if (isset($o['VatRatePercent'])) $this->VatRatePercent = $o['VatRatePercent'];
if (isset($o['CurrencySign'])) $this->CurrencySign = $o['CurrencySign'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
if (isset($this->UnitId)) $o['UnitId'] = $this->UnitId;
if (isset($this->CodingId)) $o['CodingId'] = $this->CodingId;
if (isset($this->VatRate)) $o['VatRate'] = $this->VatRate;
if (isset($this->VatRatePercent)) $o['VatRatePercent'] = $this->VatRatePercent;
if (isset($this->CurrencySign)) $o['CurrencySign'] = $this->CurrencySign;
return empty($o) ? new class(){} : $o;
}
}
class EAccountingArticleQuery implements ICompany, JsonSerializable
{
public function __construct(
/** @var string|null */
public ?string $CompanyId=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['CompanyId'])) $this->CompanyId = $o['CompanyId'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->CompanyId)) $o['CompanyId'] = $this->CompanyId;
return empty($o) ? new class(){} : $o;
}
}
PHP EAccountingArticleQuery 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.
GET /eaccounting/articles HTTP/1.1 Host: api.bokamera.se Accept: application/xml
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: length <EAccountingDtos.EAccountingArticleQueryResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos"> <ArticleId>00000000-0000-0000-0000-000000000000</ArticleId> <ArticleName>String</ArticleName> <ArticlePrice>0</ArticlePrice> <CreatedDate>0001-01-01T00:00:00</CreatedDate> <CodingId>String</CodingId> <CurrencySign>String</CurrencySign> <UnitId>String</UnitId> <VatRate>String</VatRate> <VatRatePercent>String</VatRatePercent> </EAccountingDtos.EAccountingArticleQueryResponse>