2021-11-27 09:59:50 +00:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2020-2021 Антон Аксенов (Anthony Axenov)
|
|
|
|
*
|
|
|
|
* This code is licensed under MIT.
|
|
|
|
* Этот код распространяется по лицензии MIT.
|
|
|
|
* https://github.com/anthonyaxenov/atol-online/blob/master/LICENSE
|
|
|
|
*/
|
|
|
|
|
|
|
|
declare(strict_types = 1);
|
|
|
|
|
|
|
|
namespace AtolOnline\Entities;
|
|
|
|
|
|
|
|
use AtolOnline\Enums\AgentTypes;
|
|
|
|
use AtolOnline\Exceptions\InvalidEnumValueException;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Класс, описывающий данные агента
|
|
|
|
*
|
|
|
|
* @see https://online.atol.ru/files/API_atol_online_v4.pdf Документация, стр 26-28
|
|
|
|
*/
|
2021-12-03 10:24:21 +00:00
|
|
|
final class AgentInfo extends Entity
|
2021-11-27 09:59:50 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var string|null Признак агента (1057)
|
|
|
|
*/
|
|
|
|
protected ?string $type = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var PayingAgent|null Платёжный агент
|
|
|
|
*/
|
|
|
|
protected ?PayingAgent $paying_agent = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var ReceivePaymentsOperator|null Оператор по приёму платежей
|
|
|
|
*/
|
|
|
|
protected ?ReceivePaymentsOperator $receive_payments_operator = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var MoneyTransferOperator|null Оператор перевода
|
|
|
|
*/
|
|
|
|
protected ?MoneyTransferOperator $money_transfer_operator = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Конструктор
|
|
|
|
*
|
|
|
|
* @param string|null $type Признак агента (1057)
|
2021-12-03 10:23:00 +00:00
|
|
|
* @param PayingAgent|null $pagent Платёжный агент
|
|
|
|
* @param ReceivePaymentsOperator|null $rp_operator Оператор по приёму платежей
|
|
|
|
* @param MoneyTransferOperator|null $mt_operator Оператор перевода
|
2021-11-27 09:59:50 +00:00
|
|
|
* @throws InvalidEnumValueException
|
|
|
|
*/
|
|
|
|
public function __construct(
|
|
|
|
?string $type = null,
|
2021-12-03 10:23:00 +00:00
|
|
|
?PayingAgent $pagent = null,
|
|
|
|
?ReceivePaymentsOperator $rp_operator = null,
|
|
|
|
?MoneyTransferOperator $mt_operator = null,
|
2021-11-27 09:59:50 +00:00
|
|
|
) {
|
2021-11-27 16:44:43 +00:00
|
|
|
!is_null($type) && $this->setType($type);
|
2021-12-03 10:23:00 +00:00
|
|
|
!is_null($pagent) && $this->setPayingAgent($pagent);
|
|
|
|
!is_null($rp_operator) && $this->setReceivePaymentsOperator($rp_operator);
|
|
|
|
!is_null($mt_operator) && $this->setMoneyTransferOperator($mt_operator);
|
2021-11-27 09:59:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Возвращает установленный признак оператора
|
|
|
|
*
|
|
|
|
* @return string|null
|
|
|
|
*/
|
|
|
|
public function getType(): ?string
|
|
|
|
{
|
|
|
|
return $this->type;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Устанавливает признак оператора
|
|
|
|
*
|
|
|
|
* @param string|null $type
|
|
|
|
* @return AgentInfo
|
2021-11-27 16:44:43 +00:00
|
|
|
* @throws InvalidEnumValueException
|
2021-11-27 09:59:50 +00:00
|
|
|
*/
|
2021-12-03 10:23:00 +00:00
|
|
|
public function setType(?string $type): self
|
2021-11-27 09:59:50 +00:00
|
|
|
{
|
2021-11-27 16:44:43 +00:00
|
|
|
AgentTypes::isValid($type) && $this->type = $type;
|
2021-11-27 09:59:50 +00:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Взвращает установленного платёжного агента
|
|
|
|
*
|
|
|
|
* @return PayingAgent|null
|
|
|
|
*/
|
|
|
|
public function getPayingAgent(): ?PayingAgent
|
|
|
|
{
|
|
|
|
return $this->paying_agent;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Устанавливает платёжного агента
|
|
|
|
*
|
2021-12-03 10:23:00 +00:00
|
|
|
* @param PayingAgent|null $agent
|
2021-11-27 09:59:50 +00:00
|
|
|
* @return AgentInfo
|
|
|
|
*/
|
2021-12-03 10:23:00 +00:00
|
|
|
public function setPayingAgent(?PayingAgent $agent): self
|
2021-11-27 09:59:50 +00:00
|
|
|
{
|
2021-12-03 10:23:00 +00:00
|
|
|
$this->paying_agent = $agent;
|
2021-11-27 09:59:50 +00:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Возвращает установленного оператора по приёму платежей
|
|
|
|
*
|
|
|
|
* @return ReceivePaymentsOperator|null
|
|
|
|
*/
|
|
|
|
public function getReceivePaymentsOperator(): ?ReceivePaymentsOperator
|
|
|
|
{
|
|
|
|
return $this->receive_payments_operator;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Устанавливает оператора по приёму платежей
|
|
|
|
*
|
2021-12-03 10:23:00 +00:00
|
|
|
* @param ReceivePaymentsOperator|null $operator
|
2021-11-27 09:59:50 +00:00
|
|
|
* @return AgentInfo
|
|
|
|
*/
|
2021-12-03 10:23:00 +00:00
|
|
|
public function setReceivePaymentsOperator(?ReceivePaymentsOperator $operator): self
|
2021-11-27 09:59:50 +00:00
|
|
|
{
|
2021-12-03 10:23:00 +00:00
|
|
|
$this->receive_payments_operator = $operator;
|
2021-11-27 09:59:50 +00:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Возвращает установленного оператора перевода
|
|
|
|
*
|
|
|
|
* @return MoneyTransferOperator|null
|
|
|
|
*/
|
|
|
|
public function getMoneyTransferOperator(): ?MoneyTransferOperator
|
|
|
|
{
|
|
|
|
return $this->money_transfer_operator;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Устанавливает оператора перевода
|
|
|
|
*
|
2021-12-03 10:23:00 +00:00
|
|
|
* @param MoneyTransferOperator|null $operator
|
2021-11-27 09:59:50 +00:00
|
|
|
* @return AgentInfo
|
|
|
|
*/
|
2021-12-03 10:23:00 +00:00
|
|
|
public function setMoneyTransferOperator(?MoneyTransferOperator $operator): self
|
2021-11-27 09:59:50 +00:00
|
|
|
{
|
2021-12-03 10:23:00 +00:00
|
|
|
$this->money_transfer_operator = $operator;
|
2021-11-27 09:59:50 +00:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
|
|
|
public function jsonSerialize(): array
|
|
|
|
{
|
|
|
|
$json = [];
|
|
|
|
$this->getType() && $json['type'] = $this->getType();
|
|
|
|
$this->getPayingAgent()?->jsonSerialize() && $json['paying_agent'] = $this
|
|
|
|
->getPayingAgent()->jsonSerialize();
|
|
|
|
$this->getReceivePaymentsOperator()?->jsonSerialize() && $json['receive_payments_operator'] = $this
|
|
|
|
->getReceivePaymentsOperator()->jsonSerialize();
|
|
|
|
$this->getMoneyTransferOperator()?->jsonSerialize() && $json['money_transfer_operator'] = $this
|
|
|
|
->getMoneyTransferOperator()->jsonSerialize();
|
|
|
|
return $json;
|
|
|
|
}
|
|
|
|
}
|