From 70630799855c34a60b9a345e584fb29292e3c34a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=B0=8F=E4=B9=90?= Date: Thu, 19 Jan 2017 10:40:58 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=A8=E9=80=9A=E7=94=A8=E5=8D=A1?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=20(#575)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 补全通用卡接口 * codacy fix * styleci fix * StyleCI fix * fix testcase --- src/Card/Card.php | 28 +++++++++++++++++++++++----- tests/Card/CardTest.php | 4 ++-- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/Card/Card.php b/src/Card/Card.php index 6c28a13c5..9ccfdee9c 100644 --- a/src/Card/Card.php +++ b/src/Card/Card.php @@ -64,8 +64,8 @@ class Card extends AbstractAPI const API_UPDATE_CODE = 'https://api.weixin.qq.com/card/code/update'; const API_DELETE_CARD = 'https://api.weixin.qq.com/card/delete'; const API_DISABLE_CARD = 'https://api.weixin.qq.com/card/code/unavailable'; - const API_ACTIVATE_CARD = 'https://api.weixin.qq.com/card/membercard/activate'; - const API_ACTIVATE_USER_FORM = 'https://api.weixin.qq.com/card/membercard/activateuserform/set'; + const API_ACTIVATE_MEMBER_CARD = 'https://api.weixin.qq.com/card/membercard/activate'; + const API_ACTIVATE_MEMBER_USER_FORM = 'https://api.weixin.qq.com/card/membercard/activateuserform/set'; const API_GET_MEMBER_USER_INFO = 'https://api.weixin.qq.com/card/membercard/userinfo/get'; const API_UPDATE_MEMBER_CARD_USER = 'https://api.weixin.qq.com/card/membercard/updateuser'; const API_CREATE_SUB_MERCHANT = 'https://api.weixin.qq.com/card/submerchant/submit'; @@ -73,6 +73,8 @@ class Card extends AbstractAPI const API_GET_SUB_MERCHANT = 'https://api.weixin.qq.com/card/submerchant/get'; const API_LIST_SUB_MERCHANT = 'https://api.weixin.qq.com/card/submerchant/batchget'; const API_GET_CATEGORIES = 'https://api.weixin.qq.com/card/getapplyprotocol'; + const API_ACTIVATE_GENERAL_CARD = 'https://api.weixin.qq.com/card/generalcard/activate'; + const API_UPDATE_GENERAL_CARD_USER = 'https://api.weixin.qq.com/card/generalcard/updateuser'; /** * 获取卡券颜色. @@ -633,9 +635,13 @@ public function disable($code, $cardId = '') * * @return \EasyWeChat\Support\Collection */ - public function activate($info = []) + public function activate($info = [], $cardType = 'member_card') { - return $this->parseJSON('json', [self::API_ACTIVATE_CARD, $info]); + if ($cardType === 'general_card') { + return $this->parseJSON('json', [self::API_ACTIVATE_GENERAL_CARD, $info]); + } + + return $this->parseJSON('json', [self::API_ACTIVATE_MEMBER_CARD, $info]); } /** @@ -651,7 +657,7 @@ public function activateUserForm($cardId, array $requiredForm = [], array $optio { $params = array_merge(['card_id' => $cardId], $requiredForm, $optionalForm); - return $this->parseJSON('json', [self::API_ACTIVATE_USER_FORM, $params]); + return $this->parseJSON('json', [self::API_ACTIVATE_MEMBER_USER_FORM, $params]); } /** @@ -684,6 +690,18 @@ public function updateMemberCardUser(array $params = []) return $this->parseJSON('json', [self::API_UPDATE_MEMBER_CARD_USER, $params]); } + /** + * 更新通用员信息. + * + * @param array $params + * + * @return \EasyWeChat\Support\Collection + */ + public function updateGeneralCardUser(array $params = []) + { + return $this->parseJSON('json', [self::API_UPDATE_GENERAL_CARD_USER, $params]); + } + /** * 添加子商户. * diff --git a/tests/Card/CardTest.php b/tests/Card/CardTest.php index 4865bfc90..1137c800b 100644 --- a/tests/Card/CardTest.php +++ b/tests/Card/CardTest.php @@ -539,7 +539,7 @@ public function testActivate() ]; $result = $card->activate($activate); - $this->assertStringStartsWith(Card::API_ACTIVATE_CARD, $result['api']); + $this->assertStringStartsWith(Card::API_ACTIVATE_MEMBER_CARD, $result['api']); $this->assertEquals($activate, $result['params']); } @@ -575,7 +575,7 @@ public function testActivateUserForm() ]; $result = $card->activateUserForm($cardId, $requiredForm, $optionalForm); - $this->assertStringStartsWith(Card::API_ACTIVATE_USER_FORM, $result['api']); + $this->assertStringStartsWith(Card::API_ACTIVATE_MEMBER_USER_FORM, $result['api']); $this->assertEquals($cardId, $result['params']['card_id']); }