digitaluapi

<back to all web services

SendGridMailTemplateRequest

Requires Authentication
Requires any of the roles:Client, Admin, Partner
The following routes are available for this service:
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 .xml suffix or ?format=xml

HTTP + XML

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: application/xml
Content-Type: application/xml
Content-Length: length

<SendGridMailTemplateRequest xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/digitaluapi.ServiceInterface">
  <APIKey>String</APIKey>
  <From xmlns:d2p1="http://schemas.datacontract.org/2004/07/SendGrid.Helpers.Mail">
    <d2p1:Email>String</d2p1:Email>
    <d2p1:Name>String</d2p1:Name>
  </From>
  <Personalizations xmlns:d2p1="http://schemas.datacontract.org/2004/07/SendGrid.Helpers.Mail">
    <d2p1:Personalization>
      <d2p1:Bccs>
        <d2p1:EmailAddress>
          <d2p1:Email>String</d2p1:Email>
          <d2p1:Name>String</d2p1:Name>
        </d2p1:EmailAddress>
      </d2p1:Bccs>
      <d2p1:Ccs>
        <d2p1:EmailAddress>
          <d2p1:Email>String</d2p1:Email>
          <d2p1:Name>String</d2p1:Name>
        </d2p1:EmailAddress>
      </d2p1:Ccs>
      <d2p1:CustomArgs xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
        <d4p1:KeyValueOfstringstring>
          <d4p1:Key>String</d4p1:Key>
          <d4p1:Value>String</d4p1:Value>
        </d4p1:KeyValueOfstringstring>
      </d2p1:CustomArgs>
      <d2p1:From>
        <d2p1:Email>String</d2p1:Email>
        <d2p1:Name>String</d2p1:Name>
      </d2p1:From>
      <d2p1:Headers xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
        <d4p1:KeyValueOfstringstring>
          <d4p1:Key>String</d4p1:Key>
          <d4p1:Value>String</d4p1:Value>
        </d4p1:KeyValueOfstringstring>
      </d2p1:Headers>
      <d2p1:SendAt>0</d2p1:SendAt>
      <d2p1:Subject>String</d2p1:Subject>
      <d2p1:Substitutions xmlns:d4p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
        <d4p1:KeyValueOfstringstring>
          <d4p1:Key>String</d4p1:Key>
          <d4p1:Value>String</d4p1:Value>
        </d4p1:KeyValueOfstringstring>
      </d2p1:Substitutions>
      <d2p1:TemplateData />
      <d2p1:Tos>
        <d2p1:EmailAddress>
          <d2p1:Email>String</d2p1:Email>
          <d2p1:Name>String</d2p1:Name>
        </d2p1:EmailAddress>
      </d2p1:Tos>
    </d2p1:Personalization>
  </Personalizations>
  <Subject>String</Subject>
  <TemplatesId>String</TemplatesId>
</SendGridMailTemplateRequest>
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/" />