| GET | /api/v5/meteringpoints/{Ean}/readings/{Filter}/{DateFrom} | Shows all readings available after DateFrom | |
|---|---|---|---|
| GET | /api/v5/meteringpoints/{Ean}/readings/{Filter}/{DateFrom}/{DateTo} | Shows readings for period |
<?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};
enum DateTimeFormat : string
{
case ISO8601 = 'ISO8601';
case UTC = 'UTC';
case NL = 'NL';
case NLOffset = 'NLOffset';
case IN = 'IN';
case INOffset = 'INOffset';
case Unix = 'Unix';
case UnixMillis = 'UnixMillis';
}
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='',
/** @description Normally the result of the request is put inside a resultobject with some status information about the request. If you want the output as csv this outer object can be irritating. Default value: FALSE */
// @ApiMember(DataType="Boolean", Description="Normally the result of the request is put inside a resultobject with some status information about the request. If you want the output as csv this outer object can be irritating. Default value: FALSE ", Name="OnlyPayload")
/** @var bool|null */
public ?bool $OnlyPayload=null,
/** @description Show the request as interpreted by the api. Useful to see how filters / dates are parsed. If no value us provided, the default value is: FALSE */
// @ApiMember(DataType="Boolean", Description="Show the request as interpreted by the api. Useful to see how filters / dates are parsed. If no value us provided, the default value is: FALSE ", Name="ShowRequest")
/** @var bool|null */
public ?bool $ShowRequest=null,
/** @description Format all DateTime in the response object. If used in browser, sometimes ISO8601 is not correctly transformed. Enum options: ISO8601 (DEFAULT), UTC, NL, NLOffset, Unix, UnixMillis */
// @ApiMember(DataType="Enum", Description="Format all DateTime in the response object. If used in browser, sometimes ISO8601 is not correctly transformed. Enum options: ISO8601 (DEFAULT), UTC, NL, NLOffset, Unix, UnixMillis", Name="DateTimeFormat")
/** @var DateTimeFormat|null */
public ?DateTimeFormat $DateTimeFormat=null
) {
}
/** @throws Exception */
public function fromMap($o): void {
if (isset($o['ApiKey'])) $this->ApiKey = $o['ApiKey'];
if (isset($o['OnlyPayload'])) $this->OnlyPayload = $o['OnlyPayload'];
if (isset($o['ShowRequest'])) $this->ShowRequest = $o['ShowRequest'];
if (isset($o['DateTimeFormat'])) $this->DateTimeFormat = JsonConverters::from('DateTimeFormat', $o['DateTimeFormat']);
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = [];
if (isset($this->ApiKey)) $o['ApiKey'] = $this->ApiKey;
if (isset($this->OnlyPayload)) $o['OnlyPayload'] = $this->OnlyPayload;
if (isset($this->ShowRequest)) $o['ShowRequest'] = $this->ShowRequest;
if (isset($this->DateTimeFormat)) $o['DateTimeFormat'] = JsonConverters::to('DateTimeFormat', $this->DateTimeFormat);
return empty($o) ? new class(){} : $o;
}
}
enum Filter : string
{
case None = 'None';
case Hour = 'Hour';
case Day = 'Day';
case Month = 'Month';
case Year = 'Year';
}
enum MeasurementSource : string
{
case Detail = 'Detail';
case Day = 'Day';
case Month = 'Month';
case Unknown = 'Unknown';
}
/** @description Get readings of a metering point */
// @Api(Description="Get readings of a metering point")
class Reading extends Generic implements JsonSerializable
{
/**
* @param string $ApiKey
* @param bool|null $OnlyPayload
* @param bool|null $ShowRequest
* @param DateTimeFormat|null $DateTimeFormat
*/
public function __construct(
string $ApiKey='',
?bool $OnlyPayload=null,
?bool $ShowRequest=null,
?DateTimeFormat $DateTimeFormat=null,
/** @description Request of details of specific metering point with Ean */
// @ApiMember(DataType="EAN (18 numbers)", Description="Request of details of specific metering point with Ean", Name="Ean")
/** @var string|null */
public ?string $Ean=null,
/** @description Detail gives hourly readings for gas and 15 minutes readings for electricity. Only register 1.8.0 (G&E) and 2.8.0 (E) are available. The Day and Month filter are by default also based on the detail readings. Optional it is possible to get the values from the day channels. Advantage: readings are the readings visible as on the smart meter and for electricity the High/Low distinction is available. Downside: for some of the older smart meter models, no decimals are available. Registers starting with 1 are usage, starting with 2 are return. Registers ending on 1 are normal/high tariff, ending on 2 are low/night/weekend tariff. For gas only register 1.8.0 is available. For electricity 1.8.1/1.8.2/2.8.1/2.8.2 are available */
// @ApiMember(DataType="Enum: none/hour/day/month/year", Description="Detail gives hourly readings for gas and 15 minutes readings for electricity. Only register 1.8.0 (G&E) and 2.8.0 (E) are available. The Day and Month filter are by default also based on the detail readings. Optional it is possible to get the values from the day channels. Advantage: readings are the readings visible as on the smart meter and for electricity the High/Low distinction is available. Downside: for some of the older smart meter models, no decimals are available. Registers starting with 1 are usage, starting with 2 are return. Registers ending on 1 are normal/high tariff, ending on 2 are low/night/weekend tariff. For gas only register 1.8.0 is available. For electricity 1.8.1/1.8.2/2.8.1/2.8.2 are available", IsRequired=true, Name="Filter")
/** @var Filter|null */
public ?Filter $Filter=null,
/** @description Start date the readings are requested for */
// @ApiMember(DataType="Date: yyyy-mm-dd", Description="Start date the readings are requested for", IsRequired=true, Name="DateFrom")
/** @var DateTime */
public DateTime $DateFrom=new DateTime(),
/** @description End date the readings are requested for (this date is included in the response). If no date is provided the DateTo will be seven days from DateFrom. */
// @ApiMember(DataType="Date: yyyy-mm-dd", Description="End date the readings are requested for (this date is included in the response). If no date is provided the DateTo will be seven days from DateFrom.", Name="DateTo")
/** @var DateTime|null */
public ?DateTime $DateTo=null,
/** @description See filter. Readings are available from the Detail or Day channel. Default value: Detail */
// @ApiMember(DataType="Enum: detail/day", Description="See filter. Readings are available from the Detail or Day channel. Default value: Detail", Name="Source")
/** @var MeasurementSource|null */
public ?MeasurementSource $Source=null,
/** @description Add column with Dutch day (Default: false) */
// @ApiMember(DataType="Boolean", Description="Add column with Dutch day (Default: false)", Name="AddDateNL")
/** @var bool|null */
public ?bool $AddDateNL=null,
/** @description Add the first reading of the next day if available. Only available/relevant if no aggregation / source is detail (Default: true) */
// @ApiMember(DataType="Boolean", Description="Add the first reading of the next day if available. Only available/relevant if no aggregation / source is detail (Default: true)", Name="AddFirstReadingNextDay")
/** @var bool|null */
public ?bool $AddFirstReadingNextDay=null,
/** @description Add columns with CreatedOn and LastUpdated (Default: false) */
// @ApiMember(DataType="Boolean", Description="Add columns with CreatedOn and LastUpdated (Default: false)", Name="AddTimestamps")
/** @var bool|null */
public ?bool $AddTimestamps=null,
/** @description Add column with ean (Default: false) */
// @ApiMember(DataType="Boolean", Description="Add column with ean (Default: false)", Name="AddEan")
/** @var bool|null */
public ?bool $AddEan=null,
/** @description Add column with the meter serial number (Default: false) */
// @ApiMember(DataType="Boolean", Description="Add column with the meter serial number (Default: false)", Name="AddMeterId")
/** @var bool|null */
public ?bool $AddMeterId=null,
/** @description Create a row for each register instead of a column/field for each register (Default: false) */
// @ApiMember(DataType="Boolean", Description="Create a row for each register instead of a column/field for each register (Default: false)", Name="RegistersInRows")
/** @var bool|null */
public ?bool $RegistersInRows=null
) {
parent::__construct($ApiKey,$OnlyPayload,$ShowRequest,$DateTimeFormat);
}
/** @throws Exception */
public function fromMap($o): void {
parent::fromMap($o);
if (isset($o['Ean'])) $this->Ean = $o['Ean'];
if (isset($o['Filter'])) $this->Filter = JsonConverters::from('Filter', $o['Filter']);
if (isset($o['DateFrom'])) $this->DateFrom = JsonConverters::from('DateTime', $o['DateFrom']);
if (isset($o['DateTo'])) $this->DateTo = JsonConverters::from('DateTime', $o['DateTo']);
if (isset($o['Source'])) $this->Source = JsonConverters::from('MeasurementSource', $o['Source']);
if (isset($o['AddDateNL'])) $this->AddDateNL = $o['AddDateNL'];
if (isset($o['AddFirstReadingNextDay'])) $this->AddFirstReadingNextDay = $o['AddFirstReadingNextDay'];
if (isset($o['AddTimestamps'])) $this->AddTimestamps = $o['AddTimestamps'];
if (isset($o['AddEan'])) $this->AddEan = $o['AddEan'];
if (isset($o['AddMeterId'])) $this->AddMeterId = $o['AddMeterId'];
if (isset($o['RegistersInRows'])) $this->RegistersInRows = $o['RegistersInRows'];
}
/** @throws Exception */
public function jsonSerialize(): mixed
{
$o = parent::jsonSerialize();
if (isset($this->Ean)) $o['Ean'] = $this->Ean;
if (isset($this->Filter)) $o['Filter'] = JsonConverters::to('Filter', $this->Filter);
if (isset($this->DateFrom)) $o['DateFrom'] = JsonConverters::to('DateTime', $this->DateFrom);
if (isset($this->DateTo)) $o['DateTo'] = JsonConverters::to('DateTime', $this->DateTo);
if (isset($this->Source)) $o['Source'] = JsonConverters::to('MeasurementSource', $this->Source);
if (isset($this->AddDateNL)) $o['AddDateNL'] = $this->AddDateNL;
if (isset($this->AddFirstReadingNextDay)) $o['AddFirstReadingNextDay'] = $this->AddFirstReadingNextDay;
if (isset($this->AddTimestamps)) $o['AddTimestamps'] = $this->AddTimestamps;
if (isset($this->AddEan)) $o['AddEan'] = $this->AddEan;
if (isset($this->AddMeterId)) $o['AddMeterId'] = $this->AddMeterId;
if (isset($this->RegistersInRows)) $o['RegistersInRows'] = $this->RegistersInRows;
return empty($o) ? new class(){} : $o;
}
}
To override the Content-type in your clients, use the HTTP Accept Header, append the .xml suffix or ?format=xml
The following are sample HTTP requests and responses. The placeholders shown need to be replaced with actual values.
GET /api/v5/meteringpoints/{Ean}/readings/{Filter}/{DateFrom} HTTP/1.1
Host: p4v8.smartdatasolutions.nl
Accept: application/xml