From 6f0f56c6a76729f2eff98d7f6d41bcea23a305fb Mon Sep 17 00:00:00 2001 From: ahuzhamberdiev Date: Fri, 19 Dec 2025 01:53:16 +0500 Subject: [PATCH] init --- src/AmoCRM/Models/LeadModel.php | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/AmoCRM/Models/LeadModel.php b/src/AmoCRM/Models/LeadModel.php index 27cd3c4..303fc7d 100644 --- a/src/AmoCRM/Models/LeadModel.php +++ b/src/AmoCRM/Models/LeadModel.php @@ -5,7 +5,6 @@ use AmoCRM\Models\Interfaces\ComplexTagsManagerInterface; use AmoCRM\Models\Leads\Sources\LeadSourceApi; use AmoCRM\Models\Traits\MutateTagsTrait; -use AmoCRM\EntitiesServices\Unsorted; use AmoCRM\Exceptions\InvalidArgumentException; use AmoCRM\Helpers\EntityTypesInterface; use AmoCRM\Client\AmoCRMApiRequest; @@ -111,7 +110,7 @@ class LeadModel extends BaseApiModel implements protected $closestTaskAt; /** - * @var int + * @var float|null */ protected $price; @@ -257,7 +256,12 @@ public function setName(string $name): self */ public function getPrice(): ?int { - return $this->price; + return isset($this->price) ? (int)$this->price : null; + } + + public function getPriceWithMinorUnits(): ?float + { + return isset($this->price) ? (float)$this->price : .0; } /** @@ -266,6 +270,16 @@ public function getPrice(): ?int * @return self */ public function setPrice(?int $price): self + { + $this->price = (float)$price; + + return $this; + } + + /** + * @noinspection PhpUnused + */ + public function setPriceWithMinorUnits(?float $price): self { $this->price = $price; @@ -745,7 +759,7 @@ public static function fromArray(array $lead): self } if (array_key_exists('price', $lead) && !is_null($lead['price'])) { - $leadModel->setPrice((int)$lead['price']); + $leadModel->setPrice((float)$lead['price']); } if (array_key_exists('responsible_user_id', $lead) && !is_null($lead['responsible_user_id'])) { @@ -861,6 +875,7 @@ public function toArray(): array $result = [ 'name' => $this->getName(), 'price' => $this->getPrice(), + 'price_with_minor_units' => $this->getPriceWithMinorUnits(), 'responsible_user_id' => $this->getResponsibleUserId(), 'group_id' => $this->getGroupId(), 'status_id' => $this->getStatusId(), @@ -936,6 +951,11 @@ public function toApi(?string $requestId = "0"): array $result['price'] = $this->getPrice(); } + $priceWmu = $this->getPriceWithMinorUnits(); + if ($priceWmu !== null) { + $result['price_with_minor_units'] = $priceWmu; + } + if (!is_null($this->getResponsibleUserId())) { $result['responsible_user_id'] = $this->getResponsibleUserId(); }