定制 rpungello/sdk-client 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

Latest Version on Packagist Tests Total Downloads

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

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-08-08