oaoa / naturhouse-api-v2
Naturhouse CRM 的 API 客户端
v0.1.0
2020-02-26 16:51 UTC
Requires
- guzzlehttp/guzzle: ^6.5
- nette/utils: ^3.1
Requires (Dev)
- phpunit/phpunit: ^9.0
This package is not auto-updated.
Last update: 2024-09-20 12:40:39 UTC
README
此库是 Naturhouse CRM 的开源客户端库,主要用于支持分销合作伙伴。API 描述 https://naturhouseapiv2.docs.apiary.io/
Naturhouse 公共 API 支持:
- 获取分支列表
- 获取为客户端提供的包列表
- 获取联系时间列表(何时创建联系的机会)
- 创建联系
- 获取创建的联系(以验证其状态)
安装
使用 composer
$ composer require oaoa/naturhouse-api-v2
基本用法
最简单的情况是
- 获取活动分支列表
- 创建联系
- 检查联系状态
$configuration = [ 'hostname' => 'https://kalendar.naturhouse-cz.cz/api/v2/', 'auth_token' => 'seecret token; you can get one from Naturhouse', ]; $client = new \Naturhouse\Client($configuration); // fetch list of all active branches $branches = $client->getBranches(); // prepare contact data $contact = new \Naturhouse\Entities\Contact(); $contact->setFname('krestni'); $contact->setLname('prijmeni'); $contact->setBranch($branches[0]->getId()); $contact->setNote('testovaci kontakt'); // create contact try{ $response = $client->createContact($contact); $contactId = $response->getId(); //fetch contact state $fetchedContact = $client->getContact($contactId); // print contact state var_dump($fetchedContact->getStatus()); } catch(\Naturhouse\Exceptions\ClientException $e) { echo $e->getMessage(); }
说明
请注意,分支可能会在 > 10 分钟内更改,因此请不要缓存超过一天。如果您向非活动分支创建联系,API 将返回错误。