Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,31 @@ EnergyLabelCollection {
addition: null,
street: "Schiphol Boulevard",
city: "Schiphol",
registrationDate: DateTime("2022-08-30"),
inspectionDate: DateTime("2022-08-02"),
validUntilDate: DateTime("2032-08-02"),
constructionType: "utiliteitsbouw",
buildingType: null,
energyLabel: "A+++",
maxEnergyDemand: 98.4,
maxFossilEnergyDemand: 55.48,
minRenewableShare: 55.3
calculationType: "NTA 8800:2022 (basisopname utiliteitsbouw)",
inspectionType: "basis",
status: "bestaand",
constructionYear: 2019,
usageAreaThermalZone: 5648.39,
compactness: 1.16,
energyDemand: 98.4,
energyDemandRequirement: null,
primaryFossilEnergy: 55.48,
primaryFossilEnergyRequirement: null,
primaryFossilEnergyEmg: null,
renewableShare: 55.3,
renewableShareRequirement: null,
renewableShareEmg: null,
calculatedEnergyConsumption: 55.48,
heatDemand: 55.02,
calculatedCo2Emission: 13.01,
temperatureExcess: 0,
temperatureExcessRequirement: null
}
]
}
Expand Down
25 changes: 21 additions & 4 deletions src/DTO/EnergyLabel.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,30 @@ public function __construct(
public readonly ?string $addition,
public readonly string $street,
public readonly string $city,
public readonly DateTime $registrationDate,
public readonly DateTime $inspectionDate,
public readonly DateTime $validUntilDate,
public readonly string $constructionType,
public readonly ?string $buildingType,
public readonly string $energyLabel,
public readonly ?float $maxEnergyDemand,
public readonly ?float $maxFossilEnergyDemand,
public readonly ?float $minRenewableShare,
public readonly ?string $energyLabel,
public readonly string $calculationType,
public readonly ?string $inspectionType,
public readonly ?string $status,
public readonly int $constructionYear,
public readonly ?float $usageAreaThermalZone,
public readonly ?float $compactness,
public readonly ?float $energyDemand,
public readonly ?float $energyDemandRequirement,
public readonly ?float $primaryFossilEnergy,
public readonly ?float $primaryFossilEnergyRequirement,
public readonly ?float $primaryFossilEnergyEmg,
public readonly ?float $renewableShare,
public readonly ?float $renewableShareRequirement,
public readonly ?float $renewableShareEmg,
public readonly ?float $calculatedEnergyConsumption,
public readonly ?float $heatDemand,
public readonly ?float $calculatedCo2Emission,
public readonly ?float $temperatureExcess,
public readonly ?float $temperatureExcessRequirement,
) {}
}
25 changes: 21 additions & 4 deletions src/Factories/EnergyLabelCollectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,31 @@ class EnergyLabelCollectionFactory
* street: string,
* city: string,
* energy_labels: array<array{
* registration_date: string,
* inspection_date: string,
* valid_until_date: string,
* status: string|null,
* construction_type: string,
* building_type: string|null,
* energy_label: string,
* max_energy_demand: float,
* max_fossil_energy_demand: float,
* min_renewable_share: float,
* energy_label: string|null,
* calculation_type: string,
* inspection_type: string|null,
* construction_year: int,
* thermal_zone_area?: float|null,
* compactness?: float|null,
* energy_demand?: float|null,
* energy_demand_requirement?: float|null,
* primary_fossil_energy?: float|null,
* primary_fossil_energy_requirement?: float|null,
* primary_fossil_energy_emg?: float|null,
* renewable_energy_share?: float|null,
* renewable_energy_share_requirement?: float|null,
* renewable_energy_share_emg?: float|null,
* calculated_energy_consumption?: float|null,
* heat_demand?: float|null,
* calculated_co2_emission?: float|null,
* temperature_excess?: float|null,
* temperature_excess_requirement?: float|null,
* }>
* }
* } $response
Expand Down
56 changes: 45 additions & 11 deletions src/Factories/EnergyLabelFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,31 @@ class EnergyLabelFactory
* addition?: string|null,
* street: string,
* city: string,
* registration_date: string,
* inspection_date: string,
* valid_until_date: string,
* status: string|null,
* construction_type: string,
* building_type: string|null,
* energy_label: string,
* max_energy_demand: float,
* max_fossil_energy_demand: float,
* min_renewable_share: float,
* energy_label: string|null,
* calculation_type: string,
* inspection_type: string|null,
* construction_year: int,
* thermal_zone_area?: float|null,
* compactness?: float|null,
* energy_demand?: float|null,
* energy_demand_requirement?: float|null,
* primary_fossil_energy?: float|null,
* primary_fossil_energy_requirement?: float|null,
* primary_fossil_energy_emg?: float|null,
* renewable_energy_share?: float|null,
* renewable_energy_share_requirement?: float|null,
* renewable_energy_share_emg?: float|null,
* calculated_energy_consumption?: float|null,
* heat_demand?: float|null,
* calculated_co2_emission?: float|null,
* temperature_excess?: float|null,
* temperature_excess_requirement?: float|null,
* } $attributes
*/
public static function make(array $attributes): EnergyLabel
Expand All @@ -32,14 +49,31 @@ public static function make(array $attributes): EnergyLabel
addition: $attributes['addition'] ?? null,
street: $attributes['street'],
city: $attributes['city'],
inspectionDate: new DateTime($attributes['inspection_date']),
validUntilDate: new DateTime($attributes['valid_until_date']),
registrationDate: DateTime::createFromFormat('d-m-Y', $attributes['registration_date']), // @phpstan-ignore argument.type
inspectionDate: DateTime::createFromFormat('d-m-Y', $attributes['inspection_date']), // @phpstan-ignore argument.type
validUntilDate: DateTime::createFromFormat('d-m-Y', $attributes['valid_until_date']), // @phpstan-ignore argument.type
constructionType: $attributes['construction_type'],
buildingType: $attributes['building_type'],
energyLabel: $attributes['energy_label'],
maxEnergyDemand: $attributes['max_energy_demand'],
maxFossilEnergyDemand: $attributes['max_fossil_energy_demand'],
minRenewableShare: $attributes['min_renewable_share'],
buildingType: $attributes['building_type'] ?? null,
energyLabel: $attributes['energy_label'] ?? null,
calculationType: $attributes['calculation_type'],
inspectionType: $attributes['inspection_type'] ?? null,
status: $attributes['status'] ?? null,
constructionYear: $attributes['construction_year'],
usageAreaThermalZone: $attributes['thermal_zone_area'] ?? null,
compactness: $attributes['compactness'] ?? null,
energyDemand: $attributes['energy_demand'] ?? null,
energyDemandRequirement: $attributes['energy_demand_requirement'] ?? null,
primaryFossilEnergy: $attributes['primary_fossil_energy'] ?? null,
primaryFossilEnergyRequirement: $attributes['primary_fossil_energy_requirement'] ?? null,
primaryFossilEnergyEmg: $attributes['primary_fossil_energy_emg'] ?? null,
renewableShare: $attributes['renewable_energy_share'] ?? null,
renewableShareRequirement: $attributes['renewable_energy_share_requirement'] ?? null,
renewableShareEmg: $attributes['renewable_energy_share_emg'] ?? null,
calculatedEnergyConsumption: $attributes['calculated_energy_consumption'] ?? null,
heatDemand: $attributes['heat_demand'] ?? null,
calculatedCo2Emission: $attributes['calculated_co2_emission'] ?? null,
temperatureExcess: $attributes['temperature_excess'] ?? null,
temperatureExcessRequirement: $attributes['temperature_excess_requirement'] ?? null,
);
}
}
2 changes: 1 addition & 1 deletion src/Resources/EnergyLabelResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function get(
// @phpstan-ignore-next-line
return EnergyLabelCollectionFactory::make($this->request(
method: 'GET',
path: 'v1/energy-label',
path: 'v2/energy-label',
query: [
'postcode' => $postcode,
'number' => $number,
Expand Down
33 changes: 33 additions & 0 deletions tests/Resources/AddressResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,25 @@ public function test_get_single_result(): void

$this->assertInstanceOf(AddressCollection::class, $result);
$this->assertCount(1, $result);

$address = $result->all()[0];
$this->assertSame('1118BN', $address->postcode);
$this->assertSame(800, $address->number);
$this->assertSame('', $address->addition);
$this->assertSame('Schiphol Boulevard', $address->street);
$this->assertSame('Schiphol', $address->city);
$this->assertSame('Haarlemmermeer', $address->municipality);
$this->assertSame('Noord-Holland', $address->province);
$this->assertSame('Nederland', $address->country);
$this->assertSame(52.30528553688755, $address->coordinates->latitude);
$this->assertSame(4.750645160863609, $address->coordinates->longitude);
$this->assertNull($address->neighborhood);
$this->assertNull($address->district);
$this->assertNull($address->function);
$this->assertNull($address->location_status);
$this->assertNull($address->property_status);
$this->assertNull($address->surface_area);
$this->assertNull($address->construction_year);
}

public function test_get_multiple_results(): void
Expand All @@ -33,5 +52,19 @@ public function test_get_multiple_results(): void

$this->assertInstanceOf(AddressCollection::class, $result);
$this->assertCount(4, $result);

$additions = array_map(fn($address) => $address->addition, $result->all());
$this->assertSame(['A', 'B', 'C', 'D'], $additions);

$first = $result->all()[0];
$this->assertSame('1015CN', $first->postcode);
$this->assertSame(10, $first->number);
$this->assertSame('Keizersgracht', $first->street);
$this->assertSame('Amsterdam', $first->city);
$this->assertSame('Amsterdam', $first->municipality);
$this->assertSame('Noord-Holland', $first->province);
$this->assertSame('Nederland', $first->country);
$this->assertSame(52.379401496779124, $first->coordinates->latitude);
$this->assertSame(4.889216673725493, $first->coordinates->longitude);
}
}
74 changes: 68 additions & 6 deletions tests/Resources/EnergyLabelResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,88 @@ public function test_get_single_result(): void
$result = $this->client
->energyLabels()
->get(
postcode: '1118BN',
number: 800,
postcode: '5465SM',
number: 7,
addition: null,
);

$this->assertInstanceOf(EnergyLabelCollection::class, $result);
$this->assertCount(1, $result);

$label = $result->all()[0];
$this->assertSame('5465SM', $label->postcode);
$this->assertSame(7, $label->number);
$this->assertNull($label->addition);
$this->assertSame('Klaverhoeve', $label->street);
$this->assertSame('Veghel', $label->city);
$this->assertSame('31-08-2026', $label->registrationDate->format('d-m-Y'));
$this->assertSame('31-08-2026', $label->inspectionDate->format('d-m-Y'));
$this->assertSame('31-08-2036', $label->validUntilDate->format('d-m-Y'));
$this->assertSame('woningbouw', $label->constructionType);
$this->assertSame('twee-onder-één-kap', $label->buildingType);
$this->assertSame('A++++', $label->energyLabel);
$this->assertSame('NTA 8800:2025 (detailopname woningbouw)', $label->calculationType);
$this->assertSame('detail', $label->inspectionType);
$this->assertSame('oplevering', $label->status);
$this->assertSame(2025, $label->constructionYear);
$this->assertSame(130.89, $label->usageAreaThermalZone);
$this->assertSame(2.31, $label->compactness);
$this->assertSame(76.54, $label->energyDemand);
$this->assertSame(79.38, $label->energyDemandRequirement);
$this->assertSame(-7.02, $label->primaryFossilEnergy);
$this->assertSame(30.0, $label->primaryFossilEnergyRequirement);
$this->assertNull($label->primaryFossilEnergyEmg);
$this->assertSame(107.7, $label->renewableShare);
$this->assertSame(50.0, $label->renewableShareRequirement);
$this->assertNull($label->renewableShareEmg);
$this->assertSame(-7.03, $label->calculatedEnergyConsumption);
$this->assertSame(47.59, $label->heatDemand);
$this->assertSame(-1.3, $label->calculatedCo2Emission);
$this->assertSame(0.0, $label->temperatureExcess);
$this->assertSame(1.2, $label->temperatureExcessRequirement);
}

public function test_get_multiple_results(): void
{
$result = $this->client
->energyLabels()
->get(
postcode: '1015CN',
number: 10,
addition: 'A',
postcode: '7316ER',
number: 73,
addition: null,
);

$this->assertInstanceOf(EnergyLabelCollection::class, $result);
$this->assertCount(2, $result);
$this->assertCount(3, $result);

$energyLabels = array_map(fn($label) => $label->energyLabel, $result->all());
$this->assertSame(['C', 'E', 'G'], $energyLabels);

$first = $result->all()[0];
$this->assertSame('7316ER', $first->postcode);
$this->assertSame(73, $first->number);
$this->assertNull($first->addition);
$this->assertSame('Laan van Kerschoten', $first->street);
$this->assertSame('Apeldoorn', $first->city);
$this->assertSame('09-10-2025', $first->registrationDate->format('d-m-Y'));
$this->assertSame('07-10-2025', $first->inspectionDate->format('d-m-Y'));
$this->assertSame('07-10-2035', $first->validUntilDate->format('d-m-Y'));
$this->assertSame('woningbouw', $first->constructionType);
$this->assertSame('twee-onder-één-kap', $first->buildingType);
$this->assertSame('basis', $first->inspectionType);
$this->assertSame('bestaand', $first->status);
$this->assertSame(1958, $first->constructionYear);
$this->assertSame(177.57, $first->energyDemand);
$this->assertSame(218.86, $first->primaryFossilEnergy);
$this->assertSame(1.24, $first->temperatureExcess);
$this->assertNull($first->temperatureExcessRequirement);

$third = $result->all()[2];
$this->assertSame('utiliteitsbouw', $third->constructionType);
$this->assertNull($third->buildingType);
$this->assertSame('G', $third->energyLabel);
$this->assertSame(580.39, $third->primaryFossilEnergyEmg);
$this->assertSame(3.2, $third->renewableShare);
$this->assertSame(3.2, $third->renewableShareEmg);
}
}
Loading
Loading