Skip to content

Commit

Permalink
[Refactor] Improved celcoin base api
Browse files Browse the repository at this point in the history
  • Loading branch information
adeildo-jr committed Mar 25, 2024
1 parent f6bb644 commit cd543ed
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions src/Common/CelcoinBaseApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,8 @@ public function get(string $endpoint, array|string|null $query = null, $response
{
$token = $this->getToken() ?? $this->auth->getToken();
$request = Http::withToken($token)
->withHeaders([
'accept' => 'application/json',
'content-type' => 'application/json',
]);
->asJson()
->acceptJson();

if ($this->mtlsCert && $this->mtlsKey && $this->mtlsPassphrase) {
$request = $this->setRequestMtls($request);
Expand All @@ -99,10 +97,8 @@ public function post(string $endpoint, array $body = [], Attachable $attachment
{
$token = $this->getToken() ?? $this->auth->getToken();
$request = Http::withToken($token)
->withHeaders([
'accept' => 'application/json',
'content-type' => 'application/json'
]);
->asJson()
->acceptJson();

if ($this->mtlsCert && $this->mtlsKey && $this->mtlsPassphrase) {
$request = $this->setRequestMtls($request);
Expand Down Expand Up @@ -138,10 +134,8 @@ public function put(
{
$token = $this->getToken() ?? $this->auth->getToken();
$request = Http::withToken($token)
->withHeaders([
'accept' => 'application/json',
'content-type' => 'application/json',
]);
->asJson()
->acceptJson();

if ($this->mtlsCert && $this->mtlsKey && $this->mtlsPassphrase) {
$request = $this->setRequestMtls($request);
Expand All @@ -164,11 +158,9 @@ public function patch(
$body_format = $asJson ? 'json' : 'form_params';
$token = $this->getToken() ?? $this->auth->getToken();
$request = Http::withToken($token)
->bodyFormat($body_format)
->withHeaders([
'accept' => 'application/json',
'content-type' => 'application/json',
]);
->asJson()
->acceptJson()
->bodyFormat($body_format);

if ($this->mtlsCert && $this->mtlsKey && $this->mtlsPassphrase) {
$request = $this->setRequestMtls($request);
Expand Down

0 comments on commit cd543ed

Please sign in to comment.