mirror of
https://github.com/anikeen-com/id.git
synced 2026-03-15 06:36:14 +00:00
refactored code
Signed-off-by: Maurice Preuß (envoyr) <hello@envoyr.com>
This commit is contained in:
48
src/Id/Concerns/ManagesInvoices.php
Normal file
48
src/Id/Concerns/ManagesInvoices.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace Anikeen\Id\Concerns;
|
||||
|
||||
use Anikeen\Id\ApiOperations\Request;
|
||||
use Anikeen\Id\Exceptions\RequestRequiresClientIdException;
|
||||
use Anikeen\Id\Result;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
|
||||
trait ManagesInvoices
|
||||
{
|
||||
use Request;
|
||||
|
||||
/**
|
||||
* Get invoices from the current user.
|
||||
*
|
||||
* @throws RequestRequiresClientIdException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function invoices(): Result
|
||||
{
|
||||
return $this->request('GET', 'v1/invoices');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get given invoice from the current user.
|
||||
*
|
||||
* @param string $invoiceId The invoice ID
|
||||
* @throws RequestRequiresClientIdException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function invoice(string $invoiceId): Result
|
||||
{
|
||||
return $this->request('GET', sprintf('v1/invoices/%s', $invoiceId));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get download url from given invoice.
|
||||
*
|
||||
* @param string $invoiceId The invoice ID
|
||||
* @throws RequestRequiresClientIdException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function getInvoiceDownloadUrl(string $invoiceId): string
|
||||
{
|
||||
return $this->request('PUT', sprintf('v1/invoices/%s', $invoiceId))->data->download_url;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user