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