digitaluapi

<back to all web services

SendGridWebHook

<?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 SendGridWebHooksData implements JsonSerializable
{
    public function __construct(
        // @DataMember(Name="email")
        /** @var string|null */
        public ?string $email=null,

        // @DataMember(Name="timestamp")
        /** @var int */
        public int $timestamp=0,

        /** @var string|null */
        public ?string $SmtpId=null,
        /** @var string|null */
        public ?string $Event=null,
        /** @var string[]|null */
        public ?array $Category=null,
        /** @var string|null */
        public ?string $Sg_Event_Id=null,
        /** @var string|null */
        public ?string $Sg_Message_Id=null,
        /** @var string|null */
        public ?string $Useragent=null,
        /** @var string|null */
        public ?string $Ip=null,
        /** @var string|null */
        public ?string $Url=null,
        /** @var string|null */
        public ?string $Asm_Group_id=null,
        /** @var string|null */
        public ?string $OurUniqueId=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['email'])) $this->email = $o['email'];
        if (isset($o['timestamp'])) $this->timestamp = $o['timestamp'];
        if (isset($o['SmtpId'])) $this->SmtpId = $o['SmtpId'];
        if (isset($o['Event'])) $this->Event = $o['Event'];
        if (isset($o['Category'])) $this->Category = JsonConverters::fromArray('string', $o['Category']);
        if (isset($o['Sg_Event_Id'])) $this->Sg_Event_Id = $o['Sg_Event_Id'];
        if (isset($o['Sg_Message_Id'])) $this->Sg_Message_Id = $o['Sg_Message_Id'];
        if (isset($o['Useragent'])) $this->Useragent = $o['Useragent'];
        if (isset($o['Ip'])) $this->Ip = $o['Ip'];
        if (isset($o['Url'])) $this->Url = $o['Url'];
        if (isset($o['Asm_Group_id'])) $this->Asm_Group_id = $o['Asm_Group_id'];
        if (isset($o['OurUniqueId'])) $this->OurUniqueId = $o['OurUniqueId'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->email)) $o['email'] = $this->email;
        if (isset($this->timestamp)) $o['timestamp'] = $this->timestamp;
        if (isset($this->SmtpId)) $o['SmtpId'] = $this->SmtpId;
        if (isset($this->Event)) $o['Event'] = $this->Event;
        if (isset($this->Category)) $o['Category'] = JsonConverters::toArray('string', $this->Category);
        if (isset($this->Sg_Event_Id)) $o['Sg_Event_Id'] = $this->Sg_Event_Id;
        if (isset($this->Sg_Message_Id)) $o['Sg_Message_Id'] = $this->Sg_Message_Id;
        if (isset($this->Useragent)) $o['Useragent'] = $this->Useragent;
        if (isset($this->Ip)) $o['Ip'] = $this->Ip;
        if (isset($this->Url)) $o['Url'] = $this->Url;
        if (isset($this->Asm_Group_id)) $o['Asm_Group_id'] = $this->Asm_Group_id;
        if (isset($this->OurUniqueId)) $o['OurUniqueId'] = $this->OurUniqueId;
        return empty($o) ? new class(){} : $o;
    }
}

/**
 * @template array of SendGridWebHooksData
 */
class SendGridWebHook extends \ArrayObject implements JsonSerializable
{
    public function __construct(SendGridWebHooksData ...$items) {
        parent::__construct($items, \ArrayObject::STD_PROP_LIST);
    }
    
    /** @throws \Exception */
    public function append($value): void {
        if ($value instanceof SendGridWebHooksData)
            parent::append($value);
        else
            throw new \Exception("Can only append a SendGridWebHooksData to " . __CLASS__);
    }
    
    /** @throws Exception */
    public function fromMap($o): void {
        foreach ($o as $item) {
            $el = new SendGridWebHooksData();
            $el->fromMap($item);
            $this->append($el);
        }
    }
    
    /** @throws Exception */
    public function jsonSerialize(): array {
        return parent::getArrayCopy();
    }
}

PHP SendGridWebHook DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv

HTTP + JSV

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /jsv/reply/SendGridWebHook HTTP/1.1 
Host: duengageapi.uat.scadsoftware.com 
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length

[
	
]
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	
}