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