| @@ 101-119 (lines=19) @@ | ||
| 98 | * |
|
| 99 | * @return Custom[] |
|
| 100 | */ |
|
| 101 | public function getProjectCustoms($project) |
|
| 102 | { |
|
| 103 | if ($project instanceof Project) { |
|
| 104 | $project = $project->getId(); |
|
| 105 | } else { |
|
| 106 | $project = intval($project); |
|
| 107 | } |
|
| 108 | ||
| 109 | $url = '/project/'.$project.'/customs'; |
|
| 110 | ||
| 111 | $response = LPTrackerRequest::sendRequest($url, [], 'GET', $this->token, $this->address); |
|
| 112 | ||
| 113 | $result = []; |
|
| 114 | foreach ($response as $customData) { |
|
| 115 | $result[] = new Custom($customData); |
|
| 116 | } |
|
| 117 | ||
| 118 | return $result; |
|
| 119 | } |
|
| 120 | ||
| 121 | ||
| 122 | /** |
|
| @@ 127-145 (lines=19) @@ | ||
| 124 | * |
|
| 125 | * @return ContactField[] |
|
| 126 | */ |
|
| 127 | public function getProjectFields($project) |
|
| 128 | { |
|
| 129 | if ($project instanceof Project) { |
|
| 130 | $project = $project->getId(); |
|
| 131 | } else { |
|
| 132 | $project = intval($project); |
|
| 133 | } |
|
| 134 | ||
| 135 | $url = '/project/'.$project.'/fields'; |
|
| 136 | ||
| 137 | $response = LPTrackerRequest::sendRequest($url, [], 'GET', $this->token, $this->address); |
|
| 138 | ||
| 139 | $result = []; |
|
| 140 | foreach ($response as $customData) { |
|
| 141 | $result[] = new ContactField($customData); |
|
| 142 | } |
|
| 143 | ||
| 144 | return $result; |
|
| 145 | } |
|
| 146 | ||
| 147 | ||
| 148 | /** |
|
| @@ 460-478 (lines=19) @@ | ||
| 457 | * |
|
| 458 | * @return Comment[] |
|
| 459 | */ |
|
| 460 | public function getLeadComments($lead) |
|
| 461 | { |
|
| 462 | if ($lead instanceof Lead) { |
|
| 463 | $lead = $lead->getId(); |
|
| 464 | } else { |
|
| 465 | $lead = intval($lead); |
|
| 466 | } |
|
| 467 | ||
| 468 | $url = '/lead/'.$lead.'/comments'; |
|
| 469 | ||
| 470 | $response = LPTrackerRequest::sendRequest($url, [], 'GET', $this->token, $this->address); |
|
| 471 | ||
| 472 | $result = []; |
|
| 473 | foreach ($response as $commentData) { |
|
| 474 | $result[] = new Comment($commentData); |
|
| 475 | } |
|
| 476 | ||
| 477 | return $result; |
|
| 478 | } |
|
| 479 | ||
| 480 | ||
| 481 | /** |
|
| @@ 487-506 (lines=20) @@ | ||
| 484 | * |
|
| 485 | * @return Comment |
|
| 486 | */ |
|
| 487 | public function addCommentToLead($lead, $text) |
|
| 488 | { |
|
| 489 | if ($lead instanceof Lead) { |
|
| 490 | $lead = $lead->getId(); |
|
| 491 | } else { |
|
| 492 | $lead = intval($lead); |
|
| 493 | } |
|
| 494 | ||
| 495 | $url = '/lead/'.$lead.'/comment'; |
|
| 496 | ||
| 497 | $data = [ |
|
| 498 | 'text' => $text |
|
| 499 | ]; |
|
| 500 | ||
| 501 | $response = LPTrackerRequest::sendRequest($url, $data, 'POST', $this->token, $this->address); |
|
| 502 | ||
| 503 | $comment = new Comment($response); |
|
| 504 | ||
| 505 | return $comment; |
|
| 506 | } |
|
| 507 | ||
| 508 | ||
| 509 | /** |
|