Requires any of the roles: | bookingsupplier-administrator-write, superadmin, bookingsupplier-administrator-read |
POST | /messages/templates/test | Test to send a message 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 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)
// @ValidateRequest(Validator="IsAuthenticated")
class TestSendMessageTemplate 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 message template title. */
// @ApiMember(Description="The message template title.")
/** @var string|null */
public ?string $Title=null,
/** @description The newsletter template body. */
// @ApiMember(Description="The newsletter template body.", IsRequired=true)
/** @var string */
public string $Body='',
/** @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 Message template lanugage */
// @ApiMember(Description="Message template lanugage", IsRequired=true)
/** @var string */
public string $Language='',
/** @description The services that is connected to the message. If null it will be connected to all services. */
// @ApiMember(Description="The services that is connected to the message. 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['Receiver'])) $this->Receiver = $o['Receiver'];
if (isset($o['Title'])) $this->Title = $o['Title'];
if (isset($o['Body'])) $this->Body = $o['Body'];
if (isset($o['TypeId'])) $this->TypeId = $o['TypeId'];
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->Receiver)) $o['Receiver'] = $this->Receiver;
if (isset($this->Title)) $o['Title'] = $this->Title;
if (isset($this->Body)) $o['Body'] = $this->Body;
if (isset($this->TypeId)) $o['TypeId'] = $this->TypeId;
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 TestSendMessageTemplate DTOs
To override the Content-type in your clients, use the HTTP Accept Header, append the .other suffix or ?format=other
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /messages/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","Title":"String","Body":"String","TypeId":0,"Language":"String","Services":[0]}
HTTP/1.1 200 OK Content-Type: text/jsonl 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}