stefandoorn/becosoft-fashionpro-nl-php-api

Becosoft Fashionpro NL API 的 PHP 封装

dev-master 2023-09-07 09:43 UTC

This package is auto-updated.

Last update: 2024-09-07 12:14:47 UTC


README

Build StatusScrutinizer Code QualityCode CoverageLatest Stable VersionLicense

此软件包提供了一个简单的 PHP 封装,围绕 Becosoft Fashionpro API: http://api.fashionpro.becosoft.net/swagger/ui/index

请注意

  • 端点使用荷兰语。目前尚无英文 API。
  • 此软件包中提供的实体按 API 中使用的方式编写,所有其他代码均基于英文。

要求

  • PHP >= 5.5

安装

composer require stefandoorn/becosoft-fashionpro-nl-php-api

使用

创建包装实例

/**
 * Api constructor.
 * @param GatewayInterface $gateway
 */
public function __construct(GatewayInterface $gateway)

快速入门

$gateway = GatewayFactory::get('apiKey', $debug = true);
$api = new Api($gateway);

API 允许您插入自己的 Gateway。默认的 Gateway(来自工厂)使用 Guzzle 实例进行 API 通信,并使用 NullLogger 实例进行日志记录(无日志记录)。提供您自己的日志记录器以确保可以进行日志记录。如果需要,也可以提供您自己的网关实现。

获取项目

  • 在实体上使用 get 以发送单个 GET 请求,并使用您指定的可选过滤器。请参阅 API 文档,了解每个实体可以使用哪些过滤器。
  • 在实体上使用 getAll 以获取符合您过滤器的所有项目。包装器会负责分批发送足够多的请求来获取所有项目(使用 take/skip 参数),每批 50 个项目。

示例

加载文章

$gateway = GatewayFactory::get('apiKey', $debug = true);
$api = new Api($gateway);
$entity = new Artikel($this->api);

$allArticles = $entity->getAll();

带有过滤器的文章加载

$gateway = GatewayFactory::get('apiKey', $debug = true);
$api = new Api($gateway);

$allArticles = $entity->getAll([
    'brand' => $brand,
    'internetPublished' => 'true',
]);

发布项目

  • 在实体上使用 post 将单个项目推送到 Becosoft。

示例

发布 Web 订单

$gateway = GatewayFactory::get('apiKey', $debug = true);
$api = new Api($gateway);
$entity = new BecosoftApi\Entity\Weborder($this->api);

$weborder = new BecosoftApi\Model\Weborder;
$weborder->WeborderId = 1;

...
$result = $entity->post($weborder->toJson();

目前您必须自己插入 JSON 对象,这提供了灵活性。Web 订单模型只是一个辅助模型,以确保您以正确的名称插入字段。