atanenl/twinfield

用于使用Twinfield SOAP服务的库。

0.1.5 2017-01-06 14:12 UTC

This package is not auto-updated.

Last update: 2024-09-15 02:01:16 UTC


README

一个用于Twinfield集成的PHP库。由来自Pronamic的Remco Tolsma和Leon Rowland开发。使用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

现在,让我们看看当前的模块

以下示例中,我们将使用客户组件作为展示。虽然这将是所有组件(包括当前的发票)的方法

通常情况下,如果使用工厂

  • 添加/编辑:创建对象,创建工厂,在相关工厂的提交方法中提供对象。
  • 检索:创建工厂,向相应的 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 对象。

注意事项

高级文档即将推出。详细介绍不使用工厂类的方法。同时提供更多对响应和数据控制的机会,以及更深入的使用示例和建议。

贡献

您可以为此项目的开发做出贡献。尽量按照其他两个组件已实施的方式行事。

一个很大的需求是保持向后兼容性,所以如果您有任何关于大规模重构或更改的计划,请首先提出问题。

构建

  • npm install
  • composer install

链接

作者

许可

版权所有 2009-2013 Pronamic。

本程序是自由软件;您可以按照自由软件基金会发布的GNU通用公共许可证的条款重新分发和/或修改它;许可证版本2,或者(根据您的选择)任何较新版本。

本程序以希望它将是有用的为目的进行分发;但没有任何保证;甚至没有关于适销性或适用于特定目的的暗示保证。有关详细信息,请参阅GNU通用公共许可证。

您应该已随本程序收到GNU通用公共许可证的一份副本;如果没有,请写信给自由软件基金会,Inc.,59 Temple Place,Suite 330,波士顿,MA 02111-1307 USA