Requires any of the roles: | bookingsupplier-administrator-write, superadmin |
GET | /webhook/messages | List webhook message |
---|
<?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 ClientWebhookRequestBase implements JsonSerializable
{
public function __construct(
/** @var string */
public string $ClientId=''
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['ClientId'])) $this->ClientId = $o['ClientId'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->ClientId)) $o['ClientId'] = $this->ClientId;
return empty($o) ? new class(){} : $o;
}
}
enum Ordering : int
{
case Ascending = 'ascending';
case Descending = 'descending';
}
class ListMessagesRequestDto extends ClientWebhookRequestBase implements JsonSerializable
{
/**
* @param string $ClientId
*/
public function __construct(
string $ClientId='',
/** @var DateTime|null */
public ?DateTime $Before=null,
/** @var DateTime|null */
public ?DateTime $After=null,
/** @var string|null */
public ?string $Channel=null,
/** @var string|null */
public ?string $Iterator=null,
/** @var int|null */
public ?int $Limit=null,
/** @var Ordering|null */
public ?Ordering $Order=null,
/** @var array<string>|null */
public ?array $EventTypes=null,
/** @var bool|null */
public ?bool $WithContent=null
) {
parent::__construct($ClientId);
}
/** @throws Exception */
public function fromMap($o): void {
parent::fromMap($o);
if (isset($o['Before'])) $this->Before = JsonConverters::from('DateTime', $o['Before']);
if (isset($o['After'])) $this->After = JsonConverters::from('DateTime', $o['After']);
if (isset($o['Channel'])) $this->Channel = $o['Channel'];
if (isset($o['Iterator'])) $this->Iterator = $o['Iterator'];
if (isset($o['Limit'])) $this->Limit = $o['Limit'];
if (isset($o['Order'])) $this->Order = JsonConverters::from('Ordering', $o['Order']);
if (isset($o['EventTypes'])) $this->EventTypes = JsonConverters::fromArray('string', $o['EventTypes']);
if (isset($o['WithContent'])) $this->WithContent = $o['WithContent'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
if (isset($this->Before)) $o['Before'] = JsonConverters::to('DateTime', $this->Before);
if (isset($this->After)) $o['After'] = JsonConverters::to('DateTime', $this->After);
if (isset($this->Channel)) $o['Channel'] = $this->Channel;
if (isset($this->Iterator)) $o['Iterator'] = $this->Iterator;
if (isset($this->Limit)) $o['Limit'] = $this->Limit;
if (isset($this->Order)) $o['Order'] = JsonConverters::to('Ordering', $this->Order);
if (isset($this->EventTypes)) $o['EventTypes'] = JsonConverters::toArray('string', $this->EventTypes);
if (isset($this->WithContent)) $o['WithContent'] = $this->WithContent;
return empty($o) ? new class(){} : $o;
}
}
class ListMessagesResponseDto implements JsonSerializable
{
public function __construct(
/** @var GetMessageResponseDto[] */
public array $Data=[],
/** @var bool|null */
public ?bool $Done=null,
/** @var string */
public string $Iterator=''
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Data'])) $this->Data = JsonConverters::fromArray('GetMessageResponseDto', $o['Data']);
if (isset($o['Done'])) $this->Done = $o['Done'];
if (isset($o['Iterator'])) $this->Iterator = $o['Iterator'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Data)) $o['Data'] = JsonConverters::toArray('GetMessageResponseDto', $this->Data);
if (isset($this->Done)) $o['Done'] = $this->Done;
if (isset($this->Iterator)) $o['Iterator'] = $this->Iterator;
return empty($o) ? new class(){} : $o;
}
}
// @ApiResponse(Description="You were unauthorized to call this service", StatusCode=401)
// @ValidateRequest(Validator="IsAuthenticated")
class ListWebhookMessages extends ListMessagesRequestDto implements ICompany, JsonSerializable
{
/**
* @param string $ClientId
* @param DateTime|null $Before
* @param DateTime|null $After
* @param string|null $Channel
* @param string|null $Iterator
* @param int|null $Limit
* @param Ordering|null $Order
* @param array<string>|null $EventTypes
* @param bool|null $WithContent
*/
public function __construct(
string $ClientId='',
?DateTime $Before=null,
?DateTime $After=null,
?string $Channel=null,
?string $Iterator=null,
?int $Limit=null,
?Ordering $Order=null,
?array $EventTypes=null,
?bool $WithContent=null,
/** @description The company id, if empty will use the company id for the user you are logged in with. */
// @ApiMember(Description="The company id, if empty will use the company id for the user you are logged in with.", IsRequired=true, ParameterType="query")
/** @var string */
public string $CompanyId=''
) {
parent::__construct($ClientId,$Before,$After,$Channel,$Iterator,$Limit,$Order,$EventTypes,$WithContent);
}
/** @throws Exception */
public function fromMap($o): void {
parent::fromMap($o);
if (isset($o['CompanyId'])) $this->CompanyId = $o['CompanyId'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
if (isset($this->CompanyId)) $o['CompanyId'] = $this->CompanyId;
return empty($o) ? new class(){} : $o;
}
}
class GetMessageResponseDto implements JsonSerializable
{
public function __construct(
/** @var string */
public string $Id='',
/** @var array<string>|null */
public ?array $Channels=null,
/** @var string */
public string $EventType='',
/** @var array<string,string>|null */
public ?array $Metadata=null,
/** @var Object|null */
public ?Object $Payload=null,
/** @var string */
public string $EventId='',
/** @var DateTime */
public DateTime $Timestamp=new DateTime()
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Id'])) $this->Id = $o['Id'];
if (isset($o['Channels'])) $this->Channels = JsonConverters::fromArray('string', $o['Channels']);
if (isset($o['EventType'])) $this->EventType = $o['EventType'];
if (isset($o['Metadata'])) $this->Metadata = JsonConverters::from(JsonConverters::context('Dictionary',genericArgs:['string','string']), $o['Metadata']);
if (isset($o['Payload'])) $this->Payload = JsonConverters::from('Object', $o['Payload']);
if (isset($o['EventId'])) $this->EventId = $o['EventId'];
if (isset($o['Timestamp'])) $this->Timestamp = JsonConverters::from('DateTime', $o['Timestamp']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Id)) $o['Id'] = $this->Id;
if (isset($this->Channels)) $o['Channels'] = JsonConverters::toArray('string', $this->Channels);
if (isset($this->EventType)) $o['EventType'] = $this->EventType;
if (isset($this->Metadata)) $o['Metadata'] = JsonConverters::to(JsonConverters::context('Dictionary',genericArgs:['string','string']), $this->Metadata);
if (isset($this->Payload)) $o['Payload'] = JsonConverters::to('Object', $this->Payload);
if (isset($this->EventId)) $o['EventId'] = $this->EventId;
if (isset($this->Timestamp)) $o['Timestamp'] = JsonConverters::to('DateTime', $this->Timestamp);
return empty($o) ? new class(){} : $o;
}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .other suffix or ?format=other
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
GET /webhook/messages HTTP/1.1 Host: api.bokamera.se Accept: text/jsonl
HTTP/1.1 200 OK Content-Type: text/jsonl Content-Length: length {"Data":[{"Id":"String","Channels":["String"],"EventType":"String","Metadata":{"String":"String"},"Payload":{},"EventId":"String"}],"Done":false,"Iterator":"String"}