BokaMera.API.Host

<back to all web services

CreateMessageTemplate

Requires Authentication
Requires any of the roles:bookingsupplier-administrator-write, superadmin
The following routes are available for this service:
POST/messages/templatesCreate a new company message templatesCreate a new company message templates.
<?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 MessageTypeQueryResponse implements JsonSerializable
{
    public function __construct(
        /** @description The message type id */
        // @ApiMember(Description="The message type id")
        /** @var int */
        public int $Id=0,

        /** @description The message type name. */
        // @ApiMember(Description="The message type name.")
        /** @var string|null */
        public ?string $Name=null,

        /** @description The message type description. */
        // @ApiMember(Description="The message type description.")
        /** @var string|null */
        public ?string $Description=null,

        /** @description The maximum number of charachters that can be entered into message body using this type. */
        // @ApiMember(Description="The maximum number of charachters that can be entered into message body using this type.")
        /** @var int */
        public int $MaxCharacters=0,

        /** @description The default text that is always included when sending messages of this type. */
        // @ApiMember(Description="The default text that is always included when sending messages of this type.")
        /** @var string|null */
        public ?string $DefaultText=null,

        /** @description The send method for this type. 1 = Email, 2 = SMS. */
        // @ApiMember(Description="The send method for this type. 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['Name'])) $this->Name = $o['Name'];
        if (isset($o['Description'])) $this->Description = $o['Description'];
        if (isset($o['MaxCharacters'])) $this->MaxCharacters = $o['MaxCharacters'];
        if (isset($o['DefaultText'])) $this->DefaultText = $o['DefaultText'];
        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->Name)) $o['Name'] = $this->Name;
        if (isset($this->Description)) $o['Description'] = $this->Description;
        if (isset($this->MaxCharacters)) $o['MaxCharacters'] = $this->MaxCharacters;
        if (isset($this->DefaultText)) $o['DefaultText'] = $this->DefaultText;
        if (isset($this->SendMethodId)) $o['SendMethodId'] = $this->SendMethodId;
        return empty($o) ? new class(){} : $o;
    }
}

class MessageServices implements JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $Id=0,
        /** @description Name of the service */
        // @ApiMember(Description="Name of the service")
        /** @var string|null */
        public ?string $Name=null,

        /** @description The image url of the service */
        // @ApiMember(Description="The image url of the service")
        /** @var string|null */
        public ?string $ImageUrl=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['ImageUrl'])) $this->ImageUrl = JsonConverters::from('string', $o['ImageUrl']);
    }
    
    /** @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->ImageUrl)) $o['ImageUrl'] = JsonConverters::to('string', $this->ImageUrl);
        return empty($o) ? new class(){} : $o;
    }
}

class MessageTemplatesQueryResponse implements JsonSerializable
{
    public function __construct(
        /** @description The message template id */
        // @ApiMember(Description="The message template id")
        /** @var int */
        public int $Id=0,

        /** @description The message template name. */
        // @ApiMember(Description="The message template name.")
        /** @var string|null */
        public ?string $Name=null,

        /** @description The message template title. */
        // @ApiMember(Description="The message template title.")
        /** @var string|null */
        public ?string $Title=null,

        /** @description The message template title. */
        // @ApiMember(Description="The message template title.")
        /** @var string|null */
        public ?string $Body=null,

        /** @description The message template sender (an email for message types with sendmethod 1, for SMS this cannot be set). */
        // @ApiMember(Description="The message template sender (an email for message types with sendmethod 1, for SMS this cannot be set).")
        /** @var string|null */
        public ?string $Sender=null,

        /** @description If the message template is the default message currently in use. */
        // @ApiMember(Description="If the message template is the default message currently in use.")
        /** @var bool|null */
        public ?bool $Default=null,

        /** @description If the message type information. */
        // @ApiMember(Description="If the message type information.")
        /** @var MessageTypeQueryResponse|null */
        public ?MessageTypeQueryResponse $MessageType=null,

        /** @description Template language. */
        // @ApiMember(Description="Template language.")
        /** @var string|null */
        public ?string $Language=null,

        /** @description The connected services which the template is valid for. If empty then it's valid for all services. */
        // @ApiMember(Description="The connected services which the template is valid for. If empty then it's valid for all services.")
        /** @var array<MessageServices>|null */
        public ?array $Services=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['Title'])) $this->Title = $o['Title'];
        if (isset($o['Body'])) $this->Body = $o['Body'];
        if (isset($o['Sender'])) $this->Sender = $o['Sender'];
        if (isset($o['Default'])) $this->Default = $o['Default'];
        if (isset($o['MessageType'])) $this->MessageType = JsonConverters::from('MessageTypeQueryResponse', $o['MessageType']);
        if (isset($o['Language'])) $this->Language = $o['Language'];
        if (isset($o['Services'])) $this->Services = JsonConverters::fromArray('MessageServices', $o['Services']);
    }
    
    /** @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->Title)) $o['Title'] = $this->Title;
        if (isset($this->Body)) $o['Body'] = $this->Body;
        if (isset($this->Sender)) $o['Sender'] = $this->Sender;
        if (isset($this->Default)) $o['Default'] = $this->Default;
        if (isset($this->MessageType)) $o['MessageType'] = JsonConverters::to('MessageTypeQueryResponse', $this->MessageType);
        if (isset($this->Language)) $o['Language'] = $this->Language;
        if (isset($this->Services)) $o['Services'] = JsonConverters::toArray('MessageServices', $this->Services);
        return empty($o) ? new class(){} : $o;
    }
}

// @ApiResponse(Description="You were unauthorized to call this service", StatusCode=401)
// @ValidateRequest(Validator="IsAuthenticated")
class CreateMessageTemplate 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 message type id. See GET /messages/templates/types  */
        // @ApiMember(Description="The message type id. See GET /messages/templates/types ", IsRequired=true)
        /** @var int */
        public int $TypeId=0,

        /** @description The message template name. */
        // @ApiMember(Description="The message template name.", IsRequired=true)
        /** @var string */
        public string $Name='',

        /** @description The message template title. */
        // @ApiMember(Description="The message template title.", IsRequired=true)
        /** @var string */
        public string $Title='',

        /** @description The message template title. */
        // @ApiMember(Description="The message template title.", IsRequired=true)
        /** @var string */
        public string $Body='',

        /** @description The message template sender (an email for message types with sendmethod 1, for SMS this cannot be set). */
        // @ApiMember(Description="The message template sender (an email for message types with sendmethod 1, for SMS this cannot be set).")
        /** @var string|null */
        public ?string $Sender=null,

        /** @description Template Language sv / en */
        // @ApiMember(Description="Template Language sv / en")
        /** @var string|null */
        public ?string $Language=null,

        /** @description The services that is connected to the template. If null it will be connected to all services. */
        // @ApiMember(Description="The services that is connected to the template. If null it will be connected to all services.")
        /** @var int[]|null */
        public ?array $Services=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['CompanyId'])) $this->CompanyId = $o['CompanyId'];
        if (isset($o['TypeId'])) $this->TypeId = $o['TypeId'];
        if (isset($o['Name'])) $this->Name = $o['Name'];
        if (isset($o['Title'])) $this->Title = $o['Title'];
        if (isset($o['Body'])) $this->Body = $o['Body'];
        if (isset($o['Sender'])) $this->Sender = $o['Sender'];
        if (isset($o['Language'])) $this->Language = $o['Language'];
        if (isset($o['Services'])) $this->Services = JsonConverters::fromArray('int', $o['Services']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->CompanyId)) $o['CompanyId'] = $this->CompanyId;
        if (isset($this->TypeId)) $o['TypeId'] = $this->TypeId;
        if (isset($this->Name)) $o['Name'] = $this->Name;
        if (isset($this->Title)) $o['Title'] = $this->Title;
        if (isset($this->Body)) $o['Body'] = $this->Body;
        if (isset($this->Sender)) $o['Sender'] = $this->Sender;
        if (isset($this->Language)) $o['Language'] = $this->Language;
        if (isset($this->Services)) $o['Services'] = JsonConverters::toArray('int', $this->Services);
        return empty($o) ? new class(){} : $o;
    }
}

PHP CreateMessageTemplate DTOs

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

HTTP + XML

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

POST /messages/templates HTTP/1.1 
Host: api.bokamera.se 
Accept: application/xml
Content-Type: application/xml
Content-Length: length

<CreateMessageTemplate xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos">
  <Body>String</Body>
  <CompanyId>00000000-0000-0000-0000-000000000000</CompanyId>
  <Language>String</Language>
  <Name>String</Name>
  <Sender>String</Sender>
  <Services xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
    <d2p1:int>0</d2p1:int>
  </Services>
  <Title>String</Title>
  <TypeId>0</TypeId>
</CreateMessageTemplate>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<MessageTemplatesQueryResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos">
  <Body>String</Body>
  <Default>false</Default>
  <Id>0</Id>
  <Language>String</Language>
  <MessageType>
    <DefaultText>String</DefaultText>
    <Description>String</Description>
    <Id>0</Id>
    <MaxCharacters>0</MaxCharacters>
    <Name>String</Name>
    <SendMethodId>0</SendMethodId>
  </MessageType>
  <Name>String</Name>
  <Sender>String</Sender>
  <Services>
    <MessageServices>
      <Id>0</Id>
      <ImageUrl i:nil="true" />
      <Name>String</Name>
    </MessageServices>
  </Services>
  <Title>String</Title>
</MessageTemplatesQueryResponse>