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