nikitanp/alfacrm-api-php

v2.0.0 2023-03-04 22:28 UTC

This package is auto-updated.

Last update: 2024-09-05 01:53:55 UTC


README

Latest Version on Packagist

描述

本包是 AlfaCRM REST API 的 PHP 客户端 REST API AlfaCRM

客户端使用 PSR-18PSR-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']);