<back to all web services

ReadingsBulk

The following routes are available for this service:
GET/v8/readings-bulk
GET/v8/readings-bulk/{from}
<?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 Generic implements JsonSerializable
{
    public function __construct(
        /** @description Api-key. Used to provide credentials to the api. Can also be provided through the request headers with key: X-API-KEY */
        // @ApiMember(DataType="String", Description="Api-key. Used to provide credentials to the api. Can also be provided through the request headers with key: X-API-KEY", IsRequired=true, Name="ApiKey")
        /** @var string */
        public string $apiKey=''
    ) {
    }

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

class P4ReadingDay implements JsonSerializable
{
    public function __construct(
        /** @var string|null */
        public ?string $ean=null,
        /** @var string|null */
        public ?string $meterId=null,
        /** @var DateTime */
        public DateTime $queryDate=new DateTime(),
        /** @var string|null */
        public ?string $measureUnit=null,
        /** @var float|null */
        public ?float $r180=null,
        /** @var float|null */
        public ?float $r181=null,
        /** @var float|null */
        public ?float $r182=null,
        /** @var float|null */
        public ?float $r280=null,
        /** @var float|null */
        public ?float $r281=null,
        /** @var float|null */
        public ?float $r282=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['ean'])) $this->ean = $o['ean'];
        if (isset($o['meterId'])) $this->meterId = $o['meterId'];
        if (isset($o['queryDate'])) $this->queryDate = JsonConverters::from('DateTime', $o['queryDate']);
        if (isset($o['measureUnit'])) $this->measureUnit = $o['measureUnit'];
        if (isset($o['r180'])) $this->r180 = $o['r180'];
        if (isset($o['r181'])) $this->r181 = $o['r181'];
        if (isset($o['r182'])) $this->r182 = $o['r182'];
        if (isset($o['r280'])) $this->r280 = $o['r280'];
        if (isset($o['r281'])) $this->r281 = $o['r281'];
        if (isset($o['r282'])) $this->r282 = $o['r282'];
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->ean)) $o['ean'] = $this->ean;
        if (isset($this->meterId)) $o['meterId'] = $this->meterId;
        if (isset($this->queryDate)) $o['queryDate'] = JsonConverters::to('DateTime', $this->queryDate);
        if (isset($this->measureUnit)) $o['measureUnit'] = $this->measureUnit;
        if (isset($this->r180)) $o['r180'] = $this->r180;
        if (isset($this->r181)) $o['r181'] = $this->r181;
        if (isset($this->r182)) $o['r182'] = $this->r182;
        if (isset($this->r280)) $o['r280'] = $this->r280;
        if (isset($this->r281)) $o['r281'] = $this->r281;
        if (isset($this->r282)) $o['r282'] = $this->r282;
        return empty($o) ? new class(){} : $o;
    }
}

class P4ReadingIntervalItem implements JsonSerializable
{
    public function __construct(
        /** @var DateTime */
        public DateTime $dateTimeOffset=new DateTime(),
        /** @var float */
        public float $r180=0.0,
        /** @var float|null */
        public ?float $r280=null
    ) {
    }

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

class P4ReadingInterval implements JsonSerializable
{
    public function __construct(
        /** @var string|null */
        public ?string $ean=null,
        /** @var string|null */
        public ?string $meterId=null,
        /** @var DateTime */
        public DateTime $queryDate=new DateTime(),
        /** @var string|null */
        public ?string $measureUnit=null,
        /** @var array<P4ReadingIntervalItem>|null */
        public ?array $items=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['ean'])) $this->ean = $o['ean'];
        if (isset($o['meterId'])) $this->meterId = $o['meterId'];
        if (isset($o['queryDate'])) $this->queryDate = JsonConverters::from('DateTime', $o['queryDate']);
        if (isset($o['measureUnit'])) $this->measureUnit = $o['measureUnit'];
        if (isset($o['items'])) $this->items = JsonConverters::fromArray('P4ReadingIntervalItem', $o['items']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->ean)) $o['ean'] = $this->ean;
        if (isset($this->meterId)) $o['meterId'] = $this->meterId;
        if (isset($this->queryDate)) $o['queryDate'] = JsonConverters::to('DateTime', $this->queryDate);
        if (isset($this->measureUnit)) $o['measureUnit'] = $this->measureUnit;
        if (isset($this->items)) $o['items'] = JsonConverters::toArray('P4ReadingIntervalItem', $this->items);
        return empty($o) ? new class(){} : $o;
    }
}

class P4Rejection implements JsonSerializable
{
    public function __construct(
        /** @var string|null */
        public ?string $ean=null,
        /** @var DateTime */
        public DateTime $queryDate=new DateTime(),
        /** @var string|null */
        public ?string $queryReason=null,
        /** @var string|null */
        public ?string $rejectionCode=null,
        /** @var string|null */
        public ?string $rejectionText=null
    ) {
    }

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

class P4ReadingsBulk implements JsonSerializable
{
    public function __construct(
        /** @var string|null */
        public ?string $message=null,
        /** @var string */
        public string $timeStamp='',
        /** @var int|null */
        public ?int $dayObjectCount=null,
        /** @var int|null */
        public ?int $intervalObjectCount=null,
        /** @var int|null */
        public ?int $rejectionObjectCount=null,
        /** @var array<P4ReadingDay>|null */
        public ?array $dayObjects=null,
        /** @var array<P4ReadingInterval>|null */
        public ?array $intervalObjects=null,
        /** @var array<P4Rejection>|null */
        public ?array $rejectionObjects=null
    ) {
    }

    /** @throws Exception */
    public function fromMap($o): void {
        if (isset($o['message'])) $this->message = $o['message'];
        if (isset($o['timeStamp'])) $this->timeStamp = $o['timeStamp'];
        if (isset($o['dayObjectCount'])) $this->dayObjectCount = $o['dayObjectCount'];
        if (isset($o['intervalObjectCount'])) $this->intervalObjectCount = $o['intervalObjectCount'];
        if (isset($o['rejectionObjectCount'])) $this->rejectionObjectCount = $o['rejectionObjectCount'];
        if (isset($o['dayObjects'])) $this->dayObjects = JsonConverters::fromArray('P4ReadingDay', $o['dayObjects']);
        if (isset($o['intervalObjects'])) $this->intervalObjects = JsonConverters::fromArray('P4ReadingInterval', $o['intervalObjects']);
        if (isset($o['rejectionObjects'])) $this->rejectionObjects = JsonConverters::fromArray('P4Rejection', $o['rejectionObjects']);
    }
    
    /** @throws Exception */
    public function jsonSerialize(): mixed
    {
        $o = [];
        if (isset($this->message)) $o['message'] = $this->message;
        if (isset($this->timeStamp)) $o['timeStamp'] = $this->timeStamp;
        if (isset($this->dayObjectCount)) $o['dayObjectCount'] = $this->dayObjectCount;
        if (isset($this->intervalObjectCount)) $o['intervalObjectCount'] = $this->intervalObjectCount;
        if (isset($this->rejectionObjectCount)) $o['rejectionObjectCount'] = $this->rejectionObjectCount;
        if (isset($this->dayObjects)) $o['dayObjects'] = JsonConverters::toArray('P4ReadingDay', $this->dayObjects);
        if (isset($this->intervalObjects)) $o['intervalObjects'] = JsonConverters::toArray('P4ReadingInterval', $this->intervalObjects);
        if (isset($this->rejectionObjects)) $o['rejectionObjects'] = JsonConverters::toArray('P4Rejection', $this->rejectionObjects);
        return empty($o) ? new class(){} : $o;
    }
}

enum Filter : string
{
    case None = 'None';
    case Hour = 'Hour';
    case Day = 'Day';
    case LastDayOnly = 'LastDayOnly';
    case Month = 'Month';
}

class ReadingsBulk extends Generic implements IGet, JsonSerializable
{
    /**
     * @param string $apiKey
     */
    public function __construct(
        string $apiKey='',
        /** @description If not given, the first object is given after the last request, otherwise gives the first ... data objects received from EDSN/Grid operator received after the given time stamp. Keep in mind, the time stamp is related to when SDS received the data from EDSN, not the date of the data itself! */
        // @ApiMember(DataType="Time stamp with format: yyyyMMdd-HHmmss-ffffff", Description="If not given, the first object is given after the last request, otherwise gives the first ... data objects received from EDSN/Grid operator received after the given time stamp. Keep in mind, the time stamp is related to when SDS received the data from EDSN, not the date of the data itself!", Name="From")
        /** @var string|null */
        public ?string $from=null,

        /** @description Include received interval objects in the result */
        // @ApiMember(DataType="Boolean, default: true", Description="Include received interval objects in the result", Name="IncludeIntervalObjects")
        /** @var bool|null */
        public ?bool $includeIntervalObjects=null,

        /** @description Include received day objects in the result */
        // @ApiMember(DataType="Boolean, default: false", Description="Include received day objects in the result", Name="IncludeDayObjects")
        /** @var bool|null */
        public ?bool $includeDayObjects=null,

        /** @description Gives option to filter return objects, for example to get always only hour records or day records */
        // @ApiMember(DataType="Enum: None, Hour, Day, LastDayOnly, Month", Description="Gives option to filter return objects, for example to get always only hour records or day records", Name="ObjectFilter")
        /** @var Filter|null */
        public ?Filter $objectFilter=null
    ) {
        parent::__construct($apiKey);
    }

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

PHP ReadingsBulk 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.

GET /v8/readings-bulk HTTP/1.1 
Host: p4.smartdatasolutions.eu 
Accept: text/jsonl
HTTP/1.1 200 OK
Content-Type: text/jsonl
Content-Length: length

{"message":"String","timeStamp":"String","dayObjectCount":0,"intervalObjectCount":0,"rejectionObjectCount":0,"dayObjects":[{"ean":"String","meterId":"String","queryDate":"0001-01-01","measureUnit":"String","r180":0,"r181":0,"r182":0,"r280":0,"r281":0,"r282":0}],"intervalObjects":[{"ean":"String","meterId":"String","queryDate":"0001-01-01","measureUnit":"String","items":[{"dateTimeOffset":"0001-01-01T00:00:00+00:00","r180":0,"r280":0}]}],"rejectionObjects":[{"ean":"String","queryDate":"0001-01-01","queryReason":"String","rejectionCode":"String","rejectionText":"String"}]}