public function get(string $url, array $header = [])
public function post(string $url, string|array $postFields, array $header = [])
public function delete(string $url, string|array $postFields = '', array $header = [])
Laravel API Helper Command - facilitates caching JSON API responses
Example:
class UserCommand extends LaravelApiHelpersCommand
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'api:get-users {--cached}';
...
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
if ($file = $this->checkCachedFileExists()) {
$this->info('A cached API result file was returned');
return $file;
}
$result = file_put_contents($this->cachedFile, Api::getUsers());
$this->info('The API command was successful');
return $result;
}
You can install the package via composer:
composer require fintech-systems/laravel-api-helpers
$api = new Api();
$result = $api->convertWhatsAppNumberToWhmcsPhoneNumber('27823096710');
expect($result)->toEqual('+27.82 309 6710');
$api = new Api();
$result = $api->convertWhatsAppNumberToWhmcsPhoneNumber('14085551234');
expect($result)->toEqual('+1.408-555-1234');
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.