MCPcopy
hub / github.com/wechaty/python-wechaty / from_json

Method from_json

src/wechaty/user/friendship.py:252–276  ·  view source on GitHub ↗

create friendShip by friendshipJson Args: json_data: the json data of the friendship Examples: >>> friendship = Friendship.from_json(friendshipJson) Returns: Friendship: the friendship created

(
        cls,
        json_data: Union[str, FriendshipPayload]
    )

Source from the content-addressed store, hash-verified

250
251 @classmethod
252 async def from_json(
253 cls,
254 json_data: Union[str, FriendshipPayload]
255 ) -> Friendship:
256 """
257 create friendShip by friendshipJson
258 Args:
259 json_data: the json data of the friendship
260 Examples:
261 >>> friendship = Friendship.from_json(friendshipJson)
262 Returns:
263 Friendship: the friendship created
264 """
265 log.info('from_json() <%s>', json_data)
266 if isinstance(json_data, str):
267 payload = FriendshipPayload(**json.loads(json_data))
268 else:
269 payload = json_data
270
271 await cls.get_puppet().friendship_payload(
272 friendship_id=payload.id, payload=payload
273 )
274 friendship = cls.get_wechaty().Friendship.load(payload.contact_id)
275 await friendship.ready()
276 return friendship

Callers 1

message_fileMethod · 0.45

Calls 5

friendship_payloadMethod · 0.80
get_puppetMethod · 0.80
get_wechatyMethod · 0.80
loadMethod · 0.45
readyMethod · 0.45

Tested by

no test coverage detected