Skip to content

Commit b3e1b8e

Browse files
authored
Merge pull request #534 from DawidVH/ecloud-billing-history
eCloud BillingHistory
2 parents bea0037 + 3cbdc0e commit b3e1b8e

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

src/eCloud/BillingHistoryClient.php

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace UKFast\SDK\eCloud;
4+
5+
use UKFast\SDK\eCloud\Entities\BillingHistory;
6+
use UKFast\SDK\Entities\ClientEntityInterface;
7+
use UKFast\SDK\Traits\PageItems;
8+
9+
class BillingHistoryClient extends Client implements ClientEntityInterface
10+
{
11+
use PageItems;
12+
13+
protected $collectionPath = 'v2/billing-history';
14+
15+
public function getEntityMap()
16+
{
17+
return BillingHistory::$entityMap;
18+
}
19+
20+
public function loadEntity($data)
21+
{
22+
return new BillingHistory(
23+
$this->apiToFriendly($data, BillingHistory::$entityMap)
24+
);
25+
}
26+
}

src/eCloud/Client.php

+8
Original file line numberDiff line numberDiff line change
@@ -407,4 +407,12 @@ public function vpnGatewayUsers()
407407
{
408408
return (new VpnGatewayUserClient($this->httpClient))->auth($this->token);
409409
}
410+
411+
/**
412+
* @return BaseClient
413+
*/
414+
public function billingHistory()
415+
{
416+
return (new BillingHistoryClient($this->httpClient))->auth($this->token);
417+
}
410418
}
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace UKFast\SDK\eCloud\Entities;
4+
5+
use DateTime;
6+
use UKFast\SDK\Entity;
7+
8+
/**
9+
* @property string $id
10+
* @property DateTime $billingPeriodStart
11+
* @property DateTime $billingPeriodEnd
12+
* @property float $consumptionTotal
13+
* @property float $planSpendLimit
14+
* @property float $planOverage
15+
* @property DateTime $createdAt
16+
* @property DateTime $updatedAt
17+
*/
18+
class BillingHistory extends Entity
19+
{
20+
protected $dates = ['billingPeriodStart', 'billingPeriodEnd', 'createdAt', 'updatedAt'];
21+
22+
public static $entityMap = [
23+
'id' => 'id',
24+
'billing_period_start' => 'billingPeriodStart',
25+
'billing_period_end' => 'billingPeriodEnd',
26+
'consumption_total' => 'consumptionTotal',
27+
'plan_spend_limit' => 'planSpendLimit',
28+
'plan_overage' => 'planOverage',
29+
'created_at' => 'createdAt',
30+
'updated_at' => 'updatedAt',
31+
];
32+
}

0 commit comments

Comments
 (0)