Trackunit API

<back to all web services

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 .soap11 suffix or ?format=soap11

HTTP + SOAP11

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

POST /soap11 HTTP/1.1 
Host: api.trackunit.com 
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: CreateAlarm

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>

<CreateAlarm xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.servicestack.net/types">
  <ADVoltageInputIndex>0</ADVoltageInputIndex>
  <ADVoltageLimits>
    <ADVoltageLowerLimit>0</ADVoltageLowerLimit>
    <ADVoltageUpperLimit>0</ADVoltageUpperLimit>
  </ADVoltageLimits>
  <AllUnits>false</AllUnits>
  <BatteryLevel>0</BatteryLevel>
  <EmailRecipients xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
    <d2p1:string>String</d2p1:string>
  </EmailRecipients>
  <Enabled>false</Enabled>
  <ExpectedArrivalTime>0001-01-01T00:00:00</ExpectedArrivalTime>
  <Groups xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
    <d2p1:string>String</d2p1:string>
  </Groups>
  <InputIndex>0</InputIndex>
  <Interval>0</Interval>
  <Location>
    <Latitude>0</Latitude>
    <Longitude>0</Longitude>
  </Location>
  <Name>String</Name>
  <PointId>String</PointId>
  <PowerLevel>0</PowerLevel>
  <Radius>0</Radius>
  <SmsRecipients xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
    <d2p1:string>String</d2p1:string>
  </SmsRecipients>
  <SystemRecipients xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
    <d2p1:string>String</d2p1:string>
  </SystemRecipients>
  <TemperatureLimits>
    <Temperature1LowerLimit>0</Temperature1LowerLimit>
    <Temperature1UpperLimit>0</Temperature1UpperLimit>
    <Temperature2LowerLimit>0</Temperature2LowerLimit>
    <Temperature2UpperLimit>0</Temperature2UpperLimit>
  </TemperatureLimits>
  <Threshold>0</Threshold>
  <TimeEnd>
    <Hour>0</Hour>
    <Minute>0</Minute>
  </TimeEnd>
  <TimeStart>
    <Hour>0</Hour>
    <Minute>0</Minute>
  </TimeStart>
  <Type>String</Type>
  <Units xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
    <d2p1:string>String</d2p1:string>
  </Units>
  <Weekdays xmlns:d2p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
    <d2p1:string>String</d2p1:string>
  </Weekdays>
  <ZoneId>String</ZoneId>
</CreateAlarm>

</soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Content-Type: application/xml
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>

<CreateAlarmResponse xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.servicestack.net/types">
  <Id>String</Id>
  <ResponseStatus>
    <ErrorCode>String</ErrorCode>
    <Message>String</Message>
    <StackTrace>String</StackTrace>
    <Errors>
      <ResponseError>
        <ErrorCode>String</ErrorCode>
        <FieldName>String</FieldName>
        <Message>String</Message>
        <Meta xmlns:d5p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
          <d5p1:KeyValueOfstringstring>
            <d5p1:Key>String</d5p1:Key>
            <d5p1:Value>String</d5p1:Value>
          </d5p1:KeyValueOfstringstring>
        </Meta>
      </ResponseError>
    </Errors>
    <Meta xmlns:d3p1="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
      <d3p1:KeyValueOfstringstring>
        <d3p1:Key>String</d3p1:Key>
        <d3p1:Value>String</d3p1:Value>
      </d3p1:KeyValueOfstringstring>
    </Meta>
  </ResponseStatus>
</CreateAlarmResponse>

</soap:Body>
</soap:Envelope>