| POST | /sendgridevents |
|---|
<?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 SendGridEvent implements JsonSerializable
{
public function __construct(
// @DataMember(Name="sg_event_id")
/** @var string|null */
public ?string $sg_event_id=null,
// @DataMember(Name="sg_message_id")
/** @var string|null */
public ?string $sg_message_id=null,
/** @var string|null */
public ?string $email=null,
/** @var int */
public int $timestamp=0,
// @DataMember(Name="smtp-id")
/** @var string|null */
public ?string $smtp_id=null,
/** @var string|null */
public ?string $event=null,
/** @var string|null */
public ?string $type=null,
/** @var string[]|null */
public ?array $category=null,
/** @var string|null */
public ?string $reason=null,
/** @var string|null */
public ?string $status=null,
/** @var string|null */
public ?string $userAgent=null,
/** @var string|null */
public ?string $ip=null,
/** @var string|null */
public ?string $url=null,
// @DataMember(Name="url_offset")
/** @var string|null */
public ?string $url_offset=null,
// @DataMember(Name="sg_machine_open")
/** @var bool|null */
public ?bool $sg_machine_open=null,
/** @var string|null */
public ?string $tls=null,
// @DataMember(Name="unique_args")
/** @var array<string,string>|null */
public ?array $unique_args=null,
// @DataMember(Name="custom_args")
/** @var array<string,string>|null */
public ?array $custom_args=null,
// @DataMember(Name="marketing_campaign_id")
/** @var string|null */
public ?string $marketing_campaign_id=null,
// @DataMember(Name="marketing_campaign_name")
/** @var string|null */
public ?string $marketing_campaign_name=null,
// @DataMember(Name="singlesend_id")
/** @var string|null */
public ?string $singlesend_id=null,
// @DataMember(Name="singlesend_name")
/** @var string|null */
public ?string $singlesend_name=null,
// @DataMember(Name="bounce_classification")
/** @var string|null */
public ?string $bounce_classification=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
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['email'])) $this->email = $o['email'];
if (isset($o['timestamp'])) $this->timestamp = $o['timestamp'];
if (isset($o['smtp_id'])) $this->smtp_id = $o['smtp_id'];
if (isset($o['event'])) $this->event = $o['event'];
if (isset($o['type'])) $this->type = $o['type'];
if (isset($o['category'])) $this->category = JsonConverters::fromArray('string', $o['category']);
if (isset($o['reason'])) $this->reason = $o['reason'];
if (isset($o['status'])) $this->status = $o['status'];
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['url_offset'])) $this->url_offset = $o['url_offset'];
if (isset($o['sg_machine_open'])) $this->sg_machine_open = $o['sg_machine_open'];
if (isset($o['tls'])) $this->tls = $o['tls'];
if (isset($o['unique_args'])) $this->unique_args = JsonConverters::from(JsonConverters::context('Dictionary',genericArgs:['string','string']), $o['unique_args']);
if (isset($o['custom_args'])) $this->custom_args = JsonConverters::from(JsonConverters::context('Dictionary',genericArgs:['string','string']), $o['custom_args']);
if (isset($o['marketing_campaign_id'])) $this->marketing_campaign_id = $o['marketing_campaign_id'];
if (isset($o['marketing_campaign_name'])) $this->marketing_campaign_name = $o['marketing_campaign_name'];
if (isset($o['singlesend_id'])) $this->singlesend_id = $o['singlesend_id'];
if (isset($o['singlesend_name'])) $this->singlesend_name = $o['singlesend_name'];
if (isset($o['bounce_classification'])) $this->bounce_classification = $o['bounce_classification'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
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->email)) $o['email'] = $this->email;
if (isset($this->timestamp)) $o['timestamp'] = $this->timestamp;
if (isset($this->smtp_id)) $o['smtp_id'] = $this->smtp_id;
if (isset($this->event)) $o['event'] = $this->event;
if (isset($this->type)) $o['type'] = $this->type;
if (isset($this->category)) $o['category'] = JsonConverters::toArray('string', $this->category);
if (isset($this->reason)) $o['reason'] = $this->reason;
if (isset($this->status)) $o['status'] = $this->status;
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->url_offset)) $o['url_offset'] = $this->url_offset;
if (isset($this->sg_machine_open)) $o['sg_machine_open'] = $this->sg_machine_open;
if (isset($this->tls)) $o['tls'] = $this->tls;
if (isset($this->unique_args)) $o['unique_args'] = JsonConverters::to(JsonConverters::context('Dictionary',genericArgs:['string','string']), $this->unique_args);
if (isset($this->custom_args)) $o['custom_args'] = JsonConverters::to(JsonConverters::context('Dictionary',genericArgs:['string','string']), $this->custom_args);
if (isset($this->marketing_campaign_id)) $o['marketing_campaign_id'] = $this->marketing_campaign_id;
if (isset($this->marketing_campaign_name)) $o['marketing_campaign_name'] = $this->marketing_campaign_name;
if (isset($this->singlesend_id)) $o['singlesend_id'] = $this->singlesend_id;
if (isset($this->singlesend_name)) $o['singlesend_name'] = $this->singlesend_name;
if (isset($this->bounce_classification)) $o['bounce_classification'] = $this->bounce_classification;
return empty($o) ? new class(){} : $o;
}
}
/**
* @template array of SendGridEvent
*/
class SendGridEvents extends \ArrayObject implements JsonSerializable
{
public function __construct(SendGridEvent ...$items) {
parent::__construct($items, \ArrayObject::STD_PROP_LIST);
}
/** @throws \Exception */
public function append($value): void {
if ($value instanceof SendGridEvent)
parent::append($value);
else
throw new \Exception("Can only append a SendGridEvent to " . __CLASS__);
}
/** @throws Exception */
public function fromMap($o): void {
foreach ($o as $item) {
$el = new SendGridEvent();
$el->fromMap($item);
$this->append($el);
}
}
/** @throws Exception */
public function jsonSerialize(): array {
return parent::getArrayCopy();
}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .jsv suffix or ?format=jsv
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /sendgridevents HTTP/1.1
Host: cpmwebservices-t.clarkpud.com
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length
[
]
HTTP/1.1 200 OK Content-Type: text/jsv Content-Length: length (string)