示例#1
0
 async def create(cls) -> MiniProgram:
     """
     static create MiniProgram method
     :return:
     """
     log.info('MiniProgram created')
     # TODO -> create default mini_program payload
     payload = MiniProgramPayload()
     return MiniProgram(payload)
    def create_from_json(cls, payload_data: dict) -> MiniProgram:
        """
        create the mini_program from json data
        """
        log.info(f'loading the mini-program from json data <{payload_data}>')

        payload = MiniProgramPayload(**payload_data)

        mini_program = cls(payload=payload)
        return mini_program
 async def message_mini_program(self, message_id: str) -> MiniProgramPayload:
     """
     extract mini_program from message
     :param message_id:
     :return:
     """
     # TODO -> need to MiniProgram
     # response = await self.puppet_stub.message_mini_program(id=message_id)
     # return MiniProgramPayload(response.mini_program)
     return MiniProgramPayload()
示例#4
0
    async def message_mini_program(self, message_id: str) -> MiniProgramPayload:
        """
        extract mini_program from message
        :param message_id:
        :return:
        """
        # TODO -> need to MiniProgram
        if self.puppet_stub is None:
            raise Exception('puppet_stub should not be none')

        response = await self.puppet_stub.message_mini_program(id=message_id)
        response_dict = json.loads(response.mini_program)
        try:
            mini_program = MiniProgramPayload(**response_dict)
        except Exception as e:
            raise WechatyPuppetPayloadError(f'can"t init mini-program payload {response_dict}')\
                from e
        return mini_program
示例#5
0
 async def create(cls) -> MiniProgram:
     """
     static create MiniProgram method
     :return:
     """
     log.info('MiniProgram created')
     # TODO -> create default mini_program payload
     default_mini_program = {
         "app_id": "todo",
         "description": "todo",
         "page_path": "todo",
         "thumb_key": "",
         "thumb_url": "",
         "title": "",
         "user_name": ""
     }
     payload = MiniProgramPayload(*default_mini_program)
     return MiniProgram(payload)