atapatel / sylius-api-client

Sylius API客户端

0.2.6 2020-05-25 08:53 UTC

This package is not auto-updated.

Last update: 2024-09-25 17:10:37 UTC


README

Latest Version Build Status Code Coverage Quality Score Total Downloads

安装

通过Composer

$ composer require friendsofapi/sylius-api-client

用法

$apiClient = SyliusClient::create($endpoint, $clientId, $clientSecret);
$accessToken = $apiClient->createNewAccessToken($username, $password);
$apiClient->authenticate($accessToken);
$allProducts = $apiClient->product()->getAll()

开发

API通常分为几类,称为资源。在你的实现中,你也应该反映这些类别,例如在Api/中有它们自己的类。让我们看看我们的案例中的Api/Stats。任何调用的响应都应该是一个位于Model/Stats/X中的对象,例如Model/Stats/Total

注入器

最终用户选择使用哪个注入器。默认注入器应该返回领域对象。

请求构建器

请求构建器在需要时创建一个带有多部分流的PSR-7请求。如果API不需要多部分流,你应该移除RequestBuilder并用RequestFactory替换。

许可证

MIT许可证(MIT)。请参阅许可证文件以获取更多信息。