Requires any of the roles: | bookingsupplier-administrator-write, superadmin |
POST | /newsletter/send | Send 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;
}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml
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: application/xml
Content-Type: application/xml
Content-Length: length
<SendNewsLetter xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos">
<CompanyId>00000000-0000-0000-0000-000000000000</CompanyId>
<Customers xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<d2p1:guid>00000000-0000-0000-0000-000000000000</d2p1:guid>
</Customers>
<Id>0</Id>
<SendDate>0001-01-01T00:00:00</SendDate>
</SendNewsLetter>
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: length <SendNewslettersResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/BokaMera.API.ServiceModel.Dtos"> <MessageExample>String</MessageExample> <SendMethodId>0</SendMethodId> <Total>0</Total> </SendNewslettersResponse>