| Total Complexity | 5 |
| Total Lines | 56 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 5 | class Auth |
||
| 6 | { |
||
| 7 | const PRODUCTION = ''; |
||
| 8 | const SANDBOX = 'https://devportal.itau.com.br/api/jwt'; |
||
| 9 | |||
| 10 | private string $apiUrl; |
||
| 11 | private array $fields; |
||
| 12 | private string $method; |
||
| 13 | protected ?object $response; |
||
| 14 | |||
| 15 | public function __construct() |
||
| 16 | { |
||
| 17 | $this->method = 'POST'; |
||
| 18 | } |
||
| 19 | |||
| 20 | public function production(): self |
||
| 21 | { |
||
| 22 | $this->apiUrl = self::PRODUCTION; |
||
| 23 | return $this; |
||
| 24 | } |
||
| 25 | |||
| 26 | public function sandbox(): self |
||
| 30 | } |
||
| 31 | |||
| 32 | public function token(string $clientId, string $clientSecret): ?object |
||
| 33 | { |
||
| 34 | $this->fields = array_map("strip_tags", [ |
||
| 35 | 'client_id' => $clientId, |
||
| 36 | 'client_secret' => $clientSecret |
||
| 37 | ]); |
||
| 38 | |||
| 39 | $this->dispatch(); |
||
| 40 | return $this->response; |
||
| 41 | } |
||
| 42 | |||
| 43 | private function dispatch(): void |
||
| 61 | } |
||
| 62 | } |