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