| @@ 329-357 (lines=29) @@ | ||
| 326 | * @throws ZohoCRMResponseException |
|
| 327 | * @throws \Exception |
|
| 328 | */ |
|
| 329 | public function getDeletedRecordIds(\DateTimeInterface $lastModifiedTime = null, $limit = null) |
|
| 330 | { |
|
| 331 | $globalDeletedIDs = array(); |
|
| 332 | ||
| 333 | do { |
|
| 334 | try { |
|
| 335 | $fromIndex = count($globalDeletedIDs) + 1; |
|
| 336 | $toIndex = $fromIndex + self::MAX_GET_RECORDS - 1; |
|
| 337 | ||
| 338 | if ($limit) { |
|
| 339 | $toIndex = min($limit - 1, $toIndex); |
|
| 340 | } |
|
| 341 | ||
| 342 | $response = $this->zohoClient->getDeletedRecordIds($this->getModule(), $lastModifiedTime, $fromIndex, $toIndex); |
|
| 343 | $deletedIDs = $response->getDeletedIds(); |
|
| 344 | } catch (ZohoCRMResponseException $e) { |
|
| 345 | // No records found? Let's return an empty array! |
|
| 346 | if ($e->getZohoCode() == 4422) { |
|
| 347 | $deletedIDs = array(); |
|
| 348 | } else { |
|
| 349 | throw $e; |
|
| 350 | } |
|
| 351 | } |
|
| 352 | ||
| 353 | $globalDeletedIDs = array_merge($globalDeletedIDs, $deletedIDs); |
|
| 354 | } while (count($deletedIDs) == self::MAX_GET_RECORDS); |
|
| 355 | ||
| 356 | return $globalDeletedIDs; |
|
| 357 | } |
|
| 358 | ||
| 359 | /** |
|
| 360 | * Implements getRecords API method. |
|
| @@ 370-398 (lines=29) @@ | ||
| 367 | * |
|
| 368 | * @throws ZohoCRMResponseException |
|
| 369 | */ |
|
| 370 | public function getRelatedRecords($id, $parentModule, $limit = null) |
|
| 371 | { |
|
| 372 | $globalResponse = array(); |
|
| 373 | ||
| 374 | do { |
|
| 375 | try { |
|
| 376 | $fromIndex = count($globalResponse) + 1; |
|
| 377 | $toIndex = $fromIndex + self::MAX_GET_RECORDS - 1; |
|
| 378 | ||
| 379 | if ($limit) { |
|
| 380 | $toIndex = min($limit - 1, $toIndex); |
|
| 381 | } |
|
| 382 | ||
| 383 | $response = $this->zohoClient->getRelatedRecords($this->getModule(), $id, $parentModule, $fromIndex, $toIndex); |
|
| 384 | $beans = $this->getBeansFromResponse($response); |
|
| 385 | } catch (ZohoCRMResponseException $e) { |
|
| 386 | // No records found? Let's return an empty array! |
|
| 387 | if ($e->getCode() == 4422) { |
|
| 388 | $beans = array(); |
|
| 389 | } else { |
|
| 390 | throw $e; |
|
| 391 | } |
|
| 392 | } |
|
| 393 | ||
| 394 | $globalResponse = array_merge($globalResponse, $beans); |
|
| 395 | } while (count($beans) == self::MAX_GET_RECORDS); |
|
| 396 | ||
| 397 | return $globalResponse; |
|
| 398 | } |
|
| 399 | ||
| 400 | /** |
|
| 401 | * Implements searchRecords API method. |
|