mirror of
https://github.com/status-im/status-go.git
synced 2025-02-11 22:37:41 +00:00
41 lines
1.5 KiB
Python
41 lines
1.5 KiB
Python
|
from clients.rpc import RpcClient
|
||
|
from clients.services.service import Service
|
||
|
|
||
|
|
||
|
class WakuextService(Service):
|
||
|
def __init__(self, client: RpcClient):
|
||
|
super().__init__(client, "wakuext")
|
||
|
|
||
|
def send_contact_request(self, contact_id: str, message: str):
|
||
|
params = [{"id": contact_id, "message": message}]
|
||
|
response = self.rpc_request("sendContactRequest", params)
|
||
|
return response.json()
|
||
|
|
||
|
def accept_contact_request(self, request_id: str):
|
||
|
params = [{"id": request_id}]
|
||
|
response = self.rpc_request("acceptContactRequest", params)
|
||
|
return response.json()
|
||
|
|
||
|
def get_contacts(self):
|
||
|
response = self.rpc_request("contacts")
|
||
|
return response.json()
|
||
|
|
||
|
def send_message(self, contact_id: str, message: str):
|
||
|
params = [{"id": contact_id, "message": message}]
|
||
|
response = self.rpc_request("sendOneToOneMessage", params)
|
||
|
return response.json()
|
||
|
|
||
|
def start_messenger(self):
|
||
|
response = self.rpc_request("startMessenger")
|
||
|
json_response = response.json()
|
||
|
|
||
|
if "error" in json_response:
|
||
|
assert json_response["error"]["code"] == -32000
|
||
|
assert json_response["error"]["message"] == "messenger already started"
|
||
|
return
|
||
|
|
||
|
def create_group_chat_with_members(self, pubkey_list: list, group_chat_name: str):
|
||
|
params = [None, group_chat_name, pubkey_list]
|
||
|
response = self.rpc_request("createGroupChatWithMembers", params)
|
||
|
return response.json()
|