| @@ 471-488 (lines=18) @@ | ||
| 468 | * @return View |
|
| 469 | * @throws LPTrackerSDKException |
|
| 470 | */ |
|
| 471 | public function saveView(View $view) |
|
| 472 | { |
|
| 473 | if ( ! $view->validate()) { |
|
| 474 | throw new LPTrackerSDKException('Invalid view'); |
|
| 475 | } |
|
| 476 | ||
| 477 | if ($view->getId() > 0) { |
|
| 478 | $url = '/view/'.$view->getId(); |
|
| 479 | ||
| 480 | $response = LPTrackerRequest::sendRequest($url, $view->toArray(), 'PUT', $this->token, $this->address); |
|
| 481 | } else { |
|
| 482 | $response = LPTrackerRequest::sendRequest('/view', $view->toArray(), 'POST', $this->token, $this->address); |
|
| 483 | } |
|
| 484 | ||
| 485 | $resultView = new View($response); |
|
| 486 | ||
| 487 | return $resultView; |
|
| 488 | } |
|
| 489 | ||
| 490 | ||
| 491 | /** |
|
| @@ 579-596 (lines=18) @@ | ||
| 576 | * @return Lead |
|
| 577 | * @throws LPTrackerSDKException |
|
| 578 | */ |
|
| 579 | public function saveLead(Lead $lead) |
|
| 580 | { |
|
| 581 | if ( ! $lead->validate()) { |
|
| 582 | throw new LPTrackerSDKException('Invalid lead'); |
|
| 583 | } |
|
| 584 | ||
| 585 | if ($lead->getId() > 0) { |
|
| 586 | $url = '/lead/'.$lead->getId(); |
|
| 587 | ||
| 588 | $response = LPTrackerRequest::sendRequest($url, $lead->toArray(), 'PUT', $this->token, $this->address); |
|
| 589 | } else { |
|
| 590 | $response = LPTrackerRequest::sendRequest('/lead', $lead->toArray(), 'POST', $this->token, $this->address); |
|
| 591 | } |
|
| 592 | ||
| 593 | $resultLead = new Lead($response); |
|
| 594 | ||
| 595 | return $resultLead; |
|
| 596 | } |
|
| 597 | ||
| 598 | ||
| 599 | /** |
|