Trackunit API

<back to all web services

CreateAlarm

The following routes are available for this service:
POST/Alarm
GET POST/CreateAlarm
<?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};


// @DataContract
class CreateAlarmResponse implements JsonSerializable
{
    public function __construct(
        // @DataMember
        /** @var string|null */
        public ?string $id=null,

        // @DataMember
        /** @var ResponseStatus|null */
        public ?ResponseStatus $responseStatus=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['id'])) $this->id = $o['id'];
        if (isset($o['responseStatus'])) $this->responseStatus = JsonConverters::from('ResponseStatus', $o['responseStatus']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->id)) $o['id'] = $this->id;
        if (isset($this->responseStatus)) $o['responseStatus'] = JsonConverters::to('ResponseStatus', $this->responseStatus);
        return empty($o) ? new class(){} : $o;
    }
}

// @DataContract
class TemperatureAlarmLimits implements JsonSerializable
{
    public function __construct(
        // @DataMember
        /** @var float|null */
        public ?float $temperature1LowerLimit=null,

        // @DataMember
        /** @var float|null */
        public ?float $temperature1UpperLimit=null,

        // @DataMember
        /** @var float|null */
        public ?float $temperature2LowerLimit=null,

        // @DataMember
        /** @var float|null */
        public ?float $temperature2UpperLimit=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['temperature1LowerLimit'])) $this->temperature1LowerLimit = $o['temperature1LowerLimit'];
        if (isset($o['temperature1UpperLimit'])) $this->temperature1UpperLimit = $o['temperature1UpperLimit'];
        if (isset($o['temperature2LowerLimit'])) $this->temperature2LowerLimit = $o['temperature2LowerLimit'];
        if (isset($o['temperature2UpperLimit'])) $this->temperature2UpperLimit = $o['temperature2UpperLimit'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->temperature1LowerLimit)) $o['temperature1LowerLimit'] = $this->temperature1LowerLimit;
        if (isset($this->temperature1UpperLimit)) $o['temperature1UpperLimit'] = $this->temperature1UpperLimit;
        if (isset($this->temperature2LowerLimit)) $o['temperature2LowerLimit'] = $this->temperature2LowerLimit;
        if (isset($this->temperature2UpperLimit)) $o['temperature2UpperLimit'] = $this->temperature2UpperLimit;
        return empty($o) ? new class(){} : $o;
    }
}

// @DataContract
class ADVoltageAlarmLimits implements JsonSerializable
{
    public function __construct(
        // @DataMember
        /** @var float|null */
        public ?float $adVoltageLowerLimit=null,

        // @DataMember
        /** @var float|null */
        public ?float $adVoltageUpperLimit=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['adVoltageLowerLimit'])) $this->adVoltageLowerLimit = $o['adVoltageLowerLimit'];
        if (isset($o['adVoltageUpperLimit'])) $this->adVoltageUpperLimit = $o['adVoltageUpperLimit'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->adVoltageLowerLimit)) $o['adVoltageLowerLimit'] = $this->adVoltageLowerLimit;
        if (isset($this->adVoltageUpperLimit)) $o['adVoltageUpperLimit'] = $this->adVoltageUpperLimit;
        return empty($o) ? new class(){} : $o;
    }
}

// @DataContract
class Location implements JsonSerializable
{
    public function __construct(
        // @DataMember
        /** @var float */
        public float $latitude=0.0,

        // @DataMember
        /** @var float */
        public float $longitude=0.0
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['latitude'])) $this->latitude = $o['latitude'];
        if (isset($o['longitude'])) $this->longitude = $o['longitude'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->latitude)) $o['latitude'] = $this->latitude;
        if (isset($this->longitude)) $o['longitude'] = $this->longitude;
        return empty($o) ? new class(){} : $o;
    }
}

// @DataContract
class TimeOfDay implements JsonSerializable
{
    public function __construct(
        // @DataMember
        /** @var int */
        public int $hour=0,

        // @DataMember
        /** @var int */
        public int $minute=0
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['hour'])) $this->hour = $o['hour'];
        if (isset($o['minute'])) $this->minute = $o['minute'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->hour)) $o['hour'] = $this->hour;
        if (isset($this->minute)) $o['minute'] = $this->minute;
        return empty($o) ? new class(){} : $o;
    }
}

// @DataContract
class CreateAlarm implements JsonSerializable
{
    public function __construct(
        // @DataMember
        /** @var string|null */
        public ?string $name=null,

        // @DataMember
        /** @var string|null */
        public ?string $type=null,

        // @DataMember
        /** @var bool|null */
        public ?bool $enabled=null,

        // @DataMember
        /** @var bool|null */
        public ?bool $allUnits=null,

        // @DataMember
        /** @var string[]|null */
        public ?array $units=null,

        // @DataMember
        /** @var string[]|null */
        public ?array $groups=null,

        // @DataMember
        /** @var string[]|null */
        public ?array $emailRecipients=null,

        // @DataMember
        /** @var string[]|null */
        public ?array $systemRecipients=null,

        // @DataMember
        /** @var string[]|null */
        public ?array $smsRecipients=null,

        // @DataMember
        /** @var TemperatureAlarmLimits|null */
        public ?TemperatureAlarmLimits $temperatureLimits=null,

        // @DataMember
        /** @var ADVoltageAlarmLimits|null */
        public ?ADVoltageAlarmLimits $adVoltageLimits=null,

        // @DataMember
        /** @var int|null */
        public ?int $adVoltageInputIndex=null,

        // @DataMember
        /** @var float|null */
        public ?float $threshold=null,

        // @DataMember
        /** @var float|null */
        public ?float $batteryLevel=null,

        // @DataMember
        /** @var Location|null */
        public ?Location $location=null,

        // @DataMember
        /** @var float|null */
        public ?float $radius=null,

        // @DataMember
        /** @var int|null */
        public ?int $inputIndex=null,

        // @DataMember
        /** @var float|null */
        public ?float $interval=null,

        // @DataMember
        /** @var string|null */
        public ?string $pointId=null,

        // @DataMember
        /** @var DateTime|null */
        public ?DateTime $expectedArrivalTime=null,

        // @DataMember
        /** @var float|null */
        public ?float $powerLevel=null,

        // @DataMember
        /** @var string[]|null */
        public ?array $weekdays=null,

        // @DataMember
        /** @var TimeOfDay|null */
        public ?TimeOfDay $timeStart=null,

        // @DataMember
        /** @var TimeOfDay|null */
        public ?TimeOfDay $timeEnd=null,

        // @DataMember
        /** @var string|null */
        public ?string $zoneId=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['name'])) $this->name = $o['name'];
        if (isset($o['type'])) $this->type = $o['type'];
        if (isset($o['enabled'])) $this->enabled = $o['enabled'];
        if (isset($o['allUnits'])) $this->allUnits = $o['allUnits'];
        if (isset($o['units'])) $this->units = JsonConverters::fromArray('string', $o['units']);
        if (isset($o['groups'])) $this->groups = JsonConverters::fromArray('string', $o['groups']);
        if (isset($o['emailRecipients'])) $this->emailRecipients = JsonConverters::fromArray('string', $o['emailRecipients']);
        if (isset($o['systemRecipients'])) $this->systemRecipients = JsonConverters::fromArray('string', $o['systemRecipients']);
        if (isset($o['smsRecipients'])) $this->smsRecipients = JsonConverters::fromArray('string', $o['smsRecipients']);
        if (isset($o['temperatureLimits'])) $this->temperatureLimits = JsonConverters::from('TemperatureAlarmLimits', $o['temperatureLimits']);
        if (isset($o['adVoltageLimits'])) $this->adVoltageLimits = JsonConverters::from('ADVoltageAlarmLimits', $o['adVoltageLimits']);
        if (isset($o['adVoltageInputIndex'])) $this->adVoltageInputIndex = $o['adVoltageInputIndex'];
        if (isset($o['threshold'])) $this->threshold = $o['threshold'];
        if (isset($o['batteryLevel'])) $this->batteryLevel = $o['batteryLevel'];
        if (isset($o['location'])) $this->location = JsonConverters::from('Location', $o['location']);
        if (isset($o['radius'])) $this->radius = $o['radius'];
        if (isset($o['inputIndex'])) $this->inputIndex = $o['inputIndex'];
        if (isset($o['interval'])) $this->interval = $o['interval'];
        if (isset($o['pointId'])) $this->pointId = $o['pointId'];
        if (isset($o['expectedArrivalTime'])) $this->expectedArrivalTime = JsonConverters::from('DateTime', $o['expectedArrivalTime']);
        if (isset($o['powerLevel'])) $this->powerLevel = $o['powerLevel'];
        if (isset($o['weekdays'])) $this->weekdays = JsonConverters::fromArray('string', $o['weekdays']);
        if (isset($o['timeStart'])) $this->timeStart = JsonConverters::from('TimeOfDay', $o['timeStart']);
        if (isset($o['timeEnd'])) $this->timeEnd = JsonConverters::from('TimeOfDay', $o['timeEnd']);
        if (isset($o['zoneId'])) $this->zoneId = $o['zoneId'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->name)) $o['name'] = $this->name;
        if (isset($this->type)) $o['type'] = $this->type;
        if (isset($this->enabled)) $o['enabled'] = $this->enabled;
        if (isset($this->allUnits)) $o['allUnits'] = $this->allUnits;
        if (isset($this->units)) $o['units'] = JsonConverters::toArray('string', $this->units);
        if (isset($this->groups)) $o['groups'] = JsonConverters::toArray('string', $this->groups);
        if (isset($this->emailRecipients)) $o['emailRecipients'] = JsonConverters::toArray('string', $this->emailRecipients);
        if (isset($this->systemRecipients)) $o['systemRecipients'] = JsonConverters::toArray('string', $this->systemRecipients);
        if (isset($this->smsRecipients)) $o['smsRecipients'] = JsonConverters::toArray('string', $this->smsRecipients);
        if (isset($this->temperatureLimits)) $o['temperatureLimits'] = JsonConverters::to('TemperatureAlarmLimits', $this->temperatureLimits);
        if (isset($this->adVoltageLimits)) $o['adVoltageLimits'] = JsonConverters::to('ADVoltageAlarmLimits', $this->adVoltageLimits);
        if (isset($this->adVoltageInputIndex)) $o['adVoltageInputIndex'] = $this->adVoltageInputIndex;
        if (isset($this->threshold)) $o['threshold'] = $this->threshold;
        if (isset($this->batteryLevel)) $o['batteryLevel'] = $this->batteryLevel;
        if (isset($this->location)) $o['location'] = JsonConverters::to('Location', $this->location);
        if (isset($this->radius)) $o['radius'] = $this->radius;
        if (isset($this->inputIndex)) $o['inputIndex'] = $this->inputIndex;
        if (isset($this->interval)) $o['interval'] = $this->interval;
        if (isset($this->pointId)) $o['pointId'] = $this->pointId;
        if (isset($this->expectedArrivalTime)) $o['expectedArrivalTime'] = JsonConverters::to('DateTime', $this->expectedArrivalTime);
        if (isset($this->powerLevel)) $o['powerLevel'] = $this->powerLevel;
        if (isset($this->weekdays)) $o['weekdays'] = JsonConverters::toArray('string', $this->weekdays);
        if (isset($this->timeStart)) $o['timeStart'] = JsonConverters::to('TimeOfDay', $this->timeStart);
        if (isset($this->timeEnd)) $o['timeEnd'] = JsonConverters::to('TimeOfDay', $this->timeEnd);
        if (isset($this->zoneId)) $o['zoneId'] = $this->zoneId;
        return empty($o) ? new class(){} : $o;
    }
}

PHP CreateAlarm DTOs

To override the Content-type in your clients, use the HTTP Accept Header, append the .other suffix or ?format=other

HTTP + OTHER

The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.

POST /Alarm HTTP/1.1 
Host: api.trackunit.com 
Accept: text/jsonl
Content-Type: text/jsonl
Content-Length: length

{"name":"String","type":"String","enabled":false,"allUnits":false,"units":["String"],"groups":["String"],"emailRecipients":["String"],"systemRecipients":["String"],"smsRecipients":["String"],"temperatureLimits":{"temperature1LowerLimit":0,"temperature1UpperLimit":0,"temperature2LowerLimit":0,"temperature2UpperLimit":0},"adVoltageLimits":{"adVoltageLowerLimit":0,"adVoltageUpperLimit":0},"adVoltageInputIndex":0,"threshold":0,"batteryLevel":0,"location":{"latitude":0,"longitude":0},"radius":0,"inputIndex":0,"interval":0,"pointId":"String","expectedArrivalTime":"0001-01-01T00:00:00.0000000Z","powerLevel":0,"weekdays":["String"],"timeStart":{"hour":0,"minute":0},"timeEnd":{"hour":0,"minute":0},"zoneId":"String"}
HTTP/1.1 200 OK
Content-Type: text/jsonl
Content-Length: length

{"id":"String","responseStatus":{"errorCode":"String","message":"String","stackTrace":"String","errors":[{"errorCode":"String","fieldName":"String","message":"String","meta":{"String":"String"}}],"meta":{"String":"String"}}}