| Requires any of the roles: | Client, Admin, Partner |
| All Verbs | /sendmail/sendgridtemplate |
|---|
<?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 EmailAddress implements JsonSerializable
{
public function __construct(
/** @var string|null */
public ?string $Name=null,
/** @var string|null */
public ?string $Email=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Name'])) $this->Name = $o['Name'];
if (isset($o['Email'])) $this->Email = $o['Email'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Name)) $o['Name'] = $this->Name;
if (isset($this->Email)) $o['Email'] = $this->Email;
return empty($o) ? new class(){} : $o;
}
}
class Personalization implements JsonSerializable
{
public function __construct(
/** @var array<EmailAddress>|null */
public ?array $Tos=null,
/** @var array<EmailAddress>|null */
public ?array $Ccs=null,
/** @var array<EmailAddress>|null */
public ?array $Bccs=null,
/** @var EmailAddress|null */
public ?EmailAddress $From=null,
/** @var string|null */
public ?string $Subject=null,
/** @var array<string,string>|null */
public ?array $Headers=null,
/** @var array<string,string>|null */
public ?array $Substitutions=null,
/** @var array<string,string>|null */
public ?array $CustomArgs=null,
/** @var int|null */
public ?int $SendAt=null,
/** @var Object|null */
public ?Object $TemplateData=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['Tos'])) $this->Tos = JsonConverters::fromArray('EmailAddress', $o['Tos']);
if (isset($o['Ccs'])) $this->Ccs = JsonConverters::fromArray('EmailAddress', $o['Ccs']);
if (isset($o['Bccs'])) $this->Bccs = JsonConverters::fromArray('EmailAddress', $o['Bccs']);
if (isset($o['From'])) $this->From = JsonConverters::from('EmailAddress', $o['From']);
if (isset($o['Subject'])) $this->Subject = $o['Subject'];
if (isset($o['Headers'])) $this->Headers = JsonConverters::from(JsonConverters::context('Dictionary',genericArgs:['string','string']), $o['Headers']);
if (isset($o['Substitutions'])) $this->Substitutions = JsonConverters::from(JsonConverters::context('Dictionary',genericArgs:['string','string']), $o['Substitutions']);
if (isset($o['CustomArgs'])) $this->CustomArgs = JsonConverters::from(JsonConverters::context('Dictionary',genericArgs:['string','string']), $o['CustomArgs']);
if (isset($o['SendAt'])) $this->SendAt = $o['SendAt'];
if (isset($o['TemplateData'])) $this->TemplateData = JsonConverters::from('Object', $o['TemplateData']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->Tos)) $o['Tos'] = JsonConverters::toArray('EmailAddress', $this->Tos);
if (isset($this->Ccs)) $o['Ccs'] = JsonConverters::toArray('EmailAddress', $this->Ccs);
if (isset($this->Bccs)) $o['Bccs'] = JsonConverters::toArray('EmailAddress', $this->Bccs);
if (isset($this->From)) $o['From'] = JsonConverters::to('EmailAddress', $this->From);
if (isset($this->Subject)) $o['Subject'] = $this->Subject;
if (isset($this->Headers)) $o['Headers'] = JsonConverters::to(JsonConverters::context('Dictionary',genericArgs:['string','string']), $this->Headers);
if (isset($this->Substitutions)) $o['Substitutions'] = JsonConverters::to(JsonConverters::context('Dictionary',genericArgs:['string','string']), $this->Substitutions);
if (isset($this->CustomArgs)) $o['CustomArgs'] = JsonConverters::to(JsonConverters::context('Dictionary',genericArgs:['string','string']), $this->CustomArgs);
if (isset($this->SendAt)) $o['SendAt'] = $this->SendAt;
if (isset($this->TemplateData)) $o['TemplateData'] = JsonConverters::to('Object', $this->TemplateData);
return empty($o) ? new class(){} : $o;
}
}
class SendGridMailTemplateRequest implements JsonSerializable
{
public function __construct(
/** @var EmailAddress|null */
public ?EmailAddress $From=null,
/** @var string|null */
public ?string $Subject=null,
/** @var string|null */
public ?string $TemplatesId=null,
/** @var string|null */
public ?string $APIKey=null,
/** @var array<Personalization>|null */
public ?array $Personalizations=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['From'])) $this->From = JsonConverters::from('EmailAddress', $o['From']);
if (isset($o['Subject'])) $this->Subject = $o['Subject'];
if (isset($o['TemplatesId'])) $this->TemplatesId = $o['TemplatesId'];
if (isset($o['APIKey'])) $this->APIKey = $o['APIKey'];
if (isset($o['Personalizations'])) $this->Personalizations = JsonConverters::fromArray('Personalization', $o['Personalizations']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->From)) $o['From'] = JsonConverters::to('EmailAddress', $this->From);
if (isset($this->Subject)) $o['Subject'] = $this->Subject;
if (isset($this->TemplatesId)) $o['TemplatesId'] = $this->TemplatesId;
if (isset($this->APIKey)) $o['APIKey'] = $this->APIKey;
if (isset($this->Personalizations)) $o['Personalizations'] = JsonConverters::toArray('Personalization', $this->Personalizations);
return empty($o) ? new class(){} : $o;
}
}
PHP SendGridMailTemplateRequest 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 /sendmail/sendgridtemplate HTTP/1.1
Host: duengageapi.uat.scadsoftware.com
Accept: text/jsonl
Content-Type: text/jsonl
Content-Length: length
{"From":{"Name":"String","Email":"String"},"Subject":"String","TemplatesId":"String","APIKey":"String","Personalizations":[{"Tos":[{"Name":"String","Email":"String"}],"Ccs":[{"Name":"String","Email":"String"}],"Bccs":[{"Name":"String","Email":"String"}],"From":{"Name":"String","Email":"String"},"Subject":"String","Headers":{"String":"String"},"Substitutions":{"String":"String"},"CustomArgs":{"String":"String"},"SendAt":0,"TemplateData":{}}]}
HTTP/1.1 200 OK
Content-Type: text/jsonl
Content-Length: length
{}