bartlomiejbeta/lead-desk-api-client-lib

LeadDesk Api 客户端

0.1.0 2017-09-01 13:28 UTC

This package is auto-updated.

Last update: 2024-09-17 03:02:37 UTC


README

此存储库包含 LeadDesk API 客户端库。它使用 HTTPlug 使客户端更加灵活。

有关 LD 的更多信息,请访问 http://leaddesk.com/

有关 HTTPlug 的更多信息,请访问 http://docs.php-http.org/en/latest/httplug/introduction.html

待办事项

  • 添加缓存支持
  • 添加更多 Lead Desk API 端点(请随意提交 PR)
  • 添加测试

安装

使用 composer 安装包

composer require bartlomiejbeta/lead-desk-api-client-lib

需要以下客户端实现之一

  • php-http/guzzle6-adapter
  • php-http/guzzle5-adapter
  • php-http/curl-client
  • php-http/socket-client
  • php-http/react-adapter
  • php-http/buzz-adapter
  • php-http/zend-adapter
  • php-http/cakephp-adapter

查看所有实现:https://packagist.org.cn/providers/php-http/client-implementation

例如:composer require php-http/curl-client

通用用法

$clientCredentials = new ClientCredentials($token);
$httpsClient       = HttpClientDiscovery::find();
$msg               = MessageFactoryDiscovery::find();
$stream            = StreamFactoryDiscovery::find();

$apiClient = new ApiClient($httpsClient, $clientCredentials, $msg, $stream);

/** apiClient can be used to send any lead desk api request. $request must be instace of Psr RequestInterface*/
$apiClient->sendRequest($request);

LeadDeskApi 使用

/** but also you can use some already implemented lead desk endpoints by using this */
$leadDeskApi = new LeadDeskApiClient($apiClient);

/** contact exists -> refere to lead desk api documentation */
$contactFilter       = new ContactFilter($phone, $listId);
$existRepresentation = $leadDeskApi->contactExists($contactFilter);// @see ExistsRepresentation

/** find contact -> refere to lead desk api documentation */
$contactFilter      = new ContactFilter($phone, $listId);
$findRepresentation = $leadDeskApi->findContact($contactFilter);// @see FindRepresentation

/** get contact -> refere to lead desk api documentation */
$contactIdFilter   = new ContactIdFilter($contactId);
$getRepresentation = $leadDeskApi->getContact($contactIdFilter);// @see GetRepresentation

/** delete contact -> refere to lead desk api documentation */
$contactIdFilter     = new ContactIdFilter($contactId);
$existRepresentation = $leadDeskApi->deleteContact($contactFilter);// @see ExistsRepresentation

/** create contact -> refere to lead desk api documentation */
$contactRepresentation = (new ContactRepresentation())
				->setPhone($phone)
				...;
							
$createRepresentation   = $leadDeskApi->createContact($contactRepresentation);// @see CreateRepresentation