Skip to content

Commit

Permalink
Merge pull request #84 from amocrm/hotfix/issue#81
Browse files Browse the repository at this point in the history
add call fix
  • Loading branch information
bessudnov authored Jul 22, 2020
2 parents 2923e77 + af81544 commit 99c57af
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/AmoCRM/EntitiesServices/Calls.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ protected function processAction(BaseApiCollection $collection, array $response)
*/
protected function processModelAction(BaseApiModel $apiModel, array $entity): void
{
/** @var ContactModel $apiModel */
/** @var CallModel $apiModel */
if (isset($entity['id'])) {
$apiModel->setId($entity['id']);
}
Expand Down
33 changes: 32 additions & 1 deletion src/AmoCRM/Models/CallModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace AmoCRM\Models;

use AmoCRM\Models\Interfaces\HasIdInterface;
use AmoCRM\Models\Traits\CallTrait;
use AmoCRM\Models\Traits\RequestIdTrait;

Expand All @@ -10,11 +11,16 @@
*
* @package AmoCRM\Models
*/
class CallModel extends BaseApiModel
class CallModel extends BaseApiModel implements HasIdInterface
{
use CallTrait;
use RequestIdTrait;

/**
* @var int|null
*/
protected $id;

/**
* @var string|null
*/
Expand Down Expand Up @@ -44,6 +50,10 @@ public function fromArray(array $call): CallModel
{
$model = new static();

if (isset($call['id'])) {
$this->setId($call['id']);
}

if (isset($call['uniq'])) {
$this->setUniq($call['uniq']);
}
Expand Down Expand Up @@ -85,6 +95,7 @@ public function fromArray(array $call): CallModel
public function toArray(): array
{
return [
'id' => $this->getId(),
'uniq' => $this->getUniq(),
'duration' => $this->getDuration(),
'source' => $this->getSource(),
Expand Down Expand Up @@ -122,6 +133,26 @@ public function toApi(?string $requestId = "0"): array
];
}

/**
* @return int|null
*/
public function getId(): ?int
{
return $this->id;
}

/**
* @param int $id
*
* @return CallModel
*/
public function setId(int $id): CallModel
{
$this->id = $id;

return $this;
}

/**
* @return string|null
*/
Expand Down

0 comments on commit 99c57af

Please sign in to comment.