Completed
Push — master ( e96a0c...fa76da )
by Mr
01:59
created

Transactions   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 20
c 1
b 1
f 0
dl 0
loc 70
ccs 0
cts 20
cp 0
rs 10
wmc 3

3 Methods

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