| @@ 15-70 (lines=56) @@ | ||
| 12 | * Class CustomerService |
|
| 13 | * @package linkprofit\AmoCRM\services |
|
| 14 | */ |
|
| 15 | class CustomerService extends BaseService |
|
| 16 | { |
|
| 17 | use IdentifiableList, |
|
| 18 | PaginableList; |
|
| 19 | ||
| 20 | /** |
|
| 21 | * @var Customer[] |
|
| 22 | */ |
|
| 23 | protected $entities = []; |
|
| 24 | ||
| 25 | /** |
|
| 26 | * @param Customer $customer |
|
| 27 | */ |
|
| 28 | public function add(EntityInterface $customer) |
|
| 29 | { |
|
| 30 | if ($customer instanceof Customer) { |
|
| 31 | $this->entities[] = $customer; |
|
| 32 | } |
|
| 33 | } |
|
| 34 | ||
| 35 | /** |
|
| 36 | * @param $link |
|
| 37 | * |
|
| 38 | * @return string |
|
| 39 | */ |
|
| 40 | protected function composeListLink($link) |
|
| 41 | { |
|
| 42 | $query = $this->addIdToQuery(); |
|
| 43 | $query = $this->addPaginationToQuery($query); |
|
| 44 | ||
| 45 | $link .= '?' . http_build_query($query); |
|
| 46 | ||
| 47 | return $link; |
|
| 48 | } |
|
| 49 | ||
| 50 | /** |
|
| 51 | * @param $array |
|
| 52 | * @return Customer |
|
| 53 | */ |
|
| 54 | public function parseArrayToEntity($array) |
|
| 55 | { |
|
| 56 | $customer = new Customer(); |
|
| 57 | $customer->set($array); |
|
| 58 | ||
| 59 | return $customer; |
|
| 60 | } |
|
| 61 | ||
| 62 | /** |
|
| 63 | * @return string |
|
| 64 | */ |
|
| 65 | protected function getLink() |
|
| 66 | { |
|
| 67 | return 'https://' . $this->request->getSubdomain() . '.amocrm.ru/api/v2/customers'; |
|
| 68 | } |
|
| 69 | ||
| 70 | } |
|
| @@ 14-66 (lines=53) @@ | ||
| 11 | * Class PipelineService |
|
| 12 | * @package linkprofit\AmoCRM\services |
|
| 13 | */ |
|
| 14 | class PipelineService extends BaseService |
|
| 15 | { |
|
| 16 | use IdentifiableList; |
|
| 17 | ||
| 18 | /** |
|
| 19 | * @var Pipeline[] |
|
| 20 | */ |
|
| 21 | protected $entities = []; |
|
| 22 | ||
| 23 | /** |
|
| 24 | * @param Pipeline $pipeline |
|
| 25 | */ |
|
| 26 | public function add(EntityInterface $pipeline) |
|
| 27 | { |
|
| 28 | if ($pipeline instanceof Pipeline) { |
|
| 29 | $this->entities[] = $pipeline; |
|
| 30 | } |
|
| 31 | } |
|
| 32 | ||
| 33 | /** |
|
| 34 | * @param $link |
|
| 35 | * |
|
| 36 | * @return string |
|
| 37 | */ |
|
| 38 | protected function composeListLink($link) |
|
| 39 | { |
|
| 40 | $query = $this->addIdToQuery(); |
|
| 41 | ||
| 42 | $link .= '?' . http_build_query($query); |
|
| 43 | ||
| 44 | return $link; |
|
| 45 | } |
|
| 46 | ||
| 47 | /** |
|
| 48 | * @param $array |
|
| 49 | * @return Pipeline |
|
| 50 | */ |
|
| 51 | public function parseArrayToEntity($array) |
|
| 52 | { |
|
| 53 | $pipeline = new Pipeline(); |
|
| 54 | $pipeline->set($array); |
|
| 55 | ||
| 56 | return $pipeline; |
|
| 57 | } |
|
| 58 | ||
| 59 | /** |
|
| 60 | * @return string |
|
| 61 | */ |
|
| 62 | protected function getLink() |
|
| 63 | { |
|
| 64 | return 'https://' . $this->request->getSubdomain() . '.amocrm.ru/private/api/v2/json/pipelines/set'; |
|
| 65 | } |
|
| 66 | } |
|
| @@ 14-68 (lines=55) @@ | ||
| 11 | * Class TaskService |
|
| 12 | * @package linkprofit\AmoCRM\services |
|
| 13 | */ |
|
| 14 | class TaskService extends BaseService |
|
| 15 | { |
|
| 16 | use IdentifiableList, |
|
| 17 | PaginableList; |
|
| 18 | ||
| 19 | /** |
|
| 20 | * @var Task[] |
|
| 21 | */ |
|
| 22 | protected $entities = []; |
|
| 23 | ||
| 24 | /** |
|
| 25 | * @param Task $task |
|
| 26 | */ |
|
| 27 | public function add(EntityInterface $task) |
|
| 28 | { |
|
| 29 | if ($task instanceof Task) { |
|
| 30 | $this->entities[] = $task; |
|
| 31 | } |
|
| 32 | } |
|
| 33 | ||
| 34 | /** |
|
| 35 | * @param $link |
|
| 36 | * |
|
| 37 | * @return string |
|
| 38 | */ |
|
| 39 | protected function composeListLink($link) |
|
| 40 | { |
|
| 41 | $query = $this->addIdToQuery(); |
|
| 42 | ||
| 43 | $link .= '?' . http_build_query($query); |
|
| 44 | ||
| 45 | return $link; |
|
| 46 | } |
|
| 47 | ||
| 48 | /** |
|
| 49 | * @param $array |
|
| 50 | * @return Task |
|
| 51 | */ |
|
| 52 | public function parseArrayToEntity($array) |
|
| 53 | { |
|
| 54 | $task = new Task(); |
|
| 55 | $task->set($array); |
|
| 56 | ||
| 57 | return $task; |
|
| 58 | } |
|
| 59 | ||
| 60 | /** |
|
| 61 | * @return string |
|
| 62 | */ |
|
| 63 | protected function getLink() |
|
| 64 | { |
|
| 65 | return 'https://' . $this->request->getSubdomain() . '.amocrm.ru/api/v2/tasks'; |
|
| 66 | } |
|
| 67 | ||
| 68 | } |
|