Skip to content

Commit

Permalink
add wechat channel
Browse files Browse the repository at this point in the history
  • Loading branch information
DoveChen committed May 5, 2023
1 parent 269e742 commit d127ddd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/dataStructure/ExternalContactFollowUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* @property string $remark_corp_name 该成员对此客户备注的企业名称
* @property array $remark_mobiles 该成员对此客户备注的手机号码,第三方不可获取
* @property array $add_way 该成员添加此客户的来源0、未知来源;1、 扫描二维码;2、搜索手机号;3、名片分享;4、群聊;5、手机通讯录;6、微信联系人;7、来自微信的添加好友申请;8、安装第三方应用时自动添加的客服人员;9、搜索邮箱;201、内部成员共享;202、管理员/负责人分配
* @property array $wechat_channels 该成员添加此客户的来源add_way为10时,对应的视频号信息
* @property array $oper_userid 发起添加的userid,如果成员主动添加,为成员的userid;如果是客户主动添加,则为客户的外部联系人userid;如果是内部成员共享/管理员分配,则为对应的成员/管理员userid
*
* @package dovechen\yii2\weWork\src\dataStructure
Expand Down Expand Up @@ -48,7 +49,16 @@ public static function parseFromArray ($arr)
$externalContactFollowUser->remark_corp_name = Utils::arrayGet($arr, 'remark_corp_name');
$externalContactFollowUser->remark_mobiles = Utils::arrayGet($arr, 'remark_mobiles');
$externalContactFollowUser->add_way = Utils::arrayGet($arr, 'add_way');
$externalContactFollowUser->oper_userid = Utils::arrayGet($arr, 'oper_userid');

$wechatChannels = Utils::arrayGet($arr, 'wechat_channels');
if (!is_null($wechatChannels) && !empty($wechatChannels)) {
$externalContactFollowUser->wechat_channels = [
'nickname' => Utils::arrayGet($wechatChannels, 'nickname'),
'source' => Utils::arrayGet($wechatChannels, 'source'),
];
}

$externalContactFollowUser->oper_userid = Utils::arrayGet($arr, 'oper_userid');

return $externalContactFollowUser;
}
Expand Down
11 changes: 10 additions & 1 deletion src/dataStructure/ExternalProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*
* @property AttrItem $external_attr 属性列表,目前支持文本、网页、小程序三种类型
* @property string $external_corp_name 企业对外简称,需从已认证的企业简称中选填。可在“我的企业”页中查看企业简称认证状态。
* @property array $wechat_channels 企业微信视频号相关属性,若企业未认证或未开通视频号,返回结果中该节点将不包含该字段
*
* @package dovechen\yii2\weWork\src\dataStructure
*/
Expand All @@ -30,12 +31,20 @@ public static function parseFromArray ($arr)

$externalAttr = Utils::arrayGet($arr, "external_attr");
if (!is_null($externalAttr) && !empty($externalAttr)) {
$externalProfile->external_attr = [];
$externalProfile->external_attr = [];
foreach ($externalAttr as $attr) {
array_push($externalProfile->external_attr, AttrItem::parseFromArray($attr));
}
}

$wechatChannels = Utils::arrayGet($arr, "wechat_channels");
if (!is_null($wechatChannels) && !empty($wechatChannels)) {
$externalProfile->wechat_channels = [
'nickname' => Utils::arrayGet($wechatChannels, 'nickname'),
'status' => Utils::arrayGet($wechatChannels, 'status'),
];
}

return $externalProfile;
}
}

0 comments on commit d127ddd

Please sign in to comment.