Trendsic Platform Service

<back to all web services

KpiV2LiveRequest

Requires Authentication
The following routes are available for this service:
GET,OPTIONS/v1/dashboard/kpiv2/live/{BranchId}
<?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 SvcLiveWindow implements JsonSerializable
{
    public function __construct(
        /** @var string */
        public string $StationId='',
        /** @var string|null */
        public ?string $Name=null,
        /** @var string|null */
        public ?string $Status=null,
        /** @var string|null */
        public ?string $EmployeeId=null,
        /** @var string|null */
        public ?string $EmployeeName=null,
        /** @var DateTime|null */
        public ?DateTime $SignedInUtc=null,
        /** @var DateTime|null */
        public ?DateTime $LastSeenUtc=null,
        /** @var DateTime|null */
        public ?DateTime $SinceUtc=null,
        /** @var string|null */
        public ?string $PauseReason=null,
        /** @var string|null */
        public ?string $CheckinId=null,
        /** @var string|null */
        public ?string $TicketLabel=null,
        /** @var string|null */
        public ?string $CustomerName=null,
        /** @var string|null */
        public ?string $ServiceName=null,
        /** @var DateTime|null */
        public ?DateTime $StartUtc=null,
        /** @var DateTime|null */
        public ?DateTime $CalledUtc=null,
        /** @var int */
        public int $ServedToday=0,
        /** @var DateTime|null */
        public ?DateTime $LastCalledUtc=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['StationId'])) $this->StationId = $o['StationId'];
        if (isset($o['Name'])) $this->Name = $o['Name'];
        if (isset($o['Status'])) $this->Status = $o['Status'];
        if (isset($o['EmployeeId'])) $this->EmployeeId = $o['EmployeeId'];
        if (isset($o['EmployeeName'])) $this->EmployeeName = $o['EmployeeName'];
        if (isset($o['SignedInUtc'])) $this->SignedInUtc = JsonConverters::from('DateTime', $o['SignedInUtc']);
        if (isset($o['LastSeenUtc'])) $this->LastSeenUtc = JsonConverters::from('DateTime', $o['LastSeenUtc']);
        if (isset($o['SinceUtc'])) $this->SinceUtc = JsonConverters::from('DateTime', $o['SinceUtc']);
        if (isset($o['PauseReason'])) $this->PauseReason = $o['PauseReason'];
        if (isset($o['CheckinId'])) $this->CheckinId = $o['CheckinId'];
        if (isset($o['TicketLabel'])) $this->TicketLabel = $o['TicketLabel'];
        if (isset($o['CustomerName'])) $this->CustomerName = $o['CustomerName'];
        if (isset($o['ServiceName'])) $this->ServiceName = $o['ServiceName'];
        if (isset($o['StartUtc'])) $this->StartUtc = JsonConverters::from('DateTime', $o['StartUtc']);
        if (isset($o['CalledUtc'])) $this->CalledUtc = JsonConverters::from('DateTime', $o['CalledUtc']);
        if (isset($o['ServedToday'])) $this->ServedToday = $o['ServedToday'];
        if (isset($o['LastCalledUtc'])) $this->LastCalledUtc = JsonConverters::from('DateTime', $o['LastCalledUtc']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->StationId)) $o['StationId'] = $this->StationId;
        if (isset($this->Name)) $o['Name'] = $this->Name;
        if (isset($this->Status)) $o['Status'] = $this->Status;
        if (isset($this->EmployeeId)) $o['EmployeeId'] = $this->EmployeeId;
        if (isset($this->EmployeeName)) $o['EmployeeName'] = $this->EmployeeName;
        if (isset($this->SignedInUtc)) $o['SignedInUtc'] = JsonConverters::to('DateTime', $this->SignedInUtc);
        if (isset($this->LastSeenUtc)) $o['LastSeenUtc'] = JsonConverters::to('DateTime', $this->LastSeenUtc);
        if (isset($this->SinceUtc)) $o['SinceUtc'] = JsonConverters::to('DateTime', $this->SinceUtc);
        if (isset($this->PauseReason)) $o['PauseReason'] = $this->PauseReason;
        if (isset($this->CheckinId)) $o['CheckinId'] = $this->CheckinId;
        if (isset($this->TicketLabel)) $o['TicketLabel'] = $this->TicketLabel;
        if (isset($this->CustomerName)) $o['CustomerName'] = $this->CustomerName;
        if (isset($this->ServiceName)) $o['ServiceName'] = $this->ServiceName;
        if (isset($this->StartUtc)) $o['StartUtc'] = JsonConverters::to('DateTime', $this->StartUtc);
        if (isset($this->CalledUtc)) $o['CalledUtc'] = JsonConverters::to('DateTime', $this->CalledUtc);
        if (isset($this->ServedToday)) $o['ServedToday'] = $this->ServedToday;
        if (isset($this->LastCalledUtc)) $o['LastCalledUtc'] = JsonConverters::to('DateTime', $this->LastCalledUtc);
        return empty($o) ? new class(){} : $o;
    }
}

class SvcLiveLine implements JsonSerializable
{
    public function __construct(
        /** @var string */
        public string $LineId='',
        /** @var string|null */
        public ?string $Name=null,
        /** @var int */
        public int $Waiting=0,
        /** @var DateTime|null */
        public ?DateTime $OldestHereUtc=null
    ) {
    }

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

class SvcAlert implements JsonSerializable
{
    public function __construct(
        /** @var string|null */
        public ?string $Level=null,
        /** @var string|null */
        public ?string $View=null,
        /** @var string|null */
        public ?string $Code=null,
        /** @var string|null */
        public ?string $StationId=null,
        /** @var string|null */
        public ?string $EmployeeId=null,
        /** @var string|null */
        public ?string $BranchId=null,
        /** @var string|null */
        public ?string $LineId=null,
        /** @var string|null */
        public ?string $Name=null,
        /** @var string|null */
        public ?string $OtherLineId=null,
        /** @var string|null */
        public ?string $OtherName=null,
        /** @var array<string>|null */
        public ?array $StationIds=null,
        /** @var array<string,float>|null */
        public ?array $Values=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['Level'])) $this->Level = $o['Level'];
        if (isset($o['View'])) $this->View = $o['View'];
        if (isset($o['Code'])) $this->Code = $o['Code'];
        if (isset($o['StationId'])) $this->StationId = $o['StationId'];
        if (isset($o['EmployeeId'])) $this->EmployeeId = $o['EmployeeId'];
        if (isset($o['BranchId'])) $this->BranchId = $o['BranchId'];
        if (isset($o['LineId'])) $this->LineId = $o['LineId'];
        if (isset($o['Name'])) $this->Name = $o['Name'];
        if (isset($o['OtherLineId'])) $this->OtherLineId = $o['OtherLineId'];
        if (isset($o['OtherName'])) $this->OtherName = $o['OtherName'];
        if (isset($o['StationIds'])) $this->StationIds = JsonConverters::fromArray('Guid', $o['StationIds']);
        if (isset($o['Values'])) $this->Values = JsonConverters::from(JsonConverters::context('Dictionary',genericArgs:['string','float']), $o['Values']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->Level)) $o['Level'] = $this->Level;
        if (isset($this->View)) $o['View'] = $this->View;
        if (isset($this->Code)) $o['Code'] = $this->Code;
        if (isset($this->StationId)) $o['StationId'] = $this->StationId;
        if (isset($this->EmployeeId)) $o['EmployeeId'] = $this->EmployeeId;
        if (isset($this->BranchId)) $o['BranchId'] = $this->BranchId;
        if (isset($this->LineId)) $o['LineId'] = $this->LineId;
        if (isset($this->Name)) $o['Name'] = $this->Name;
        if (isset($this->OtherLineId)) $o['OtherLineId'] = $this->OtherLineId;
        if (isset($this->OtherName)) $o['OtherName'] = $this->OtherName;
        if (isset($this->StationIds)) $o['StationIds'] = JsonConverters::toArray('Guid', $this->StationIds);
        if (isset($this->Values)) $o['Values'] = JsonConverters::to(JsonConverters::context('Dictionary',genericArgs:['string','float']), $this->Values);
        return empty($o) ? new class(){} : $o;
    }
}

class SvcLive implements JsonSerializable
{
    public function __construct(
        /** @var string */
        public string $BranchId='',
        /** @var DateTime */
        public DateTime $NowUtc=new DateTime(),
        /** @var int */
        public int $LocalOffMin=0,
        /** @var string|null */
        public ?string $ZoneCode=null,
        /** @var array<SvcLiveWindow>|null */
        public ?array $Windows=null,
        /** @var array<SvcLiveLine>|null */
        public ?array $Line=null,
        /** @var int */
        public int $InLine=0,
        /** @var int */
        public int $LongestWaitSec=0,
        /** @var int */
        public int $Staffed=0,
        /** @var array<SvcAlert>|null */
        public ?array $Alerts=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['BranchId'])) $this->BranchId = $o['BranchId'];
        if (isset($o['NowUtc'])) $this->NowUtc = JsonConverters::from('DateTime', $o['NowUtc']);
        if (isset($o['LocalOffMin'])) $this->LocalOffMin = $o['LocalOffMin'];
        if (isset($o['ZoneCode'])) $this->ZoneCode = $o['ZoneCode'];
        if (isset($o['Windows'])) $this->Windows = JsonConverters::fromArray('SvcLiveWindow', $o['Windows']);
        if (isset($o['Line'])) $this->Line = JsonConverters::fromArray('SvcLiveLine', $o['Line']);
        if (isset($o['InLine'])) $this->InLine = $o['InLine'];
        if (isset($o['LongestWaitSec'])) $this->LongestWaitSec = $o['LongestWaitSec'];
        if (isset($o['Staffed'])) $this->Staffed = $o['Staffed'];
        if (isset($o['Alerts'])) $this->Alerts = JsonConverters::fromArray('SvcAlert', $o['Alerts']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->BranchId)) $o['BranchId'] = $this->BranchId;
        if (isset($this->NowUtc)) $o['NowUtc'] = JsonConverters::to('DateTime', $this->NowUtc);
        if (isset($this->LocalOffMin)) $o['LocalOffMin'] = $this->LocalOffMin;
        if (isset($this->ZoneCode)) $o['ZoneCode'] = $this->ZoneCode;
        if (isset($this->Windows)) $o['Windows'] = JsonConverters::toArray('SvcLiveWindow', $this->Windows);
        if (isset($this->Line)) $o['Line'] = JsonConverters::toArray('SvcLiveLine', $this->Line);
        if (isset($this->InLine)) $o['InLine'] = $this->InLine;
        if (isset($this->LongestWaitSec)) $o['LongestWaitSec'] = $this->LongestWaitSec;
        if (isset($this->Staffed)) $o['Staffed'] = $this->Staffed;
        if (isset($this->Alerts)) $o['Alerts'] = JsonConverters::toArray('SvcAlert', $this->Alerts);
        return empty($o) ? new class(){} : $o;
    }
}

class KpiV2LiveResponse implements JsonSerializable
{
    public function __construct(
        /** @var ResponseStatus|null */
        public ?ResponseStatus $ResponseStatus=null,
        /** @var SvcLive|null */
        public ?SvcLive $Live=null
    ) {
    }

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

class KpiV2LiveRequest implements JsonSerializable
{
    public function __construct(
        /** @var string */
        public string $BranchId=''
    ) {
    }

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

PHP KpiV2LiveRequest DTOs

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

HTTP + JSV

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

GET /v1/dashboard/kpiv2/live/{BranchId} HTTP/1.1 
Host: api.dev.dynamics.trendsic.com 
Accept: text/jsv
HTTP/1.1 200 OK
Content-Type: text/jsv
Content-Length: length

{
	ResponseStatus: 
	{
		ErrorCode: String,
		Message: String,
		StackTrace: String,
		Errors: 
		[
			{
				ErrorCode: String,
				FieldName: String,
				Message: String,
				Meta: 
				{
					String: String
				}
			}
		],
		Meta: 
		{
			String: String
		}
	},
	Live: 
	{
		BranchId: 00000000000000000000000000000000,
		NowUtc: 0001-01-01,
		LocalOffMin: 0,
		ZoneCode: String,
		Windows: 
		[
			{
				StationId: 00000000000000000000000000000000,
				Name: String,
				Status: String,
				EmployeeId: 00000000000000000000000000000000,
				EmployeeName: String,
				SignedInUtc: 0001-01-01,
				LastSeenUtc: 0001-01-01,
				SinceUtc: 0001-01-01,
				PauseReason: String,
				CheckinId: 00000000000000000000000000000000,
				TicketLabel: String,
				CustomerName: String,
				ServiceName: String,
				StartUtc: 0001-01-01,
				CalledUtc: 0001-01-01,
				ServedToday: 0,
				LastCalledUtc: 0001-01-01
			}
		],
		Line: 
		[
			{
				LineId: 00000000000000000000000000000000,
				Name: String,
				Waiting: 0,
				OldestHereUtc: 0001-01-01
			}
		],
		InLine: 0,
		LongestWaitSec: 0,
		Staffed: 0,
		Alerts: 
		[
			{
				Level: String,
				View: String,
				Code: String,
				StationId: 00000000000000000000000000000000,
				EmployeeId: 00000000000000000000000000000000,
				BranchId: 00000000000000000000000000000000,
				LineId: 00000000000000000000000000000000,
				Name: String,
				OtherLineId: 00000000000000000000000000000000,
				OtherName: String,
				StationIds: 
				[
					00000000000000000000000000000000
				],
				Values: 
				{
					String: 0
				}
			}
		]
	}
}