Conditions | 3 |
Total Lines | 35 |
Code Lines | 21 |
Lines | 0 |
Ratio | 0 % |
Tests | 1 |
CRAP Score | 9.762 |
Changes | 0 |
Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.
There are several approaches to avoid long parameter lists:
1 | # -*- coding: utf-8 -*- |
||
39 | 10 | def set(self, |
|
40 | agent_id, |
||
41 | name=None, |
||
42 | description=None, |
||
43 | redirect_domain=None, |
||
44 | logo_media_id=None, |
||
45 | report_location_flag=0, |
||
46 | is_report_user=True, |
||
47 | is_report_enter=True): |
||
48 | """ |
||
49 | 设置应用 |
||
50 | https://work.weixin.qq.com/api/doc#90000/90135/90228 |
||
51 | |||
52 | :param agent_id: 企业应用的id |
||
53 | :param name: 企业应用名称,长度不超过32个utf8字符 |
||
54 | :param description: 企业应用详情,长度为4至120个utf8字符 |
||
55 | :param redirect_domain: 企业应用可信域名。注意:域名需通过所有权校验,否则jssdk功能将受限,此时返回错误码85005 |
||
56 | :param logo_media_id: 企业应用头像的mediaid,通过素材管理接口上传图片获得mediaid,上传后会自动裁剪成方形和圆形两个头像 |
||
57 | :param report_location_flag: 企业应用是否打开地理位置上报 0:不上报;1:进入会话上报; |
||
58 | :param is_report_enter: 是否上报用户进入应用事件。0:不接收;1:接收。 |
||
59 | :param is_report_user: 是否接收用户变更通知。0:不接收;1:接收。 |
||
60 | :return: 返回的 JSON 数据包 |
||
61 | """ |
||
62 | agent_data = optionaldict() |
||
63 | agent_data['agentid'] = agent_id |
||
64 | agent_data['name'] = name |
||
65 | agent_data['description'] = description |
||
66 | agent_data['redirect_domain'] = redirect_domain |
||
67 | agent_data['logo_mediaid'] = logo_media_id |
||
68 | agent_data['report_location_flag'] = report_location_flag |
||
69 | agent_data['isreportenter'] = 1 if is_report_enter else 0 |
||
70 | agent_data['isreportuser'] = 1 if is_report_user else 0 |
||
71 | return self._post( |
||
72 | 'agent/set', |
||
73 | data=agent_data |
||
74 | ) |
||
75 |