EvilFreelancer /
resova-api-php
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Resova\Endpoints; |
||
| 4 | |||
| 5 | use Resova\Client; |
||
| 6 | use Resova\Interfaces\QueryInterface; |
||
| 7 | use Resova\Models\Transaction; |
||
| 8 | use Resova\Models\TransactionRequest; |
||
| 9 | use Resova\Models\TransactionUpdate; |
||
| 10 | use Resova\Models\Webhook; |
||
| 11 | use Resova\Models\WebhookDelete; |
||
| 12 | use Resova\Models\WebhookList; |
||
| 13 | |||
| 14 | class Transactions extends Client |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * @var string |
||
| 18 | */ |
||
| 19 | protected $namespace = __CLASS__; |
||
| 20 | |||
| 21 | /** |
||
| 22 | * Create a transaction |
||
| 23 | * Retrieves the details of a transaction. Provide the unique id for the transaction. |
||
| 24 | * |
||
| 25 | * @param TransactionRequest $transaction |
||
| 26 | * |
||
| 27 | * @return \Resova\Interfaces\QueryInterface |
||
| 28 | */ |
||
| 29 | public function create(TransactionRequest $transaction): QueryInterface |
||
| 30 | { |
||
| 31 | $transaction->setRequired([ |
||
| 32 | 'basket_id', |
||
| 33 | 'payment', |
||
| 34 | ]); |
||
| 35 | |||
| 36 | // Set HTTP params |
||
| 37 | $this->type = 'post'; |
||
| 38 | $this->endpoint = '/transactions'; |
||
| 39 | $this->params = $transaction; |
||
| 40 | $this->response = Transaction::class; |
||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 41 | |||
| 42 | return $this; |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Retrieve a transaction |
||
| 47 | * Retrieves the details of a transaction. Provide the unique id for the transaction. |
||
| 48 | * |
||
| 49 | * @param int $transaction_id The transaction id |
||
| 50 | * |
||
| 51 | * @return $this |
||
| 52 | */ |
||
| 53 | public function __invoke(int $transaction_id): self |
||
| 54 | { |
||
| 55 | $this->transaction_id = $transaction_id; |
||
|
0 ignored issues
–
show
|
|||
| 56 | |||
| 57 | // Set HTTP params |
||
| 58 | $this->type = 'get'; |
||
| 59 | $this->endpoint = '/transactions/' . $transaction_id; |
||
| 60 | $this->response = Transaction::class; |
||
|
0 ignored issues
–
show
|
|||
| 61 | |||
| 62 | return $this; |
||
| 63 | } |
||
| 64 | |||
| 65 | /** |
||
| 66 | * Update a transaction |
||
| 67 | * Updates the specified transaction by setting the values of the parameters passed. |
||
| 68 | * Any parameters not provided will be left unchanged. |
||
| 69 | * This request accepts mostly the same arguments as the transaction creation call. |
||
| 70 | * |
||
| 71 | * @param TransactionUpdate $transaction |
||
| 72 | * |
||
| 73 | * @return \Resova\Interfaces\QueryInterface |
||
| 74 | */ |
||
| 75 | public function update(TransactionUpdate $transaction): QueryInterface |
||
| 76 | { |
||
| 77 | // Set HTTP params |
||
| 78 | $this->type = 'put'; |
||
| 79 | $this->endpoint = '/transactions/' . $this->transaction_id; |
||
| 80 | $this->params = $transaction; |
||
| 81 | $this->response = Transaction::class; |
||
|
0 ignored issues
–
show
|
|||
| 82 | |||
| 83 | return $this; |
||
| 84 | } |
||
| 85 | } |
||
| 86 |