Skip to content

Commit

Permalink
Merge pull request #11 from amocrm/hotfix/issue#9
Browse files Browse the repository at this point in the history
no carbon for timestamps for now
  • Loading branch information
bessudnov authored Jun 6, 2020
2 parents 8344fe7 + d2454c2 commit 77c00aa
Showing 1 changed file with 65 additions and 52 deletions.
117 changes: 65 additions & 52 deletions src/AmoCRM/Models/AccountModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,54 @@
use AmoCRM\Collections\UsersGroupsCollection;
use AmoCRM\Models\AccountSettings\AmojoRights;
use AmoCRM\Models\AccountSettings\DateTimeSettings;
use Carbon\Carbon;

class AccountModel extends BaseApiModel
{
/** @var string ID аккаунта в сервисе чатов */
public const AMOJO_ID = 'amojo_id';
/** @var string UUID аккаунта */
public const UUID = 'uuid';
/** @var string Права на встроенные чаты */
public const AMOJO_RIGHTS = 'amojo_rights';
/** @var string Группы пользователей */
public const USER_GROUPS = 'users_groups';
/** @var string Типы задач */
public const TASK_TYPES = 'task_types';
/** @var string Версия аккаунта */
public const VERSION = 'version';
/** @var string Настройки форматов времени */
public const DATETIME_SETTINGS = 'datetime_settings';

/** @var string Покупатели недоступны. */
public const CUSTOMERS_MODE_UNAVAILABLE = 'unavailable';
/** @var string Покупатели выключены. */
public const CUSTOMERS_MODE_DISABLED = 'disabled';

/**
* Режим периодических покупок (когда статус покупателя зависит от кол-ва дней до следующего платежа)
* и покупатель оказывается в определенном статусе при совершении покупки
*
* @var string
*/
public const CUSTOMERS_MODE_PERIODICITY = 'periodicity';

/**
* Статус, в котором находится покупатель, не зависит от даты следующей покупки
*
* @var string
* @deprecated
*/
public const CUSTOMERS_MODE_DYNAMIC = 'dynamic';

/**
* Покупатели не имеют статусов, но разделены по сегментам по принципу:
* каждый покупатель может входить в состав множества сегментов
* каждый сегмент может иметь множество покупателей
*
* @var string
*/
public const SEGMENTS = 'segments';

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

Expand Down Expand Up @@ -64,11 +100,8 @@ class AccountModel extends BaseApiModel
/** @var int */
protected $mobileFeatureVersion;

/** @var bool */
protected $customersEnabled;

/** @var bool */
protected $periodicityEnabled;
/** @var string */
protected $customersMode;

/** @var bool */
protected $lossReasonsEnabled;
Expand Down Expand Up @@ -178,11 +211,11 @@ public function getCreatedAt(): int
}

/**
* @param Carbon $timestamp
* @param int $timestamp
*
* @return self
*/
public function setCreatedAt(Carbon $timestamp): self
public function setCreatedAt(int $timestamp): self
{
$this->createdAt = $timestamp;

Expand All @@ -198,11 +231,11 @@ public function getUpdatedAt(): int
}

/**
* @param Carbon $timestamp
* @param int $timestamp
*
* @return self
*/
public function setUpdatedAt(Carbon $timestamp): self
public function setUpdatedAt(int $timestamp): self
{
$this->updatedAt = $timestamp;

Expand Down Expand Up @@ -284,8 +317,7 @@ public static function fromArray(array $account): self
->setCountry((string)$account['country'])
->setUnsortedOn((bool)$account['is_unsorted_on'])
->setMobileFeatureVersion((int)$account['mobile_feature_version'])
->setCustomersEnabled((bool)$account['is_customers_enabled'])
->setPeriodicityEnabled((bool)$account['is_periodicity_enabled'])
->setCustomersMode($account['customers_mode'])
->setLossReasonsEnabled((bool)$account['is_loss_reason_enabled'])
->setHelpbotEnabled((bool)$account['is_helpbot_enabled'])
->setContactNameDisplayOrder((int)$account['contact_name_display_order']);
Expand Down Expand Up @@ -357,8 +389,7 @@ public function toArray(): array
'country' => $this->getCountry(),
'is_unsorted_on' => $this->getIsUnsortedOn(),
'mobile_feature_version' => $this->getMobileFeatureVersion(),
'is_customers_enabled' => $this->getIsCustomersEnabled(),
'is_periodicity_enabled' => $this->getIsPeriodicityEnabled(),
'customers_mode' => $this->getCustomersMode(),
'is_loss_reason_enabled' => $this->getIsLossReasonsEnabled(),
'is_helpbot_enabled' => $this->getIsHelpbotEnabled(),
'contact_name_display_order' => $this->getContactNameDisplayOrder(),
Expand Down Expand Up @@ -395,6 +426,26 @@ public function toArray(): array
return $result;
}

/**
* @return string
*/
public function getCustomersMode(): string
{
return $this->customersMode;
}

/**
* @param string $customersMode
*
* @return AccountModel
*/
public function setCustomersMode(string $customersMode): AccountModel
{
$this->customersMode = $customersMode;

return $this;
}

/**
* @return AmojoRights|null
*/
Expand Down Expand Up @@ -509,44 +560,6 @@ public function setMobileFeatureVersion(int $mobileFeatureVersion): self
return $this;
}

/**
* @return bool
*/
public function getIsCustomersEnabled(): bool
{
return $this->customersEnabled;
}

/**
* @param bool $customersEnabled
* @return AccountModel
*/
public function setCustomersEnabled(bool $customersEnabled): self
{
$this->customersEnabled = $customersEnabled;

return $this;
}

/**
* @return bool
*/
public function getIsPeriodicityEnabled(): bool
{
return $this->periodicityEnabled;
}

/**
* @param bool $periodicityEnabled
* @return AccountModel
*/
public function setPeriodicityEnabled(bool $periodicityEnabled): self
{
$this->periodicityEnabled = $periodicityEnabled;

return $this;
}

/**
* @return bool
*/
Expand Down

0 comments on commit 77c00aa

Please sign in to comment.