@@ 482-499 (lines=18) @@ | ||
479 | * @return View |
|
480 | * @throws LPTrackerSDKException |
|
481 | */ |
|
482 | public function saveView(View $view) |
|
483 | { |
|
484 | if ( ! $view->validate()) { |
|
485 | throw new LPTrackerSDKException('Invalid view'); |
|
486 | } |
|
487 | ||
488 | if ($view->getId() > 0) { |
|
489 | $url = '/view/'.$view->getId(); |
|
490 | ||
491 | $response = LPTrackerRequest::sendRequest($url, $view->toArray(), 'PUT', $this->token, $this->address); |
|
492 | } else { |
|
493 | $response = LPTrackerRequest::sendRequest('/view', $view->toArray(), 'POST', $this->token, $this->address); |
|
494 | } |
|
495 | ||
496 | $resultView = new View($response); |
|
497 | ||
498 | return $resultView; |
|
499 | } |
|
500 | ||
501 | ||
502 | /** |
|
@@ 599-616 (lines=18) @@ | ||
596 | * @return Lead |
|
597 | * @throws LPTrackerSDKException |
|
598 | */ |
|
599 | public function saveLead(Lead $lead) |
|
600 | { |
|
601 | if ( ! $lead->validate()) { |
|
602 | throw new LPTrackerSDKException('Invalid lead'); |
|
603 | } |
|
604 | ||
605 | if ($lead->getId() > 0) { |
|
606 | $url = '/lead/'.$lead->getId(); |
|
607 | ||
608 | $response = LPTrackerRequest::sendRequest($url, $lead->toArray(true), 'PUT', $this->token, $this->address); |
|
609 | } else { |
|
610 | $response = LPTrackerRequest::sendRequest('/lead', $lead->toArray(true), 'POST', $this->token, |
|
611 | $this->address); |
|
612 | } |
|
613 | ||
614 | $resultLead = new Lead($response); |
|
615 | ||
616 | return $resultLead; |
|
617 | } |
|
618 | ||
619 |