professionalweb / crm-buffer-lib
用于与CRMBuffer通信的库
v0.1.9
2019-07-02 12:58 UTC
Requires
- illuminate/support: 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.*
README
项目结构
Facades/
Interfaces/
Models/
Services/
要求
- PHP 7.1+
安装
将仓库添加到 composer.json
"repositories": [ { "type": "git", "url": "https://github.com/SergioMadness/crm-buffer-lib.git" } ]
在您的 composer.json
的 require
部分手动添加以下内容
"professionalweb/crm-buffer": "@dev"
之后运行 composer update
。
或者直接执行
composer require professionalweb/crm-buffer:@dev
初始化
config/app.php
<?php return [ 'providers' => [ ... \professionalweb\crmbuffer\CRMBufferProvider::class, ... ], ];
config/crm-buffer.php
<?php return [ 'url' => 'https://crm-buffer.com/api/v1', 'client_id' => '%your_client_id%', 'client_secret' => '%your_client_secret%', ];
使用示例
<?php namespace App\Jobs; use Illuminate\Bus\Queueable; use Illuminate\Queue\SerializesModels; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Queue\ShouldQueue; use professionalweb\crmbuffer\Interfaces\CRMBufferService; /** * Process new lead * @package App\Jobs */ class NewLead implements ShouldQueue { use InteractsWithQueue, Queueable, SerializesModels; public $title; public $name; public $email; public $phone; public $comment; public $visitorId; public $productId; public $country; public $city; public $position; /** * Execute the job. * * @param CRMBufferService $crmService * * @return void */ public function handle(CRMBufferService $crmService) { $lead = $crmService->lead(); if ($this->title) { $lead->setTitle($this->title); } if ($this->name) { $lead->setName($this->name); } if ($this->email) { $lead->setEmail($this->email); } if ($this->phone) { $lead->setPhone($this->phone); } if ($this->visitorId) { $lead->setVisitorId($this->visitorId); } if ($this->comment) { $lead->setComment($this->comment); } if ($this->productId) { $lead->setProductId($this->productId); } if ($this->country) { $lead->setCountry($this->country); } if ($this->city) { $lead->setCity($this->city); } if ($this->productId) { $lead->setProductId($this->productId); } if ($this->position) { $lead->setPosition($this->position); } $lead->send(); } }