Skip to content

Commit 34c9c21

Browse files
committed
added view call method and test
1 parent fb6d652 commit 34c9c21

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

messagebird/client.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import json
33

44
from messagebird.balance import Balance
5+
from messagebird.call import Call
56
from messagebird.contact import Contact, ContactList
67
from messagebird.error import Error
78
from messagebird.group import Group, GroupList
@@ -28,6 +29,9 @@
2829
CONVERSATION_WEB_HOOKS_PATH = 'webhooks'
2930
CONVERSATION_TYPE = 'conversation'
3031

32+
VOICE_API_ROOT='https://voice.messagebird.com/'
33+
VOICE_TYPE = 'voice'
34+
3135

3236
class ErrorException(Exception):
3337
def __init__(self, errors):
@@ -48,6 +52,9 @@ def _get_http_client(self, type=REST_TYPE):
4852
if type == REST_TYPE:
4953
return HttpClient(ENDPOINT, self.access_key, USER_AGENT)
5054

55+
if type == VOICE_TYPE:
56+
return HttpClient(VOICE_API_ROOT, self.access_key, USER_AGENT)
57+
5158
return HttpClient(CONVERSATION_API_ROOT, self.access_key, USER_AGENT)
5259

5360
def request(self, path, method='GET', params=None, type=REST_TYPE):
@@ -86,6 +93,10 @@ def balance(self):
8693
"""Retrieve your balance."""
8794
return Balance().load(self.request('balance'))
8895

96+
def call(self,id):
97+
"""Retrieve the information of a specific call"""
98+
return Call().load(self.request('calls/' + str(id), 'GET', None, VOICE_TYPE))
99+
89100
def hlr(self, id):
90101
"""Retrieve the information of a specific HLR lookup."""
91102
return HLR().load(self.request('hlr/' + str(id)))

messagebird/http_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def request(self, path, method='GET', params=None):
2121
"""Builds a request and gets a response."""
2222
if params is None: params = {}
2323
url = urljoin(self.endpoint, path)
24-
24+
print url
2525
headers = {
2626
'Accept': 'application/json',
2727
'Authorization': 'AccessKey ' + self.access_key,
@@ -46,5 +46,5 @@ def request(self, path, method='GET', params=None):
4646
response_text = response.text
4747
else:
4848
response.raise_for_status()
49-
49+
5050
return response_text

0 commit comments

Comments
 (0)