Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add card message type #794

Merged
merged 1 commit into from
Jul 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'),
],
];
}

}