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]
)
| 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 |
no test coverage detected