diff --git a/src/Bot/Model/Entity/Cost.php b/src/Bot/Model/Entity/Cost.php deleted file mode 100644 index ca6b33b..0000000 --- a/src/Bot/Model/Entity/Cost.php +++ /dev/null @@ -1,81 +0,0 @@ - - * @license https://opensource.org/licenses/MIT MIT License - * @link http://help.retailcrm.pro/docs/Developers - */ - -namespace RetailCrm\Mg\Bot\Model\Entity; - -use JMS\Serializer\Annotation\Accessor; -use JMS\Serializer\Annotation\SkipWhenEmpty; -use JMS\Serializer\Annotation\Type; -use RetailCrm\Mg\Bot\Model\ModelInterface; - -/** - * Cost class - * - * @package RetailCrm\Mg\Bot\Model\Entity - * @author retailCRM - * @license https://opensource.org/licenses/MIT MIT License - * @link http://help.retailcrm.pro/docs/Developers - */ -class Cost implements ModelInterface -{ - /** - * @var float $value - * - * @Type("float") - * @Accessor(getter="getValue",setter="setValue") - * @SkipWhenEmpty() - */ - private $value; - - /** - * @var string $currency - * - * @Type("string") - * @Accessor(getter="getCurrency",setter="setCurrency") - * - * @Assert\Currency - */ - private $currency; - - /** - * @return float - */ - public function getValue() - { - return $this->value; - } - - /** - * @param float $value - */ - public function setValue(float $value) - { - $this->value = $value; - } - - /** - * @return string - */ - public function getCurrency() - { - return $this->currency; - } - - /** - * @param string $currency - */ - public function setCurrency(string $currency) - { - $this->currency = $currency; - } -} diff --git a/src/Bot/Model/Entity/Delivery.php b/src/Bot/Model/Entity/Delivery.php deleted file mode 100644 index 75474d3..0000000 --- a/src/Bot/Model/Entity/Delivery.php +++ /dev/null @@ -1,132 +0,0 @@ - - * @license https://opensource.org/licenses/MIT MIT License - * @link http://help.retailcrm.pro/docs/Developers - */ - -namespace RetailCrm\Mg\Bot\Model\Entity; - -use JMS\Serializer\Annotation\Accessor; -use JMS\Serializer\Annotation\SkipWhenEmpty; -use JMS\Serializer\Annotation\Type; -use RetailCrm\Mg\Bot\Model\ModelInterface; - -/** - * Delivery class - * - * @package RetailCrm\Mg\Bot\Model\Entity - * @author retailCRM - * @license https://opensource.org/licenses/MIT MIT License - * @link http://help.retailcrm.pro/docs/Developers - */ -class Delivery implements ModelInterface -{ - /** - * @var string $name - * - * @Type("string") - * @Accessor(getter="getName",setter="setName") - * - * @Assert\NotBlank - */ - private $name; - - /** - * @var Cost $price - * - * @Type("Cost") - * @Accessor(getter="getPrice",setter="setPrice") - * - * @Assert\Currency - */ - private $price; - - /** - * @var string $address - * - * @Type("string") - * @Accessor(getter="getAddress",setter="setAddress") - * @SkipWhenEmpty() - */ - private $address; - - /** - * @var string $comment - * - * @Type("string") - * @Accessor(getter="getComment",setter="setComment") - * @SkipWhenEmpty() - */ - private $comment; - - /** - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * @param string $name - */ - public function setName(string $name) - { - $this->name = $name; - } - - /** - * @return Cost - */ - public function getPrice() - { - return $this->price; - } - - /** - * @param Cost $price - */ - public function setPrice(Cost $price) - { - $this->price = $price; - } - - /** - * @return string - */ - public function getAddress() - { - return $this->address; - } - - /** - * @param string $address - */ - public function setAddress(string $address) - { - $this->address = $address; - } - - /** - * @return string - */ - public function getComment() - { - return $this->comment; - } - - /** - * @param string $comment - */ - public function setComment(string $comment) - { - $this->comment = $comment; - } -} diff --git a/src/Bot/Model/Entity/Item.php b/src/Bot/Model/Entity/Item.php deleted file mode 100644 index 80a17ad..0000000 --- a/src/Bot/Model/Entity/Item.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @license https://opensource.org/licenses/MIT MIT License - * @link http://help.retailcrm.pro/docs/Developers - */ - -namespace RetailCrm\Mg\Bot\Model\Entity; - -use JMS\Serializer\Annotation\Accessor; -use JMS\Serializer\Annotation\SkipWhenEmpty; -use JMS\Serializer\Annotation\Type; -use RetailCrm\Mg\Bot\Model\ModelInterface; - -/** - * Item class - * - * @package RetailCrm\Mg\Bot\Model\Entity - * @author retailCRM - * @license https://opensource.org/licenses/MIT MIT License - * @link http://help.retailcrm.pro/docs/Developers - */ -class Item implements ModelInterface -{ - /** - * @var string $id - * - * @Type("string") - * @Accessor(getter="getId",setter="setId") - * @SkipWhenEmpty() - */ - private $id; - - /** - * @var string $caption - * - * @Type("string") - * @Accessor(getter="getCaption",setter="setCaption") - * @SkipWhenEmpty() - */ - private $caption; - - /** - * @return string - */ - public function getId() - { - return $this->id; - } - - /** - * @param string $id - */ - public function setId(string $id) - { - $this->id = $id; - } - - /** - * @return string - */ - public function getCaption() - { - return $this->caption; - } - - /** - * @param string $caption - */ - public function setCaption(string $caption) - { - $this->caption = $caption; - } -} diff --git a/src/Bot/Model/Entity/Message/Message.php b/src/Bot/Model/Entity/Message/Message.php index 5fe9c01..0f56c52 100644 --- a/src/Bot/Model/Entity/Message/Message.php +++ b/src/Bot/Model/Entity/Message/Message.php @@ -166,7 +166,7 @@ class Message implements ModelInterface /** * @var Dialog $dialog * - * @Type("Dialog") + * @Type("RetailCrm\Mg\Bot\Model\Entity\Dialog") * @Accessor(getter="getDialog",setter="setDialog") * @SkipWhenEmpty() */ @@ -193,7 +193,7 @@ class Message implements ModelInterface /** * @var MessageOrder $order * - * @Type("MessageOrder") + * @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageOrder") * @Accessor(getter="getOrder",setter="setOrder") * @SkipWhenEmpty() */ @@ -202,7 +202,7 @@ class Message implements ModelInterface /** * @var MessageProduct $product * - * @Type("MessageProduct") + * @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageProduct") * @Accessor(getter="getProduct",setter="setProduct") * @SkipWhenEmpty() */ diff --git a/src/Bot/Model/Entity/Message/MessageCost.php b/src/Bot/Model/Entity/Message/MessageCost.php index 4b08406..30e8bce 100644 --- a/src/Bot/Model/Entity/Message/MessageCost.php +++ b/src/Bot/Model/Entity/Message/MessageCost.php @@ -13,6 +13,7 @@ namespace RetailCrm\Mg\Bot\Model\Entity\Message; +use Symfony\Component\Validator\Constraints as Assert; use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\Type; diff --git a/src/Bot/Model/Entity/Message/MessageDelivery.php b/src/Bot/Model/Entity/Message/MessageDelivery.php index 89dad67..15526fb 100644 --- a/src/Bot/Model/Entity/Message/MessageDelivery.php +++ b/src/Bot/Model/Entity/Message/MessageDelivery.php @@ -13,6 +13,7 @@ namespace RetailCrm\Mg\Bot\Model\Entity\Message; +use Symfony\Component\Validator\Constraints as Assert; use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\Type; @@ -41,7 +42,7 @@ class MessageDelivery implements ModelInterface /** * @var MessageCost $price * - * @Type("Cost") + * @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageCost") * @Accessor(getter="getPrice",setter="setPrice") * * @Assert\Currency diff --git a/src/Bot/Model/Entity/Message/MessageOrder.php b/src/Bot/Model/Entity/Message/MessageOrder.php index eb5adc6..52eb7dd 100644 --- a/src/Bot/Model/Entity/Message/MessageOrder.php +++ b/src/Bot/Model/Entity/Message/MessageOrder.php @@ -58,7 +58,7 @@ class MessageOrder implements ModelInterface /** * @var MessageCost $cost * - * @Type("MessageCost") + * @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageCost") * @Accessor(getter="getCost",setter="setCost") * @SkipWhenEmpty() */ @@ -67,7 +67,7 @@ class MessageOrder implements ModelInterface /** * @var MessageStatus $status * - * @Type("MessageStatus") + * @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageStatus") * @Accessor(getter="getStatus",setter="setStatus") * @SkipWhenEmpty() */ @@ -76,7 +76,7 @@ class MessageOrder implements ModelInterface /** * @var MessageDelivery $delivery * - * @Type("MessageDelivery") + * @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageDelivery") * @Accessor(getter="getDelivery",setter="setDelivery") * @SkipWhenEmpty() */ diff --git a/src/Bot/Model/Entity/Message/MessageOrderItem.php b/src/Bot/Model/Entity/Message/MessageOrderItem.php index 5027f83..487232b 100644 --- a/src/Bot/Model/Entity/Message/MessageOrderItem.php +++ b/src/Bot/Model/Entity/Message/MessageOrderItem.php @@ -58,7 +58,7 @@ class MessageOrderItem implements ModelInterface /** * @var MessageCost * - * @Type("MessageCost") + * @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageCost") * @Accessor(getter="getPrice",setter="setPrice") * @SkipWhenEmpty() */ @@ -67,8 +67,8 @@ class MessageOrderItem implements ModelInterface /** * @var MessageQuantity * - * @Type("MessageQuantity") - * @Accessor(getter="getQuantity",setter="setQuantity) + * @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageQuantity") + * @Accessor(getter="getQuantity",setter="setQuantity") * @SkipWhenEmpty() */ private $quantity; diff --git a/src/Bot/Model/Entity/Message/MessagePayment.php b/src/Bot/Model/Entity/Message/MessagePayment.php index a01c895..0ef48c6 100644 --- a/src/Bot/Model/Entity/Message/MessagePayment.php +++ b/src/Bot/Model/Entity/Message/MessagePayment.php @@ -40,7 +40,7 @@ class MessagePayment implements ModelInterface /** * @var MessageOrderPaymentStatus $status * - * @Type("MessageOrderPaymentStatus") + * @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageOrderPaymentStatus") * @Accessor(getter="getStatus",setter="setStatus") * @SkipWhenEmpty() */ @@ -49,7 +49,7 @@ class MessagePayment implements ModelInterface /** * @var MessageCost $amount * - * @Type("MessageCost") + * @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageCost") * @Accessor(getter="getAmount",setter="setAmount") * @SkipWhenEmpty() */ diff --git a/src/Bot/Model/Entity/Message/MessageProduct.php b/src/Bot/Model/Entity/Message/MessageProduct.php index 166123e..a4d0674 100644 --- a/src/Bot/Model/Entity/Message/MessageProduct.php +++ b/src/Bot/Model/Entity/Message/MessageProduct.php @@ -76,7 +76,7 @@ class MessageProduct implements ModelInterface /** * @var MessageCost $cost * - * @Type("Cost") + * @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageCost") * @Accessor(getter="getCost",setter="setCost") * @SkipWhenEmpty() */ @@ -85,8 +85,8 @@ class MessageProduct implements ModelInterface /** * @var MessageQuantity $quantity * - * @Type("MessageQuantity") - * @Accessor(getter="getQuantity",setter="setQuantity) + * @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageQuantity") + * @Accessor(getter="getQuantity",setter="setQuantity") * @SkipWhenEmpty() */ private $quantity; diff --git a/src/Bot/Model/Entity/Message/MessageQuantity.php b/src/Bot/Model/Entity/Message/MessageQuantity.php index 36c57d8..27b0211 100644 --- a/src/Bot/Model/Entity/Message/MessageQuantity.php +++ b/src/Bot/Model/Entity/Message/MessageQuantity.php @@ -13,6 +13,7 @@ namespace RetailCrm\Mg\Bot\Model\Entity\Message; +use Symfony\Component\Validator\Constraints as Assert; use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\Type; diff --git a/src/Bot/Model/Entity/Order.php b/src/Bot/Model/Entity/Order.php deleted file mode 100644 index cf6d6f7..0000000 --- a/src/Bot/Model/Entity/Order.php +++ /dev/null @@ -1,230 +0,0 @@ - - * @license https://opensource.org/licenses/MIT MIT License - * @link http://help.retailcrm.pro/docs/Developers - */ - -namespace RetailCrm\Mg\Bot\Model\Entity; - -use JMS\Serializer\Annotation\Accessor; -use JMS\Serializer\Annotation\SkipWhenEmpty; -use JMS\Serializer\Annotation\Type; -use RetailCrm\Mg\Bot\Model\ModelInterface; - -/** - * Order class - * - * @package RetailCrm\Mg\Bot\Model\Entity - * @author retailCRM - * @license https://opensource.org/licenses/MIT MIT License - * @link http://help.retailcrm.pro/docs/Developers - */ -class Order implements ModelInterface -{ - /** - * @var string $number - * - * @Type("string") - * @Accessor(getter="getNumber",setter="setNumber") - * @SkipWhenEmpty() - */ - private $number; - - /** - * @var string $url - * - * @Type("string") - * @Accessor(getter="getUrl",setter="setUrl") - * @SkipWhenEmpty() - */ - private $url; - - /** - * @var string $date - * - * @Type("string") - * @Accessor(getter="getDate",setter="setDate") - * @SkipWhenEmpty() - */ - private $date; - - /** - * @var Cost $cost - * - * @Type("Cost") - * @Accessor(getter="getCost",setter="setCost") - * @SkipWhenEmpty() - */ - private $cost; - - /** - * @var Status $status - * - * @Type("Status") - * @Accessor(getter="getStatus",setter="setStatus") - * @SkipWhenEmpty() - */ - private $status; - - /** - * @var Delivery $delivery - * - * @Type("Delivery") - * @Accessor(getter="getDelivery",setter="setDelivery") - * @SkipWhenEmpty() - */ - private $delivery; - - /** - * @var array $items - * - * @Type("array") - * @Accessor(getter="getItems",setter="setItems") - * @SkipWhenEmpty() - */ - private $items; - - /** - * @var array $payments - * - * @Type("array") - * @Accessor(getter="getPayments",setter="setPayments") - * @SkipWhenEmpty() - */ - private $payments; - - /** - * @return string - */ - public function getNumber() - { - return $this->number; - } - - /** - * @param string $number - */ - public function setNumber(string $number) - { - $this->number = $number; - } - - /** - * @return string - */ - public function getUrl() - { - return $this->url; - } - - /** - * @param string $url - */ - public function setUrl(string $url) - { - $this->url = $url; - } - - /** - * @return string - */ - public function getDate() - { - return $this->date; - } - - /** - * @param string $date - */ - public function setDate(string $date) - { - $this->date = $date; - } - - /** - * @return Cost - */ - public function getCost() - { - return $this->cost; - } - - /** - * @param Cost $cost - */ - public function setCost(Cost $cost) - { - $this->cost = $cost; - } - - /** - * @return Status - */ - public function getStatus() - { - return $this->status; - } - - /** - * @param Status $status - */ - public function setStatus(Status $status) - { - $this->status = $status; - } - - /** - * @return Delivery - */ - public function getDelivery() - { - return $this->delivery; - } - - /** - * @param Delivery $delivery - */ - public function setDelivery(Delivery $delivery) - { - $this->delivery = $delivery; - } - - /** - * @return array - */ - public function getItems() - { - return $this->items; - } - - /** - * @param array $items - */ - public function setItems(array $items) - { - $this->items = $items; - } - - /** - * @return array - */ - public function getPayments() - { - return $this->payments; - } - - /** - * @param array $payments - */ - public function setPayments(array $payments) - { - $this->payments = $payments; - } -} diff --git a/src/Bot/Model/Entity/OrderItem.php b/src/Bot/Model/Entity/OrderItem.php deleted file mode 100644 index 2729070..0000000 --- a/src/Bot/Model/Entity/OrderItem.php +++ /dev/null @@ -1,155 +0,0 @@ - - * @license https://opensource.org/licenses/MIT MIT License - * @link http://help.retailcrm.pro/docs/Developers - */ - -namespace RetailCrm\Mg\Bot\Model\Entity; - -use JMS\Serializer\Annotation\Accessor; -use JMS\Serializer\Annotation\SkipWhenEmpty; -use JMS\Serializer\Annotation\Type; -use RetailCrm\Mg\Bot\Model\ModelInterface; - -/** - * OrderItem class - * - * @package RetailCrm\Mg\Bot\Model\Entity - * @author retailCRM - * @license https://opensource.org/licenses/MIT MIT License - * @link http://help.retailcrm.pro/docs/Developers - */ -class OrderItem implements ModelInterface -{ - /** - * @var string $name - * - * @Type("string") - * @Accessor(getter="getName",setter="setName") - * @SkipWhenEmpty() - */ - private $name; - - /** - * @var string $url - * - * @Type("string") - * @Accessor(getter="getUrl",setter="setUrl") - * @SkipWhenEmpty() - */ - private $url; - - /** - * @var string $img - * - * @Type("string") - * @Accessor(getter="getImg",setter="setImg") - * @SkipWhenEmpty() - */ - private $img; - - /** - * @var Cost $price - * - * @Type("Cost") - * @Accessor(getter="getPrice",setter="setPrice") - * @SkipWhenEmpty() - */ - private $price; - - /** - * @var Quantity $quantity - * - * @Type("Quantity") - * @Accessor(getter="getQuantity",setter="setQuantity) - * @SkipWhenEmpty() - */ - private $quantity; - - /** - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * @param string $name - */ - public function setName(string $name) - { - $this->name = $name; - } - - /** - * @return string - */ - public function getUrl() - { - return $this->url; - } - - /** - * @param string $url - */ - public function setUrl(string $url) - { - $this->url = $url; - } - - /** - * @return string - */ - public function getImg() - { - return $this->img; - } - - /** - * @param string $img - */ - public function setImg(string $img) - { - $this->img = $img; - } - - /** - * @return Cost - */ - public function getPrice() - { - return $this->price; - } - - /** - * @param Cost $price - */ - public function setPrice(Cost $price) - { - $this->price = $price; - } - - /** - * @return Quantity - */ - public function getQuantity() - { - return $this->quantity; - } - - /** - * @param Quantity $quantity - */ - public function setQuantity(Quantity $quantity) - { - $this->quantity = $quantity; - } -} diff --git a/src/Bot/Model/Entity/Payment.php b/src/Bot/Model/Entity/Payment.php deleted file mode 100644 index fa89da3..0000000 --- a/src/Bot/Model/Entity/Payment.php +++ /dev/null @@ -1,105 +0,0 @@ - - * @license https://opensource.org/licenses/MIT MIT License - * @link http://help.retailcrm.pro/docs/Developers - */ - -namespace RetailCrm\Mg\Bot\Model\Entity; - -use JMS\Serializer\Annotation\Accessor; -use JMS\Serializer\Annotation\SkipWhenEmpty; -use JMS\Serializer\Annotation\Type; -use RetailCrm\Mg\Bot\Model\ModelInterface; - -/** - * Payment class - * - * @package RetailCrm\Mg\Bot\Model\Entity - * @author retailCRM - * @license https://opensource.org/licenses/MIT MIT License - * @link http://help.retailcrm.pro/docs/Developers - */ -class Payment implements ModelInterface -{ - /** - * @var string $name - * - * @Type("string") - * @Accessor(getter="getName",setter="setName") - * @SkipWhenEmpty() - */ - private $name; - - /** - * @var PaymentStatus $status - * - * @Type("PaymentStatus") - * @Accessor(getter="getStatus",setter="setStatus") - * @SkipWhenEmpty() - */ - private $status; - - /** - * @var Cost $amount - * - * @Type("Cost") - * @Accessor(getter="getAmount",setter="setAmount") - * @SkipWhenEmpty() - */ - private $amount; - - /** - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * @param string $name - */ - public function setName(string $name) - { - $this->name = $name; - } - - /** - * @return PaymentStatus - */ - public function getStatus() - { - return $this->status; - } - - /** - * @param PaymentStatus $status - */ - public function setStatus(PaymentStatus $status) - { - $this->status = $status; - } - - /** - * @return Cost - */ - public function getAmount() - { - return $this->amount; - } - - /** - * @param Cost $amount - */ - public function setAmount(Cost $amount) - { - $this->amount = $amount; - } -} diff --git a/src/Bot/Model/Entity/PaymentStatus.php b/src/Bot/Model/Entity/PaymentStatus.php deleted file mode 100644 index 7bf487f..0000000 --- a/src/Bot/Model/Entity/PaymentStatus.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @license https://opensource.org/licenses/MIT MIT License - * @link http://help.retailcrm.pro/docs/Developers - */ - -namespace RetailCrm\Mg\Bot\Model\Entity; - -use JMS\Serializer\Annotation\Accessor; -use JMS\Serializer\Annotation\SkipWhenEmpty; -use JMS\Serializer\Annotation\Type; -use RetailCrm\Mg\Bot\Model\ModelInterface; - -/** - * PaymentStatus class - * - * @package RetailCrm\Mg\Bot\Model\Entity - * @author retailCRM - * @license https://opensource.org/licenses/MIT MIT License - * @link http://help.retailcrm.pro/docs/Developers - */ -class PaymentStatus implements ModelInterface -{ - /** - * @var string $name - * - * @Type("string") - * @Accessor(getter="getName",setter="setName") - * @SkipWhenEmpty() - */ - private $name; - - /** - * @var bool $payed - * - * @Type("bool") - * @Accessor(getter="getPayed",setter="setPayed") - * @SkipWhenEmpty() - */ - private $payed; - - /** - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * @param string $name - */ - public function setName(string $name) - { - $this->name = $name; - } - - /** - * @return bool - */ - public function isPayed() - { - return $this->payed; - } - - /** - * @param bool $payed - */ - public function setPayed(bool $payed) - { - $this->payed = $payed; - } -} diff --git a/src/Bot/Model/Entity/Product.php b/src/Bot/Model/Entity/Product.php deleted file mode 100644 index 606bbbf..0000000 --- a/src/Bot/Model/Entity/Product.php +++ /dev/null @@ -1,205 +0,0 @@ - - * @license https://opensource.org/licenses/MIT MIT License - * @link http://help.retailcrm.pro/docs/Developers - */ - -namespace RetailCrm\Mg\Bot\Model\Entity; - -use JMS\Serializer\Annotation\Accessor; -use JMS\Serializer\Annotation\SkipWhenEmpty; -use JMS\Serializer\Annotation\Type; -use RetailCrm\Mg\Bot\Model\ModelInterface; - -/** - * Product class - * - * @package RetailCrm\Mg\Bot\Model\Entity - * @author retailCRM - * @license https://opensource.org/licenses/MIT MIT License - * @link http://help.retailcrm.pro/docs/Developers - */ -class Product implements ModelInterface -{ - /** - * @var int $id - * - * @Type("int") - * @Accessor(getter="getId",setter="setId") - * @SkipWhenEmpty() - */ - private $id; - - /** - * @var string $name - * - * @Type("string") - * @Accessor(getter="getName",setter="setName") - * @SkipWhenEmpty() - */ - private $name; - - /** - * @var string $article - * - * @Type("string") - * @Accessor(getter="getArticle",setter="setArticle") - * @SkipWhenEmpty() - */ - private $article; - - /** - * @var string $url - * - * @Type("string") - * @Accessor(getter="getUrl",setter="setUrl") - * @SkipWhenEmpty() - */ - private $url; - - /** - * @var string $img - * - * @Type("string") - * @Accessor(getter="getImg",setter="setImg") - * @SkipWhenEmpty() - */ - private $img; - - /** - * @var Cost $cost - * - * @Type("Cost") - * @Accessor(getter="getCost",setter="setCost") - * @SkipWhenEmpty() - */ - private $cost; - - /** - * @var Quantity $quantity - * - * @Type("Quantity") - * @Accessor(getter="getQuantity",setter="setQuantity) - * @SkipWhenEmpty() - */ - private $quantity; - - /** - * @return int - */ - public function getId(): int - { - return $this->id; - } - - /** - * @param int $id - */ - public function setId(int $id) - { - $this->id = $id; - } - - /** - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * @param string $name - */ - public function setName(string $name) - { - $this->name = $name; - } - - /** - * @return string - */ - public function getArticle() - { - return $this->article; - } - - /** - * @param string $article - */ - public function setArticle(string $article) - { - $this->article = $article; - } - - /** - * @return string - */ - public function getUrl() - { - return $this->url; - } - - /** - * @param string $url - */ - public function setUrl(string $url) - { - $this->url = $url; - } - - /** - * @return string - */ - public function getImg() - { - return $this->img; - } - - /** - * @param string $img - */ - public function setImg(string $img) - { - $this->img = $img; - } - - /** - * @return Cost - */ - public function getCost() - { - return $this->cost; - } - - /** - * @param Cost $cost - */ - public function setCost(Cost $cost) - { - $this->cost = $cost; - } - - /** - * @return Quantity - */ - public function getQuantity() - { - return $this->quantity; - } - - /** - * @param Quantity $quantity - */ - public function setQuantity(Quantity $quantity) - { - $this->quantity = $quantity; - } -} diff --git a/src/Bot/Model/Entity/Quantity.php b/src/Bot/Model/Entity/Quantity.php deleted file mode 100644 index 09fdedd..0000000 --- a/src/Bot/Model/Entity/Quantity.php +++ /dev/null @@ -1,81 +0,0 @@ - - * @license https://opensource.org/licenses/MIT MIT License - * @link http://help.retailcrm.pro/docs/Developers - */ - -namespace RetailCrm\Mg\Bot\Model\Entity; - -use JMS\Serializer\Annotation\Accessor; -use JMS\Serializer\Annotation\SkipWhenEmpty; -use JMS\Serializer\Annotation\Type; -use RetailCrm\Mg\Bot\Model\ModelInterface; - -/** - * Quantity class - * - * @package RetailCrm\Mg\Bot\Model\Entity - * @author retailCRM - * @license https://opensource.org/licenses/MIT MIT License - * @link http://help.retailcrm.pro/docs/Developers - */ -class Quantity implements ModelInterface -{ - /** - * @var float $value - * - * @Type("float") - * @Accessor(getter="getValue",setter="setValue") - * @SkipWhenEmpty() - */ - private $value; - - /** - * @var string $unit - * - * @Type("string") - * @Accessor(getter="getUnit",setter="setUnit") - * - * @Assert\Currency - */ - private $unit; - - /** - * @return float - */ - public function getValue() - { - return $this->value; - } - - /** - * @param float $value - */ - public function setValue(float $value) - { - $this->value = $value; - } - - /** - * @return string - */ - public function getUnit() - { - return $this->unit; - } - - /** - * @param string $unit - */ - public function setUnit(string $unit) - { - $this->unit = $unit; - } -} diff --git a/src/Bot/Model/Entity/Status.php b/src/Bot/Model/Entity/Status.php deleted file mode 100644 index f0747a5..0000000 --- a/src/Bot/Model/Entity/Status.php +++ /dev/null @@ -1,80 +0,0 @@ - - * @license https://opensource.org/licenses/MIT MIT License - * @link http://help.retailcrm.pro/docs/Developers - */ - -namespace RetailCrm\Mg\Bot\Model\Entity; - -use JMS\Serializer\Annotation\Accessor; -use JMS\Serializer\Annotation\SkipWhenEmpty; -use JMS\Serializer\Annotation\Type; -use RetailCrm\Mg\Bot\Model\ModelInterface; - -/** - * Status class - * - * @package RetailCrm\Mg\Bot\Model\Entity - * @author retailCRM - * @license https://opensource.org/licenses/MIT MIT License - * @link http://help.retailcrm.pro/docs/Developers - */ -class Status implements ModelInterface -{ - /** - * @var string $code - * - * @Type("string") - * @Accessor(getter="getCode",setter="setCode") - * @SkipWhenEmpty() - */ - private $code; - - /** - * @var string $name - * - * @Type("string") - * @Accessor(getter="getName",setter="setName") - * @SkipWhenEmpty() - */ - private $name; - - /** - * @return string - */ - public function getCode() - { - return $this->code; - } - - /** - * @param string $code - */ - public function setCode(string $code) - { - $this->code = $code; - } - - /** - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * @param string $name - */ - public function setName(string $name) - { - $this->name = $name; - } -} diff --git a/src/Bot/Model/Request/MessageSendRequest.php b/src/Bot/Model/Request/MessageSendRequest.php index 6817a2f..c2cd4b1 100644 --- a/src/Bot/Model/Request/MessageSendRequest.php +++ b/src/Bot/Model/Request/MessageSendRequest.php @@ -13,6 +13,7 @@ namespace RetailCrm\Mg\Bot\Model\Request; +use JMS\Serializer\Annotation as Serializer; use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\Type; @@ -45,15 +46,14 @@ class MessageSendRequest implements ModelInterface * * @Type("string") * @Accessor(getter="getContent",setter="setContent") - * - * @Assert\NotBlank + * @SkipWhenEmpty() */ private $content; /** * @var MessageProduct $product * - * @Type("Product") + * @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageProduct") * @Accessor(getter="getProduct",setter="setProduct") * @SkipWhenEmpty() */ @@ -62,7 +62,7 @@ class MessageSendRequest implements ModelInterface /** * @var MessageOrder $order * - * @Type("Order") + * @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageOrder") * @Accessor(getter="getOrder",setter="setOrder") * @SkipWhenEmpty() */ diff --git a/src/Register.php b/src/Register.php index 6e47c59..828a885 100644 --- a/src/Register.php +++ b/src/Register.php @@ -63,7 +63,7 @@ class Register * * @Type("string") * @Accessor(getter="getName",setter="setName") - * @SkipWhenEmpty + * @Assert\NotBlank() */ private $name; @@ -112,6 +112,7 @@ class Register * * @Type("string") * @Accessor(getter="getAccountUrl",setter="setAccountUrl") + * @SerializedName("accountUrl") * * @Assert\NotBlank * @Assert\Url( @@ -330,22 +331,32 @@ class Register /** * Get configuration as JSON * - * @return array|string - * @todo make exact type + * @return string */ public function getJsonConfiguration() { - return Serializer::serialize($this); + $serialized = Serializer::serialize($this); + + if (is_string($serialized)) { + return $serialized; + } + + return ''; } /** * Get configuration as array * - * @return array|string - * @todo make exact type + * @return array */ public function getArrayConfiguration() { - return Serializer::serialize($this, Serializer::S_ARRAY); + $serialized = Serializer::serialize($this, Serializer::S_ARRAY); + + if (is_array($serialized)) { + return $serialized; + } + + return []; } } diff --git a/tests/Bot/Tests/FileTest.php b/tests/Bot/Tests/FileTest.php index 430ba1c..1d1586a 100644 --- a/tests/Bot/Tests/FileTest.php +++ b/tests/Bot/Tests/FileTest.php @@ -22,7 +22,7 @@ use RetailCrm\Mg\Bot\Test\TestCase; * * Class UploadFileTest * - * @package RetailCrm\Mg\Bot\Tests + * @package RetailCrm\Mg\Bot\Tests * @author retailCRM * @license https://opensource.org/licenses/MIT MIT License * @link http://help.retailcrm.pro/docs/Developers diff --git a/tests/Bot/Tests/MessagesTest.php b/tests/Bot/Tests/MessagesTest.php index a0fee60..114ddbc 100644 --- a/tests/Bot/Tests/MessagesTest.php +++ b/tests/Bot/Tests/MessagesTest.php @@ -14,8 +14,17 @@ namespace RetailCrm\Mg\Bot\Tests; use RetailCrm\Mg\Bot\Model\Constants; +use RetailCrm\Mg\Bot\Model\Entity\Message\MessageCost; +use RetailCrm\Mg\Bot\Model\Entity\Message\MessageDelivery; +use RetailCrm\Mg\Bot\Model\Entity\Message\MessageOrder; +use RetailCrm\Mg\Bot\Model\Entity\Message\MessageOrderItem; +use RetailCrm\Mg\Bot\Model\Entity\Message\MessageOrderPaymentStatus; +use RetailCrm\Mg\Bot\Model\Entity\Message\MessageProduct; +use RetailCrm\Mg\Bot\Model\Entity\Message\MessageQuantity; +use RetailCrm\Mg\Bot\Model\Entity\Message\MessageStatus; use RetailCrm\Mg\Bot\Model\Request\MessageEditRequest; use RetailCrm\Mg\Bot\Model\Request\MessageSendRequest; +use RetailCrm\Mg\Bot\Model\Response\MessageSendResponse; use RetailCrm\Mg\Bot\Test\TestCase; /** @@ -59,7 +68,7 @@ class MessagesTest extends TestCase * @group("messages") * @throws \Exception */ - public function testMessageSend() + public function testMessageSendText() { $client = self::getApiClient( null, @@ -78,9 +87,135 @@ class MessagesTest extends TestCase $response = $client->messageSend($request); - self::assertTrue($response->isSuccessful()); - self::assertEquals(0, count($response->getErrors())); - self::assertEquals(3636, $response->getMessageId()); + self::assertInstanceOf(MessageSendResponse::class, $response); + + if ($response instanceof MessageSendResponse) { + self::assertTrue($response->isSuccessful()); + self::assertEquals(0, count($response->getErrors())); + self::assertEquals(3636, $response->getMessageId()); + } + } + + /** + * @group("messages") + * @throws \Exception + */ + public function testMessageSendOrder() + { + $client = self::getApiClient( + null, + null, + false, + $this->getResponse( + '{"message_id":3636,"time":"2019-06-24T06:02:04.434291791Z"}', + 201 + ) + ); + + $cost = new MessageCost(); + $cost->setCurrency("₽"); + $cost->setValue(500); + + $delivery = new MessageDelivery(); + $delivery->setAddress('address'); + $delivery->setComment('comment'); + $delivery->setName('test delivery'); + $delivery->setPrice($cost); + + $quantity = new MessageQuantity(); + $quantity->setUnit('pcs'); + $quantity->setValue(1); + + $item = new MessageOrderItem(); + $item->setName('product'); + $item->setPrice($cost); + $item->setImg('https://example.com/image.jpeg'); + $item->setQuantity($quantity); + $item->setUrl('https://example.com'); + + $orderStatus = new MessageStatus(); + $orderStatus->setName('name'); + $orderStatus->setCode('code'); + + $payment = new MessageOrderPaymentStatus(); + $payment->setName('card'); + $payment->setPayed(true); + + $order = new MessageOrder(); + $order->setCost($cost); + $order->setDelivery($delivery); + $order->setDate(date('Y-m-d\TH:i:s\.u\Z')); + $order->setItems([$item]); + $order->setUrl('https://example.com'); + $order->setNumber('2038C'); + $order->setPayments([$payment]); + $order->setStatus($orderStatus); + + $request = new MessageSendRequest(); + $request->setChatId(28); + $request->setType(Constants::MESSAGE_TYPE_ORDER); + $request->setScope(Constants::MESSAGE_SCOPE_PUBLIC); + $request->setOrder($order); + + $response = $client->messageSend($request); + + self::assertInstanceOf(MessageSendResponse::class, $response); + + if ($response instanceof MessageSendResponse) { + self::assertTrue($response->isSuccessful()); + self::assertEquals(0, count($response->getErrors())); + self::assertEquals(3636, $response->getMessageId()); + } + } + + /** + * @group("messages") + * @throws \Exception + */ + public function testMessageSendProduct() + { + $client = self::getApiClient( + null, + null, + false, + $this->getResponse( + '{"message_id":3636,"time":"2019-06-24T06:02:04.434291791Z"}', + 201 + ) + ); + + $cost = new MessageCost(); + $cost->setCurrency("₽"); + $cost->setValue(500); + + $quantity = new MessageQuantity(); + $quantity->setUnit('pcs'); + $quantity->setValue(1); + + $product = new MessageProduct(); + $product->setId(1); + $product->setName('product'); + $product->setUrl('https://example.com'); + $product->setImg('https://example.com/image.jpg'); + $product->setQuantity($quantity); + $product->setCost($cost); + $product->setArticle('article'); + + $request = new MessageSendRequest(); + $request->setChatId(28); + $request->setType(Constants::MESSAGE_TYPE_PRODUCT); + $request->setScope(Constants::MESSAGE_SCOPE_PUBLIC); + $request->setProduct($product); + + $response = $client->messageSend($request); + + self::assertInstanceOf(MessageSendResponse::class, $response); + + if ($response instanceof MessageSendResponse) { + self::assertTrue($response->isSuccessful()); + self::assertEquals(0, count($response->getErrors())); + self::assertEquals(3636, $response->getMessageId()); + } } /** diff --git a/tests/Bot/Tests/RegisterTest.php b/tests/Bot/Tests/RegisterTest.php new file mode 100644 index 0000000..e60e86f --- /dev/null +++ b/tests/Bot/Tests/RegisterTest.php @@ -0,0 +1,93 @@ + + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ + +namespace RetailCrm\Mg\Bot\Tests; + +use RetailCrm\Common\Register; +use RetailCrm\Mg\Bot\Test\TestCase; + +/** + * PHP version 7.0 + * + * Class RegisterTest + * + * @package RetailCrm\Mg\Bot\Tests + * @author retailCRM + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ +class RegisterTest extends TestCase +{ + /** @var Register $register */ + private static $register; + + /** + * testGetArrayConfiguration + * @group("register") + */ + public function testGetArrayConfiguration() + { + static::assertRegister(static::getRegister()->getArrayConfiguration()); + } + + /** + * testGetJsonConfiguration + * @group("register") + */ + public function testGetJsonConfiguration() + { + static::assertRegister(json_decode(static::getRegister()->getJsonConfiguration(), true)); + } + + /** + * assertRegister asserts passed array properties with current register object + * + * @param array $serialized + */ + private static function assertRegister(array $serialized): void + { + static::assertNotEmpty($serialized, 'ERROR: Serialized array is empty'); + + if (!empty($serialized)) { + static::assertEquals(static::getRegister()->getName(), $serialized['name']); + static::assertEquals(static::getRegister()->getCode(), $serialized['code']); + static::assertEquals(static::getRegister()->getBaseUrl(), $serialized['baseUrl']); + static::assertEquals(static::getRegister()->getLogo(), $serialized['logo']); + static::assertEquals(static::getRegister()->getAccountUrl(), $serialized['accountUrl']); + static::assertEquals(static::getRegister()->getActions(), $serialized['actions']); + static::assertEquals(static::getRegister()->getActive(), $serialized['active']); + static::assertEquals(static::getRegister()->getAvailableCountries(), $serialized['availableCountries']); + static::assertEquals(static::getRegister()->getClientId(), $serialized['clientId']); + static::assertEquals(static::getRegister()->getIntegrationCode(), $serialized['integrationCode']); + static::assertEquals(static::getRegister()->getIntegrations(), $serialized['integrations']); + } + } + + private static function getRegister(): Register + { + if (empty(static::$register)) { + static::$register = new Register(); + static::$register->setName('name'); + static::$register->setCode('code'); + static::$register->setBaseUrl('https://example.com'); + static::$register->setLogo('https://example.com/logo.png'); + static::$register->setAccountUrl('https://example.com/account'); + static::$register->setActions(['/activity']); + static::$register->setActive(true); + static::$register->setAvailableCountries(['RU']); + static::$register->setClientId('long random hash of /dev/urandom'); + static::$register->setIntegrationCode('integrationCode'); + static::$register->setIntegrations(['mgBot' => []]); + } + + return static::$register; + } +}