<?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};
/** @description Logs details of an event(crash,error,unexpected result) and the device status at the time of the event. */
// @Api(Description="Logs details of an event(crash,error,unexpected result) and the device status at the time of the event.")
class LogDeviceStatus implements JsonSerializable
{
public function __construct(
/** @description Guid of the Appliance this Device is logging an event status for. */
// @ApiMember(DataType="Guid", Description="Guid of the Appliance this Device is logging an event status for.", IsRequired=true, Name="ApplianceId", ParameterType="query")
/** @var string */
public string $ApplianceId='',
/** @description Guid representing the saved Device */
// @ApiMember(DataType="Guid", Description="Guid representing the saved Device", IsRequired=true, Name="DeviceId", ParameterType="query")
/** @var string */
public string $DeviceId='',
/** @description The latitude the device was last located at. */
// @ApiMember(DataType="double", Description="The latitude the device was last located at.", IsRequired=true, Name="Latitude", ParameterType="query")
/** @var float */
public float $Latitude=0.0,
/** @description The longitude the device was last located at. */
// @ApiMember(DataType="double", Description="The longitude the device was last located at.", IsRequired=true, Name="Longitude", ParameterType="query")
/** @var float */
public float $Longitude=0.0,
/** @description Name of the event we're logging. */
// @ApiMember(DataType="string", Description="Name of the event we're logging.", Name="EventName", ParameterType="query")
/** @var string|null */
public ?string $EventName=null,
/** @description Details of the event up to (255 char). */
// @ApiMember(DataType="string", Description="Details of the event up to (255 char).", Name="EventDetail1", ParameterType="query")
/** @var string|null */
public ?string $EventDetail1=null,
/** @description Details of the event up to (255 char). */
// @ApiMember(DataType="string", Description="Details of the event up to (255 char).", Name="EventDetail2", ParameterType="query")
/** @var string|null */
public ?string $EventDetail2=null,
/** @description Details of the event up to (255 char). */
// @ApiMember(DataType="string", Description="Details of the event up to (255 char).", Name="EventDetail3", ParameterType="query")
/** @var string|null */
public ?string $EventDetail3=null,
/** @description Details of the event up to (255 char). */
// @ApiMember(DataType="string", Description="Details of the event up to (255 char).", Name="EventDetail4", ParameterType="query")
/** @var string|null */
public ?string $EventDetail4=null,
/** @description Details of the event up to (255 char). */
// @ApiMember(DataType="string", Description="Details of the event up to (255 char).", Name="EventDetail5", ParameterType="query")
/** @var string|null */
public ?string $EventDetail5=null,
/** @description Details of the event up to (255 char). */
// @ApiMember(DataType="string", Description="Details of the event up to (255 char).", Name="Orientation", ParameterType="query")
/** @var string|null */
public ?string $Orientation=null,
/** @description The device internet connection status. */
// @ApiMember(DataType="string", Description="The device internet connection status.", Name="InternetConnectionStatus", ParameterType="query")
/** @var string|null */
public ?string $InternetConnectionStatus=null,
/** @description Unlimited text field for logging details of the event. */
// @ApiMember(DataType="string", Description="Unlimited text field for logging details of the event.", Name="Log", ParameterType="query")
/** @var string|null */
public ?string $Log=null,
/** @description Date and Time of the event. */
// @ApiMember(DataType="DateTime", Description="Date and Time of the event.", Name="Event", ParameterType="query")
/** @var DateTime */
public DateTime $Event=new DateTime(),
/** @description True if the device is in portrait mode. */
// @ApiMember(DataType="bool", Description="True if the device is in portrait mode.", Name="IsInPortrait", ParameterType="query")
/** @var bool|null */
public ?bool $IsInPortrait=null,
/** @description True if the device is in landscape mode. */
// @ApiMember(DataType="bool", Description="True if the device is in landscape mode.", Name="IsInLandscape", ParameterType="query")
/** @var bool|null */
public ?bool $IsInLandscape=null,
/** @description True if cellular data is enabled. */
// @ApiMember(DataType="bool", Description="True if cellular data is enabled.", Name="CellularDataEnabled", ParameterType="query")
/** @var bool|null */
public ?bool $CellularDataEnabled=null,
/** @description True if data roaming is enabled. */
// @ApiMember(DataType="bool", Description="True if data roaming is enabled.", Name="DataRoamingEnabled", ParameterType="query")
/** @var bool|null */
public ?bool $DataRoamingEnabled=null,
/** @description True if the network is available. */
// @ApiMember(DataType="bool", Description="True if the network is available.", Name="IsNetworkAvailable", ParameterType="query")
/** @var bool|null */
public ?bool $IsNetworkAvailable=null,
/** @description True if the device can send an sms. */
// @ApiMember(DataType="bool", Description="True if the device can send an sms.", Name="CanSendSMS", ParameterType="query")
/** @var bool|null */
public ?bool $CanSendSMS=null,
/** @description True if the battery is charging. */
// @ApiMember(DataType="bool", Description="True if the battery is charging.", Name="BatteryCharging", ParameterType="query")
/** @var bool|null */
public ?bool $BatteryCharging=null,
/** @description The amount of battery life left as a percentage. */
// @ApiMember(DataType="int", Description="The amount of battery life left as a percentage.", Name="BatteryLevel", ParameterType="query")
/** @var int */
public int $BatteryLevel=0,
/** @description The Guid of a saved Media Object. */
// @ApiMember(DataType="Guid", Description="The Guid of a saved Media Object.", Name="MediaFileId1", ParameterType="query")
/** @var string */
public string $MediaFileId1='',
/** @description The Guid of a saved Media Object. */
// @ApiMember(DataType="Guid", Description="The Guid of a saved Media Object.", Name="MediaFileId2", ParameterType="query")
/** @var string */
public string $MediaFileId2=''
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['ApplianceId'])) $this->ApplianceId = $o['ApplianceId'];
if (isset($o['DeviceId'])) $this->DeviceId = $o['DeviceId'];
if (isset($o['Latitude'])) $this->Latitude = $o['Latitude'];
if (isset($o['Longitude'])) $this->Longitude = $o['Longitude'];
if (isset($o['EventName'])) $this->EventName = $o['EventName'];
if (isset($o['EventDetail1'])) $this->EventDetail1 = $o['EventDetail1'];
if (isset($o['EventDetail2'])) $this->EventDetail2 = $o['EventDetail2'];
if (isset($o['EventDetail3'])) $this->EventDetail3 = $o['EventDetail3'];
if (isset($o['EventDetail4'])) $this->EventDetail4 = $o['EventDetail4'];
if (isset($o['EventDetail5'])) $this->EventDetail5 = $o['EventDetail5'];
if (isset($o['Orientation'])) $this->Orientation = $o['Orientation'];
if (isset($o['InternetConnectionStatus'])) $this->InternetConnectionStatus = $o['InternetConnectionStatus'];
if (isset($o['Log'])) $this->Log = $o['Log'];
if (isset($o['Event'])) $this->Event = JsonConverters::from('DateTime', $o['Event']);
if (isset($o['IsInPortrait'])) $this->IsInPortrait = $o['IsInPortrait'];
if (isset($o['IsInLandscape'])) $this->IsInLandscape = $o['IsInLandscape'];
if (isset($o['CellularDataEnabled'])) $this->CellularDataEnabled = $o['CellularDataEnabled'];
if (isset($o['DataRoamingEnabled'])) $this->DataRoamingEnabled = $o['DataRoamingEnabled'];
if (isset($o['IsNetworkAvailable'])) $this->IsNetworkAvailable = $o['IsNetworkAvailable'];
if (isset($o['CanSendSMS'])) $this->CanSendSMS = $o['CanSendSMS'];
if (isset($o['BatteryCharging'])) $this->BatteryCharging = $o['BatteryCharging'];
if (isset($o['BatteryLevel'])) $this->BatteryLevel = $o['BatteryLevel'];
if (isset($o['MediaFileId1'])) $this->MediaFileId1 = $o['MediaFileId1'];
if (isset($o['MediaFileId2'])) $this->MediaFileId2 = $o['MediaFileId2'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->ApplianceId)) $o['ApplianceId'] = $this->ApplianceId;
if (isset($this->DeviceId)) $o['DeviceId'] = $this->DeviceId;
if (isset($this->Latitude)) $o['Latitude'] = $this->Latitude;
if (isset($this->Longitude)) $o['Longitude'] = $this->Longitude;
if (isset($this->EventName)) $o['EventName'] = $this->EventName;
if (isset($this->EventDetail1)) $o['EventDetail1'] = $this->EventDetail1;
if (isset($this->EventDetail2)) $o['EventDetail2'] = $this->EventDetail2;
if (isset($this->EventDetail3)) $o['EventDetail3'] = $this->EventDetail3;
if (isset($this->EventDetail4)) $o['EventDetail4'] = $this->EventDetail4;
if (isset($this->EventDetail5)) $o['EventDetail5'] = $this->EventDetail5;
if (isset($this->Orientation)) $o['Orientation'] = $this->Orientation;
if (isset($this->InternetConnectionStatus)) $o['InternetConnectionStatus'] = $this->InternetConnectionStatus;
if (isset($this->Log)) $o['Log'] = $this->Log;
if (isset($this->Event)) $o['Event'] = JsonConverters::to('DateTime', $this->Event);
if (isset($this->IsInPortrait)) $o['IsInPortrait'] = $this->IsInPortrait;
if (isset($this->IsInLandscape)) $o['IsInLandscape'] = $this->IsInLandscape;
if (isset($this->CellularDataEnabled)) $o['CellularDataEnabled'] = $this->CellularDataEnabled;
if (isset($this->DataRoamingEnabled)) $o['DataRoamingEnabled'] = $this->DataRoamingEnabled;
if (isset($this->IsNetworkAvailable)) $o['IsNetworkAvailable'] = $this->IsNetworkAvailable;
if (isset($this->CanSendSMS)) $o['CanSendSMS'] = $this->CanSendSMS;
if (isset($this->BatteryCharging)) $o['BatteryCharging'] = $this->BatteryCharging;
if (isset($this->BatteryLevel)) $o['BatteryLevel'] = $this->BatteryLevel;
if (isset($this->MediaFileId1)) $o['MediaFileId1'] = $this->MediaFileId1;
if (isset($this->MediaFileId2)) $o['MediaFileId2'] = $this->MediaFileId2;
return empty($o) ? new class(){} : $o;
}
}
/** @description Logs multiple device event details. Details include an event(crash,error,unexpected result) and the device status at the time of the event. */
// @Api(Description="Logs multiple device event details. Details include an event(crash,error,unexpected result) and the device status at the time of the event.")
class LogDeviceStatuses implements JsonSerializable
{
public function __construct(
/** @description A list of logged event statuses for a device. */
// @ApiMember(DataType="int", Description="A list of logged event statuses for a device.", IsRequired=true, Name="DeviceStatuses", ParameterType="query")
/** @var array<LogDeviceStatus>|null */
public ?array $DeviceStatuses=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['DeviceStatuses'])) $this->DeviceStatuses = JsonConverters::fromArray('LogDeviceStatus', $o['DeviceStatuses']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->DeviceStatuses)) $o['DeviceStatuses'] = JsonConverters::toArray('LogDeviceStatus', $this->DeviceStatuses);
return empty($o) ? new class(){} : $o;
}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .other suffix or ?format=other
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
POST /jsonl/reply/LogDeviceStatuses HTTP/1.1
Host: pfapi.pstpf.com.au
Accept: text/jsonl
Content-Type: text/jsonl
Content-Length: length
{"DeviceStatuses":[{"ApplianceId":"00000000-0000-0000-0000-000000000000","DeviceId":"00000000-0000-0000-0000-000000000000","Latitude":0,"Longitude":0,"EventName":"String","EventDetail1":"String","EventDetail2":"String","EventDetail3":"String","EventDetail4":"String","EventDetail5":"String","Orientation":"String","InternetConnectionStatus":"String","Log":"String","Event":"0001-01-01T00:00:00.0000000","IsInPortrait":false,"IsInLandscape":false,"CellularDataEnabled":false,"DataRoamingEnabled":false,"IsNetworkAvailable":false,"CanSendSMS":false,"BatteryCharging":false,"BatteryLevel":0,"MediaFileId1":"00000000-0000-0000-0000-000000000000","MediaFileId2":"00000000-0000-0000-0000-000000000000"}]}
HTTP/1.1 200 OK
Content-Type: text/jsonl
Content-Length: length
{"ErrorCode":"String","Message":"String","StackTrace":"String","Errors":[{"ErrorCode":"String","FieldName":"String","Message":"String","Meta":{"String":"String"}}],"Meta":{"String":"String"}}