Skip to content

Commit

Permalink
add new endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
jhowbhz authored Feb 29, 2024
1 parent af2fcee commit 2935ee8
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions src/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,4 +275,66 @@ public static function CEP(String $action = '', Array $data = []) {

}

public static function HoliDays(String $action = '', Array $data = []) {

try {

$base_uri = "https://gateway.apibrasil.io/api/v2/holidays/".$action;
$method = $data['method'] ?? 'POST';

$headers = [
"Content-Type" => "application/json",
"Accept" => "application/json",
"Authorization" => "Bearer ".$data['Bearer'],
];

if (isset($data['DeviceToken'])) {
$headers['DeviceToken'] = $data['DeviceToken'];
}

$body = $data['body'] ?? [];

$response = self::defaultRequest($method, $base_uri, $action, $headers, $body);
return $response;

} catch (ClientException $e) {

$response = $e->getResponse();
return json_decode((string)($response->getBody()->getContents()));

}

}

public static function DDD(String $action = '', Array $data = []) {

try {

$base_uri = "https://gateway.apibrasil.io/api/v2/ddd/".$action;
$method = $data['method'] ?? 'POST';

$headers = [
"Content-Type" => "application/json",
"Accept" => "application/json",
"Authorization" => "Bearer ".$data['Bearer'],
];

if (isset($data['DeviceToken'])) {
$headers['DeviceToken'] = $data['DeviceToken'];
}

$body = $data['body'] ?? [];

$response = self::defaultRequest($method, $base_uri, $action, $headers, $body);
return $response;

} catch (ClientException $e) {

$response = $e->getResponse();
return json_decode((string)($response->getBody()->getContents()));

}

}

}

0 comments on commit 2935ee8

Please sign in to comment.