@@ 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 |
|
@@ 525-544 (lines=20) @@ | ||
522 | * @return Lead |
|
523 | * @throws LPTrackerSDKException |
|
524 | */ |
|
525 | public function saveLead(Lead $lead) |
|
526 | { |
|
527 | if (!$lead->validate()) { |
|
528 | throw new LPTrackerSDKException('Invalid lead'); |
|
529 | } |
|
530 | ||
531 | if ($lead->getId() > 0) { |
|
532 | $url = '/lead/' . $lead->getId(); |
|
533 | $response = LPTrackerRequest::sendRequest($url, $lead->toArray(true), 'PUT', $this->token, $this->address); |
|
534 | } else { |
|
535 | $response = LPTrackerRequest::sendRequest( |
|
536 | '/lead', |
|
537 | $lead->toArray(true), |
|
538 | 'POST', |
|
539 | $this->token, |
|
540 | $this->address |
|
541 | ); |
|
542 | } |
|
543 | return new Lead($response); |
|
544 | } |
|
545 | ||
546 | /** |
|
547 | * @param Lead|int $lead |