Skip to content

Commit

Permalink
Merge pull request #534 from DawidVH/ecloud-billing-history
Browse files Browse the repository at this point in the history
eCloud BillingHistory
  • Loading branch information
DawidVH authored Sep 20, 2024
2 parents bea0037 + 3cbdc0e commit b3e1b8e
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/eCloud/BillingHistoryClient.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace UKFast\SDK\eCloud;

use UKFast\SDK\eCloud\Entities\BillingHistory;
use UKFast\SDK\Entities\ClientEntityInterface;
use UKFast\SDK\Traits\PageItems;

class BillingHistoryClient extends Client implements ClientEntityInterface
{
use PageItems;

protected $collectionPath = 'v2/billing-history';

public function getEntityMap()
{
return BillingHistory::$entityMap;
}

public function loadEntity($data)
{
return new BillingHistory(
$this->apiToFriendly($data, BillingHistory::$entityMap)
);
}
}
8 changes: 8 additions & 0 deletions src/eCloud/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,4 +407,12 @@ public function vpnGatewayUsers()
{
return (new VpnGatewayUserClient($this->httpClient))->auth($this->token);
}

/**
* @return BaseClient
*/
public function billingHistory()
{
return (new BillingHistoryClient($this->httpClient))->auth($this->token);
}
}
32 changes: 32 additions & 0 deletions src/eCloud/Entities/BillingHistory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace UKFast\SDK\eCloud\Entities;

use DateTime;
use UKFast\SDK\Entity;

/**
* @property string $id
* @property DateTime $billingPeriodStart
* @property DateTime $billingPeriodEnd
* @property float $consumptionTotal
* @property float $planSpendLimit
* @property float $planOverage
* @property DateTime $createdAt
* @property DateTime $updatedAt
*/
class BillingHistory extends Entity
{
protected $dates = ['billingPeriodStart', 'billingPeriodEnd', 'createdAt', 'updatedAt'];

public static $entityMap = [
'id' => 'id',
'billing_period_start' => 'billingPeriodStart',
'billing_period_end' => 'billingPeriodEnd',
'consumption_total' => 'consumptionTotal',
'plan_spend_limit' => 'planSpendLimit',
'plan_overage' => 'planOverage',
'created_at' => 'createdAt',
'updated_at' => 'updatedAt',
];
}

0 comments on commit b3e1b8e

Please sign in to comment.