| POST | /cmd/locations/devices/add |
|---|
<?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 DeviceUsageMode : int
{
case ClerkServiced = 0;
case Personal = 1;
case SelfService = 2;
case Unknown = -1;
}
enum DeviceUserInterface : int
{
case Tablet = 0;
case Kiosk = 1;
case Default = 2;
case Unknown = -1;
}
class Ref implements JsonSerializable
{
public function __construct(
/** @var string */
public string $id='',
/** @var string */
public string $val=''
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['id'])) $this->id = $o['id'];
if (isset($o['val'])) $this->val = $o['val'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->id)) $o['id'] = $this->id;
if (isset($this->val)) $o['val'] = $this->val;
return empty($o) ? new class(){} : $o;
}
}
enum DeviceManagement : int
{
case Partner = 1;
case Platform = 2;
}
class DeviceProfile implements JsonSerializable
{
public function __construct(
/** @var DeviceUsageMode|null */
public ?DeviceUsageMode $usageMode=null,
/** @var DeviceUserInterface|null */
public ?DeviceUserInterface $userInterface=null,
/** @var Ref|null */
public ?Ref $wallet=null,
/** @var DeviceManagement|null */
public ?DeviceManagement $managedBy=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['usageMode'])) $this->usageMode = JsonConverters::from('DeviceUsageMode', $o['usageMode']);
if (isset($o['userInterface'])) $this->userInterface = JsonConverters::from('DeviceUserInterface', $o['userInterface']);
if (isset($o['wallet'])) $this->wallet = JsonConverters::from('Ref', $o['wallet']);
if (isset($o['managedBy'])) $this->managedBy = JsonConverters::from('DeviceManagement', $o['managedBy']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->usageMode)) $o['usageMode'] = JsonConverters::to('DeviceUsageMode', $this->usageMode);
if (isset($this->userInterface)) $o['userInterface'] = JsonConverters::to('DeviceUserInterface', $this->userInterface);
if (isset($this->wallet)) $o['wallet'] = JsonConverters::to('Ref', $this->wallet);
if (isset($this->managedBy)) $o['managedBy'] = JsonConverters::to('DeviceManagement', $this->managedBy);
return empty($o) ? new class(){} : $o;
}
}
class Device implements JsonSerializable
{
public function __construct(
/** @var string|null */
public ?string $id=null,
/** @var string|null */
public ?string $name=null,
/** @var bool|null */
public ?bool $isActive=null,
/** @var DeviceProfile|null */
public ?DeviceProfile $profile=null,
/** @var RecordDictionary2<string, string>|null */
public ?RecordDictionary2 $integrationsData=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['id'])) $this->id = $o['id'];
if (isset($o['name'])) $this->name = $o['name'];
if (isset($o['isActive'])) $this->isActive = $o['isActive'];
if (isset($o['profile'])) $this->profile = JsonConverters::from('DeviceProfile', $o['profile']);
if (isset($o['integrationsData'])) $this->integrationsData = JsonConverters::from(JsonConverters::context('RecordDictionary2',genericArgs:['string','string']), $o['integrationsData']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->id)) $o['id'] = $this->id;
if (isset($this->name)) $o['name'] = $this->name;
if (isset($this->isActive)) $o['isActive'] = $this->isActive;
if (isset($this->profile)) $o['profile'] = JsonConverters::to('DeviceProfile', $this->profile);
if (isset($this->integrationsData)) $o['integrationsData'] = JsonConverters::to(JsonConverters::context('RecordDictionary2',genericArgs:['string','string']), $this->integrationsData);
return empty($o) ? new class(){} : $o;
}
}
class AddLocationDevice implements JsonSerializable
{
public function __construct(
/** @var string|null */
public ?string $id=null,
/** @var Device|null */
public ?Device $device=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['id'])) $this->id = $o['id'];
if (isset($o['device'])) $this->device = JsonConverters::from('Device', $o['device']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->id)) $o['id'] = $this->id;
if (isset($this->device)) $o['device'] = JsonConverters::to('Device', $this->device);
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 .json suffix or ?format=json
To embed the response in a jsonp callback, append ?callback=myCallback
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /cmd/locations/devices/add HTTP/1.1
Host: api.bettor.webhop.biz
Accept: application/json
Content-Type: application/json
Content-Length: length
{"id":"String","device":{"id":"String","name":"String","isActive":false,"profile":{"usageMode":0,"userInterface":0,"wallet":{"id":"String","val":"String"},"managedBy":0},"integrationsData":{"String":"String"}}}
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: length
{"errorCode":"String","message":"String","stackTrace":"String","errors":[{"errorCode":"String","fieldName":"String","message":"String","meta":{"String":"String"}}],"meta":{"String":"String"}}