Cochrane+ App API

<back to all web services

AttendanceSessionStatusChangeRequest

Requires Authentication
The following routes are available for this service:
POST/attendance/sessionstatus
<?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 ApiServiceRequest implements IServiceRequest, IHasApiKey, IHasDeviceInfo, JsonSerializable
{
    public function __construct(
        /** @description The API Key required for authentication */
        // @ApiMember(DataType="string", Description="The API Key required for authentication", IsRequired=true)
        /** @var string */
        public string $apiKey='',

        /** @description Latitude of the user making this request */
        // @ApiMember(DataType="double", Description="Latitude of the user making this request")
        /** @var float */
        public float $latitude=0.0,

        /** @description Longitude of the user making this request */
        // @ApiMember(DataType="double", Description="Longitude of the user making this request")
        /** @var float */
        public float $longitude=0.0
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['apiKey'])) $this->apiKey = $o['apiKey'];
        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->apiKey)) $o['apiKey'] = $this->apiKey;
        if (isset($this->latitude)) $o['latitude'] = $this->latitude;
        if (isset($this->longitude)) $o['longitude'] = $this->longitude;
        return empty($o) ? new class(){} : $o;
    }
}

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;
    }
}

enum AttendanceEventType : int
{
    case ClockOut = 0;
    case ClockIn = 1;
    case StartLunch = 2;
    case EndLunch = 3;
    case StartBreak = 4;
    case EndBreak = 5;
}

class AttendanceEventData implements JsonSerializable
{
    public function __construct(
        /** @var AttendanceEventType|null */
        public ?AttendanceEventType $type=null,
        /** @var string|null */
        public ?string $time=null,
        /** @var string|null */
        public ?string $location=null
    ) {
    }

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

class AttendanceSessionInfo implements JsonSerializable
{
    public function __construct(
        /** @var int */
        public int $attendanceSessionId=0,
        /** @var float */
        public float $attendanceGoalTime=0.0,
        /** @var string|null */
        public ?string $attendanceGoalTimeValue=null,
        /** @var array<AttendanceEventData>|null */
        public ?array $attendanceEvents=null,
        /** @var string|null */
        public ?string $startDate=null,
        /** @var string|null */
        public ?string $endDate=null,
        /** @var bool|null */
        public ?bool $isClockedIn=null,
        /** @var float */
        public float $timeElapsed=0.0,
        /** @var AttendanceEventType|null */
        public ?AttendanceEventType $latestEventType=null,
        /** @var float */
        public float $totalBreakTime=0.0,
        /** @var float */
        public float $totalLunchTime=0.0,
        /** @var bool|null */
        public ?bool $isNew=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['attendanceSessionId'])) $this->attendanceSessionId = $o['attendanceSessionId'];
        if (isset($o['attendanceGoalTime'])) $this->attendanceGoalTime = $o['attendanceGoalTime'];
        if (isset($o['attendanceGoalTimeValue'])) $this->attendanceGoalTimeValue = $o['attendanceGoalTimeValue'];
        if (isset($o['attendanceEvents'])) $this->attendanceEvents = JsonConverters::fromArray('AttendanceEventData', $o['attendanceEvents']);
        if (isset($o['startDate'])) $this->startDate = $o['startDate'];
        if (isset($o['endDate'])) $this->endDate = $o['endDate'];
        if (isset($o['isClockedIn'])) $this->isClockedIn = $o['isClockedIn'];
        if (isset($o['timeElapsed'])) $this->timeElapsed = $o['timeElapsed'];
        if (isset($o['latestEventType'])) $this->latestEventType = JsonConverters::from('AttendanceEventType', $o['latestEventType']);
        if (isset($o['totalBreakTime'])) $this->totalBreakTime = $o['totalBreakTime'];
        if (isset($o['totalLunchTime'])) $this->totalLunchTime = $o['totalLunchTime'];
        if (isset($o['isNew'])) $this->isNew = $o['isNew'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->attendanceSessionId)) $o['attendanceSessionId'] = $this->attendanceSessionId;
        if (isset($this->attendanceGoalTime)) $o['attendanceGoalTime'] = $this->attendanceGoalTime;
        if (isset($this->attendanceGoalTimeValue)) $o['attendanceGoalTimeValue'] = $this->attendanceGoalTimeValue;
        if (isset($this->attendanceEvents)) $o['attendanceEvents'] = JsonConverters::toArray('AttendanceEventData', $this->attendanceEvents);
        if (isset($this->startDate)) $o['startDate'] = $this->startDate;
        if (isset($this->endDate)) $o['endDate'] = $this->endDate;
        if (isset($this->isClockedIn)) $o['isClockedIn'] = $this->isClockedIn;
        if (isset($this->timeElapsed)) $o['timeElapsed'] = $this->timeElapsed;
        if (isset($this->latestEventType)) $o['latestEventType'] = JsonConverters::to('AttendanceEventType', $this->latestEventType);
        if (isset($this->totalBreakTime)) $o['totalBreakTime'] = $this->totalBreakTime;
        if (isset($this->totalLunchTime)) $o['totalLunchTime'] = $this->totalLunchTime;
        if (isset($this->isNew)) $o['isNew'] = $this->isNew;
        return empty($o) ? new class(){} : $o;
    }
}

class GetAttendanceSessionInfoResponse extends ApiServiceResponse implements JsonSerializable
{
    /**
     * @param string|null $description
     * @param string|null $heading
     * @param bool|null $wasSuccessful
     * @param Object|null $modelState
     */
    public function __construct(
        ?string $description=null,
        ?string $heading=null,
        ?bool $wasSuccessful=null,
        ?Object $modelState=null,
        /** @var AttendanceSessionInfo|null */
        public ?AttendanceSessionInfo $sessionInfo=null
    ) {
        parent::__construct($description,$heading,$wasSuccessful,$modelState);
    }

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

class AttendanceSessionStatusChangeRequest extends ApiServiceRequest implements JsonSerializable
{
    /**
     * @param string $apiKey
     * @param float $latitude
     * @param float $longitude
     */
    public function __construct(
        string $apiKey='',
        float $latitude=0.0,
        float $longitude=0.0,
        /** @var int */
        public int $attendanceSessionId=0,
        /** @var AttendanceEventType|null */
        public ?AttendanceEventType $eventType=null,
        /** @var string|null */
        public ?string $timeZoneName=null
    ) {
        parent::__construct($apiKey,$latitude,$longitude);
    }

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

PHP AttendanceSessionStatusChangeRequest DTOs

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

HTTP + CSV

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

POST /attendance/sessionstatus HTTP/1.1 
Host: cochraneplus-api-dev.happen.zone 
Accept: text/csv
Content-Type: text/csv
Content-Length: length

{"attendanceSessionId":0,"eventType":0,"timeZoneName":"String","apiKey":"String","latitude":0,"longitude":0}
HTTP/1.1 200 OK
Content-Type: text/csv
Content-Length: length

{"sessionInfo":{"attendanceSessionId":0,"attendanceGoalTime":0,"attendanceGoalTimeValue":"00:00:00","attendanceEvents":[{}],"startDate":"String","endDate":"String","isClockedIn":false,"timeElapsed":0,"latestEventType":0,"totalBreakTime":0,"totalLunchTime":0,"isNew":false},"description":"String","heading":"String","wasSuccessful":false,"modelState":{}}