@@ 532-545 (lines=14) @@ | ||
529 | * @return View |
|
530 | * @throws LPTrackerSDKException |
|
531 | */ |
|
532 | public function saveView(View $view) |
|
533 | { |
|
534 | if (!$view->validate()) { |
|
535 | throw new LPTrackerSDKException('Invalid view'); |
|
536 | } |
|
537 | ||
538 | if ($view->getId() > 0) { |
|
539 | $url = '/view/' . $view->getId(); |
|
540 | $response = LPTrackerRequest::sendRequest($url, $view->toArray(), 'PUT', $this->token, $this->address); |
|
541 | } else { |
|
542 | $response = LPTrackerRequest::sendRequest('/view', $view->toArray(), 'POST', $this->token, $this->address); |
|
543 | } |
|
544 | return new View($response); |
|
545 | } |
|
546 | ||
547 | /** |
|
548 | * @param View|int $view |
|
@@ 660-679 (lines=20) @@ | ||
657 | * @return Lead |
|
658 | * @throws LPTrackerSDKException |
|
659 | */ |
|
660 | public function saveLead(Lead $lead) |
|
661 | { |
|
662 | if (!$lead->validate()) { |
|
663 | throw new LPTrackerSDKException('Invalid lead'); |
|
664 | } |
|
665 | ||
666 | if ($lead->getId() > 0) { |
|
667 | $url = '/lead/' . $lead->getId(); |
|
668 | $response = LPTrackerRequest::sendRequest($url, $lead->toArray(true), 'PUT', $this->token, $this->address); |
|
669 | } else { |
|
670 | $response = LPTrackerRequest::sendRequest( |
|
671 | '/lead', |
|
672 | $lead->toArray(true), |
|
673 | 'POST', |
|
674 | $this->token, |
|
675 | $this->address |
|
676 | ); |
|
677 | } |
|
678 | return new Lead($response); |
|
679 | } |
|
680 | ||
681 | /** |
|
682 | * @param Lead|int $lead |