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