POST | /v1/reports | Retrieve Report by ReportName and Filters |
---|
<?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 DashboardReportResult implements JsonSerializable
{
public function __construct(
/** @var int */
public int $totalCount=0,
/** @var array<Object>|null */
public ?array $reportResult=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['totalCount'])) $this->totalCount = $o['totalCount'];
if (isset($o['reportResult'])) $this->reportResult = JsonConverters::fromArray('Object', $o['reportResult']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->totalCount)) $o['totalCount'] = $this->totalCount;
if (isset($this->reportResult)) $o['reportResult'] = JsonConverters::toArray('Object', $this->reportResult);
return empty($o) ? new class(){} : $o;
}
}
enum ReportFilterType : string
{
case list = 'list';
case list_like = 'list_like';
case date = 'date';
case range = 'range';
}
class ReportFilter implements JsonSerializable
{
public function __construct(
/** @var ReportFilterType|null */
public ?ReportFilterType $type=null,
/** @var array<string>|null */
public ?array $values=null,
/** @var DateTime|null */
public ?DateTime $start=null,
/** @var DateTime|null */
public ?DateTime $end=null,
/** @var int|null */
public ?int $higherThan=null,
/** @var int|null */
public ?int $lowerThan=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['type'])) $this->type = JsonConverters::from('ReportFilterType', $o['type']);
if (isset($o['values'])) $this->values = JsonConverters::fromArray('string', $o['values']);
if (isset($o['start'])) $this->start = JsonConverters::from('DateTime', $o['start']);
if (isset($o['end'])) $this->end = JsonConverters::from('DateTime', $o['end']);
if (isset($o['higherThan'])) $this->higherThan = $o['higherThan'];
if (isset($o['lowerThan'])) $this->lowerThan = $o['lowerThan'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->type)) $o['type'] = JsonConverters::to('ReportFilterType', $this->type);
if (isset($this->values)) $o['values'] = JsonConverters::toArray('string', $this->values);
if (isset($this->start)) $o['start'] = JsonConverters::to('DateTime', $this->start);
if (isset($this->end)) $o['end'] = JsonConverters::to('DateTime', $this->end);
if (isset($this->higherThan)) $o['higherThan'] = $this->higherThan;
if (isset($this->lowerThan)) $o['lowerThan'] = $this->lowerThan;
return empty($o) ? new class(){} : $o;
}
}
class ReportsPaging implements JsonSerializable
{
public function __construct(
/** @var int */
public int $page=0,
/** @var int */
public int $pageSize=0
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['page'])) $this->page = $o['page'];
if (isset($o['pageSize'])) $this->pageSize = $o['pageSize'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->page)) $o['page'] = $this->page;
if (isset($this->pageSize)) $o['pageSize'] = $this->pageSize;
return empty($o) ? new class(){} : $o;
}
}
enum ReportSortType : string
{
case asc = 'asc';
case desc = 'desc';
}
class DashboardReportRequest implements IPost, JsonSerializable
{
public function __construct(
/** @description Report Name */
// @ApiMember(Description="Report Name", IsRequired=true, ParameterType="body")
/** @var string */
public string $reportName='',
/** @description Filters */
// @ApiMember(Description="Filters", IsRequired=true, ParameterType="body")
/** @var array<string,ReportFilter>|null */
public ?array $filters=null,
/** @description Paging */
// @ApiMember(Description="Paging", ParameterType="body")
/** @var ReportsPaging|null */
public ?ReportsPaging $paging=null,
/** @description Sorting */
// @ApiMember(Description="Sorting", ParameterType="body")
/** @var array<string,ReportSortType>|null */
public ?array $sorting=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['reportName'])) $this->reportName = $o['reportName'];
if (isset($o['filters'])) $this->filters = JsonConverters::from(JsonConverters::context('Dictionary',genericArgs:['string','ReportFilter']), $o['filters']);
if (isset($o['paging'])) $this->paging = JsonConverters::from('ReportsPaging', $o['paging']);
if (isset($o['sorting'])) $this->sorting = JsonConverters::from(JsonConverters::context('Dictionary',genericArgs:['string','ReportSortType']), $o['sorting']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->reportName)) $o['reportName'] = $this->reportName;
if (isset($this->filters)) $o['filters'] = JsonConverters::to(JsonConverters::context('Dictionary',genericArgs:['string','ReportFilter']), $this->filters);
if (isset($this->paging)) $o['paging'] = JsonConverters::to('ReportsPaging', $this->paging);
if (isset($this->sorting)) $o['sorting'] = JsonConverters::to(JsonConverters::context('Dictionary',genericArgs:['string','ReportSortType']), $this->sorting);
return empty($o) ? new class(){} : $o;
}
}
PHP DashboardReportRequest 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.
POST /v1/reports HTTP/1.1
Host: uat-api-vehicle-mgt-mb-dhc.rapp-customers.co.uk
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length
{
reportName: String,
filters:
{
String:
{
type: list,
start: 0001-01-01,
end: 0001-01-01,
higherThan: 0,
lowerThan: 0
}
},
paging:
{
page: 0,
pageSize: 0
},
sorting:
{
String: asc
}
}
HTTP/1.1 200 OK Content-Type: text/jsv Content-Length: length { totalCount: 0 }