金融科技系统 / laravel-api-helpers
各种助手,使与API交互更加容易
v0.1.5
2022-08-19 13:18 UTC
Requires
- php: ^8.0
- illuminate/contracts: ^9.25
- spatie/laravel-package-tools: ^1.12
Requires (Dev)
- nunomaduro/collision: ^6.2
- orchestra/testbench: ^7.6
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.2
- spatie/laravel-ray: ^1.30
- vimeo/psalm: ^4.26
README
一个辅助库,便于与API工作
API:获取、POST、删除
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助手命令 - 便于缓存JSON API响应
示例
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; }
安装
您可以通过composer安装此包
composer require fintech-systems/laravel-api-helpers
用法
WhatsApp到WHMCS电话号码转换
$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
变更日志
请参阅变更日志以了解最近的变化。
贡献
请参阅贡献指南以获取详细信息。
安全漏洞
请审查我们的安全策略以了解如何报告安全漏洞。
致谢
许可证
MIT许可证(MIT)。请参阅许可证文件以获取更多信息。