nikitanp / alfacrm-api-php
AlfaCRM API
v2.0.0
2023-03-04 22:28 UTC
Requires
- php: ^7.4|^8.0
- ext-json: *
- psr/http-client: ^1.0
- psr/http-factory: ^1.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- guzzlehttp/guzzle: ^7.0
- phpunit/phpunit: ^9.0
- vimeo/psalm: ^5.0
Suggests
- guzzlehttp/guzzle: great http client
README
描述
本包是 AlfaCRM REST API 的 PHP 客户端 REST API AlfaCRM
客户端使用 PSR-18 和 PSR-17 进行工作。例如,可以使用 guzzlehttp/guzzle 库作为 http 客户端,并使用 http-interop/http-factory-guzzle 作为其 PSR-17 实现。
安装
composer require nikitanp/alfacrm-api-php
基本方法
基本方法位于类 \Nikitanp\AlfacrmApiPhp\Entities\AbstractEntity 中
get(int $page = 0, array $filterData = []): array返回一个数据页,支持过滤getAll(array $filterData = []): \Generator返回所有实体,支持过滤。getFirst(array $filterData = []): array返回第一个元素。count(array $filterData = []): int返回具有指定过滤器的结果数量。fields(array $filterData = []): array返回可能的字段。结果取自系统的第一个响应。create(array $entityData): array创建实体update(int $entityId, array $updateData): array更新实体delete(int $entityId): array删除实体
使用示例
$apiClient = new \Nikitanp\AlfacrmApiPhp\Client( $psr18Client, $psr17RequestFactory, $psr17StreamFactory ); $apiClient->setDomain('domain.alfacrm.pro'); $apiClient->setEmail('admin@domain.exaple'); $apiClient->setApiKey('application-api-key'); $apiClient->authorize(); $customer = new \Nikitanp\AlfacrmApiPhp\Entities\Customer($apiClient); $customer->fields(); $customer->count(); $customer->get(); $customer->getAll(); $customer->getAllArchived(); $customer->create(['customer_data']); $customer->delete(1); $customer->update(1, ['customer_data']);