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