| POST | /location/background |
|---|
<?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 ApiServiceResponse implements IServiceResponse, JsonSerializable
{
public function __construct(
/** @var string|null */
public ?string $description=null,
/** @var string|null */
public ?string $heading=null,
/** @var bool|null */
public ?bool $wasSuccessful=null,
/** @var Object|null */
public ?Object $modelState=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['description'])) $this->description = $o['description'];
if (isset($o['heading'])) $this->heading = $o['heading'];
if (isset($o['wasSuccessful'])) $this->wasSuccessful = $o['wasSuccessful'];
if (isset($o['modelState'])) $this->modelState = JsonConverters::from('Object', $o['modelState']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->description)) $o['description'] = $this->description;
if (isset($this->heading)) $o['heading'] = $this->heading;
if (isset($this->wasSuccessful)) $o['wasSuccessful'] = $this->wasSuccessful;
if (isset($this->modelState)) $o['modelState'] = JsonConverters::to('Object', $this->modelState);
return empty($o) ? new class(){} : $o;
}
}
class CoordsData implements JsonSerializable
{
public function __construct(
/** @var float */
public float $speed=0.0,
/** @var float */
public float $longitude=0.0,
/** @var float */
public float $latitude=0.0,
/** @var float */
public float $accuracy=0.0,
/** @var float */
public float $altitude=0.0,
/** @var float */
public float $heading=0.0
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['speed'])) $this->speed = $o['speed'];
if (isset($o['longitude'])) $this->longitude = $o['longitude'];
if (isset($o['latitude'])) $this->latitude = $o['latitude'];
if (isset($o['accuracy'])) $this->accuracy = $o['accuracy'];
if (isset($o['altitude'])) $this->altitude = $o['altitude'];
if (isset($o['heading'])) $this->heading = $o['heading'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->speed)) $o['speed'] = $this->speed;
if (isset($this->longitude)) $o['longitude'] = $this->longitude;
if (isset($this->latitude)) $o['latitude'] = $this->latitude;
if (isset($this->accuracy)) $o['accuracy'] = $this->accuracy;
if (isset($this->altitude)) $o['altitude'] = $this->altitude;
if (isset($this->heading)) $o['heading'] = $this->heading;
return empty($o) ? new class(){} : $o;
}
}
class ExtrasData implements JsonSerializable
{
public function __construct(
/** @var int */
public int $systemUserId=0,
/** @var string */
public string $deviceId=''
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['systemUserId'])) $this->systemUserId = $o['systemUserId'];
if (isset($o['deviceId'])) $this->deviceId = $o['deviceId'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->systemUserId)) $o['systemUserId'] = $this->systemUserId;
if (isset($this->deviceId)) $o['deviceId'] = $this->deviceId;
return empty($o) ? new class(){} : $o;
}
}
class ActivityData implements JsonSerializable
{
public function __construct(
/** @var string|null */
public ?string $type=null,
/** @var int */
public int $confidence=0
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['type'])) $this->type = $o['type'];
if (isset($o['confidence'])) $this->confidence = $o['confidence'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->type)) $o['type'] = $this->type;
if (isset($this->confidence)) $o['confidence'] = $this->confidence;
return empty($o) ? new class(){} : $o;
}
}
class BatteryData implements JsonSerializable
{
public function __construct(
/** @var float */
public float $level=0.0,
/** @var bool|null */
public ?bool $is_charging=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['level'])) $this->level = $o['level'];
if (isset($o['is_charging'])) $this->is_charging = $o['is_charging'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->level)) $o['level'] = $this->level;
if (isset($this->is_charging)) $o['is_charging'] = $this->is_charging;
return empty($o) ? new class(){} : $o;
}
}
class LocationData implements JsonSerializable
{
public function __construct(
/** @var CoordsData|null */
public ?CoordsData $coords=null,
/** @var ExtrasData|null */
public ?ExtrasData $extras=null,
/** @var bool|null */
public ?bool $is_moving=null,
/** @var float */
public float $odometer=0.0,
/** @var string|null */
public ?string $uuid=null,
/** @var ActivityData|null */
public ?ActivityData $activity=null,
/** @var BatteryData|null */
public ?BatteryData $battery=null,
/** @var DateTime */
public DateTime $timestamp=new DateTime()
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['coords'])) $this->coords = JsonConverters::from('CoordsData', $o['coords']);
if (isset($o['extras'])) $this->extras = JsonConverters::from('ExtrasData', $o['extras']);
if (isset($o['is_moving'])) $this->is_moving = $o['is_moving'];
if (isset($o['odometer'])) $this->odometer = $o['odometer'];
if (isset($o['uuid'])) $this->uuid = $o['uuid'];
if (isset($o['activity'])) $this->activity = JsonConverters::from('ActivityData', $o['activity']);
if (isset($o['battery'])) $this->battery = JsonConverters::from('BatteryData', $o['battery']);
if (isset($o['timestamp'])) $this->timestamp = JsonConverters::from('DateTime', $o['timestamp']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->coords)) $o['coords'] = JsonConverters::to('CoordsData', $this->coords);
if (isset($this->extras)) $o['extras'] = JsonConverters::to('ExtrasData', $this->extras);
if (isset($this->is_moving)) $o['is_moving'] = $this->is_moving;
if (isset($this->odometer)) $o['odometer'] = $this->odometer;
if (isset($this->uuid)) $o['uuid'] = $this->uuid;
if (isset($this->activity)) $o['activity'] = JsonConverters::to('ActivityData', $this->activity);
if (isset($this->battery)) $o['battery'] = JsonConverters::to('BatteryData', $this->battery);
if (isset($this->timestamp)) $o['timestamp'] = JsonConverters::to('DateTime', $this->timestamp);
return empty($o) ? new class(){} : $o;
}
}
class BackgroundLocationReceived implements IHasApiKey, JsonSerializable
{
public function __construct(
/** @var string|null */
public ?string $apiKey=null,
/** @var LocationData|null */
public ?LocationData $location=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['apiKey'])) $this->apiKey = $o['apiKey'];
if (isset($o['location'])) $this->location = JsonConverters::from('LocationData', $o['location']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->apiKey)) $o['apiKey'] = $this->apiKey;
if (isset($this->location)) $o['location'] = JsonConverters::to('LocationData', $this->location);
return empty($o) ? new class(){} : $o;
}
}
PHP BackgroundLocationReceived DTOs
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 /location/background HTTP/1.1
Host: cochraneplus-api-dev.happen.zone
Accept: text/jsonl
Content-Type: text/jsonl
Content-Length: length
{"apiKey":"String","location":{"coords":{"speed":0,"longitude":0,"latitude":0,"accuracy":0,"altitude":0,"heading":0},"extras":{"systemUserId":0,"deviceId":"00000000-0000-0000-0000-000000000000"},"is_moving":false,"odometer":0,"uuid":"String","activity":{"type":"String","confidence":0},"battery":{"level":0,"is_charging":false},"timestamp":"0001-01-01T00:00:00.0000000"}}
HTTP/1.1 200 OK
Content-Type: text/jsonl
Content-Length: length
{"description":"String","heading":"String","wasSuccessful":false,"modelState":{}}