BokaMera.API.Host

<back to all web services

TestSendNewsLetter

Requires Authentication
Requires any of the roles:bookingsupplier-administrator-write, superadmin
The following routes are available for this service:
POST/newsletter/templates/testTest to send a newsletter to a Email or Mobile phone recepient using SMS.
<?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 NewsletterLogQueryResponse implements JsonSerializable
{
    public function __construct(
        /** @description The message log id */
        // @ApiMember(Description="The message log id")
        /** @var int */
        public int $Id=0,

        /** @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 Nessage Title. */
        // @ApiMember(Description="Nessage Title.")
        /** @var string|null */
        public ?string $MessageTitle=null,

        /** @description Nessage Body. */
        // @ApiMember(Description="Nessage 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['Receiver'])) $this->Receiver = $o['Receiver'];
        if (isset($o['MessageTitle'])) $this->MessageTitle = $o['MessageTitle'];
        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->Receiver)) $o['Receiver'] = $this->Receiver;
        if (isset($this->MessageTitle)) $o['MessageTitle'] = $this->MessageTitle;
        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)
// @ValidateRequest(Validator="IsAuthenticated")
class TestSendNewsLetter 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 email recepient to receive the newsletter. For templates with send method SMS you need to enter a valid mobile phone number and send method Email a valid Email must be provided. */
        // @ApiMember(Description="The email recepient to receive the newsletter. For templates with send method SMS you need to enter a valid mobile phone number and send method Email a valid Email must be provided.", IsRequired=true)
        /** @var string */
        public string $Receiver='',

        /** @description The newsletter template id. */
        // @ApiMember(Description="The newsletter template id.", IsRequired=true)
        /** @var int */
        public int $Id=0
    ) {
    }

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

PHP TestSendNewsLetter DTOs

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

HTTP + OTHER

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

POST /newsletter/templates/test HTTP/1.1 
Host: api.bokamera.se 
Accept: text/jsonl
Content-Type: text/jsonl
Content-Length: length

{"CompanyId":"00000000-0000-0000-0000-000000000000","Receiver":"String","Id":0}
HTTP/1.1 200 OK
Content-Type: text/jsonl
Content-Length: length

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