pronamic / twinfield
[已弃用] 使用 Twinfield Soap 服务库。
Requires
- php: >=5.4
This package is auto-updated.
Last update: 2024-08-29 03:57:59 UTC
README
此库已迁移到 https://github.com/php-twinfield/twinfield。
用于 Twinfield 集成的 PHP 库。由 Remco Tolsma 和 Leon Rowland 开发,来自 Pronamic。使用 Twinfield SOAP 服务,让您的 PHP 应用程序直接与您的 Twinfield 账户通信。
自动加载
类遵循 PSR2 命名约定。
使用方法
通用使用信息
组件将包含用于简化 Twinfield 请求和发送过程的工厂。每个工厂只需 \Pronamic\Twinfield\Secure\Config() 类及其填写好的详细信息。
配置类使用示例。
$config = new \Pronamic\Twinfield\Secure\Config(); $config->setCredentials('Username', 'Password', 'Organization', 'Office');
- 或在使用 OAuth 时
$config = new \Pronamic\Twinfield\Secure\Config(); $config->setOAuthParameters('clientID', 'clientSecret', 'returnURL', 'Organization', 'Office', true); //the true parameter at the end tells the system to automatically redirect to twinfield to login
现在,让我们看看当前模块
在下面的示例中,我们将使用客户组件作为展示。尽管这将是所有组件(包括当前发票)的方法
通常如下,如果使用工厂
- 添加/编辑:创建对象,创建工厂,在相关工厂的 Submit 方法中提供对象。
- 检索:创建工厂,向相应的 listAll() 和 get() 方法提供所有必需的参数
添加/编辑
创建您的客户对象
$customer = new \Pronamic\Twinfield\Customer\Customer(); $customer ->setID(10666) ->setName('Leon Rowland') ->setType('DEB') ->setWebsite('http://leon.rowland.nl') ->setEBilling(true) ->setEBillMail('leon@rowland.nl') ->setVatCode('VL') ->setDueDays(10) ->setCocNumber('12341234');
客户可以与地址相关联
$customerAddress = new \Pronamic\Twinfield\Customer\CustomerAddress(); $customerAddress ->setDefault(false) ->setType('invoice') ->setField1('Testing field 1') ->setField2('Testing field 2') ->setField3('Testing field 3') ->setPostcode('1212 AB') ->setCity('TestCity') ->setCountry('NL') ->setTelephone('010-12345') ->setFax('010-1234') ->setEmail('test@email.com');
将地址分配给客户
$customer->addAddress($customerAddress);
现在让我们提交它!
use \Pronamic\Twinfield\Customer as TwinfieldCustomer; // Config object prepared and passed to the CustomerFactory $customerFactory = new TwinfieldCustomer\CustomerFactory($config); //$customer = new TwinfieldCustomer\Customer(); // Attempt to send the Customer document if($customerFactory->send($customer)){ // Use the Mapper to turn the response back into a TwinfieldCustomer\Customer $successfulCustomer = TwinfieldCustomer\Mapper\CustomerMapper::map($customerFactory->getResponse()); }
检索/请求
您现在可以获取所有客户或获取单个客户。
use \Pronamic\Twinfield\Customer as TwinfieldCustomer; // Config object prepared and passed into the CustomerFactory $customerFactory = new TwinfieldCustomer\CustomerFactory($config); $customers = $customerFactory->listAll();
目前,listAll 将返回仅包含名称和简称的数组。
$customer = $customerFactory->get('customerCode', 'office[optional]');
get() 的响应将是一个 \Pronamic\Twinfield\Customer\Customer 对象。
注意
高级文档即将推出。详细介绍不带工厂类的使用方法。让您在响应和数据上拥有更多控制,以及更深入的示例和使用建议。
贡献
您可以为此项目做出贡献。尽量保持与其他 2 个组件实施的方式一致。
维护向后兼容性是一个大要求,所以如果您有任何关于大规模重构或更改的计划,请首先在问题中提出。
构建
- npm install
- composer install
链接
作者
许可
版权 2009-2013 Pronamic。
此程序是免费软件;您可以重新分发它并/或修改它,前提是您遵守自由软件基金会根据 GNU 通用公共许可证发布的条款;许可证版本 2,或(根据您的选择)任何后续版本。
此程序是在希望它有用的希望下分发的;但没有任何保证;甚至没有关于适销性或适用于特定目的的暗示性保证。有关详细信息,请参阅 GNU 通用公共许可证。
您应该已收到此程序的 GNU 通用公共许可证副本;如果没有,请写信给自由软件基金会,Inc.,59 Temple Place,Suite 330,波士顿,MA 02111-1307 USA