| @@ 485-498 (lines=14) @@ | ||
| 482 | * @return View |
|
| 483 | * @throws LPTrackerSDKException |
|
| 484 | */ |
|
| 485 | public function saveView(View $view) |
|
| 486 | { |
|
| 487 | if (!$view->validate()) { |
|
| 488 | throw new LPTrackerSDKException('Invalid view'); |
|
| 489 | } |
|
| 490 | ||
| 491 | if ($view->getId() > 0) { |
|
| 492 | $url = '/view/' . $view->getId(); |
|
| 493 | $response = LPTrackerRequest::sendRequest($url, $view->toArray(), 'PUT', $this->token, $this->address); |
|
| 494 | } else { |
|
| 495 | $response = LPTrackerRequest::sendRequest('/view', $view->toArray(), 'POST', $this->token, $this->address); |
|
| 496 | } |
|
| 497 | return new View($response); |
|
| 498 | } |
|
| 499 | ||
| 500 | /** |
|
| 501 | * @param View|int $view |
|
| @@ 615-634 (lines=20) @@ | ||
| 612 | * @return Lead |
|
| 613 | * @throws LPTrackerSDKException |
|
| 614 | */ |
|
| 615 | public function saveLead(Lead $lead) |
|
| 616 | { |
|
| 617 | if (!$lead->validate()) { |
|
| 618 | throw new LPTrackerSDKException('Invalid lead'); |
|
| 619 | } |
|
| 620 | ||
| 621 | if ($lead->getId() > 0) { |
|
| 622 | $url = '/lead/' . $lead->getId(); |
|
| 623 | $response = LPTrackerRequest::sendRequest($url, $lead->toArray(true), 'PUT', $this->token, $this->address); |
|
| 624 | } else { |
|
| 625 | $response = LPTrackerRequest::sendRequest( |
|
| 626 | '/lead', |
|
| 627 | $lead->toArray(true), |
|
| 628 | 'POST', |
|
| 629 | $this->token, |
|
| 630 | $this->address |
|
| 631 | ); |
|
| 632 | } |
|
| 633 | return new Lead($response); |
|
| 634 | } |
|
| 635 | ||
| 636 | /** |
|
| 637 | * @param Lead|int $lead |
|