Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
32 changes: 32 additions & 0 deletions mobtexting/voice.py
Original file line number Diff line number Diff line change
@@ -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