easyinspect/economic

经济API调用包装器。

v0.2-alpha 2017-12-04 12:03 UTC

This package is auto-updated.

Last update: 2024-08-28 09:07:31 UTC


README

PHP包装器,用于实现E-conomic REST API的流畅接口模式

此包装器用于与E-conomic开发者协议配合使用,其中最终用户可以通过令牌将他们的协议连接到您的系统。请查看连接指南以了解获取令牌的机制,详情请见https://www.e-conomic.com/developer/connect

此E-conomic PHP包装器支持以下选项

  1. 客户 - 创建、显示、更新、删除以及通过可筛选选项进行筛选。
  2. 货币 - 获取所有货币以及通过货币代码获取单个货币,例如 "DKK"。
  3. 单位 - 创建、显示、更新、删除。
  4. 产品 - 创建、显示、更新、删除。
  5. 付款类型 - 获取所有付款类型以及通过ID获取单个付款类型。
  6. 布局 - 获取所有布局以及通过ID获取单个布局。
  7. 发票(草稿) - 创建带空发票行,创建带已分配产品的发票行,并且可以预订发票。

1. 入门指南

为了使用此E-conomic包装器,您需要提供AppSecretToken和AgreementGrantToken密钥。AppSecretToken是从您的E-conomic开发者账户中获得的,而AgreementGrantToken是从客户那里获得的。请参阅https://www.e-conomic.com/developer/connect的步骤2A(手动获取)或步骤2B(自动获取)以了解令牌的获取方式。

请确保设置正确的E-conomic包装器命名空间。

$economic = new Economic(
    'AppSecretToken key',
    'AgreementGrantToken key'
); 

2. 客户

存在两种不同的客户对象,如下所示。

  • 客户

  • 客户集合

    2.1. 客户

    读取 - 您可以使用此对象逐个检索客户,同时此对象也是您用于创建、更新和删除特定客户时使用的对象。

    $customer = $economic
                ->customer()
                ->get('ID'); // This will give you all information about this customer.
    

    创建 - 如果您想创建客户,则必须在创建之前提供五个必需属性,它们是 名称、货币、付款条款、客户组、增值税区

    $customer = $economic
                ->customer()
                ->setCurrency('DKK') // You can retrive one list with all available currencies.
                ->setName('Test Company')
                ->setPaymentTermsNumber(1)
                ->setCustomerGroupNumber(1)
                ->setVatZoneNumber(1)
                ->create();
                ->getCustomerNumber(); After you have created this customer you can retrieve its ID by doing this.
    

    更新 - 更新客户的过程几乎相同,但您不必提供任何属性,您可以简单地选择更新任何属性。

    $customer = $economic
                ->customer()
                ->get('ID') // Retrieve existing customer
                ->setName('Test Company')
                ->setCustomerGroupNumber(2)
                ->setVatZoneNumber(1)
                ->update(); // Updates customer.
    

    删除 - 您可以简单的方法删除任何客户。

    $customer = $economic
                ->customer()
                ->get('ID')
                ->delete(); // Deletes customer.
    

    2.2. 客户集合

    读取 - 这将为您提供所有客户的完整列表,另一个选项是您可以根据客户名称进行筛选。

    $customer = $economic
                ->customerCollection()
                ->all();
    

    筛选 - 通过可筛选属性进行筛选,如果某些内容匹配,则将返回包含有关给定客户信息的对象,请确保阅读文档以了解可以筛选哪些属性,我还建议您阅读筛选文档以了解它们支持的运算符。

    可筛选属性: https://restdocs.e-conomic.com/#customers

    筛选运算符: https://restdocs.e-conomic.com/#filtering

    $customer = $economic
                ->customerCollection()
                ->all(new Filter(['name'], ['$like:'], ['Mikkel'])); // Bear in mind you can filter on more properties, you simply add                                                                           them to the array.