POST | /bookinglog | Add a new event to booking log | Add a new event to the booking of the company of the currently logged in user, only administrators are allowed to add items to event log. |
---|
<?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 BookingLogEventTypeResponse implements JsonSerializable
{
public function __construct(
/** @description The event type id */
// @ApiMember(Description="The event type id")
/** @var int */
public int $Id=0,
/** @description The event type name */
// @ApiMember(Description="The event type name")
/** @var string|null */
public ?string $Name=null,
/** @description The event type description */
// @ApiMember(Description="The event type description")
/** @var string|null */
public ?string $Description=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Id'])) $this->Id = $o['Id'];
if (isset($o['Name'])) $this->Name = $o['Name'];
if (isset($o['Description'])) $this->Description = $o['Description'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Id)) $o['Id'] = $this->Id;
if (isset($this->Name)) $o['Name'] = $this->Name;
if (isset($this->Description)) $o['Description'] = $this->Description;
return empty($o) ? new class(){} : $o;
}
}
class BookingLogQueryResponse implements JsonSerializable
{
public function __construct(
/** @description The booking log id */
// @ApiMember(Description="The booking log id")
/** @var int */
public int $Id=0,
/** @description The booking id */
// @ApiMember(Description="The booking id")
/** @var int */
public int $BookingId=0,
/** @description The type of event */
// @ApiMember(Description="The type of event")
/** @var int */
public int $EventTypeId=0,
/** @description The type of event */
// @ApiMember(Description="The type of event")
/** @var BookingLogEventTypeResponse|null */
public ?BookingLogEventTypeResponse $EventType=null,
/** @description Comments that could be added to the event log item */
// @ApiMember(Description="Comments that could be added to the event log item")
/** @var string|null */
public ?string $Comments=null,
/** @description The user created the event */
// @ApiMember(Description="The user created the event")
/** @var string|null */
public ?string $UserName=null,
/** @description Then date when the event occured */
// @ApiMember(Description="Then date when the event occured")
/** @var DateTime */
public DateTime $Created=new DateTime()
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Id'])) $this->Id = $o['Id'];
if (isset($o['BookingId'])) $this->BookingId = $o['BookingId'];
if (isset($o['EventTypeId'])) $this->EventTypeId = $o['EventTypeId'];
if (isset($o['EventType'])) $this->EventType = JsonConverters::from('BookingLogEventTypeResponse', $o['EventType']);
if (isset($o['Comments'])) $this->Comments = $o['Comments'];
if (isset($o['UserName'])) $this->UserName = $o['UserName'];
if (isset($o['Created'])) $this->Created = JsonConverters::from('DateTime', $o['Created']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Id)) $o['Id'] = $this->Id;
if (isset($this->BookingId)) $o['BookingId'] = $this->BookingId;
if (isset($this->EventTypeId)) $o['EventTypeId'] = $this->EventTypeId;
if (isset($this->EventType)) $o['EventType'] = JsonConverters::to('BookingLogEventTypeResponse', $this->EventType);
if (isset($this->Comments)) $o['Comments'] = $this->Comments;
if (isset($this->UserName)) $o['UserName'] = $this->UserName;
if (isset($this->Created)) $o['Created'] = JsonConverters::to('DateTime', $this->Created);
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)
class CreateBookingLogItem implements ICompany, JsonSerializable
{
public function __construct(
/** @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.")
/** @var string|null */
public ?string $CompanyId=null,
/** @description The booking id */
// @ApiMember(Description="The booking id", IsRequired=true)
/** @var int */
public int $BookingId=0,
/** @description The type of event */
// @ApiMember(Description="The type of event", IsRequired=true)
/** @var int */
public int $EventTypeId=0,
/** @description Comments that could be added to the event log item */
// @ApiMember(Description="Comments that could be added to the event log item", IsRequired=true)
/** @var string */
public string $Comments='',
/** @description Then date when the event occured, leave blank if current datetime */
// @ApiMember(Description="Then date when the event occured, leave blank if current datetime", IsRequired=true)
/** @var DateTime */
public DateTime $Created=new DateTime()
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['CompanyId'])) $this->CompanyId = $o['CompanyId'];
if (isset($o['BookingId'])) $this->BookingId = $o['BookingId'];
if (isset($o['EventTypeId'])) $this->EventTypeId = $o['EventTypeId'];
if (isset($o['Comments'])) $this->Comments = $o['Comments'];
if (isset($o['Created'])) $this->Created = JsonConverters::from('DateTime', $o['Created']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->CompanyId)) $o['CompanyId'] = $this->CompanyId;
if (isset($this->BookingId)) $o['BookingId'] = $this->BookingId;
if (isset($this->EventTypeId)) $o['EventTypeId'] = $this->EventTypeId;
if (isset($this->Comments)) $o['Comments'] = $this->Comments;
if (isset($this->Created)) $o['Created'] = JsonConverters::to('DateTime', $this->Created);
return empty($o) ? new class(){} : $o;
}
}
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.
POST /bookinglog HTTP/1.1
Host: api.bokamera.se
Accept: application/xml
Content-Type: application/xml
Content-Length: length
<CreateBookingLogItem xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos">
<BookingId>0</BookingId>
<Comments>String</Comments>
<CompanyId>00000000-0000-0000-0000-000000000000</CompanyId>
<Created>0001-01-01T00:00:00</Created>
<EventTypeId>0</EventTypeId>
</CreateBookingLogItem>
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: length <BookingLogQueryResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos"> <BookingId>0</BookingId> <Comments>String</Comments> <Created>0001-01-01T00:00:00</Created> <EventType> <Description>String</Description> <Id>0</Id> <Name>String</Name> </EventType> <EventTypeId>0</EventTypeId> <Id>0</Id> <UserName>String</UserName> </BookingLogQueryResponse>