@@ 503-520 (lines=18) @@ | ||
500 | * @return View |
|
501 | * @throws LPTrackerSDKException |
|
502 | */ |
|
503 | public function saveView(View $view) |
|
504 | { |
|
505 | if ( ! $view->validate()) { |
|
506 | throw new LPTrackerSDKException('Invalid view'); |
|
507 | } |
|
508 | ||
509 | if ($view->getId() > 0) { |
|
510 | $url = '/view/'.$view->getId(); |
|
511 | ||
512 | $response = LPTrackerRequest::sendRequest($url, $view->toArray(), 'PUT', $this->token, $this->address); |
|
513 | } else { |
|
514 | $response = LPTrackerRequest::sendRequest('/view', $view->toArray(), 'POST', $this->token, $this->address); |
|
515 | } |
|
516 | ||
517 | $resultView = new View($response); |
|
518 | ||
519 | return $resultView; |
|
520 | } |
|
521 | ||
522 | ||
523 | /** |
|
@@ 620-638 (lines=19) @@ | ||
617 | * @return Lead |
|
618 | * @throws LPTrackerSDKException |
|
619 | */ |
|
620 | public function saveLead(Lead $lead) |
|
621 | { |
|
622 | if ( ! $lead->validate()) { |
|
623 | throw new LPTrackerSDKException('Invalid lead'); |
|
624 | } |
|
625 | ||
626 | if ($lead->getId() > 0) { |
|
627 | $url = '/lead/'.$lead->getId(); |
|
628 | ||
629 | $response = LPTrackerRequest::sendRequest($url, $lead->toArray(true), 'PUT', $this->token, $this->address); |
|
630 | } else { |
|
631 | $response = LPTrackerRequest::sendRequest('/lead', $lead->toArray(true), 'POST', $this->token, |
|
632 | $this->address); |
|
633 | } |
|
634 | ||
635 | $resultLead = new Lead($response); |
|
636 | ||
637 | return $resultLead; |
|
638 | } |
|
639 | ||
640 | ||
641 | /** |