Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
4 / 4 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
1 / 1 |
BillingService | |
100.00% |
4 / 4 |
|
100.00% |
4 / 4 |
4 | |
100.00% |
1 / 1 |
getBillingHistory | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getInvoices | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getInvoice | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getInvoiceItems | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace Vultr\VultrPhp\Services\Billing; |
6 | |
7 | use Vultr\VultrPhp\Services\VultrService; |
8 | use Vultr\VultrPhp\Util\ListOptions; |
9 | |
10 | /** |
11 | * Billing service handler, for billing endpoints. |
12 | * |
13 | * @see https://www.vultr.com/api/#tag/billing |
14 | */ |
15 | class BillingService extends VultrService |
16 | { |
17 | /** |
18 | * Retrieve the billing history of the account. |
19 | * |
20 | * @see https://www.vultr.com/api/#operation/list-billing-history |
21 | * @param $options - ListOptions|null - Interact via reference. |
22 | * @throws BillingException |
23 | * @return Bill[] |
24 | */ |
25 | public function getBillingHistory(?ListOptions &$options = null) : array |
26 | { |
27 | return $this->getListObjects('billing/history', new Bill(), $options); |
28 | } |
29 | |
30 | /** |
31 | * Retrieve the invoices of the account. |
32 | * |
33 | * @see https://www.vultr.com/api/#operation/list-invoices |
34 | * @param $options - ListOptions|null - Interact via reference. |
35 | * @throws BillingException |
36 | * @return Invoices[] |
37 | */ |
38 | public function getInvoices(?ListOptions &$options = null) : array |
39 | { |
40 | return $this->getListObjects('billing/invoices', new Invoice(), $options); |
41 | } |
42 | |
43 | /** |
44 | * Get a specific invoice based on its id. |
45 | * |
46 | * @see https://www.vultr.com/api/#operation/get-invoice |
47 | * @param $invoice_id - int |
48 | * @throws BillingException |
49 | * @return Invoice |
50 | */ |
51 | public function getInvoice(int $invoice_id) : Invoice |
52 | { |
53 | return $this->getObject('billing/invoices/'.$invoice_id, new Invoice()); |
54 | } |
55 | |
56 | /** |
57 | * Get invoice items to help drill into why the cost is what it is. |
58 | * |
59 | * @see https://www.vultr.com/api/#operation/get-invoice-items |
60 | * @param $invoice_id - int |
61 | * @param $options - ListOptions|null - Interact via reference. |
62 | * @throws BillingException |
63 | * @return InvoiceItem[] |
64 | */ |
65 | public function getInvoiceItems(int $invoice_id, ?ListOptions &$options = null) : array |
66 | { |
67 | return $this->getListObjects("billing/invoices/{$invoice_id}/items", new InvoiceItem(), $options); |
68 | } |
69 | } |