@@ -68,28 +68,28 @@ discard block |
||
68 | 68 | |
69 | 69 | public function __construct(array $leadData = []) |
70 | 70 | { |
71 | - if (!empty($leadData['id'])) { |
|
71 | + if ( ! empty($leadData['id'])) { |
|
72 | 72 | $this->id = (int) $leadData['id']; |
73 | 73 | } |
74 | - if (!empty($leadData['contact_id'])) { |
|
74 | + if ( ! empty($leadData['contact_id'])) { |
|
75 | 75 | $this->contactId = (int) $leadData['contact_id']; |
76 | 76 | } |
77 | - if (!empty($leadData['contact'])) { |
|
77 | + if ( ! empty($leadData['contact'])) { |
|
78 | 78 | $this->contact = new Contact($leadData['contact']); |
79 | 79 | } |
80 | - if (!empty($leadData['name'])) { |
|
80 | + if ( ! empty($leadData['name'])) { |
|
81 | 81 | $this->name = $leadData['name']; |
82 | 82 | } |
83 | - if (!empty($leadData['funnel'])) { |
|
83 | + if ( ! empty($leadData['funnel'])) { |
|
84 | 84 | $this->funnelId = (int) $leadData['funnel']; |
85 | 85 | } |
86 | - if (!empty($leadData['stage_id'])) { |
|
86 | + if ( ! empty($leadData['stage_id'])) { |
|
87 | 87 | $this->funnelId = (int) $leadData['stage_id']; |
88 | 88 | } |
89 | - if (!empty($leadData['view_id'])) { |
|
89 | + if ( ! empty($leadData['view_id'])) { |
|
90 | 90 | $this->viewId = (int) $leadData['view_id']; |
91 | 91 | } |
92 | - if (!empty($leadData['view'])) { |
|
92 | + if ( ! empty($leadData['view'])) { |
|
93 | 93 | $this->view = new View($leadData['view']); |
94 | 94 | } |
95 | 95 | if (isset($leadData['owner'])) { |
@@ -98,30 +98,30 @@ discard block |
||
98 | 98 | if (isset($leadData['owner_id'])) { |
99 | 99 | $this->ownerId = (int) $leadData['owner_id']; |
100 | 100 | } |
101 | - if (!empty($leadData['payments']) && is_array($leadData['payments'])) { |
|
101 | + if ( ! empty($leadData['payments']) && is_array($leadData['payments'])) { |
|
102 | 102 | foreach ($leadData['payments'] as $paymentData) { |
103 | 103 | $paymentModel = new Payment($paymentData); |
104 | 104 | $this->addPayment($paymentModel); |
105 | 105 | } |
106 | 106 | } |
107 | - if (!empty($leadData['custom']) && is_array($leadData['custom'])) { |
|
107 | + if ( ! empty($leadData['custom']) && is_array($leadData['custom'])) { |
|
108 | 108 | foreach ($leadData['custom'] as $customData) { |
109 | 109 | $customModel = new Custom($customData, $this->id); |
110 | 110 | $this->addCustom($customModel); |
111 | 111 | } |
112 | 112 | } |
113 | - if (!empty($leadData['lead_date'])) { |
|
113 | + if ( ! empty($leadData['lead_date'])) { |
|
114 | 114 | $date = \DateTime::createFromFormat('d.m.Y H:i', $leadData['lead_date']); |
115 | 115 | $this->setCreatedAt($date); |
116 | 116 | } |
117 | - if (!empty($leadData['created_at'])) { |
|
117 | + if ( ! empty($leadData['created_at'])) { |
|
118 | 118 | $date = \DateTime::createFromFormat('d.m.Y H:i', $leadData['created_at']); |
119 | 119 | $this->setCreatedAt($date); |
120 | 120 | } |
121 | - if (!empty($leadData['deal_date'])) { |
|
121 | + if ( ! empty($leadData['deal_date'])) { |
|
122 | 122 | $this->options['deal_date'] = $leadData['deal_date']; |
123 | 123 | } |
124 | - if (!empty($leadData['params']) && is_array($leadData['params'])) { |
|
124 | + if ( ! empty($leadData['params']) && is_array($leadData['params'])) { |
|
125 | 125 | $this->options['params'] = $leadData['params']; |
126 | 126 | } |
127 | 127 | } |
@@ -133,12 +133,12 @@ discard block |
||
133 | 133 | public function toArray($toSave = false) |
134 | 134 | { |
135 | 135 | $result = []; |
136 | - if (!empty($this->contactId)) { |
|
136 | + if ( ! empty($this->contactId)) { |
|
137 | 137 | $result['contact_id'] = $this->contactId; |
138 | 138 | } |
139 | - if (!empty($this->contact)) { |
|
139 | + if ( ! empty($this->contact)) { |
|
140 | 140 | if ($toSave) { |
141 | - if (!empty($this->contact->getId())) { |
|
141 | + if ( ! empty($this->contact->getId())) { |
|
142 | 142 | $result['contact_id'] = $this->contact->getId(); |
143 | 143 | } else { |
144 | 144 | $result['contact'] = $this->contact->toArray(); |
@@ -147,29 +147,29 @@ discard block |
||
147 | 147 | $result['contact'] = $this->contact->toArray(); |
148 | 148 | } |
149 | 149 | } |
150 | - if (!empty($this->id)) { |
|
150 | + if ( ! empty($this->id)) { |
|
151 | 151 | $result['id'] = $this->getId(); |
152 | 152 | } |
153 | - if (!empty($this->name)) { |
|
153 | + if ( ! empty($this->name)) { |
|
154 | 154 | $result['name'] = $this->getName(); |
155 | 155 | } |
156 | - if (!empty($this->funnelId)) { |
|
156 | + if ( ! empty($this->funnelId)) { |
|
157 | 157 | $result['funnel'] = $this->getFunnelId(); |
158 | 158 | $result['stage_id'] = $this->getFunnelId(); |
159 | 159 | } |
160 | - if (!empty($this->ownerId)) { |
|
160 | + if ( ! empty($this->ownerId)) { |
|
161 | 161 | $result['owner'] = $this->getOwnerId(); |
162 | 162 | $result['owner_id'] = $this->getOwnerId(); |
163 | 163 | } |
164 | - if (!empty($this->createdAt)) { |
|
164 | + if ( ! empty($this->createdAt)) { |
|
165 | 165 | $result['lead_date'] = $this->getCreatedAt()->format('d.m.Y H:i'); |
166 | 166 | } |
167 | - if (!empty($this->viewId)) { |
|
167 | + if ( ! empty($this->viewId)) { |
|
168 | 168 | $result['view_id'] = $this->viewId; |
169 | 169 | } |
170 | - if (!empty($this->view)) { |
|
170 | + if ( ! empty($this->view)) { |
|
171 | 171 | if ($toSave) { |
172 | - if (!empty($this->view->getId())) { |
|
172 | + if ( ! empty($this->view->getId())) { |
|
173 | 173 | $result['view_id'] = $this->view->getId(); |
174 | 174 | } else { |
175 | 175 | $result['view'] = $this->view->toArray(); |
@@ -208,11 +208,11 @@ discard block |
||
208 | 208 | throw new LPTrackerSDKException('Invalid contact ID'); |
209 | 209 | } |
210 | 210 | |
211 | - if (!empty($this->funnelId) && (int) $this->funnelId <= 0) { |
|
211 | + if ( ! empty($this->funnelId) && (int) $this->funnelId <= 0) { |
|
212 | 212 | throw new LPTrackerSDKException('Invalid funnel ID'); |
213 | 213 | } |
214 | 214 | |
215 | - if (!empty($this->ownerId) && (int) $this->ownerId < 0) { |
|
215 | + if ( ! empty($this->ownerId) && (int) $this->ownerId < 0) { |
|
216 | 216 | throw new LPTrackerSDKException('Invalid owner ID'); |
217 | 217 | } |
218 | 218 |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | } else { |
91 | 91 | $project = (int) $project; |
92 | 92 | } |
93 | - $url = '/project/' . $project; |
|
93 | + $url = '/project/'.$project; |
|
94 | 94 | $response = LPTrackerRequest::sendRequest($url, [], 'GET', $this->token, $this->address); |
95 | 95 | return new Project($response); |
96 | 96 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | } else { |
120 | 120 | $project = (int) $project; |
121 | 121 | } |
122 | - $url = '/project/' . $project . '/customs'; |
|
122 | + $url = '/project/'.$project.'/customs'; |
|
123 | 123 | $response = LPTrackerRequest::sendRequest($url, [], 'GET', $this->token, $this->address); |
124 | 124 | $result = []; |
125 | 125 | foreach ($response as $customData) { |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | } else { |
142 | 142 | $project = (int) $project; |
143 | 143 | } |
144 | - $url = '/project/' . $project . '/funnel'; |
|
144 | + $url = '/project/'.$project.'/funnel'; |
|
145 | 145 | $response = LPTrackerRequest::sendRequest($url, [], 'GET', $this->token, $this->address); |
146 | 146 | $result = []; |
147 | 147 | foreach ($response as $stageData) { |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | } else { |
164 | 164 | $project = (int) $project; |
165 | 165 | } |
166 | - $url = '/project/' . $project . '/fields'; |
|
166 | + $url = '/project/'.$project.'/fields'; |
|
167 | 167 | $response = LPTrackerRequest::sendRequest($url, [], 'GET', $this->token, $this->address); |
168 | 168 | $result = []; |
169 | 169 | foreach ($response as $customData) { |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | } else { |
186 | 186 | $project = (int) $project; |
187 | 187 | } |
188 | - $url = '/project/' . $project . '/callback-url'; |
|
188 | + $url = '/project/'.$project.'/callback-url'; |
|
189 | 189 | LPTrackerRequest::sendRequest($url, ['url' => $callbackUrl], 'PUT', $this->token, $this->address); |
190 | 190 | } |
191 | 191 | |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | throw new LPTrackerSDKException('Invalid contact ID'); |
262 | 262 | } |
263 | 263 | |
264 | - $url = '/contact/' . $contact; |
|
264 | + $url = '/contact/'.$contact; |
|
265 | 265 | $response = LPTrackerRequest::sendRequest($url, [], 'GET', $this->token, $this->address); |
266 | 266 | return new Contact($response); |
267 | 267 | } |
@@ -273,12 +273,12 @@ discard block |
||
273 | 273 | */ |
274 | 274 | public function saveContact(Contact $contact) |
275 | 275 | { |
276 | - if (!$contact->validate()) { |
|
276 | + if ( ! $contact->validate()) { |
|
277 | 277 | throw new LPTrackerSDKException('Invalid contact'); |
278 | 278 | } |
279 | 279 | |
280 | 280 | $data = $contact->toArray(); |
281 | - if (!empty($data['fields'])) { |
|
281 | + if ( ! empty($data['fields'])) { |
|
282 | 282 | $fields = []; |
283 | 283 | foreach ($data['fields'] as $key => $field) { |
284 | 284 | if (is_array($field) && isset($field['id'], $field['value'])) { |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | $data['fields'] = $fields; |
291 | 291 | } |
292 | 292 | if ($contact->getId() > 0) { |
293 | - $url = '/contact/' . $contact->getId(); |
|
293 | + $url = '/contact/'.$contact->getId(); |
|
294 | 294 | $response = LPTrackerRequest::sendRequest($url, $contact->toArray(), 'PUT', $this->token, $this->address); |
295 | 295 | } else { |
296 | 296 | $response = LPTrackerRequest::sendRequest('/contact', $contact->toArray(), 'POST', $this->token, $this->address); |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | if (isset($searchOptions['phone'])) { |
365 | 365 | $data['phone'] = $searchOptions['phone']; |
366 | 366 | } |
367 | - $url = '/contact/search?' . http_build_query($data); |
|
367 | + $url = '/contact/search?'.http_build_query($data); |
|
368 | 368 | $response = LPTrackerRequest::sendRequest($url, [], 'GET', $this->token, $this->address); |
369 | 369 | $result = []; |
370 | 370 | foreach ($response as $contactData) { |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | throw new LPTrackerSDKException('Invalid contact id'); |
390 | 390 | } |
391 | 391 | |
392 | - $url = '/contact/' . $contact . '/leads'; |
|
392 | + $url = '/contact/'.$contact.'/leads'; |
|
393 | 393 | $response = LPTrackerRequest::sendRequest($url, [], 'GET', $this->token, $this->address); |
394 | 394 | $result = []; |
395 | 395 | foreach ($response as $leadData) { |
@@ -462,11 +462,11 @@ discard block |
||
462 | 462 | */ |
463 | 463 | public function saveContactField(ContactField $field) |
464 | 464 | { |
465 | - if (!$field->validate() || empty($field->getContactId())) { |
|
465 | + if ( ! $field->validate() || empty($field->getContactId())) { |
|
466 | 466 | throw new LPTrackerSDKException('Invalid field'); |
467 | 467 | } |
468 | 468 | |
469 | - $url = '/contact/' . $field->getContactId() . '/field/' . $field->getId(); |
|
469 | + $url = '/contact/'.$field->getContactId().'/field/'.$field->getId(); |
|
470 | 470 | if ($field->getValue() === null) { |
471 | 471 | LPTrackerRequest::sendRequest($url, [], 'DELETE', $this->token, $this->address); |
472 | 472 | $response = $field->toArray(); |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | $viewData['project_id'] = (int) $project; |
495 | 495 | } |
496 | 496 | $view = new View($viewData); |
497 | - if (!$view->validate()) { |
|
497 | + if ( ! $view->validate()) { |
|
498 | 498 | throw new LPTrackerSDKException('Invalid view data'); |
499 | 499 | } |
500 | 500 | |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | throw new LPTrackerSDKException('Invalid view ID'); |
520 | 520 | } |
521 | 521 | |
522 | - $url = '/view/' . $view; |
|
522 | + $url = '/view/'.$view; |
|
523 | 523 | $response = LPTrackerRequest::sendRequest($url, [], 'GET', $this->token, $this->address); |
524 | 524 | return new View($response); |
525 | 525 | } |
@@ -531,12 +531,12 @@ discard block |
||
531 | 531 | */ |
532 | 532 | public function saveView(View $view) |
533 | 533 | { |
534 | - if (!$view->validate()) { |
|
534 | + if ( ! $view->validate()) { |
|
535 | 535 | throw new LPTrackerSDKException('Invalid view'); |
536 | 536 | } |
537 | 537 | |
538 | 538 | if ($view->getId() > 0) { |
539 | - $url = '/view/' . $view->getId(); |
|
539 | + $url = '/view/'.$view->getId(); |
|
540 | 540 | $response = LPTrackerRequest::sendRequest($url, $view->toArray(), 'PUT', $this->token, $this->address); |
541 | 541 | } else { |
542 | 542 | $response = LPTrackerRequest::sendRequest('/view', $view->toArray(), 'POST', $this->token, $this->address); |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | public function createLead($contact, array $leadData = [], array $options = []) |
573 | 573 | { |
574 | 574 | if ($contact instanceof Contact) { |
575 | - if (!empty($contact->getId())) { |
|
575 | + if ( ! empty($contact->getId())) { |
|
576 | 576 | $leadData['contact_id'] = $contact->getId(); |
577 | 577 | } else { |
578 | 578 | $leadData['contact'] = $contact->toArray(); |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | $leadData['contact_id'] = (int) $contact; |
582 | 582 | } |
583 | 583 | $lead = new Lead($leadData); |
584 | - if (!$lead->validate()) { |
|
584 | + if ( ! $lead->validate()) { |
|
585 | 585 | throw new LPTrackerSDKException('Invalid lead data'); |
586 | 586 | } |
587 | 587 | |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | throw new LPTrackerSDKException('Invalid lead ID'); |
608 | 608 | } |
609 | 609 | |
610 | - $url = '/lead/' . $lead; |
|
610 | + $url = '/lead/'.$lead; |
|
611 | 611 | $response = LPTrackerRequest::sendRequest($url, [], 'GET', $this->token, $this->address); |
612 | 612 | return new Lead($response); |
613 | 613 | } |
@@ -636,12 +636,12 @@ discard block |
||
636 | 636 | if ($custom <= 0) { |
637 | 637 | throw new LPTrackerSDKException('Invalid custom ID'); |
638 | 638 | } |
639 | - $file = (int)$file; |
|
639 | + $file = (int) $file; |
|
640 | 640 | if ($file <= 0) { |
641 | 641 | throw new LPTrackerSDKException('Invalid file ID'); |
642 | 642 | } |
643 | 643 | |
644 | - $url = '/lead/' . $lead . '/custom/' . $custom . '/file/' . $file; |
|
644 | + $url = '/lead/'.$lead.'/custom/'.$custom.'/file/'.$file; |
|
645 | 645 | $response = LPTrackerRequest::sendRequest($url, [], 'GET', $this->token, $this->address); |
646 | 646 | return new LeadFile($response); |
647 | 647 | } |
@@ -653,12 +653,12 @@ discard block |
||
653 | 653 | */ |
654 | 654 | public function saveLead(Lead $lead) |
655 | 655 | { |
656 | - if (!$lead->validate()) { |
|
656 | + if ( ! $lead->validate()) { |
|
657 | 657 | throw new LPTrackerSDKException('Invalid lead'); |
658 | 658 | } |
659 | 659 | |
660 | 660 | if ($lead->getId() > 0) { |
661 | - $url = '/lead/' . $lead->getId(); |
|
661 | + $url = '/lead/'.$lead->getId(); |
|
662 | 662 | $response = LPTrackerRequest::sendRequest($url, $lead->toArray(true), 'PUT', $this->token, $this->address); |
663 | 663 | } else { |
664 | 664 | $response = LPTrackerRequest::sendRequest( |
@@ -722,7 +722,7 @@ discard block |
||
722 | 722 | throw new LPTrackerSDKException('Invalid lead ID'); |
723 | 723 | } |
724 | 724 | |
725 | - $url = '/lead/' . $lead . '/payment'; |
|
725 | + $url = '/lead/'.$lead.'/payment'; |
|
726 | 726 | $data = [ |
727 | 727 | 'category' => $category, |
728 | 728 | 'purpose' => $purpose, |
@@ -756,7 +756,7 @@ discard block |
||
756 | 756 | } else { |
757 | 757 | $lead = (int) $lead; |
758 | 758 | } |
759 | - $url = '/lead/' . $lead . '/call'; |
|
759 | + $url = '/lead/'.$lead.'/call'; |
|
760 | 760 | LPTrackerRequest::sendRequest($url, [], 'POST', $this->token, $this->address); |
761 | 761 | } |
762 | 762 | |
@@ -774,7 +774,7 @@ discard block |
||
774 | 774 | } else { |
775 | 775 | $lead = (int) $lead; |
776 | 776 | } |
777 | - $url = '/lead/' . $lead . '/funnel'; |
|
777 | + $url = '/lead/'.$lead.'/funnel'; |
|
778 | 778 | $data = [ |
779 | 779 | 'funnel' => $newStageId, |
780 | 780 | 'options' => $options, |
@@ -809,7 +809,7 @@ discard block |
||
809 | 809 | } else { |
810 | 810 | $lead = (int) $lead; |
811 | 811 | } |
812 | - $url = '/lead/' . $lead . '/owner'; |
|
812 | + $url = '/lead/'.$lead.'/owner'; |
|
813 | 813 | $data = [ |
814 | 814 | 'owner' => $newOwnerId, |
815 | 815 | 'options' => $options, |
@@ -831,7 +831,7 @@ discard block |
||
831 | 831 | } else { |
832 | 832 | $lead = (int) $lead; |
833 | 833 | } |
834 | - $url = '/lead/' . $lead . '/comments'; |
|
834 | + $url = '/lead/'.$lead.'/comments'; |
|
835 | 835 | $response = LPTrackerRequest::sendRequest($url, [], 'GET', $this->token, $this->address); |
836 | 836 | $result = []; |
837 | 837 | foreach ($response as $commentData) { |
@@ -855,7 +855,7 @@ discard block |
||
855 | 855 | } else { |
856 | 856 | $lead = (int) $lead; |
857 | 857 | } |
858 | - $url = '/lead/' . $lead . '/comment'; |
|
858 | + $url = '/lead/'.$lead.'/comment'; |
|
859 | 859 | $data = [ |
860 | 860 | 'text' => $text, |
861 | 861 | 'options' => $options, |
@@ -883,7 +883,7 @@ discard block |
||
883 | 883 | } else { |
884 | 884 | $custom = (int) $custom; |
885 | 885 | } |
886 | - $url = '/lead/' . $lead . '/file'; |
|
886 | + $url = '/lead/'.$lead.'/file'; |
|
887 | 887 | $data = [ |
888 | 888 | 'name' => pathinfo($absolutePath, PATHINFO_BASENAME), |
889 | 889 | 'mime' => mime_content_type($absolutePath), |
@@ -900,11 +900,11 @@ discard block |
||
900 | 900 | */ |
901 | 901 | public function saveLeadCustom(Custom $custom, array $options = []) |
902 | 902 | { |
903 | - if (!$custom->validate() || empty($custom->getLeadId())) { |
|
903 | + if ( ! $custom->validate() || empty($custom->getLeadId())) { |
|
904 | 904 | throw new LPTrackerSDKException('Invalid custom'); |
905 | 905 | } |
906 | 906 | |
907 | - $url = '/lead/' . $custom->getLeadId() . '/custom/' . $custom->getId(); |
|
907 | + $url = '/lead/'.$custom->getLeadId().'/custom/'.$custom->getId(); |
|
908 | 908 | if ($custom->getValue() === null) { |
909 | 909 | $data = [ |
910 | 910 | 'options' => $options, |
@@ -967,7 +967,7 @@ discard block |
||
967 | 967 | } else { |
968 | 968 | $project = (int) $project; |
969 | 969 | } |
970 | - $actionUrl = '/custom/' . $project . '/create'; |
|
970 | + $actionUrl = '/custom/'.$project.'/create'; |
|
971 | 971 | $response = LPTrackerRequest::sendRequest($actionUrl, $options, 'POST', $this->token, $this->address); |
972 | 972 | return new CustomField($response); |
973 | 973 | } |
@@ -990,7 +990,7 @@ discard block |
||
990 | 990 | } else { |
991 | 991 | $project = (int) $project; |
992 | 992 | } |
993 | - $actionUrl = '/lead/' . $project . '/list?' . http_build_query([ |
|
993 | + $actionUrl = '/lead/'.$project.'/list?'.http_build_query([ |
|
994 | 994 | 'offset' => $offset, |
995 | 995 | 'limit' => $limit, |
996 | 996 | 'sort' => $sort, |