farfromboring / crm-sdk
该包已被弃用且不再维护。未建议替代包。
此包的最新版本(9.6.0)没有可用的许可证信息。
9.6.0
2021-01-11 02:10 UTC
Requires
- guzzlehttp/guzzle: ^6.3
- dev-master
- 9.6.0
- 9.5.0
- 9.4.0
- 9.3.0
- 9.2.0
- 9.1.0
- 9.0.0
- 8.3.4
- 8.3.0
- 8.2.0
- 8.1.0
- 8.0.0
- 7.1.1
- 7.1.0
- 7.0.0
- 6.3.1
- 6.3.0
- 6.2.0
- 6.1.0
- 6.0.0
- 5.0.0
- 4.3.2
- 4.3.1
- 4.3.0
- 4.2.0
- 4.1.0
- 4.0.4
- 4.0.3
- 4.0.2
- 4.0.1
- 4.0.0
- 3.4.2
- 3.4.1
- 3.4.0
- 3.3.4
- 3.3.3
- 3.3.2
- 3.3.1
- 3.3.0
- 3.2.0
- 3.1.1
- 3.1.0
- 3.0.4
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 2.0.0
- 1.0.1
- 1.0.0
This package is auto-updated.
Last update: 2022-03-13 20:01:26 UTC
README
此 SDK 允许您快速启动并运行您的 WebWiseUSA CRM 集成。
依赖项
GuzzleHTTP, PHP 7.1+
先决条件
crm.webwiseusa.com 账户和 API 密钥
安装
composer require farfromboring/crm-sdk
为 API 密钥和 API 版本创建环境变量
WEBWISEUSA_CRM_API_KEY="enter_it_here"
WEBWISEUSA_CRM_API_VERSION=1
如果您有多个密钥,您可以通过在 Endpoint 类实例化时提供它们或在全局设置它们来切换它们
$sdk = new UserEndpoint(); //uses default API key from the environment variables above
$sdk2 = new FormEndpoint(getenv('MY_SECOND_API_KEY'));
$sdk3 = new OrderEndpoint(getenv('MY_SECOND_API_KEY'));
//or
$sdk = new UserEndpoint();
Client::setAPIKeyGlobally(getenv('MY_SECOND_API_KEY'));
$sdk2 = new FormEndpoint(); //or FormEndpoint::create()
$sdk3 = new OrderEndpoint(); //or OrderEndpoint::create()
同样适用于 API 版本
$sdk = new UserEndpoint(null, 2);
$sdk = new FormEndpoint(null, 2);
//or
Client::setAPIVersionGlobally(2);
$sdk = new UserEndpoint(); //or UserEndpoint::create()
$sdk = new FormEndpoint(); //or FormEndpoint::create()
您还可以同时全局设置密钥和版本
Client::setAPIKeyGlobally(getenv('MY_SECOND_API_KEY'), 2);
开发/沙盒
只需在您的 API 密钥前加上 "dev_" 以启用沙盒模式。
示例
WEBWISEUSA_CRM_API_KEY="dev_[api_key_here]"
客户端用户
每个操作都会存储一个历史记录,记录了所执行的操作。为了准确地将此更改与执行此更改的用户联系起来,会自动向每个请求添加一个 client_user_id。此值从 $_ENV['CLIENT_USER_ID'] 中获取。在每次请求中,您应将此值设置为当前访客或用户的 ID。
用法
addUser 方法的示例
//instantiate the User and Company objects from the SharedObjects folder $user = new User(); //or User::create() $company = new Company(); //or Company::create() //set values (generally from a user submitted form) //it's a very good idea to perform your own validation on this data prior to setting it $user->setFname($_POST['fname']); $user->setLname($_POST['lname']); $user->setEmail($_POST['email']); $company->setName($_POST['company']); $user->setCompany($company); //instantiate the user endpoint $user_sdk = new UserEndpoint(); //or UserEndpoint::create() //an exception will be thrown if anything other than a 200 is returned //an updated User object is returned on success $new_user = $user_sdk->addUser($user);
用户
用户有三种类型
- 访客:他们系统中没有官方账户,但被同等对待。他们通过令牌来分组提交和操作。登录后,访客账户将与用户合并。
- 用户:他们是具有密码的完整用户。
- 员工:基本上与用户相同,但具有区分的能力,您可以显示诸如产品成本或管理功能之类的信息。
任何接受/需要 $user_id 的端点方法都接受这些用户的 ID。例如 $guest->getId()。
您可以使用他们在联系表单(或任何其他表单)上提供的信息创建访客,或作为完全空白的匿名访客(例如,如果某人将产品添加到他们的购物车)
$guest = new Guest(); $guest->setFname('Bob'); $guest->setLname('Jenkins'); $guest->setEmail('bob@jenkins.com'); $guest = (new GuestEndpoint())->addGuest($guest); //or $guest = (new GuestEndpoint())->addGuest();