1
0
mirror of synced 2024-11-22 11:56:03 +03:00

Merge pull request #8 from Neur0toxine/master

[fix] removed models duplicates, fixed several errors
This commit is contained in:
Alex Lushpai 2019-09-30 17:23:11 +03:00 committed by GitHub
commit 5f6179ea1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 273 additions and 1260 deletions

View File

@ -1,81 +0,0 @@
<?php
/**
* PHP version 7.1
*
* Cost entity
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @author retailCRM <integration@retailcrm.ru>
* @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 <integration@retailcrm.ru>
* @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;
}
}

View File

@ -1,132 +0,0 @@
<?php
/**
* PHP version 7.1
*
* Delivery entity
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @author retailCRM <integration@retailcrm.ru>
* @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 <integration@retailcrm.ru>
* @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;
}
}

View File

@ -1,80 +0,0 @@
<?php
/**
* PHP version 7.1
*
* Item entity
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @author retailCRM <integration@retailcrm.ru>
* @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 <integration@retailcrm.ru>
* @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;
}
}

View File

@ -166,7 +166,7 @@ class Message implements ModelInterface
/** /**
* @var Dialog $dialog * @var Dialog $dialog
* *
* @Type("Dialog") * @Type("RetailCrm\Mg\Bot\Model\Entity\Dialog")
* @Accessor(getter="getDialog",setter="setDialog") * @Accessor(getter="getDialog",setter="setDialog")
* @SkipWhenEmpty() * @SkipWhenEmpty()
*/ */
@ -193,7 +193,7 @@ class Message implements ModelInterface
/** /**
* @var MessageOrder $order * @var MessageOrder $order
* *
* @Type("MessageOrder") * @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageOrder")
* @Accessor(getter="getOrder",setter="setOrder") * @Accessor(getter="getOrder",setter="setOrder")
* @SkipWhenEmpty() * @SkipWhenEmpty()
*/ */
@ -202,7 +202,7 @@ class Message implements ModelInterface
/** /**
* @var MessageProduct $product * @var MessageProduct $product
* *
* @Type("MessageProduct") * @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageProduct")
* @Accessor(getter="getProduct",setter="setProduct") * @Accessor(getter="getProduct",setter="setProduct")
* @SkipWhenEmpty() * @SkipWhenEmpty()
*/ */

View File

@ -13,6 +13,7 @@
namespace RetailCrm\Mg\Bot\Model\Entity\Message; namespace RetailCrm\Mg\Bot\Model\Entity\Message;
use Symfony\Component\Validator\Constraints as Assert;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;

View File

@ -13,6 +13,7 @@
namespace RetailCrm\Mg\Bot\Model\Entity\Message; namespace RetailCrm\Mg\Bot\Model\Entity\Message;
use Symfony\Component\Validator\Constraints as Assert;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
@ -41,7 +42,7 @@ class MessageDelivery implements ModelInterface
/** /**
* @var MessageCost $price * @var MessageCost $price
* *
* @Type("Cost") * @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageCost")
* @Accessor(getter="getPrice",setter="setPrice") * @Accessor(getter="getPrice",setter="setPrice")
* *
* @Assert\Currency * @Assert\Currency

View File

@ -58,7 +58,7 @@ class MessageOrder implements ModelInterface
/** /**
* @var MessageCost $cost * @var MessageCost $cost
* *
* @Type("MessageCost") * @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageCost")
* @Accessor(getter="getCost",setter="setCost") * @Accessor(getter="getCost",setter="setCost")
* @SkipWhenEmpty() * @SkipWhenEmpty()
*/ */
@ -67,7 +67,7 @@ class MessageOrder implements ModelInterface
/** /**
* @var MessageStatus $status * @var MessageStatus $status
* *
* @Type("MessageStatus") * @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageStatus")
* @Accessor(getter="getStatus",setter="setStatus") * @Accessor(getter="getStatus",setter="setStatus")
* @SkipWhenEmpty() * @SkipWhenEmpty()
*/ */
@ -76,7 +76,7 @@ class MessageOrder implements ModelInterface
/** /**
* @var MessageDelivery $delivery * @var MessageDelivery $delivery
* *
* @Type("MessageDelivery") * @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageDelivery")
* @Accessor(getter="getDelivery",setter="setDelivery") * @Accessor(getter="getDelivery",setter="setDelivery")
* @SkipWhenEmpty() * @SkipWhenEmpty()
*/ */

View File

@ -58,7 +58,7 @@ class MessageOrderItem implements ModelInterface
/** /**
* @var MessageCost * @var MessageCost
* *
* @Type("MessageCost") * @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageCost")
* @Accessor(getter="getPrice",setter="setPrice") * @Accessor(getter="getPrice",setter="setPrice")
* @SkipWhenEmpty() * @SkipWhenEmpty()
*/ */
@ -67,8 +67,8 @@ class MessageOrderItem implements ModelInterface
/** /**
* @var MessageQuantity * @var MessageQuantity
* *
* @Type("MessageQuantity") * @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageQuantity")
* @Accessor(getter="getQuantity",setter="setQuantity) * @Accessor(getter="getQuantity",setter="setQuantity")
* @SkipWhenEmpty() * @SkipWhenEmpty()
*/ */
private $quantity; private $quantity;

View File

@ -40,7 +40,7 @@ class MessagePayment implements ModelInterface
/** /**
* @var MessageOrderPaymentStatus $status * @var MessageOrderPaymentStatus $status
* *
* @Type("MessageOrderPaymentStatus") * @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageOrderPaymentStatus")
* @Accessor(getter="getStatus",setter="setStatus") * @Accessor(getter="getStatus",setter="setStatus")
* @SkipWhenEmpty() * @SkipWhenEmpty()
*/ */
@ -49,7 +49,7 @@ class MessagePayment implements ModelInterface
/** /**
* @var MessageCost $amount * @var MessageCost $amount
* *
* @Type("MessageCost") * @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageCost")
* @Accessor(getter="getAmount",setter="setAmount") * @Accessor(getter="getAmount",setter="setAmount")
* @SkipWhenEmpty() * @SkipWhenEmpty()
*/ */

View File

@ -76,7 +76,7 @@ class MessageProduct implements ModelInterface
/** /**
* @var MessageCost $cost * @var MessageCost $cost
* *
* @Type("Cost") * @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageCost")
* @Accessor(getter="getCost",setter="setCost") * @Accessor(getter="getCost",setter="setCost")
* @SkipWhenEmpty() * @SkipWhenEmpty()
*/ */
@ -85,8 +85,8 @@ class MessageProduct implements ModelInterface
/** /**
* @var MessageQuantity $quantity * @var MessageQuantity $quantity
* *
* @Type("MessageQuantity") * @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageQuantity")
* @Accessor(getter="getQuantity",setter="setQuantity) * @Accessor(getter="getQuantity",setter="setQuantity")
* @SkipWhenEmpty() * @SkipWhenEmpty()
*/ */
private $quantity; private $quantity;

View File

@ -13,6 +13,7 @@
namespace RetailCrm\Mg\Bot\Model\Entity\Message; namespace RetailCrm\Mg\Bot\Model\Entity\Message;
use Symfony\Component\Validator\Constraints as Assert;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;

View File

@ -1,230 +0,0 @@
<?php
/**
* PHP version 7.1
*
* Order entity
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @author retailCRM <integration@retailcrm.ru>
* @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 <integration@retailcrm.ru>
* @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;
}
}

View File

@ -1,155 +0,0 @@
<?php
/**
* PHP version 7.1
*
* Order item entity
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @author retailCRM <integration@retailcrm.ru>
* @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 <integration@retailcrm.ru>
* @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;
}
}

View File

@ -1,105 +0,0 @@
<?php
/**
* PHP version 7.1
*
* Payment entity
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @author retailCRM <integration@retailcrm.ru>
* @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 <integration@retailcrm.ru>
* @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;
}
}

View File

@ -1,80 +0,0 @@
<?php
/**
* PHP version 7.1
*
* Payment status entity
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @author retailCRM <integration@retailcrm.ru>
* @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 <integration@retailcrm.ru>
* @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;
}
}

View File

@ -1,205 +0,0 @@
<?php
/**
* PHP version 7.1
*
* Product entity
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @author retailCRM <integration@retailcrm.ru>
* @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 <integration@retailcrm.ru>
* @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;
}
}

View File

@ -1,81 +0,0 @@
<?php
/**
* PHP version 7.1
*
* Quantity entity
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @author retailCRM <integration@retailcrm.ru>
* @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 <integration@retailcrm.ru>
* @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;
}
}

View File

@ -1,80 +0,0 @@
<?php
/**
* PHP version 7.1
*
* Status entity
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @author retailCRM <integration@retailcrm.ru>
* @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 <integration@retailcrm.ru>
* @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;
}
}

View File

@ -13,6 +13,7 @@
namespace RetailCrm\Mg\Bot\Model\Request; namespace RetailCrm\Mg\Bot\Model\Request;
use JMS\Serializer\Annotation as Serializer;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
@ -45,15 +46,14 @@ class MessageSendRequest implements ModelInterface
* *
* @Type("string") * @Type("string")
* @Accessor(getter="getContent",setter="setContent") * @Accessor(getter="getContent",setter="setContent")
* * @SkipWhenEmpty()
* @Assert\NotBlank
*/ */
private $content; private $content;
/** /**
* @var MessageProduct $product * @var MessageProduct $product
* *
* @Type("Product") * @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageProduct")
* @Accessor(getter="getProduct",setter="setProduct") * @Accessor(getter="getProduct",setter="setProduct")
* @SkipWhenEmpty() * @SkipWhenEmpty()
*/ */
@ -62,7 +62,7 @@ class MessageSendRequest implements ModelInterface
/** /**
* @var MessageOrder $order * @var MessageOrder $order
* *
* @Type("Order") * @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageOrder")
* @Accessor(getter="getOrder",setter="setOrder") * @Accessor(getter="getOrder",setter="setOrder")
* @SkipWhenEmpty() * @SkipWhenEmpty()
*/ */

View File

@ -63,7 +63,7 @@ class Register
* *
* @Type("string") * @Type("string")
* @Accessor(getter="getName",setter="setName") * @Accessor(getter="getName",setter="setName")
* @SkipWhenEmpty * @Assert\NotBlank()
*/ */
private $name; private $name;
@ -112,6 +112,7 @@ class Register
* *
* @Type("string") * @Type("string")
* @Accessor(getter="getAccountUrl",setter="setAccountUrl") * @Accessor(getter="getAccountUrl",setter="setAccountUrl")
* @SerializedName("accountUrl")
* *
* @Assert\NotBlank * @Assert\NotBlank
* @Assert\Url( * @Assert\Url(
@ -330,22 +331,32 @@ class Register
/** /**
* Get configuration as JSON * Get configuration as JSON
* *
* @return array|string * @return string
* @todo make exact type
*/ */
public function getJsonConfiguration() public function getJsonConfiguration()
{ {
return Serializer::serialize($this); $serialized = Serializer::serialize($this);
if (is_string($serialized)) {
return $serialized;
}
return '';
} }
/** /**
* Get configuration as array * Get configuration as array
* *
* @return array|string * @return array
* @todo make exact type
*/ */
public function getArrayConfiguration() public function getArrayConfiguration()
{ {
return Serializer::serialize($this, Serializer::S_ARRAY); $serialized = Serializer::serialize($this, Serializer::S_ARRAY);
if (is_array($serialized)) {
return $serialized;
}
return [];
} }
} }

View File

@ -14,8 +14,17 @@
namespace RetailCrm\Mg\Bot\Tests; namespace RetailCrm\Mg\Bot\Tests;
use RetailCrm\Mg\Bot\Model\Constants; 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\MessageEditRequest;
use RetailCrm\Mg\Bot\Model\Request\MessageSendRequest; use RetailCrm\Mg\Bot\Model\Request\MessageSendRequest;
use RetailCrm\Mg\Bot\Model\Response\MessageSendResponse;
use RetailCrm\Mg\Bot\Test\TestCase; use RetailCrm\Mg\Bot\Test\TestCase;
/** /**
@ -59,7 +68,7 @@ class MessagesTest extends TestCase
* @group("messages") * @group("messages")
* @throws \Exception * @throws \Exception
*/ */
public function testMessageSend() public function testMessageSendText()
{ {
$client = self::getApiClient( $client = self::getApiClient(
null, null,
@ -78,10 +87,136 @@ class MessagesTest extends TestCase
$response = $client->messageSend($request); $response = $client->messageSend($request);
self::assertInstanceOf(MessageSendResponse::class, $response);
if ($response instanceof MessageSendResponse) {
self::assertTrue($response->isSuccessful()); self::assertTrue($response->isSuccessful());
self::assertEquals(0, count($response->getErrors())); self::assertEquals(0, count($response->getErrors()));
self::assertEquals(3636, $response->getMessageId()); 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());
}
}
/** /**
* @group("messages") * @group("messages")

View File

@ -0,0 +1,93 @@
<?php
/**
* PHP version 7.1
*
* RegisterTest.php
*
* @author retailCRM <integration@retailcrm.ru>
* @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 <integration@retailcrm.ru>
* @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;
}
}