| All Verbs | /qry/users/notifications |
|---|
<?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};
enum Severity : int
{
case Success = 0;
case Info = 1;
case Warning = 2;
case Error = 3;
}
enum NotificationType : int
{
case Default = 0;
case SlipDeliveryConfirmationRequest = 1;
case SlipDeliveryIssueResolved = 2;
}
class Notification implements JsonSerializable
{
public function __construct(
/** @var Severity|null */
public ?Severity $severity=null,
/** @var NotificationType|null */
public ?NotificationType $type=null,
/** @var RecordDictionary2<string, string>|null */
public ?RecordDictionary2 $data=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['severity'])) $this->severity = JsonConverters::from('Severity', $o['severity']);
if (isset($o['type'])) $this->type = JsonConverters::from('NotificationType', $o['type']);
if (isset($o['data'])) $this->data = JsonConverters::from(JsonConverters::context('RecordDictionary2',genericArgs:['string','string']), $o['data']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->severity)) $o['severity'] = JsonConverters::to('Severity', $this->severity);
if (isset($this->type)) $o['type'] = JsonConverters::to('NotificationType', $this->type);
if (isset($this->data)) $o['data'] = JsonConverters::to(JsonConverters::context('RecordDictionary2',genericArgs:['string','string']), $this->data);
return empty($o) ? new class(){} : $o;
}
}
class UserNotification implements JsonSerializable
{
public function __construct(
/** @var string|null */
public ?string $id=null,
/** @var Notification|null */
public ?Notification $notification=null,
/** @var DateTime */
public DateTime $dispatchedAt=new DateTime()
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['id'])) $this->id = $o['id'];
if (isset($o['notification'])) $this->notification = JsonConverters::from('Notification', $o['notification']);
if (isset($o['dispatchedAt'])) $this->dispatchedAt = JsonConverters::from('DateTime', $o['dispatchedAt']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->id)) $o['id'] = $this->id;
if (isset($this->notification)) $o['notification'] = JsonConverters::to('Notification', $this->notification);
if (isset($this->dispatchedAt)) $o['dispatchedAt'] = JsonConverters::to('DateTime', $this->dispatchedAt);
return empty($o) ? new class(){} : $o;
}
}
class UserNotifications implements JsonSerializable
{
public function __construct(
/** @var string|null */
public ?string $id=null,
/** @var int */
public int $n=0,
/** @var int */
public int $s=0,
/** @var int */
public int $i=0,
/** @var int */
public int $w=0,
/** @var int */
public int $e=0,
/** @var array<string,UserNotification>|null */
public ?array $notifications=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['id'])) $this->id = $o['id'];
if (isset($o['n'])) $this->n = $o['n'];
if (isset($o['s'])) $this->s = $o['s'];
if (isset($o['i'])) $this->i = $o['i'];
if (isset($o['w'])) $this->w = $o['w'];
if (isset($o['e'])) $this->e = $o['e'];
if (isset($o['notifications'])) $this->notifications = JsonConverters::from(JsonConverters::context('Dictionary',genericArgs:['string','UserNotification']), $o['notifications']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->id)) $o['id'] = $this->id;
if (isset($this->n)) $o['n'] = $this->n;
if (isset($this->s)) $o['s'] = $this->s;
if (isset($this->i)) $o['i'] = $this->i;
if (isset($this->w)) $o['w'] = $this->w;
if (isset($this->e)) $o['e'] = $this->e;
if (isset($this->notifications)) $o['notifications'] = JsonConverters::to(JsonConverters::context('Dictionary',genericArgs:['string','UserNotification']), $this->notifications);
return empty($o) ? new class(){} : $o;
}
}
class GetUserNotifications implements JsonSerializable
{
public function __construct(
/** @var string|null */
public ?string $id=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['id'])) $this->id = $o['id'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->id)) $o['id'] = $this->id;
return empty($o) ? new class(){} : $o;
}
}
/**
* @template TKey
* @template TVal
* @template array of TKey
* @template array1 of TVal
*/
class RecordDictionary2 extends array implements JsonSerializable
{
public array $genericArgs = [];
public static function create(array $genericArgs=[]): RecordDictionary2 {
$to = new RecordDictionary2();
$to->genericArgs = $genericArgs;
return $to;
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
return empty($o) ? new class(){} : $o;
}
}
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 /qry/users/notifications HTTP/1.1
Host: api.sbbet.ath.cx
Accept: text/jsv
Content-Type: text/jsv
Content-Length: length
{
id: String
}
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length
{
id: String,
n: 1,
s: 1,
i: 0,
w: 0,
e: 0,
notifications:
{
String:
{
id: String,
notification:
{
severity: 0,
type: 0,
data:
{
String: String
}
},
dispatchedAt: 0001-01-01
}
}
}