Requires any of the roles: | bookingsupplier-administrator-write, superadmin, bookingsupplier-administrator-read |
GET | /statistics |
---|
<?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 BookedByDay implements JsonSerializable
{
public function __construct(
/** @var DateTime */
public DateTime $Date=new DateTime(),
/** @var int */
public int $Value=0
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Date'])) $this->Date = JsonConverters::from('DateTime', $o['Date']);
if (isset($o['Value'])) $this->Value = $o['Value'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Date)) $o['Date'] = JsonConverters::to('DateTime', $this->Date);
if (isset($this->Value)) $o['Value'] = $this->Value;
return empty($o) ? new class(){} : $o;
}
}
class StatisticQueryResponse implements JsonSerializable
{
public function __construct(
/** @var int */
public int $NumberOfOccuringBookings=0,
/** @var int */
public int $NumberOfCanceledBookings=0,
/** @var int */
public int $NumberOfCreatedBookings=0,
/** @var int */
public int $NumberOfCreatedCustomers=0,
/** @var array<BookedByDay>|null */
public ?array $OccuringBookingsByDay=null,
/** @var array<BookedByDay>|null */
public ?array $CanceledBookingsByDay=null,
/** @var array<BookedByDay>|null */
public ?array $CreatedBookingsByDay=null,
/** @var array<BookedByDay>|null */
public ?array $CreatedCustomersByDay=null,
/** @var ResponseStatus|null */
public ?ResponseStatus $ResponseStatus=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['NumberOfOccuringBookings'])) $this->NumberOfOccuringBookings = $o['NumberOfOccuringBookings'];
if (isset($o['NumberOfCanceledBookings'])) $this->NumberOfCanceledBookings = $o['NumberOfCanceledBookings'];
if (isset($o['NumberOfCreatedBookings'])) $this->NumberOfCreatedBookings = $o['NumberOfCreatedBookings'];
if (isset($o['NumberOfCreatedCustomers'])) $this->NumberOfCreatedCustomers = $o['NumberOfCreatedCustomers'];
if (isset($o['OccuringBookingsByDay'])) $this->OccuringBookingsByDay = JsonConverters::fromArray('BookedByDay', $o['OccuringBookingsByDay']);
if (isset($o['CanceledBookingsByDay'])) $this->CanceledBookingsByDay = JsonConverters::fromArray('BookedByDay', $o['CanceledBookingsByDay']);
if (isset($o['CreatedBookingsByDay'])) $this->CreatedBookingsByDay = JsonConverters::fromArray('BookedByDay', $o['CreatedBookingsByDay']);
if (isset($o['CreatedCustomersByDay'])) $this->CreatedCustomersByDay = JsonConverters::fromArray('BookedByDay', $o['CreatedCustomersByDay']);
if (isset($o['ResponseStatus'])) $this->ResponseStatus = JsonConverters::from('ResponseStatus', $o['ResponseStatus']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->NumberOfOccuringBookings)) $o['NumberOfOccuringBookings'] = $this->NumberOfOccuringBookings;
if (isset($this->NumberOfCanceledBookings)) $o['NumberOfCanceledBookings'] = $this->NumberOfCanceledBookings;
if (isset($this->NumberOfCreatedBookings)) $o['NumberOfCreatedBookings'] = $this->NumberOfCreatedBookings;
if (isset($this->NumberOfCreatedCustomers)) $o['NumberOfCreatedCustomers'] = $this->NumberOfCreatedCustomers;
if (isset($this->OccuringBookingsByDay)) $o['OccuringBookingsByDay'] = JsonConverters::toArray('BookedByDay', $this->OccuringBookingsByDay);
if (isset($this->CanceledBookingsByDay)) $o['CanceledBookingsByDay'] = JsonConverters::toArray('BookedByDay', $this->CanceledBookingsByDay);
if (isset($this->CreatedBookingsByDay)) $o['CreatedBookingsByDay'] = JsonConverters::toArray('BookedByDay', $this->CreatedBookingsByDay);
if (isset($this->CreatedCustomersByDay)) $o['CreatedCustomersByDay'] = JsonConverters::toArray('BookedByDay', $this->CreatedCustomersByDay);
if (isset($this->ResponseStatus)) $o['ResponseStatus'] = JsonConverters::to('ResponseStatus', $this->ResponseStatus);
return empty($o) ? new class(){} : $o;
}
}
// @ApiResponse(Description="You were unauthorized to call this service", StatusCode=401)
// @ApiResponse(Description="You have too low privilegies to call this service", StatusCode=403)
// @ValidateRequest(Validator="IsAuthenticated")
class StatisticQuery implements ICompany, JsonSerializable
{
public function __construct(
/** @description Enter the company id, if blank company id and you are an admin, your company id will be used. */
// @ApiMember(Description="Enter the company id, if blank company id and you are an admin, your company id will be used.", IsRequired=true, ParameterType="query")
/** @var string */
public string $CompanyId='',
/** @description Start of interval to get bookings and customers */
// @ApiMember(Description="Start of interval to get bookings and customers", IsRequired=true, ParameterType="query")
// @Required()
/** @var DateTime */
public DateTime $From=new DateTime(),
/** @description End of interval to get bookings and customers */
// @ApiMember(Description="End of interval to get bookings and customers", IsRequired=true, ParameterType="query")
/** @var DateTime */
public DateTime $To=new DateTime(),
/** @description Set true if you want to include booked events by day */
// @ApiMember(Description="Set true if you want to include booked events by day", ParameterType="query")
/** @var bool|null */
public ?bool $IncludeOccuringBookingsByDay=null,
/** @description Set true if you want to include canceled booked events by day */
// @ApiMember(Description="Set true if you want to include canceled booked events by day", ParameterType="query")
/** @var bool|null */
public ?bool $IncludeBookingsCanceledByDay=null,
/** @description Set true if you want to include booking created by day */
// @ApiMember(Description="Set true if you want to include booking created by day", ParameterType="query")
/** @var bool|null */
public ?bool $IncludeCreatedBookingsByDay=null,
/** @description Set true if you want to include customers created by day */
// @ApiMember(Description="Set true if you want to include customers created by day", ParameterType="query")
/** @var bool|null */
public ?bool $IncludeCreatedCustomersByDay=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['CompanyId'])) $this->CompanyId = $o['CompanyId'];
if (isset($o['From'])) $this->From = JsonConverters::from('DateTime', $o['From']);
if (isset($o['To'])) $this->To = JsonConverters::from('DateTime', $o['To']);
if (isset($o['IncludeOccuringBookingsByDay'])) $this->IncludeOccuringBookingsByDay = $o['IncludeOccuringBookingsByDay'];
if (isset($o['IncludeBookingsCanceledByDay'])) $this->IncludeBookingsCanceledByDay = $o['IncludeBookingsCanceledByDay'];
if (isset($o['IncludeCreatedBookingsByDay'])) $this->IncludeCreatedBookingsByDay = $o['IncludeCreatedBookingsByDay'];
if (isset($o['IncludeCreatedCustomersByDay'])) $this->IncludeCreatedCustomersByDay = $o['IncludeCreatedCustomersByDay'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->CompanyId)) $o['CompanyId'] = $this->CompanyId;
if (isset($this->From)) $o['From'] = JsonConverters::to('DateTime', $this->From);
if (isset($this->To)) $o['To'] = JsonConverters::to('DateTime', $this->To);
if (isset($this->IncludeOccuringBookingsByDay)) $o['IncludeOccuringBookingsByDay'] = $this->IncludeOccuringBookingsByDay;
if (isset($this->IncludeBookingsCanceledByDay)) $o['IncludeBookingsCanceledByDay'] = $this->IncludeBookingsCanceledByDay;
if (isset($this->IncludeCreatedBookingsByDay)) $o['IncludeCreatedBookingsByDay'] = $this->IncludeCreatedBookingsByDay;
if (isset($this->IncludeCreatedCustomersByDay)) $o['IncludeCreatedCustomersByDay'] = $this->IncludeCreatedCustomersByDay;
return empty($o) ? new class(){} : $o;
}
}
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.
GET /statistics HTTP/1.1 Host: api.bokamera.se Accept: text/csv
HTTP/1.1 200 OK Content-Type: text/csv Content-Length: length {"NumberOfOccuringBookings":0,"NumberOfCanceledBookings":0,"NumberOfCreatedBookings":0,"NumberOfCreatedCustomers":0,"OccuringBookingsByDay":[{"Value":0}],"CanceledBookingsByDay":[{"Value":0}],"CreatedBookingsByDay":[{"Value":0}],"CreatedCustomersByDay":[{"Value":0}],"ResponseStatus":{"ErrorCode":"String","Message":"String","StackTrace":"String","Errors":[{"ErrorCode":"String","FieldName":"String","Message":"String","Meta":{"String":"String"}}],"Meta":{"String":"String"}}}