Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add lead support #284

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# bitrix24-php-sdk change log

## 2.0-alpha.6 — 7.02.2021
## 2.0-alpha.7 — 7.05.2022

### Added
* add `Leads` [добавить поддержку лидов](https://github.com/mesilov/bitrix24-php-sdk/issues/282)

## 2.0-alpha.6 — 7.02.2022

### Added

Expand Down
16 changes: 16 additions & 0 deletions src/Services/CRM/CRMServiceBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,20 @@ public function userfield(): Userfield\Service\Userfield

return $this->serviceCache[__METHOD__];
}

/**
* @return Lead\Service\Lead
*/
public function lead(): Lead\Service\Lead
{
if (!isset($this->serviceCache[__METHOD__])) {
$this->serviceCache[__METHOD__] = new Lead\Service\Lead(
new Lead\Service\Batch($this->batch, $this->log),
$this->core,
$this->log
);
}

return $this->serviceCache[__METHOD__];
}
}
81 changes: 81 additions & 0 deletions src/Services/CRM/Lead/Result/LeadItemResult.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php

declare(strict_types=1);

namespace Bitrix24\SDK\Services\CRM\Lead\Result;

use Bitrix24\SDK\Services\CRM\Common\Result\AbstractCrmItem;
use DateTimeInterface;

/**
* Class LeadItemResult
*
* @property-read int $ID
* @property-read string $TITLE
* @property-read string $HONORIFIC
* @property-read string $NAME
* @property-read string $SECOND_NAME
* @property-read string $LAST_NAME
* @property-read DateTimeInterface|null $BIRTHDATE
* @property-read string $COMPANY_TITLE
* @property-read string $SOURCE_ID
* @property-read string $SOURCE_DESCRIPTION
* @property-read string $STATUS_ID
* @property-read string $STATUS_DESCRIPTION
* @property-read string $STATUS_SEMANTIC_ID
* @property-read string $POST
* @property-read string $ADDRESS
* @property-read string $ADDRESS_2
* @property-read string $ADDRESS_CITY
* @property-read string $ADDRESS_POSTAL_CODE
* @property-read string $ADDRESS_REGION
* @property-read string $ADDRESS_PROVINCE
* @property-read string $ADDRESS_COUNTRY
* @property-read string $ADDRESS_COUNTRY_CODE
* @property-read int $ADDRESS_LOC_ADDR_ID
* @property-read string $CURRENCY_ID
* @property-read string $OPPORTUNITY
* @property-read string $IS_MANUAL_OPPORTUNITY
* @property-read string $OPENED
* @property-read string $COMMENTS
* @property-read string $HAS_PHONE
* @property-read string $HAS_EMAIL
* @property-read string $HAS_IMOL
* @property-read string $ASSIGNED_BY_ID
* @property-read string $CREATED_BY_ID
* @property-read string $MODIFY_BY_ID
* @property-read string $MOVED_BY_ID
* @property-read string $DATE_CREATE
* @property-read string $DATE_MODIFY
* @property-read string $MOVED_TIME
* @property-read string $COMPANY_ID
* @property-read string $CONTACT_ID
* @property-read string $CONTACT_IDS
* @property-read string $IS_RETURN_CUSTOMER
* @property-read string $DATE_CLOSED
* @property-read string $ORIGINATOR_ID
* @property-read string $ORIGIN_ID
* @property-read string $UTM_SOURCE
* @property-read string $UTM_MEDIUM
* @property-read string $UTM_CAMPAIGN
* @property-read string $UTM_CONTENT
* @property-read string $UTM_TERM
* @property-read string $PHONE
* @property-read string $EMAIL
* @property-read string $WEB
* @property-read string $IM
* @property-read string $LINK
*/
class LeadItemResult extends AbstractCrmItem
{
/**
* @param string $userfieldName
*
* @return mixed|null
* @throws \Bitrix24\SDK\Services\CRM\Userfield\Exceptions\UserfieldNotFoundException
*/
public function getUserfieldByFieldName(string $userfieldName)
{
return $this->getKeyWithUserfieldByFieldName($userfieldName);
}
}
24 changes: 24 additions & 0 deletions src/Services/CRM/Lead/Result/LeadResult.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php


declare(strict_types=1);

namespace Bitrix24\SDK\Services\CRM\Lead\Result;

use Bitrix24\SDK\Core\Result\AbstractResult;

/**
* Class LeadResult
*
* @package Bitrix24\SDK\Services\CRM\Lead\Result
*/
class LeadResult extends AbstractResult
{
/**
* @throws \Bitrix24\SDK\Core\Exceptions\BaseException
*/
public function lead(): LeadItemResult
{
return new LeadItemResult($this->getCoreResponse()->getResponseData()->getResult()->getResultData());
}
}
31 changes: 31 additions & 0 deletions src/Services/CRM/Lead/Result/LeadsResult.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php


declare(strict_types=1);

namespace Bitrix24\SDK\Services\CRM\Lead\Result;

use Bitrix24\SDK\Core\Exceptions\BaseException;
use Bitrix24\SDK\Core\Result\AbstractResult;

/**
* Class LeadsResult
*
* @package Bitrix24\SDK\Services\CRM\Lead\Result
*/
class LeadsResult extends AbstractResult
{
/**
* @return LeadItemResult[]
* @throws BaseException
*/
public function getLeads(): array
{
$items = [];
foreach ($this->getCoreResponse()->getResponseData()->getResult()->getResultData() as $item) {
$items[] = new LeadItemResult($item);
}

return $items;
}
}
Loading