Add IM\Recent service for im.recent.* API support#466
Conversation
Implements im.recent.get, im.recent.list, im.recent.pin, im.recent.unread, and im.recent.hide via Bitrix24\SDK\Services\IM\Recent\Service\Recent. Adds RecentItemResult, RecentsResult, IMServiceBuilder::recent(), unit/integration/annotation tests, phpunit suite, and Makefile target. https://claude.ai/code/session_01JU6axyfnTk62HoezmhWfWL
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cf668f5741
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return array_values(array_map( | ||
| static fn(array $item): RecentItemResult => new RecentItemResult($item), | ||
| array_filter($this->getCoreResponse()->getResponseData()->getResult(), 'is_array') |
There was a problem hiding this comment.
Parse
im.recent.list items from nested result.items
RecentsResult::items() currently maps every top-level array inside result, but im.recent.list returns an object where dialogs are nested under result["items"] (alongside other array/object fields like copilot). In that shape, this code builds RecentItemResult objects from non-dialog payloads, so consumers of recent()->list()->items() get malformed entries (e.g., missing id, chat_id) instead of actual recent dialogs.
Useful? React with 👍 / 👎.
| $payload = [ | ||
| 'LAST_ID' => $lastId, | ||
| 'LIMIT' => $limit, |
There was a problem hiding this comment.
Use supported pagination parameter for
im.recent.list
The list() wrapper sends LAST_ID, but im.recent.list pagination is driven by OFFSET (with LIMIT). As implemented, callers cannot advance through pages via this method signature, because the provided cursor argument is not mapped to the API’s pagination contract, which can lead to repeatedly fetching the first page.
Useful? React with 👍 / 👎.
…onsTest` and update type annotations - Renamed and reorganized integration tests for `RecentItemResult` into `RecentItemResultAnnotationsTest`. - Updated `RecentItemResult` with new fields (`last_id`, `has_reminder`, `date_update`, etc.) and improved type annotations. - Enhanced type safety with consistent property definitions and runtime casting. Signed-off-by: mesilov <mesilov.maxim@gmail.com>
…ecent.get` payload fields - Adjusted PHPDoc comments in `RecentItemResult` to match live REST API data structure and magic getter behavior. - Updated `CHANGELOG.md` with details of the fix. Signed-off-by: mesilov <mesilov.maxim@gmail.com>
Description
This PR implements the
IM\Recentservice to wrap Bitrix24 REST API methods for managing recent chats and dialogs.Changes
New Service & Result Classes:
Recentservice with 5 methods:get(?int $lastId, ?int $limit): RecentsResult– Returns a shortened list of recent chatslist(?int $lastId, ?int $limit): RecentsResult– Returns the full recent dialogs list with paginationpin(string $dialogId, bool $pin): UpdatedItemResult– Pins or unpins a dialogunread(string $dialogId, string $action): UpdatedItemResult– Sets or removes the "unread" markhide(string $dialogId): UpdatedItemResult– Removes a chat from the recent listRecentItemResult– Annotated result item with properties:id,type,avatar,color,title,counter,unread,pinned,user_id,chat_id,message,date_messageRecentsResult– Container result for list responsesIntegration:
IMServiceBuilder::recent()accessor methodphpunit.xml.distwithintegration_tests_im_recenttestsuiteMakefilewithtest-integration-im-recenttargetCHANGELOG.mdTests:
RecentTestverifies service instantiationCompliance
Core(no cross-scope dependencies)Dialog,Counters)Test Plan
Run the integration test suite:
All existing unit and integration tests continue to pass.
https://claude.ai/code/session_01JU6axyfnTk62HoezmhWfWL