forked from mangati/sicoob-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSicoobPixClient.php
50 lines (44 loc) · 1.65 KB
/
SicoobPixClient.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
namespace Mangati\Sicoob;
use Mangati\Sicoob\Dto\AuthenticationToken;
use Mangati\Sicoob\Dto\Pix\ConsultaPixRequest;
use Mangati\Sicoob\Dto\Pix\ConsultaPixResponse;
use Mangati\Sicoob\Dto\Pix\NovaCobrancaVencimentoRequest;
use Mangati\Sicoob\Dto\Pix\NovaCobrancaVencimentoResponse;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\Serializer\SerializerInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
final class SicoobPixClient extends SicoobClientBase
{
private const PIX_API_URL = 'https://api.sicoob.com.br/pix/api/v2';
public function __construct(
HttpClientInterface $client,
SerializerInterface $serializer,
NormalizerInterface $normalizer,
)
{
parent::__construct($client, $serializer, $normalizer);
}
public function consultaPix(AuthenticationToken $token, ConsultaPixRequest $request): ConsultaPixResponse
{
return $this->doJsonRequest(
method: 'GET',
url: self::PIX_API_URL . '/pix',
token: $token,
requestData: $request,
expectedStatusCode: 200,
responseType: ConsultaPixResponse::class
);
}
public function novaCobrancaVencimento(AuthenticationToken $token, string $txid, NovaCobrancaVencimentoRequest $request): NovaCobrancaVencimentoResponse
{
return $this->doJsonRequest(
method: 'PUT',
url: self::PIX_API_URL . '/cobv/' . $txid,
token: $token,
requestData: $request,
expectedStatusCode: 201,
responseType: NovaCobrancaVencimentoResponse::class
);
}
}