Skip to content

Commit

Permalink
add card message type (#794)
Browse files Browse the repository at this point in the history
  • Loading branch information
IanGely authored and overtrue committed Jul 10, 2017
1 parent ad2bde9 commit 709ae13
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
53 changes: 53 additions & 0 deletions src/Kernel/Messages/Card.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

/*
* This file is part of the overtrue/wechat.
*
* (c) overtrue <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

/**
* Card.php.
*
* @author overtrue <[email protected]>
* @copyright 2015 overtrue <[email protected]>
*
* @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);
}
}
20 changes: 20 additions & 0 deletions src/OfficialAccount/CustomerService/Transformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
],
];
}

}

0 comments on commit 709ae13

Please sign in to comment.