tigerheck / laravel-vcita
Laravel 对 vCita API 的封装
v1.0.17
2023-12-26 06:32 UTC
Requires
- php: ^8.0.2
README
A Laravel 对 vCita API 的封装。
安装
通过 Composer
$ composer require tigerheck/laravel-vcita
配置
Laravel vCita 需要连接配置。要开始,您需要发布所有供应商资源
$ php artisan vendor:publish --provider="TigerHeck\Vcita\VcitaServiceProvider"
将 VCITA_BASE_URL=
和 VCITA_API_KEY=
添加到您的环境配置文件
使用
有关参数和其他内容的文档,请参阅 vCita 文档
使用 \Http::vcita() 的示例
获取客户
$response = \Http::vcita()->get("/platform/v1/clients", [
'search_term' => $email,
'search_by' => 'email',
]);
创建客户
$response = \Http::vcita()->post("/platform/v1/clients", [
'address' => $address,
'custom_field1' => $custom_field1,
'custom_field2' => $custom_field2,
'custom_field3' => $custom_field3,
'email' => $email,
'first_name' => $first_name,
'last_name' => $last_name,
'phone' => $phone,
'source_campaign' => $source_campaign,
'source_channel' => $source_channel,
'source_name' => $source_name,
'source_url' => $source_url,
'staff_id' => $staff_id,
'status' => $status,
'tags' => $tags,
]);
更新客户
$response = \Http::vcita()->put("/platform/v1/clients/{$client_id}", [
'address' => $address,
'custom_field1' => $custom_field1,
'custom_field2' => $custom_field2,
'custom_field3' => $custom_field3,
'email' => $email,
'first_name' => $first_name,
'last_name' => $last_name,
'phone' => $phone,
'source_campaign' => $source_campaign,
'source_channel' => $source_channel,
'source_name' => $source_name,
'source_url' => $source_url,
'staff_id' => $staff_id,
'status' => $status,
'tags' => $tags,
]);
通过 Id 删除客户
$response = \Http::vcita()->delete("/platform/v1/clients/{$client_id}");
通过 Id 获取客户
$response = \Http::vcita()->get("/platform/v1/clients/{$client_id}");
使用 app("vcita") 的示例
支持客户端 API,稍后提供对其他 API 的支持。
获取客户
$response = app("vcita")->allClients([
'search_term' => $email,
'search_by' => 'email',
]);
获取客户(带有特定访问点的响应)
$response = app("vcita")->allClients([
'search_term' => $email,
'search_by' => 'email',
], 'data.clients');
创建客户
$response = app("vcita")->createClient([
'address' => $address,
'custom_field1' => $custom_field1,
'custom_field2' => $custom_field2,
'custom_field3' => $custom_field3,
'email' => $email,
'first_name' => $first_name,
'last_name' => $last_name,
'phone' => $phone,
'source_campaign' => $source_campaign,
'source_channel' => $source_channel,
'source_name' => $source_name,
'source_url' => $source_url,
'staff_id' => $staff_id,
'status' => $status,
'tags' => $tags,
]);
更新客户
$response = app("vcita")->updateClient($client_id, [
'address' => $address,
'custom_field1' => $custom_field1,
'custom_field2' => $custom_field2,
'custom_field3' => $custom_field3,
'email' => $email,
'first_name' => $first_name,
'last_name' => $last_name,
'phone' => $phone,
'source_campaign' => $source_campaign,
'source_channel' => $source_channel,
'source_name' => $source_name,
'source_url' => $source_url,
'staff_id' => $staff_id,
'status' => $status,
'tags' => $tags,
]);
通过 Id 删除客户
$response = app("vcita")->deleteClient($client_id);
通过 Id 获取客户
$response = app("vcita")->getClient($client_id);