Skip to content
This repository was archived by the owner on Feb 7, 2025. It is now read-only.

Commit cabcede

Browse files
committed
fix method name in ContactsResult
Signed-off-by: mesilov <mesilov.maxim@gmail.com>
1 parent 5a268d7 commit cabcede

File tree

3 files changed

+84
-0
lines changed

3 files changed

+84
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* add php8 version support
66
* change in scope «CRM» Product service and integration tests
77
* add `AddedItemIdResultInterface` for batch-queries result
8+
* add method `countByFilter` for CRM.Contact entity
89
* fix method name in `ContactsResult`
910
* add interface `ApiClientInterface`
1011
* bump phpunit version

src/Services/CRM/Contact/Service/Contact.php

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,4 +373,64 @@ public function update(int $contactId, array $fields, array $params): UpdatedIte
373373
)
374374
);
375375
}
376+
377+
/**
378+
* @param array{
379+
* ID?: int,
380+
* HONORIFIC?: string,
381+
* NAME?: string,
382+
* SECOND_NAME?: string,
383+
* LAST_NAME?: string,
384+
* PHOTO?: string,
385+
* BIRTHDATE?: string,
386+
* TYPE_ID?: string,
387+
* SOURCE_ID?: string,
388+
* SOURCE_DESCRIPTION?: string,
389+
* POST?: string,
390+
* ADDRESS?: string,
391+
* ADDRESS_2?: string,
392+
* ADDRESS_CITY?: string,
393+
* ADDRESS_POSTAL_CODE?: string,
394+
* ADDRESS_REGION?: string,
395+
* ADDRESS_PROVINCE?: string,
396+
* ADDRESS_COUNTRY?: string,
397+
* ADDRESS_COUNTRY_CODE?: string,
398+
* ADDRESS_LOC_ADDR_ID?: int,
399+
* COMMENTS?: string,
400+
* OPENED?: string,
401+
* EXPORT?: string,
402+
* HAS_PHONE?: string,
403+
* HAS_EMAIL?: string,
404+
* HAS_IMOL?: string,
405+
* ASSIGNED_BY_ID?: string,
406+
* CREATED_BY_ID?: string,
407+
* MODIFY_BY_ID?: string,
408+
* DATE_CREATE?: string,
409+
* DATE_MODIFY?: string,
410+
* COMPANY_ID?: string,
411+
* COMPANY_IDS?: string,
412+
* LEAD_ID?: string,
413+
* ORIGINATOR_ID?: string,
414+
* ORIGIN_ID?: string,
415+
* ORIGIN_VERSION?: string,
416+
* FACE_ID?: int,
417+
* UTM_SOURCE?: string,
418+
* UTM_MEDIUM?: string,
419+
* UTM_CAMPAIGN?: string,
420+
* UTM_CONTENT?: string,
421+
* UTM_TERM?: string,
422+
* PHONE?: string,
423+
* EMAIL?: string,
424+
* WEB?: string,
425+
* IM?: string,
426+
* } $filter
427+
*
428+
* @return int
429+
* @throws \Bitrix24\SDK\Core\Exceptions\BaseException
430+
* @throws \Bitrix24\SDK\Core\Exceptions\TransportException
431+
*/
432+
public function countByFilter(array $filter = []): int
433+
{
434+
return $this->list([], $filter, ['ID'], 1)->getCoreResponse()->getResponseData()->getPagination()->getTotal();
435+
}
376436
}

tests/Integration/Services/CRM/Contact/Service/ContactTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,29 @@ public function testBatchAdd(): void
116116
self::assertEquals(count($contacts), $cnt);
117117
}
118118

119+
/**
120+
* @throws \Bitrix24\SDK\Core\Exceptions\TransportException
121+
* @throws \Bitrix24\SDK\Core\Exceptions\BaseException
122+
*/
123+
public function testCountByFilter(): void
124+
{
125+
$totalBefore = $this->contactService->countByFilter();
126+
127+
$newContactsCount = 70;
128+
129+
$contacts = [];
130+
for ($i = 1; $i <= $newContactsCount; $i++) {
131+
$contacts[] = ['NAME' => 'name-' . $i];
132+
}
133+
134+
foreach ($this->contactService->batch->add($contacts) as $item) {
135+
}
136+
137+
$totalAfter = $this->contactService->countByFilter();
138+
139+
$this->assertEquals($totalBefore + $newContactsCount, $totalAfter);
140+
}
141+
119142
public function setUp(): void
120143
{
121144
$this->contactService = Fabric::getServiceBuilder()->getCRMScope()->contact();

0 commit comments

Comments
 (0)