rpungello/sdk-client
最新稳定版本:2.1.4
Composer 安装命令:
composer require rpungello/sdk-client
包简介
Generic client for creating PHP-based SDKs using Spatie's DTOs for data transfer
关键字:
README 文档
README
Generic client for creating PHP-based SDKs using Spatie's DTOs for data transfer.
Installation
You can install the package via composer:
composer require rpungello/sdk-client
Usage
Instantiate the client
$client = new Rpungello\SdkClient('https://example.com');
GET requests
// Returns a Psr\Http\Message\ResponseInterface response $response = $client->get('/api/v1/users'); // Specify a query string $response = $client->get('/api/v1/users', [ 'page' => 1, 'limit' => 10, ]); // Returns a json-decoded array from the response body $response = $client->getJson('/api/v1/users'); // Takes the JSON data returned and wraps it in a DTO for static typing $response = $client->getDto('/api/v1/users/1', UserDto::class); // Takes the JSON data returned and converts it to an array of DTOs for static typing $response = $client->getDtoArray('/api/v1/users', UserDto::class);
PUT/POST/PATCH requests
// Returns a Psr\Http\Message\ResponseInterface response $response = $client->post('/api/v1/users', [ 'name' => 'John Doe', 'email' => 'john@example.com', ]); // Returns a json-decoded array from the response body $response = $client->postJson('/api/v1/users', [ 'name' => 'John Doe', 'email' => 'john@example.com', ]); // Takes the JSON data returned and wraps it in a DTO for static typing $user = new UserDto([ 'name' => 'John Doe', 'email' => 'john@example.com', ]); $response = $client->postDto('/api/v1/users', $user);
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 4.46k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-08-08