/usr/lib/python2.7/dist-packages/exotel/exotel.py is in python-exotel 0.1.5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | # -*- coding: utf-8 -*-
import datetime
import requests
from ._compat import urljoin
class Exotel:
def __init__(self,sid,token, baseurl='https://twilix.exotel.in/'):
self.sid = sid
self.token = token
self.baseurl = urljoin(baseurl, 'v1/Accounts/{sid}/'.format(sid=sid))
def sms(self, from_number, to, body,encoding_type = "plain", priority = "normal", status_callback = None ):
"""
sms - sends sms using exotel api
"""
return requests.post(urljoin(self.baseurl, 'Sms/send.json'),
auth = (self.sid, self.token),
data = {
'From': from_number,
'To': to,
'Body': body,
'EncodingType':encoding_type,
'Priority' : priority,
'StatusCallback' : status_callback
})
def call_flow(self,from_number,caller_id,flow_id,timelimit = 14400,timeout = 30,status_callback=None,custom_data = None):
"""
call_flow -creates a call to from_number and flow_id with the exophone(caller_id)
"""
return requests.post(urljoin(self.baseurl, 'Calls/connect.json'),
auth=(self.sid, self.token),
data={
'From': from_number,
'CallerId': caller_id,
'Url': "http://my.exotel.in/exoml/start/{flow_id}".format(flow_id=flow_id),
'TimeLimit': timelimit,
'CallType': "trans",
'TimeOut' : timeout,
'StatusCallback' : status_callback,
'CustomField' : custom_data
})
def call_number(self, from_number, caller_id, to,timelimit = 14400,timeout = 30,status_callback=None,custom_data = None):
"""
call_number -creates a call to from_number and then to with the exophone(caller_id)
"""
return requests.post(urljoin(self.baseurl, 'Calls/connect.json'),
auth=(self.sid, self.token),
data={
'From': from_number,
'CallerId': caller_id,
'To': to,
'TimeLimit': timelimit,
'CallType': "trans",
'TimeOut' : timeout,
'CustomField' : custom_data,
'StatusCallback' : status_callback
})
def call_details(self, call_sid):
"""
call_details - returns call details object as a response object
"""
return requests.get(urljoin(self.baseurl, 'Calls/{}.json'.format(call_sid)), auth=(self.sid, self.token))
def sms_details(self, sms_sid):
"""
sms_details - returns sms details object as a response object provided the sms sid
"""
return requests.get(urljoin(self.baseurl, 'Sms/Messages/{}.json'.format(sms_sid)), auth=(self.sid, self.token))
|