BokaMera.API.Host

<back to all web services

StatisticQuery

Requires Authentication
Requires any of the roles:bookingsupplier-administrator-write, superadmin, bookingsupplier-administrator-read
The following routes are available for this service:
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 $NumberOfCreatedBookings=0,
        /** @var int */
        public int $NumberOfCreatedCustomers=0,
        /** @var array<BookedByDay>|null */
        public ?array $OccuringBookingsByDay=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['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['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->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->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 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['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->IncludeCreatedBookingsByDay)) $o['IncludeCreatedBookingsByDay'] = $this->IncludeCreatedBookingsByDay;
        if (isset($this->IncludeCreatedCustomersByDay)) $o['IncludeCreatedCustomersByDay'] = $this->IncludeCreatedCustomersByDay;
        return empty($o) ? new class(){} : $o;
    }
}

PHP StatisticQuery DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml

HTTP + XML

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

GET /statistics HTTP/1.1 
Host: testapi.bokamera.se 
Accept: application/xml
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<StatisticQueryResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos">
  <CreatedBookingsByDay>
    <BookedByDay>
      <Date>0001-01-01T00:00:00</Date>
      <Value>0</Value>
    </BookedByDay>
  </CreatedBookingsByDay>
  <CreatedCustomersByDay>
    <BookedByDay>
      <Date>0001-01-01T00:00:00</Date>
      <Value>0</Value>
    </BookedByDay>
  </CreatedCustomersByDay>
  <NumberOfCreatedBookings>0</NumberOfCreatedBookings>
  <NumberOfCreatedCustomers>0</NumberOfCreatedCustomers>
  <NumberOfOccuringBookings>0</NumberOfOccuringBookings>
  <OccuringBookingsByDay>
    <BookedByDay>
      <Date>0001-01-01T00:00:00</Date>
      <Value>0</Value>
    </BookedByDay>
  </OccuringBookingsByDay>
  <ResponseStatus xmlns:d2p1="http://schemas.servicestack.net/types">
    <d2p1:ErrorCode>String</d2p1:ErrorCode>
    <d2p1:Message>String</d2p1:Message>
    <d2p1:StackTrace>String</d2p1:StackTrace>
    <d2p1:Errors>
      <d2p1:ResponseError>
        <d2p1:ErrorCode>String</d2p1:ErrorCode>
        <d2p1:FieldName>String</d2p1:FieldName>
        <d2p1:Message>String</d2p1:Message>
        <d2p1:Meta xmlns:d5p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
          <d5p1:KeyValueOfstringstring>
            <d5p1:Key>String</d5p1:Key>
            <d5p1:Value>String</d5p1:Value>
          </d5p1:KeyValueOfstringstring>
        </d2p1:Meta>
      </d2p1:ResponseError>
    </d2p1:Errors>
    <d2p1:Meta xmlns:d3p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
      <d3p1:KeyValueOfstringstring>
        <d3p1:Key>String</d3p1:Key>
        <d3p1:Value>String</d3p1:Value>
      </d3p1:KeyValueOfstringstring>
    </d2p1:Meta>
  </ResponseStatus>
</StatisticQueryResponse>