BokaMera.API.Host

<back to all web services

SendNewsLetter

Requires Authentication
Requires any of the roles:bookingsupplier-administrator-write, superadmin
The following routes are available for this service:
POST/newsletter/sendSend a newsletter to a customers.
<?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 SendNewslettersResponse implements JsonSerializable
{
    public function __construct(
        /** @description The number of messages that are added into queue. */
        // @ApiMember(Description="The number of messages that are added into queue.")
        /** @var int */
        public int $Total=0,

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

        /** @description Message example sent (in HTML format) */
        // @ApiMember(Description="Message example sent (in HTML format)")
        /** @var string|null */
        public ?string $MessageExample=null
    ) {
    }

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

// @ApiResponse(Description="You were unauthorized to call this service", StatusCode=401)
// @ValidateRequest(Validator="IsAuthenticated")
class SendNewsLetter implements ICompany, JsonSerializable
{
    public function __construct(
        /** @description The newsletter template id. */
        // @ApiMember(Description="The newsletter template id.", IsRequired=true)
        /** @var int */
        public int $Id=0,

        /** @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 datetime when the newsletters should be sent. */
        // @ApiMember(Description="The datetime when the newsletters should be sent.", IsRequired=true)
        /** @var DateTime */
        public DateTime $SendDate=new DateTime(),

        /** @description The customer ids to send newsletters to. */
        // @ApiMember(Description="The customer ids to send newsletters to.", IsRequired=true)
        /** @var array<string>|null */
        public ?array $Customers=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['Id'])) $this->Id = $o['Id'];
        if (isset($o['CompanyId'])) $this->CompanyId = $o['CompanyId'];
        if (isset($o['SendDate'])) $this->SendDate = JsonConverters::from('DateTime', $o['SendDate']);
        if (isset($o['Customers'])) $this->Customers = JsonConverters::fromArray('Guid', $o['Customers']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->Id)) $o['Id'] = $this->Id;
        if (isset($this->CompanyId)) $o['CompanyId'] = $this->CompanyId;
        if (isset($this->SendDate)) $o['SendDate'] = JsonConverters::to('DateTime', $this->SendDate);
        if (isset($this->Customers)) $o['Customers'] = JsonConverters::toArray('Guid', $this->Customers);
        return empty($o) ? new class(){} : $o;
    }
}

PHP SendNewsLetter 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/send HTTP/1.1 
Host: api.bokamera.se 
Accept: text/jsonl
Content-Type: text/jsonl
Content-Length: length

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

{"Total":0,"SendMethodId":0,"MessageExample":"String"}