diff --git a/src/Kernel/Messages/Card.php b/src/Kernel/Messages/Card.php new file mode 100644 index 000000000..ad800eeef --- /dev/null +++ b/src/Kernel/Messages/Card.php @@ -0,0 +1,53 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +/** + * Card.php. + * + * @author overtrue + * @copyright 2015 overtrue + * + * @see https://github.com/overtrue + * @see http://overtrue.me + */ + +namespace EasyWeChat\Kernel\Messages; + +/** + * Class Card. + */ +class Card extends Message +{ + + /** + * Message type. + * + * @var string + */ + protected $type = 'wxcard'; + + /** + * Properties. + * + * @var array + */ + protected $properties = ['card_id']; + + /** + * Material constructor. + * + * @param string $cardId + */ + public function __construct($cardId) + { + $this->set('card_id', $cardId); + } +} diff --git a/src/OfficialAccount/CustomerService/Transformer.php b/src/OfficialAccount/CustomerService/Transformer.php index 19417fb23..0dd4892fb 100644 --- a/src/OfficialAccount/CustomerService/Transformer.php +++ b/src/OfficialAccount/CustomerService/Transformer.php @@ -183,4 +183,24 @@ public function transformMaterial(Message $message) ], ]; } + + /** + * Transform card message. + * + * @param Message $message + * + * @return array + */ + public function transformCard(Message $message) + { + $type = $message->getType(); + + return [ + 'msgtype' => $type, + $type => [ + 'card_id' => $message->get('card_id'), + ], + ]; + } + }