@@ 429-442 (lines=14) @@ | ||
426 | * @return View |
|
427 | * @throws LPTrackerSDKException |
|
428 | */ |
|
429 | public function saveView(View $view) |
|
430 | { |
|
431 | if (!$view->validate()) { |
|
432 | throw new LPTrackerSDKException('Invalid view'); |
|
433 | } |
|
434 | ||
435 | if ($view->getId() > 0) { |
|
436 | $url = '/view/' . $view->getId(); |
|
437 | $response = LPTrackerRequest::sendRequest($url, $view->toArray(), 'PUT', $this->token, $this->address); |
|
438 | } else { |
|
439 | $response = LPTrackerRequest::sendRequest('/view', $view->toArray(), 'POST', $this->token, $this->address); |
|
440 | } |
|
441 | return new View($response); |
|
442 | } |
|
443 | ||
444 | /** |
|
445 | * @param View|int $view |
|
@@ 559-578 (lines=20) @@ | ||
556 | * @return Lead |
|
557 | * @throws LPTrackerSDKException |
|
558 | */ |
|
559 | public function saveLead(Lead $lead) |
|
560 | { |
|
561 | if (!$lead->validate()) { |
|
562 | throw new LPTrackerSDKException('Invalid lead'); |
|
563 | } |
|
564 | ||
565 | if ($lead->getId() > 0) { |
|
566 | $url = '/lead/' . $lead->getId(); |
|
567 | $response = LPTrackerRequest::sendRequest($url, $lead->toArray(true), 'PUT', $this->token, $this->address); |
|
568 | } else { |
|
569 | $response = LPTrackerRequest::sendRequest( |
|
570 | '/lead', |
|
571 | $lead->toArray(true), |
|
572 | 'POST', |
|
573 | $this->token, |
|
574 | $this->address |
|
575 | ); |
|
576 | } |
|
577 | return new Lead($response); |
|
578 | } |
|
579 | ||
580 | /** |
|
581 | * @param Lead|int $lead |