@@ 203-221 (lines=19) @@ | ||
200 | * @return Contact |
|
201 | * @throws LPTrackerSDKException |
|
202 | */ |
|
203 | public function saveContact(Contact $contact) |
|
204 | { |
|
205 | if ( ! $contact->validate()) { |
|
206 | throw new LPTrackerSDKException('Invalid contact'); |
|
207 | } |
|
208 | ||
209 | if ($contact->getId() > 0) { |
|
210 | $url = '/contact/'.$contact->getId(); |
|
211 | ||
212 | $response = LPTrackerRequest::sendRequest($url, $contact->toArray(), 'PUT', $this->token, $this->address); |
|
213 | } else { |
|
214 | $response = LPTrackerRequest::sendRequest('/contact', $contact->toArray(), 'POST', $this->token, |
|
215 | $this->address); |
|
216 | } |
|
217 | ||
218 | $resultContact = new Contact($response); |
|
219 | ||
220 | return $resultContact; |
|
221 | } |
|
222 | ||
223 | ||
224 | /** |
|
@@ 332-349 (lines=18) @@ | ||
329 | * @return Lead |
|
330 | * @throws LPTrackerSDKException |
|
331 | */ |
|
332 | public function saveLead(Lead $lead) |
|
333 | { |
|
334 | if ( ! $lead->validate()) { |
|
335 | throw new LPTrackerSDKException('Invalid lead'); |
|
336 | } |
|
337 | ||
338 | if ($lead->getId() > 0) { |
|
339 | $url = '/lead/'.$lead->getId(); |
|
340 | ||
341 | $response = LPTrackerRequest::sendRequest($url, $lead->toArray(), 'PUT', $this->token, $this->address); |
|
342 | } else { |
|
343 | $response = LPTrackerRequest::sendRequest('/lead', $lead->toArray(), 'POST', $this->token, $this->address); |
|
344 | } |
|
345 | ||
346 | $resultLead = new Lead($response); |
|
347 | ||
348 | return $resultLead; |
|
349 | } |
|
350 | ||
351 | ||
352 | /** |