PaymentEndpoint   A
last analyzed

Complexity

Total Complexity 13

Size/Duplication

Total Lines 177
Duplicated Lines 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
eloc 15
c 4
b 0
f 0
dl 0
loc 177
rs 10
wmc 13

13 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 3 1
A getByOrderId() 0 3 1
A getByUuid() 0 3 1
A getByTid() 0 3 1
A getById() 0 3 1
A captureById() 0 3 1
A cancelByOrderId() 0 3 1
A captureByTid() 0 3 1
A cancelByUuid() 0 3 1
A captureByUuid() 0 3 1
A cancelById() 0 3 1
A captureByOrderId() 0 3 1
A cancelByTid() 0 3 1
1
<?php
2
3
namespace Ipag\Sdk\Endpoint;
4
5
use Ipag\Sdk\Core\Endpoint;
6
use Ipag\Sdk\Http\Response;
7
use Ipag\Sdk\Model\PaymentTransaction;
8
9
/**
10
 * PaymentEndpoint class
11
 *
12
 * Classe responsável pelo controle dos endpoints do recurso Payment.
13
 */
14
class PaymentEndpoint extends Endpoint
15
{
16
    protected string $location = '/service';
17
18
    /**
19
     * Endpoint para criar um novo recurso `Payment`
20
     *
21
     * @param PaymentTransaction $paymentTransaction
22
     * @return Response
23
     */
24
    public function create(PaymentTransaction $paymentTransaction): Response
25
    {
26
        return $this->_POST($paymentTransaction->jsonSerialize(), [], [], '/payment');
27
    }
28
29
    /**
30
     * Endpoint para obter um recurso `Payment`
31
     *
32
     * @param string $id
33
     * @return Response
34
     *
35
     * @codeCoverageIgnore
36
     */
37
    public function getById(string $id): Response
38
    {
39
        return $this->_GET(['id' => $id], [], '/consult');
40
    }
41
42
    /**
43
     * Endpoint para obter um recurso `Payment`
44
     *
45
     * @param string $uuid
46
     * @return Response
47
     *
48
     * @codeCoverageIgnore
49
     */
50
    public function getByUuid(string $uuid): Response
51
    {
52
        return $this->_GET(['uuid' => $uuid], [], '/consult');
53
    }
54
55
    /**
56
     * Endpoint para obter um recurso `Payment`
57
     *
58
     * @param string $tid
59
     * @return Response
60
     *
61
     * @codeCoverageIgnore
62
     */
63
    public function getByTid(string $tid): Response
64
    {
65
        return $this->_GET(['tid' => $tid], [], '/consult');
66
    }
67
68
    /**
69
     * Endpoint para obter um recurso `Payment`
70
     *
71
     * @param string $orderId
72
     * @return Response
73
     *
74
     * @codeCoverageIgnore
75
     */
76
    public function getByOrderId(string $orderId): Response
77
    {
78
        return $this->_GET(['order_id' => $orderId], [], '/consult');
79
    }
80
81
    /**
82
     * Endpoint para capturar um recurso `Payment`
83
     *
84
     * @param string $id
85
     * @param ?float $amount
86
     * @return Response
87
     *
88
     * @codeCoverageIgnore
89
     */
90
    public function captureById(string $id, ?float $amount = null): Response
91
    {
92
        return $this->_POST([], compact('id', 'amount'), [], '/capture');
93
    }
94
95
    /**
96
     * Endpoint para capturar um recurso `Payment`
97
     *
98
     * @param string $uuid
99
     * @param ?float $amount
100
     * @return Response
101
     *
102
     * @codeCoverageIgnore
103
     */
104
    public function captureByUuid(string $uuid, ?float $amount = null): Response
105
    {
106
        return $this->_POST([], compact('uuid', 'amount'), [], '/capture');
107
    }
108
109
    /**
110
     * Endpoint para capturar um recurso `Payment`
111
     *
112
     * @param string $tid
113
     * @param ?float $amount
114
     * @return Response
115
     *
116
     * @codeCoverageIgnore
117
     */
118
    public function captureByTid(string $tid, ?float $amount = null): Response
119
    {
120
        return $this->_POST([], compact('tid', 'amount'), [], '/capture');
121
    }
122
123
    /**
124
     * Endpoint para capturar um recurso `Payment`
125
     *
126
     * @param string $order_id
127
     * @param ?float $amount
128
     * @return Response
129
     *
130
     * @codeCoverageIgnore
131
     */
132
    public function captureByOrderId(string $order_id, ?float $amount = null): Response
133
    {
134
        return $this->_POST([], compact('order_id', 'amount'), [], '/capture');
135
    }
136
137
    /**
138
     * Endpoint para cancelar um recurso `Payment`
139
     *
140
     * @param string $id
141
     * @param ?float $amount
142
     * @return Response
143
     *
144
     * @codeCoverageIgnore
145
     */
146
    public function cancelById(string $id, ?float $amount = null): Response
147
    {
148
        return $this->_POST([], compact('id', 'amount'), [], '/cancel');
149
    }
150
151
    /**
152
     * Endpoint para cancelar um recurso `Payment`
153
     *
154
     * @param string $uuid
155
     * @param ?float $amount
156
     * @return Response
157
     *
158
     * @codeCoverageIgnore
159
     */
160
    public function cancelByUuid(string $uuid, ?float $amount = null): Response
161
    {
162
        return $this->_POST([], compact('uuid', 'amount'), [], '/cancel');
163
    }
164
165
    /**
166
     * Endpoint para cancelar um recurso `Payment`
167
     *
168
     * @param string $tid
169
     * @param ?float $amount
170
     * @return Response
171
     *
172
     * @codeCoverageIgnore
173
     */
174
    public function cancelByTid(string $tid, ?float $amount = null): Response
175
    {
176
        return $this->_POST([], compact('tid', 'amount'), [], '/cancel');
177
    }
178
179
    /**
180
     * Endpoint para cancelar um recurso `Payment`
181
     *
182
     * @param string $order_id
183
     * @param ?float $amount
184
     * @return Response
185
     *
186
     * @codeCoverageIgnore
187
     */
188
    public function cancelByOrderId(string $order_id, ?float $amount = null): Response
189
    {
190
        return $this->_POST([], compact('order_id', 'amount'), [], '/cancel');
191
    }
192
193
}