| Total Complexity | 6 |
| Total Lines | 37 |
| Duplicated Lines | 0 % |
| Coverage | 33.33% |
| 1 | # -*- coding: utf-8 -*- |
||
| 7 | 10 | class WeChatMenu(BaseWeChatAPI): |
|
| 8 | |||
| 9 | 10 | def create(self, agent_id, menu_data): |
|
| 10 | return self._post( |
||
| 11 | 'menu/create', |
||
| 12 | params={ |
||
| 13 | 'agentid': agent_id |
||
| 14 | }, |
||
| 15 | data=menu_data |
||
| 16 | ) |
||
| 17 | |||
| 18 | 10 | def get(self, agent_id): |
|
| 19 | try: |
||
| 20 | return self._get( |
||
| 21 | 'menu/get', |
||
| 22 | params={ |
||
| 23 | 'agentid': agent_id |
||
| 24 | } |
||
| 25 | ) |
||
| 26 | except WeChatClientException as e: |
||
| 27 | if e.errcode == 46003: |
||
| 28 | # menu not exist |
||
| 29 | return None |
||
| 30 | else: |
||
| 31 | raise e |
||
| 32 | |||
| 33 | 10 | def delete(self, agent_id): |
|
| 34 | return self._get( |
||
| 35 | 'menu/delete', |
||
| 36 | params={ |
||
| 37 | 'agentid': agent_id |
||
| 38 | } |
||
| 39 | ) |
||
| 40 | |||
| 41 | 10 | def update(self, agent_id, menu_data): |
|
| 42 | self.delete(agent_id) |
||
| 43 | return self.create(agent_id, menu_data) |
||
| 44 |