refactored code

Signed-off-by: Maurice Preuß (envoyr) <hello@envoyr.com>
This commit is contained in:
2025-04-30 03:45:10 +02:00
parent 85702fcb2c
commit 4b23f6ddbb
42 changed files with 1139 additions and 594 deletions

View File

@@ -4,7 +4,7 @@ namespace Anikeen\Id\Concerns;
use Anikeen\Id\ApiOperations\Request;
use Anikeen\Id\Exceptions\RequestRequiresClientIdException;
use Anikeen\Id\Result;
use Anikeen\Id\Resources\Invoices;
use GuzzleHttp\Exception\GuzzleException;
trait ManagesInvoices
@@ -17,32 +17,9 @@ trait ManagesInvoices
* @throws RequestRequiresClientIdException
* @throws GuzzleException
*/
public function invoices(): Result
public function invoices(): Invoices
{
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 temporary download url from given invoice.
*
* @param string $invoiceId The invoice ID
* @throws RequestRequiresClientIdException
* @throws GuzzleException
*/
public function getInvoiceTemporaryUrl(string $invoiceId): string
{
return $this->request('PUT', sprintf('v1/invoices/%s', $invoiceId))->data->temporary_url;
return (new Invoices($this->request('GET', 'v1/invoices')))
->setBillable($this);
}
}