loopline-systems / closeio-api-wrapper
Close.io Api的PHP包装器
Requires
- php: >=5.6.0
- ext-curl: *
- doctrine/inflector: ^1.0
Requires (Dev)
- php-coveralls/php-coveralls: ^2.0
- phpunit/phpunit: ^5.7.10
This package is auto-updated.
Last update: 2022-01-25 23:27:50 UTC
README
CloseIo API包装器是一个允许您以面向对象的方式访问Close.io REST API并获取或创建数据的包。
已归档!
不幸的是,由于该项目的大多数原始开发者已经不在Loopline工作或处理close.io,我们已决定将其归档。这样,应该清楚该存储库不再维护。任何有兴趣维护它的人请进行分支操作,并祝您好运!
如果您想了解更多关于归档的决定,请参阅https://github.com/loopline-systems/closeio-api-wrapper/issues/122
安装
要安装库,您需要在项目中使用Composer。有关安装信息,请参阅官方文档。CloseIo Api包装器使用Httplug,不依赖于任何特定的发送HTTP消息的库。这意味着用户可以自由选择他们想要的任何PSR-7实现和HTTP客户端,无论是Guzzle还是简单的cURL客户端。
如果您只想快速开始,请运行以下命令
composer require loopline-systems/closeio-api-wrapper php-http/curl-client nyholm/psr7
这将安装库本身以及一个使用cURL的Httplug HTTP客户端适配器和创建消息所需的PSR-7实现。如果您不想使用这些包,您可以:您可以使用任何提供php-http/async-client-implementation和http-message-implementation的包。
使用
要开始,您只需要创建客户端的一个实例,然后使用其方法查询Close.io的REST API。
require_once __DIR__ . '/vendor/autoload.php'; use LooplineSystems\CloseIoApiWrapper\Client; use LooplineSystems\CloseIoApiWrapper\CloseIoApiWrapper; use LooplineSystems\CloseIoApiWrapper\Configuration; $configuration = new Configuration('{api-key}'); $client = new Client($configuration); $closeIoApiWrapper = new CloseIoApiWrapper($client); $leadsApi = $closeIoApiWrapper->getLeadApi(); // create lead $lead = new Lead(); $lead->setName('Test Company'); $lead->setDescription('Company description'); $lead->setUrl('www.test-company.com'); // address $address = new Address(); $address->setCountry('DE'); $address->setCity('Berlin'); $address->setAddress1('Main Street'); $address->setAddress2('Mitte'); // contacts $contact = new Contact(); $contact->setName('Testy Testersson'); $contact->setTitle('Chief Tester'); // emails $email = new Email(); $email->setEmail('testy-testersson@test-company.com'); $email->setType(Email::EMAIL_TYPE_OFFICE); $contact->addEmail($email); // phones $phone = new Phone(); $phone->setPhone('+491234567890'); $phone->setType(Phone::PHONE_TYPE_MOBILE); $contact->addPhone($phone); $lead->addAddress($address); $lead->addContact($contact); $response = $leadsApi->addLead($lead);
添加机会
$opportunity = new Opportunity(); $opportunity->setValue(500); $opportunity->setNote('My note on this opportunity'); $opportunity->setConfidence(85); $opportunity->setValuePeriod(Opportunity::OPPORTUNITY_FREQUENCY_MONTHLY); // you can use the leadApi to get ID for leads $opportunity->setLeadId(<lead-id>); $opportunityApi = $this->apiWrapper->getOpportunityApi(); $result = $opportunityApi->addOpportunity($opportunity);
活动
$activityApi = $this->apiWrapper->getActivityApi();
// SMS $sms = new SmsActivity(); $sms->setLocalPhone('12345'); $sms->setRemotePhone('23456'); $sms->setText('first sms'); $sms->setStatus(SmsActivity::STATUS_SCHEDULED); $activityApi->addSms($sms);
// EMails $email = new EmailActivity(); $email->setStatus(EmailActivity::STATUS_INBOX); $email->setSubject('RE: Support'); $email->setSender('Support <support@nowhere.net>'); $email->setTo('Customer <customer@nowhere.net>'); $activityApi->addEmail($sms);
更新自定义字段
$customField = new CustomField(); $customField->setId('Custom field id') $customField->addChoice('Value for choices list'); $customFieldApi = $this->apiWrapper->getCustomFieldApi(); $result = $customFieldApi->updateCustomField($customField);
信息
目前只实现了少数API,因为主要需求是创建线索。请随意添加请求并创建拉取请求,或者继续分支存储库。
我们使用https://github.com/btford/adj-noun作为我们的版本名称,所以请放心,它们没有特殊含义 :)
作者
Michael Devery - michaeldevery@gmail.com
Marco Roßdeutscher - marco.rossdeutscher@loopline-systems.com
马克·赞恩 - marc.zahn@loopline-systems.com
另请参阅参与此项目的贡献者列表。
许可
Close.io API包装器遵循MIT许可协议:有关更多信息,请参阅LICENSE文件。
! 我们与Close.io本身无关联。