Skip to content

Add IM\Counters service for im.counters.get (#433)#461

Merged
mesilov merged 4 commits intov3-devfrom
claude/fix-issue-433-2qxxs
Apr 29, 2026
Merged

Add IM\Counters service for im.counters.get (#433)#461
mesilov merged 4 commits intov3-devfrom
claude/fix-issue-433-2qxxs

Conversation

@mesilov
Copy link
Copy Markdown
Collaborator

@mesilov mesilov commented Apr 29, 2026

Q A
Bug fix? no
New feature? yes
Deprecations? no
Issues Fix #433
License MIT

Description

This PR adds support for the Bitrix24 REST API method im.counters.get, which retrieves unread message and notification counters for the currently authenticated user.

Changes

New Service Structure:

  • IM\Counters\Service\Counters – Service class with get() method
  • IM\Counters\Result\CountersResult – Result wrapper for the API response
  • IM\Counters\Result\CountersItemResult – Item class with typed properties for counter fields (TYPE, MESSAGE, NOTIFY, CHAT, LINES)

Integration:

  • Added counters() method to IMServiceBuilder for service access
  • Updated IMServiceBuilder test to verify service caching

Testing:

  • Unit test for service instantiation
  • Integration tests for API response validation and type casting
  • Custom assertions verify all API response fields are properly annotated and type-cast

Configuration:

  • Added test suite configuration in phpunit.xml.dist
  • Added Makefile target for running IM Counters integration tests
  • Updated CHANGELOG.md

Usage Example

$sdk = new Bitrix24\SDK\Bitrix24(credentials);
$counters = $sdk->getServiceBuilder()->getIMScope()->counters()->get()->counters();

echo $counters->MESSAGE;  // int
echo $counters->NOTIFY;   // int
echo $counters->CHAT;     // int
echo $counters->LINES;    // int
echo $counters->TYPE;     // string

Test Plan

All automated tests pass:

  • Unit tests verify service instantiation
  • Integration tests validate API response structure and field type casting
  • Deptrac compliance verified (no new layer violations)

https://claude.ai/code/session_017PUmAzXXyQAH4YfWJwDzzo

claude and others added 4 commits April 29, 2026 04:59
# Conflicts:
#	CHANGELOG.md
#	Makefile
#	phpunit.xml.dist
#	src/Services/IM/IMServiceBuilder.php
#	tests/Unit/Services/IM/IMServiceBuilderTest.php
…ot fields in REST payloads

- Updated `CountersItemResult` to include live-verified fields from `im.counters.get`.
- Migrated `CountersItemResult` from `AbstractItem` to `AbstractAnnotatedItem` for improved type annotations and runtime casting.
- Enhanced payload generator to handle direct root fields in the `Returned Data` REST docs table.
- Added integration and unit tests for updated field mappings and generator logic.
- Updated `CHANGELOG.md` to reflect the changes.

Signed-off-by: mesilov <mesilov.maxim@gmail.com>
@mesilov mesilov merged commit 7786881 into v3-dev Apr 29, 2026
10 checks passed
@mesilov mesilov added this to the 3.2.0 milestone Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants