diff --git a/README.md b/README.md index 3b008d4..7a6f620 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,8 @@ This package makes it easy to send [Mobtexting notifications](https://mobtexting You can install the package via pip : ``` bash -pip install git+git://github.com/mobtexting/mobtexting-python.git --user +pip instal + l git+git://github.com/mobtexting/mobtexting-python.git --user ``` ## Send SMS Usage @@ -28,6 +29,37 @@ response = client.send( print response.json() ``` +##Voice +### Voice Click2call +```python +from mobtexting.voice import Voice +# enter the following details +access_token = 'XXXXXXXXXXXXX' +bridge="DID Number" +_from="number with country code" +to="Phone number with Country Code / IVR flow to which call has to connect" + +voice = Voice(access_token) +response=voice.c2c( bridge, _from, to) +print(response.json()) +``` +### Voice Call Logs Report +```python +start_date="mm/dd/yyyy" +end_date="mm/dd/yyyy" +response=voice.call_logs(start_date,end_date) +print(response.json()) +``` + +### Voice Call Recording Report +```python +start_date="mm/dd/yyyy" +end_date="mm/dd/yyyy" +response=voice.recordings(start_date,end_date) +print(response.json()) +``` +visit [documentation](https://portal.mobtexting.com/docs/v2/verify "documentation") for a list of all parameters + ## Verify Usage ```python diff --git a/mobtexting/voice.py b/mobtexting/voice.py new file mode 100644 index 0000000..a1549ef --- /dev/null +++ b/mobtexting/voice.py @@ -0,0 +1,32 @@ +import requests + + +class Voice: + api_endpoint = 'https://portal.mobtexting.com/api/v2/' + + def __init__(self, access_token): + self.access_token = access_token + self.headers = { + 'Accept': 'application/json', + 'Authorization': access_token + } + + def c2c(self, bridge, _from, to, data={}): + url = self.api_endpoint + 'voice/c2c?access_token=' + self.access_token + '&bridge=' + bridge + '&from=' + _from + '&to=' + to + r = requests.get(url, headers=self.headers, data=data) + return r + + def c2c_post(self, bridge, _from, to, data={}): + url = self.api_endpoint + 'voice/c2c?access_token=' + self.access_token + '&bridge=' + bridge + '&from=' + _from + '&to=' + to + r = requests.post(url, headers=self.headers, data=data) + return r + + def call_logs(self, start_date, end_date): + url = self.api_endpoint + 'voice/calls?access_token=' + self.access_token + '&datetime[end_at]=' + start_date + '-' + end_date + response = requests.get(url, headers=self.headers) + return response + + def recordings(self, start_date, end_date): + url = self.api_endpoint + 'voice/calls?access_token=' + self.access_token + '&datetime[r.created_at]=' + start_date + '+' + end_date + response = requests.get(url, self.headers) + return response