| All Verbs | /sendmail/sendgrid/single |
|---|
<?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 SendGridSingleMailRequest implements JsonSerializable
{
public function __construct(
/** @var EmailAddress|null */
public ?EmailAddress $to=null,
/** @var string|null */
public ?string $subject=null,
/** @var string|null */
public ?string $templateId=null,
/** @var EmailAddress|null */
public ?EmailAddress $replyToEmail=null,
/** @var EmailAddress|null */
public ?EmailAddress $fromEmail=null,
/** @var string|null */
public ?string $plaintText=null,
/** @var string|null */
public ?string $htmlText=null,
/** @var string|null */
public ?string $apiKey=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['to'])) $this->to = JsonConverters::from('EmailAddress', $o['to']);
if (isset($o['subject'])) $this->subject = $o['subject'];
if (isset($o['templateId'])) $this->templateId = $o['templateId'];
if (isset($o['replyToEmail'])) $this->replyToEmail = JsonConverters::from('EmailAddress', $o['replyToEmail']);
if (isset($o['fromEmail'])) $this->fromEmail = JsonConverters::from('EmailAddress', $o['fromEmail']);
if (isset($o['plaintText'])) $this->plaintText = $o['plaintText'];
if (isset($o['htmlText'])) $this->htmlText = $o['htmlText'];
if (isset($o['apiKey'])) $this->apiKey = $o['apiKey'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->to)) $o['to'] = JsonConverters::to('EmailAddress', $this->to);
if (isset($this->subject)) $o['subject'] = $this->subject;
if (isset($this->templateId)) $o['templateId'] = $this->templateId;
if (isset($this->replyToEmail)) $o['replyToEmail'] = JsonConverters::to('EmailAddress', $this->replyToEmail);
if (isset($this->fromEmail)) $o['fromEmail'] = JsonConverters::to('EmailAddress', $this->fromEmail);
if (isset($this->plaintText)) $o['plaintText'] = $this->plaintText;
if (isset($this->htmlText)) $o['htmlText'] = $this->htmlText;
if (isset($this->apiKey)) $o['apiKey'] = $this->apiKey;
return empty($o) ? new class(){} : $o;
}
}
PHP SendGridSingleMailRequest DTOs
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 /sendmail/sendgrid/single HTTP/1.1
Host: api.sfgtec.com
Accept: application/xml
Content-Type: application/xml
Content-Length: length
<SendGridSingleMailRequest xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/sfgboxapi.ServiceInterface">
<APIKey>String</APIKey>
<FromEmail xmlns:d2p1="http://schemas.datacontract.org/2004/07/SendGrid.Helpers.Mail">
<d2p1:Email>String</d2p1:Email>
<d2p1:Name>String</d2p1:Name>
</FromEmail>
<HtmlText>String</HtmlText>
<PlaintText>String</PlaintText>
<ReplyToEmail xmlns:d2p1="http://schemas.datacontract.org/2004/07/SendGrid.Helpers.Mail">
<d2p1:Email>String</d2p1:Email>
<d2p1:Name>String</d2p1:Name>
</ReplyToEmail>
<Subject>String</Subject>
<TemplateId>String</TemplateId>
<To xmlns:d2p1="http://schemas.datacontract.org/2004/07/SendGrid.Helpers.Mail">
<d2p1:Email>String</d2p1:Email>
<d2p1:Name>String</d2p1:Name>
</To>
</SendGridSingleMailRequest>
HTTP/1.1 200 OK Content-Type: application/xml Content-Length: length <z:anyType xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/" />