pax_global_header00006660000000000000000000000064131307530020014504gustar00rootroot0000000000000052 comment=bb86064ad1346c6cbac0631ec13b45221588a4d0 exotel-py-0.1.5/000077500000000000000000000000001313075300200134355ustar00rootroot00000000000000exotel-py-0.1.5/.coveragerc000066400000000000000000000001251313075300200155540ustar00rootroot00000000000000[run] branch = True source = exotel/ [paths] source = .tox/*/lib/*/site-packages/ exotel-py-0.1.5/.gitignore000066400000000000000000000001421313075300200154220ustar00rootroot00000000000000*~ /exotel.egg-info/ /venv/ build/ dist/ *.pyc /htmlcov/ /.coverage /.cache/ /.tox/ /__pycache__/ exotel-py-0.1.5/.travis.yml000066400000000000000000000007621313075300200155530ustar00rootroot00000000000000language: python python: - "2.7" - "3.3" - "3.4" - "3.5" - "3.5-dev" # 3.5 development branch - "3.6" - "3.6-dev" # 3.6 development branch - "3.7-dev" # 3.7 development branch - "nightly" # currently points to 3.7-dev # command to install dependencies install: "pip install -r requirements.txt" script: # TODO: use `tox-travis` to re-use build steps from `tox.ini`. - "python setup.py install" - "coverage run -m pytest -s -vv tests/" - "coverage report --fail-under=100" exotel-py-0.1.5/LICENCE.txt000066400000000000000000000022221313075300200152360ustar00rootroot00000000000000The MIT License (MIT) Copyright © 2015 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Fork this project to create your own MIT license that you can always link to. exotel-py-0.1.5/MANIFEST000066400000000000000000000001301313075300200145600ustar00rootroot00000000000000# file GENERATED by distutils, do NOT edit setup.py exotel/__init__.py exotel/exotel.py exotel-py-0.1.5/MANIFEST.in000066400000000000000000000000001313075300200151610ustar00rootroot00000000000000exotel-py-0.1.5/Makefile000066400000000000000000000000571313075300200150770ustar00rootroot00000000000000publish: python setup.py sdist upload -r pypi exotel-py-0.1.5/README.md000066400000000000000000000025141313075300200147160ustar00rootroot00000000000000# exotel-py # [![Join the chat at https://gitter.im/sarathsp06/exotel-py](https://badges.gitter.im/sarathsp06/exotel-py.svg)](https://gitter.im/sarathsp06/exotel-py?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Build Status](https://travis-ci.org/sarathsp06/exotel-py.svg?branch=master)](https://travis-ci.org/sarathsp06/exotel-py) Python module for exotels call and sms api's(Unofficial). ### installation ### ` pip install exotel ` ## Usage ## - Initialize ``` from exotel import Exotel client = Exotel(sid,token) ``` - make call to connect a number to another ``` client.call_number('from_number','exophone','to_number') ``` - make call to connect a number to a flow ``` client.call_flow('from_number','exophone','flow_id') ``` - send an sms ``` client.sms('from_number',to_number',"sms_body") ``` - get details of an sms ``` client.sms_details('sms_sid') ``` - get details of a call ``` client.call_details('call_sid') ``` ## Authors and Contributors ## In 2015, Sarath S Pllai ([@sarath_sp06](https://twitter.com/sarath_sp06)) started .Any bug reports would be addressed .Feel free to add more functions and send me the patch with updated README ## Support or Contact ## Having trouble using the library contact me at sarath.sp06@gmail.com exotel-py-0.1.5/README.rst000066400000000000000000000011751313075300200151300ustar00rootroot00000000000000exotel-py --------- Python module for exotels call and sms api’s installation ~~~~~~~~~~~~ ``pip install exotel`` Usage ----- - Initialize ``from exotel import Exotel`` ``client = Exotel(sid,token)`` - make call to connect a number to another ``client.call_number('from_number','exophone','to_number')`` - make call to connect a number to a flow ``client.call_flow('from_number','exophone','flow_id')`` - send an sms ``client.sms('from_number',to_number',"sms_body")`` - get details of an sms ``client.sms_details('sms_sid')`` - get details of a call ``client.call_details('call_sid')`` exotel-py-0.1.5/exotel/000077500000000000000000000000001313075300200147355ustar00rootroot00000000000000exotel-py-0.1.5/exotel/__init__.py000066400000000000000000000000331313075300200170420ustar00rootroot00000000000000from .exotel import Exotel exotel-py-0.1.5/exotel/_compat.py000066400000000000000000000002641313075300200167330ustar00rootroot00000000000000# -*- coding: utf-8 -*- try: # pragma: no cover # py3 from urllib.parse import urljoin except ImportError: # pragma: no cover # py2 from urlparse import urljoin exotel-py-0.1.5/exotel/exotel.py000066400000000000000000000052701313075300200166130ustar00rootroot00000000000000# -*- 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)) exotel-py-0.1.5/requirements.txt000066400000000000000000000001471313075300200167230ustar00rootroot00000000000000coverage==4.4.1 docutils==0.13.1 requests==2.18.1 requests-mock==1.3.0 pytest==3.1.3 pytest-cov==2.5.1 exotel-py-0.1.5/setup.py000066400000000000000000000022521313075300200151500ustar00rootroot00000000000000from setuptools import setup, find_packages setup( # Application name: name="exotel", # Version number (initial): version="0.1.5", # Application author details: author="sarath", author_email="sarath.sp06@gmail.com", # Packages packages=find_packages(), # Details url="https://github.com/sarathsp06/exotel-py", download_url = 'https://github.com/sarathsp06/exotel-py/archive/v0.1.5.tar.gz', license="LICENSE.txt", description="Python SDK for Exotel API[Unofficial]", long_description=""" exotel-py --------- Python module for exotels call and sms api's installation ~~~~~~~~~~~~ ``pip install exotel`` Usage ----- - Initialize ``from exotel import Exotel`` ``client = Exotel(sid,token)`` - make call to connect a number to another ``client.call_number('from_number','exophone','to_number')`` - make call to connect a number to a flow ``client.call_flow('from_number','exophone','flow_id')`` - send an sms ``client.sms('from_number',to_number',"sms_body")`` - get details of an sms ``client.sms_details('sms_sid')`` - get details of a call ``client.call_details('call_sid')`` """ ) exotel-py-0.1.5/tests/000077500000000000000000000000001313075300200145775ustar00rootroot00000000000000exotel-py-0.1.5/tests/conftest.py000066400000000000000000000003631313075300200170000ustar00rootroot00000000000000# -*- coding: utf-8 -*- import pytest import requests_mock @pytest.fixture(scope='function', autouse=True) def mock_http(): """pytest fixture to intercept outbound HTTP requests.""" with requests_mock.mock() as m: yield m exotel-py-0.1.5/tests/test_exotel.py000066400000000000000000000050101313075300200175040ustar00rootroot00000000000000# -*- coding: utf-8 -*- from exotel import Exotel def test_sms(mock_http): mock_http.register_uri( 'POST', 'https://twilix.exotel.in/v1/Accounts/123/Sms/send.json', text=''.join(( '', '', '...', '', )), ) e = Exotel(sid='123', token='abc') rep = e.sms( from_number='012-345-6789', to='345-678-9012', body='Hello, world!', ) assert rep.status_code == 200 def test_call_flow(mock_http): mock_http.register_uri( 'POST', 'https://twilix.exotel.in/v1/Accounts/123/Calls/connect.json', text=''.join(( '', '', '...', '', )), ) e = Exotel(sid='123', token='abc') rep = e.call_flow( from_number='012-345-6789', caller_id='345-678-9012', flow_id='345', ) assert rep.status_code == 200 def test_call_number(mock_http): mock_http.register_uri( 'POST', 'https://twilix.exotel.in/v1/Accounts/123/Calls/connect.json', text=''.join(( '', '', '...', '', )), ) e = Exotel(sid='123', token='abc') rep = e.call_number( from_number='012-345-6789', to='345-678-9012', caller_id='678-901-2345', ) assert rep.status_code == 200 def test_call_details(mock_http): mock_http.register_uri( 'GET', 'https://twilix.exotel.in/v1/Accounts/123/Calls/234.json', text=''.join(( '', '', '...', '', )), ) e = Exotel(sid='123', token='abc') rep = e.call_details(call_sid='234') assert rep.status_code == 200 def test_sms_details(mock_http): mock_http.register_uri( 'GET', 'https://twilix.exotel.in/v1/Accounts/123/Sms/Messages/234.json', text=''.join(( '', '', '...', '', )), ) e = Exotel(sid='123', token='abc') rep = e.sms_details(sms_sid='234') assert rep.status_code == 200 exotel-py-0.1.5/tox.ini000066400000000000000000000003451313075300200147520ustar00rootroot00000000000000[tox] envlist = py27,py35 [testenv] deps = -rrequirements.txt commands = py35: python setup.py check -s -r coverage erase coverage run -m pytest {posargs:-s -vv tests/} coverage html coverage report --fail-under=100