sfgboxapi

<back to all web services

SendGridSingleMailRequest

Requires Authentication
The following routes are available for this service:
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 .csv suffix or ?format=csv

HTTP + CSV

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: sfgboxapi.dev.scadsoftware.com 
Accept: text/csv
Content-Type: text/csv
Content-Length: length

{"to":{"name":"String","email":"String"},"subject":"String","templateId":"String","replyToEmail":{"name":"String","email":"String"},"fromEmail":{"name":"String","email":"String"},"plaintText":"String","htmlText":"String","apiKey":"String"}
HTTP/1.1 200 OK
Content-Type: text/csv
Content-Length: length

{}