Skip to content
Snippets Groups Projects
Commit f637cd33 authored by Nico's avatar Nico
Browse files

Revise PrivatChat class

parent eab66ddd
No related branches found
No related tags found
1 merge request!4More test coverage
......@@ -4,8 +4,7 @@
from urllib.parse import urljoin
from requests import get as _get
from requests import post as _post
import requests
from briar_wrapper.constants import BASE_HTTP_URL
from briar_wrapper.model import Model
......@@ -15,20 +14,17 @@ class PrivateChat(Model):
API_ENDPOINT = "messages/"
_contact_id = 0
_on_message_received_callback = None
def __init__(self, api, contact_id):
super().__init__(api)
self._contact_id = contact_id
def get(self):
url = urljoin(BASE_HTTP_URL,
self.API_ENDPOINT + "/%d" % self._contact_id)
request = _get(url, headers=self._headers)
self.API_ENDPOINT + str(self._contact_id))
request = requests.get(url, headers=self._headers)
return request.json()
def send(self, message):
url = urljoin(BASE_HTTP_URL,
self.API_ENDPOINT + "/%i" % self._contact_id)
_post(url, headers=self._headers, json={"text": message})
self.API_ENDPOINT + str(self._contact_id))
requests.post(url, headers=self._headers, json={"text": message})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment