mirror of
https://github.com/anikeen-com/id.git
synced 2026-03-15 14:46:15 +00:00
refactored code
Signed-off-by: Maurice Preuß (envoyr) <hello@envoyr.com>
This commit is contained in:
49
src/Id/Concerns/ManagesTransactions.php
Normal file
49
src/Id/Concerns/ManagesTransactions.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Anikeen\Id\Concerns;
|
||||
|
||||
use Anikeen\Id\ApiOperations\Request;
|
||||
use Anikeen\Id\Exceptions\RequestRequiresClientIdException;
|
||||
use Anikeen\Id\Result;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
|
||||
trait ManagesTransactions
|
||||
{
|
||||
use Request;
|
||||
|
||||
/**
|
||||
* Get transactions from the current user.
|
||||
*
|
||||
* @throws RequestRequiresClientIdException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function transactions(): Result
|
||||
{
|
||||
return $this->request('GET', 'v1/transactions');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new transaction for the current user.
|
||||
*
|
||||
* @param array $attributes The attributes for the transaction.
|
||||
* @throws RequestRequiresClientIdException
|
||||
* @throws GuzzleException
|
||||
* @todo Add type hinting for the attributes array.
|
||||
*/
|
||||
public function createTransaction(array $attributes = []): Result
|
||||
{
|
||||
return $this->request('POST', 'v1/transactions', $attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get given transaction from current current user.
|
||||
*
|
||||
* @param string $transactionId The transaction ID.
|
||||
* @throws RequestRequiresClientIdException
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function transaction(string $transactionId): Result
|
||||
{
|
||||
return $this->request('GET', sprintf('v1/transactions/%s', $transactionId));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user