BokaMera.API.Host

<back to all web services

SendEmailToCompany

The following routes are available for this service:
POST/messages/sendemailtocompanySend email to company with id or sitepathThis is used by the homepage to send emails to the company
<?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 MessageLogQueryResponse implements JsonSerializable
{
    public function __construct(
        /** @description The message log id */
        // @ApiMember(Description="The message log id")
        /** @var int */
        public int $Id=0,

        /** @description The booking id for the message (if connected to a booking). */
        // @ApiMember(Description="The booking id for the message (if connected to a booking).")
        /** @var int|null */
        public ?int $BookingId=null,

        /** @description The message receiver. Either a email or a mobile phone number. */
        // @ApiMember(Description="The message receiver. Either a email or a mobile phone number.")
        /** @var string|null */
        public ?string $Receiver=null,

        /** @description Message Title. */
        // @ApiMember(Description="Message Title.")
        /** @var string|null */
        public ?string $MessageTitle=null,

        /** @description Message Storage Url. */
        // @ApiMember(Description="Message Storage Url.")
        /** @var string|null */
        public ?string $StorageUrl=null,

        /** @description Message Body. */
        // @ApiMember(Description="Message Body.")
        /** @var string|null */
        public ?string $MessageBody=null,

        /** @description When message was created. */
        // @ApiMember(Description="When message was created.")
        /** @var DateTime */
        public DateTime $Created=new DateTime(),

        /** @description When the message will be sent. */
        // @ApiMember(Description="When the message will be sent.")
        /** @var DateTime */
        public DateTime $ToSendDate=new DateTime(),

        /** @description When the message was sent. */
        // @ApiMember(Description="When the message was sent.")
        /** @var DateTime|null */
        public ?DateTime $SentDate=null,

        /** @description If Message is sent */
        // @ApiMember(Description="If Message is sent")
        /** @var bool|null */
        public ?bool $Sent=null,

        /** @description Number of retries to send the message */
        // @ApiMember(Description="Number of retries to send the message")
        /** @var int */
        public int $MessageRetries=0,

        /** @description Send Method. 1 = Email, 2 = SMS */
        // @ApiMember(Description="Send Method. 1 = Email, 2 = SMS")
        /** @var int */
        public int $SendMethodId=0
    ) {
    }

    /** @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['Receiver'])) $this->Receiver = $o['Receiver'];
        if (isset($o['MessageTitle'])) $this->MessageTitle = $o['MessageTitle'];
        if (isset($o['StorageUrl'])) $this->StorageUrl = $o['StorageUrl'];
        if (isset($o['MessageBody'])) $this->MessageBody = $o['MessageBody'];
        if (isset($o['Created'])) $this->Created = JsonConverters::from('DateTime', $o['Created']);
        if (isset($o['ToSendDate'])) $this->ToSendDate = JsonConverters::from('DateTime', $o['ToSendDate']);
        if (isset($o['SentDate'])) $this->SentDate = JsonConverters::from('DateTime', $o['SentDate']);
        if (isset($o['Sent'])) $this->Sent = $o['Sent'];
        if (isset($o['MessageRetries'])) $this->MessageRetries = $o['MessageRetries'];
        if (isset($o['SendMethodId'])) $this->SendMethodId = $o['SendMethodId'];
    }
    
    /** @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->Receiver)) $o['Receiver'] = $this->Receiver;
        if (isset($this->MessageTitle)) $o['MessageTitle'] = $this->MessageTitle;
        if (isset($this->StorageUrl)) $o['StorageUrl'] = $this->StorageUrl;
        if (isset($this->MessageBody)) $o['MessageBody'] = $this->MessageBody;
        if (isset($this->Created)) $o['Created'] = JsonConverters::to('DateTime', $this->Created);
        if (isset($this->ToSendDate)) $o['ToSendDate'] = JsonConverters::to('DateTime', $this->ToSendDate);
        if (isset($this->SentDate)) $o['SentDate'] = JsonConverters::to('DateTime', $this->SentDate);
        if (isset($this->Sent)) $o['Sent'] = $this->Sent;
        if (isset($this->MessageRetries)) $o['MessageRetries'] = $this->MessageRetries;
        if (isset($this->SendMethodId)) $o['SendMethodId'] = $this->SendMethodId;
        return empty($o) ? new class(){} : $o;
    }
}

// @ApiResponse(Description="You were unauthorized to call this service", StatusCode=401)
class SendEmailToCompany implements ICompany, JsonSerializable
{
    public function __construct(
        /** @description The company id, if empty you will need to provide the sitepath instead. */
        // @ApiMember(Description="The company id, if empty you will need to provide the sitepath instead.")
        /** @var string|null */
        public ?string $CompanyId=null,

        /** @description Message Title. */
        // @ApiMember(Description="Message Title.")
        /** @var string|null */
        public ?string $MessageTitle=null,

        /** @description Message Body. */
        // @ApiMember(Description="Message Body.")
        /** @var string|null */
        public ?string $MessageBody=null,

        /** @description Message Sender Name. */
        // @ApiMember(Description="Message Sender Name.")
        /** @var string|null */
        public ?string $Name=null,

        /** @description Message Sender Email. */
        // @ApiMember(Description="Message Sender Email.")
        /** @var string|null */
        public ?string $Email=null,

        /** @description Message Sender Phone Number. */
        // @ApiMember(Description="Message Sender Phone Number.")
        /** @var string|null */
        public ?string $Phone=null,

        /** @description The homeage sitepath. */
        // @ApiMember(Description="The homeage sitepath.")
        /** @var string|null */
        public ?string $SitePath=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['CompanyId'])) $this->CompanyId = $o['CompanyId'];
        if (isset($o['MessageTitle'])) $this->MessageTitle = $o['MessageTitle'];
        if (isset($o['MessageBody'])) $this->MessageBody = $o['MessageBody'];
        if (isset($o['Name'])) $this->Name = $o['Name'];
        if (isset($o['Email'])) $this->Email = $o['Email'];
        if (isset($o['Phone'])) $this->Phone = $o['Phone'];
        if (isset($o['SitePath'])) $this->SitePath = $o['SitePath'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->CompanyId)) $o['CompanyId'] = $this->CompanyId;
        if (isset($this->MessageTitle)) $o['MessageTitle'] = $this->MessageTitle;
        if (isset($this->MessageBody)) $o['MessageBody'] = $this->MessageBody;
        if (isset($this->Name)) $o['Name'] = $this->Name;
        if (isset($this->Email)) $o['Email'] = $this->Email;
        if (isset($this->Phone)) $o['Phone'] = $this->Phone;
        if (isset($this->SitePath)) $o['SitePath'] = $this->SitePath;
        return empty($o) ? new class(){} : $o;
    }
}

PHP SendEmailToCompany 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 /messages/sendemailtocompany HTTP/1.1 
Host: api.bokamera.se 
Accept: text/csv
Content-Type: text/csv
Content-Length: length

{"CompanyId":"00000000-0000-0000-0000-000000000000","MessageTitle":"String","MessageBody":"String","Name":"String","Email":"String","Phone":"String","SitePath":"String"}
HTTP/1.1 200 OK
Content-Type: text/csv
Content-Length: length

{"Id":0,"BookingId":0,"Receiver":"String","MessageTitle":"String","StorageUrl":"String","MessageBody":"String","SentDate":"0001-01-01T00:00:00","Sent":false,"MessageRetries":0,"SendMethodId":0}