BokaMera.API.Host

<back to all web services

CreateBookingLogItem

The following routes are available for this service:
POST/bookinglogAdd a new event to booking logAdd 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;
    }
}

PHP CreateBookingLogItem DTOs

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

HTTP + CSV

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: text/csv
Content-Type: text/csv
Content-Length: length

{"CompanyId":"00000000-0000-0000-0000-000000000000","BookingId":0,"EventTypeId":0,"Comments":"String","Created":"0001-01-01T00:00:00"}
HTTP/1.1 200 OK
Content-Type: text/csv
Content-Length: length

{"Id":0,"BookingId":0,"EventTypeId":0,"EventType":{"Id":0,"Name":"String","Description":"String"},"Comments":"String","UserName":"String"}