diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..1bf936e --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,28 @@ +name: Deploy Workflow +on: + push: + tags: + - "*" +jobs: + build: + name: Build + strategy: + matrix: + python-version: [2.7] + runs-on: ubuntu-latest + container: python:${{ matrix.python-version }} + steps: + - uses: actions/checkout@v4 + - run: python --version + - run: pip install -r requirements.txt + - run: | + pip install black + black . --check + if: matrix.python-version == '3.12' + - run: python setup.py test + - run: pip install twine wheel + - run: python setup.py sdist bdist_wheel + - run: python -m twine upload -u ${PYPI_USERNAME} -p ${PYPI_PASSWORD} dist/* + env: + PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }} + PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..bd53800 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,55 @@ +name: Main Workflow +on: [push] +jobs: + build: + name: Build + strategy: + matrix: + python-version: [ + 2.7, + 3.5, + 3.6, + 3.7, + 3.8, + 3.9, + "3.10", + "3.11", + "3.12", + latest, + rc + ] + runs-on: ubuntu-latest + container: python:${{ matrix.python-version }} + steps: + - uses: actions/checkout@v4 + - run: python --version + - run: pip install -r requirements.txt + - run: | + pip install black + black . --check + if: matrix.python-version == '3.12' + - run: | + pip install pytest + pytest + - run: python setup.py test + if: matrix.python-version != '3.12' && matrix.python-version != 'latest' + build-pypy: + name: Build PyPy + strategy: + matrix: + python-version: [2.7, 3.6, 3.9, "3.10"] + runs-on: ubuntu-latest + container: pypy:${{ matrix.python-version }} + steps: + - uses: actions/checkout@v4 + - run: pypy --version + - run: pip install -r requirements.txt + - run: | + pip install black + black . --check + if: matrix.python-version == '3.12' + - run: | + pip install pytest + pytest + - run: pypy setup.py test + if: matrix.python-version != '3.12' && matrix.python-version != 'latest' diff --git a/.gitignore b/.gitignore index cd8a821..fdb64a8 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,8 @@ session.shelve* +/.venv + /dist /build /src/twilio_api.egg-info diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 6237648..0000000 --- a/.travis.yml +++ /dev/null @@ -1,25 +0,0 @@ -dist: trusty -language: python -python: - - "2.7" - - "3.4" - - "3.5" - - "3.6" - - "pypy3" -matrix: - include: - - python: 3.8 - dist: xenial - - python: 3.9 - dist: xenial - - python: pypy - dist: xenial - - python: pypy3 - dist: xenial -before_install: - - pip install --upgrade pip setuptools -install: - - pip install -r requirements.txt - - if [[ $TRAVIS_PYTHON_VERSION != pypy* ]]; then pip install coveralls; fi -script: if [[ $TRAVIS_PYTHON_VERSION != pypy* ]]; then coverage run --source=twilio setup.py test; else python setup.py test; fi -after_success: if [[ $TRAVIS_PYTHON_VERSION != pypy* ]]; then coveralls; fi diff --git a/README.md b/README.md index 01f52b2..23097b6 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Twilio API is currently licensed under the [Apache License, Version 2.0](http:// ## Build Automation -[![Build Status](https://app.travis-ci.com/hivesolutions/twilio-api.svg?branch=master)](https://travis-ci.com/github/hivesolutions/twilio-api) +[![Build Status](https://github.com/hivesolutions/twilio-api/workflows/Main%20Workflow/badge.svg)](https://github.com/hivesolutions/twilio-api/actions) [![Coverage Status](https://coveralls.io/repos/hivesolutions/twilio-api/badge.svg?branch=master)](https://coveralls.io/r/hivesolutions/twilio-api?branch=master) [![PyPi Status](https://img.shields.io/pypi/v/twilio-api.svg)](https://pypi.python.org/pypi/twilio-api) [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://www.apache.org/licenses/) diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..77633fc --- /dev/null +++ b/pytest.ini @@ -0,0 +1,3 @@ +[pytest] +python_files = *.py +testpaths = src/twilio/test diff --git a/setup.py b/setup.py index 42e95e3..a5818dc 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # Hive Twilio API -# Copyright (c) 2008-2020 Hive Solutions Lda. +# Copyright (c) 2008-2024 Hive Solutions Lda. # # This file is part of Hive Twilio API. # @@ -22,16 +22,7 @@ __author__ = "João Magalhães " """ The author(s) of the module """ -__version__ = "1.0.0" -""" The version of the module """ - -__revision__ = "$LastChangedRevision$" -""" The revision number of the module """ - -__date__ = "$LastChangedDate$" -""" The last change date of the module """ - -__copyright__ = "Copyright (c) 2008-2020 Hive Solutions Lda." +__copyright__ = "Copyright (c) 2008-2024 Hive Solutions Lda." """ The copyright for the module """ __license__ = "Apache License, Version 2.0" @@ -41,25 +32,20 @@ import setuptools setuptools.setup( - name = "twilio-api", - version = "0.1.2", - author = "Hive Solutions Lda.", - author_email = "development@hive.pt", - description = "Twilio API Client", - license = "Apache License, Version 2.0", - keywords = "twilio api", - url = "http://twilio-api.hive.pt", - zip_safe = False, - packages = [ - "twilio" - ], - package_dir = { - "" : os.path.normpath("src") - }, - install_requires = [ - "appier" - ], - classifiers = [ + name="twilio-api", + version="0.1.2", + author="Hive Solutions Lda.", + author_email="development@hive.pt", + description="Twilio API Client", + license="Apache License, Version 2.0", + keywords="twilio api", + url="http://twilio-api.hive.pt", + zip_safe=False, + packages=["twilio"], + test_suite="nexmo.test", + package_dir={"": os.path.normpath("src")}, + install_requires=["appier"], + classifiers=[ "Development Status :: 3 - Alpha", "Topic :: Utilities", "License :: OSI Approved :: Apache Software License", @@ -74,8 +60,10 @@ "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7" + "Programming Language :: Python :: 3.7", ], - long_description = open(os.path.join(os.path.dirname(__file__), "README.md"), "rb").read().decode("utf-8"), - long_description_content_type = "text/markdown" + long_description=open(os.path.join(os.path.dirname(__file__), "README.md"), "rb") + .read() + .decode("utf-8"), + long_description_content_type="text/markdown", ) diff --git a/src/examples/__init__.py b/src/examples/__init__.py index 9c2a8ef..38303ca 100644 --- a/src/examples/__init__.py +++ b/src/examples/__init__.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # Hive Twilio API -# Copyright (c) 2008-2020 Hive Solutions Lda. +# Copyright (c) 2008-2024 Hive Solutions Lda. # # This file is part of Hive Twilio API. # @@ -19,16 +19,7 @@ # You should have received a copy of the Apache License along with # Hive Twilio API. If not, see . -__version__ = "1.0.0" -""" The version of the module """ - -__revision__ = "$LastChangedRevision$" -""" The revision number of the module """ - -__date__ = "$LastChangedDate$" -""" The last change date of the module """ - -__copyright__ = "Copyright (c) 2008-2020 Hive Solutions Lda." +__copyright__ = "Copyright (c) 2008-2024 Hive Solutions Lda." """ The copyright for the module """ __license__ = "Apache License, Version 2.0" diff --git a/src/examples/app.py b/src/examples/app.py index b946f95..a22443a 100644 --- a/src/examples/app.py +++ b/src/examples/app.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # Hive Twilio API -# Copyright (c) 2008-2020 Hive Solutions Lda. +# Copyright (c) 2008-2024 Hive Solutions Lda. # # This file is part of Hive Twilio API. # @@ -22,16 +22,7 @@ __author__ = "João Magalhães " """ The author(s) of the module """ -__version__ = "1.0.0" -""" The version of the module """ - -__revision__ = "$LastChangedRevision$" -""" The revision number of the module """ - -__date__ = "$LastChangedDate$" -""" The last change date of the module """ - -__copyright__ = "Copyright (c) 2008-2020 Hive Solutions Lda." +__copyright__ = "Copyright (c) 2008-2024 Hive Solutions Lda." """ The copyright for the module """ __license__ = "Apache License, Version 2.0" @@ -41,14 +32,11 @@ from . import base + class TwilioApp(appier.WebApp): def __init__(self, *args, **kwargs): - appier.WebApp.__init__( - self, - name = "twilio", - *args, **kwargs - ) + appier.WebApp.__init__(self, name="twilio", *args, **kwargs) @appier.route("/", "GET") def index(self): @@ -72,6 +60,7 @@ def message(self): def get_api(self): return base.get_api() + if __name__ == "__main__": app = TwilioApp() app.serve() diff --git a/src/examples/base.py b/src/examples/base.py index 66ffdf4..f2d3c79 100644 --- a/src/examples/base.py +++ b/src/examples/base.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # Hive Twilio API -# Copyright (c) 2008-2020 Hive Solutions Lda. +# Copyright (c) 2008-2024 Hive Solutions Lda. # # This file is part of Hive Twilio API. # @@ -22,16 +22,7 @@ __author__ = "João Magalhães " """ The author(s) of the module """ -__version__ = "1.0.0" -""" The version of the module """ - -__revision__ = "$LastChangedRevision$" -""" The revision number of the module """ - -__date__ = "$LastChangedDate$" -""" The last change date of the module """ - -__copyright__ = "Copyright (c) 2008-2020 Hive Solutions Lda." +__copyright__ = "Copyright (c) 2008-2024 Hive Solutions Lda." """ The copyright for the module """ __license__ = "Apache License, Version 2.0" @@ -41,8 +32,8 @@ import twilio + def get_api(): return twilio.API( - sid = appier.conf("TWILIO_SID"), - auth_token = appier.conf("TWILIO_AUTH_TOKEN") + sid=appier.conf("TWILIO_SID"), auth_token=appier.conf("TWILIO_AUTH_TOKEN") ) diff --git a/src/twilio/__init__.py b/src/twilio/__init__.py index 769eb73..a2b3008 100644 --- a/src/twilio/__init__.py +++ b/src/twilio/__init__.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # Hive Twilio API -# Copyright (c) 2008-2020 Hive Solutions Lda. +# Copyright (c) 2008-2024 Hive Solutions Lda. # # This file is part of Hive Twilio API. # @@ -19,16 +19,7 @@ # You should have received a copy of the Apache License along with # Hive Twilio API. If not, see . -__version__ = "1.0.0" -""" The version of the module """ - -__revision__ = "$LastChangedRevision$" -""" The revision number of the module """ - -__date__ = "$LastChangedDate$" -""" The last change date of the module """ - -__copyright__ = "Copyright (c) 2008-2020 Hive Solutions Lda." +__copyright__ = "Copyright (c) 2008-2024 Hive Solutions Lda." """ The copyright for the module """ __license__ = "Apache License, Version 2.0" diff --git a/src/twilio/account.py b/src/twilio/account.py index 3f5ef52..3e997d2 100644 --- a/src/twilio/account.py +++ b/src/twilio/account.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # Hive Twilio API -# Copyright (c) 2008-2020 Hive Solutions Lda. +# Copyright (c) 2008-2024 Hive Solutions Lda. # # This file is part of Hive Twilio API. # @@ -22,24 +22,16 @@ __author__ = "João Magalhães " """ The author(s) of the module """ -__version__ = "1.0.0" -""" The version of the module """ - -__revision__ = "$LastChangedRevision$" -""" The revision number of the module """ - -__date__ = "$LastChangedDate$" -""" The last change date of the module """ - -__copyright__ = "Copyright (c) 2008-2020 Hive Solutions Lda." +__copyright__ = "Copyright (c) 2008-2024 Hive Solutions Lda." """ The copyright for the module """ __license__ = "Apache License, Version 2.0" """ The license for the module """ + class AccountAPI(object): - def usage_account(self, period = "LastMonth"): + def usage_account(self, period="LastMonth"): url = self.account_url + "Usage/Records/%s.json" % period contents = self.get(url) return contents diff --git a/src/twilio/base.py b/src/twilio/base.py index a2ae7f5..5931dc9 100644 --- a/src/twilio/base.py +++ b/src/twilio/base.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # Hive Twilio API -# Copyright (c) 2008-2020 Hive Solutions Lda. +# Copyright (c) 2008-2024 Hive Solutions Lda. # # This file is part of Hive Twilio API. # @@ -22,16 +22,7 @@ __author__ = "João Magalhães " """ The author(s) of the module """ -__version__ = "1.0.0" -""" The version of the module """ - -__revision__ = "$LastChangedRevision$" -""" The revision number of the module """ - -__date__ = "$LastChangedDate$" -""" The last change date of the module """ - -__copyright__ = "Copyright (c) 2008-2020 Hive Solutions Lda." +__copyright__ = "Copyright (c) 2008-2024 Hive Solutions Lda." """ The copyright for the module """ __license__ = "Apache License, Version 2.0" @@ -51,11 +42,8 @@ going to be used in the construction of the secure URL version of the URL """ -class API( - appier.API, - account.AccountAPI, - message.MessageAPI -): + +class API(appier.API, account.AccountAPI, message.MessageAPI): def __init__(self, *args, **kwargs): appier.API.__init__(self, *args, **kwargs) @@ -69,8 +57,8 @@ def __init__(self, *args, **kwargs): def _build_url(self): if not self.sid: - raise appier.OperationalError(message = "No account sid provided") + raise appier.OperationalError(message="No account sid provided") if not self.auth_token: - raise appier.OperationalError(message = "No auth token provided") + raise appier.OperationalError(message="No auth token provided") self.secure_url = self.base_template % (self.sid, self.auth_token) self.account_url = self.secure_url + "Accounts/%s/" % self.sid diff --git a/src/twilio/message.py b/src/twilio/message.py index 6735045..19b0ead 100644 --- a/src/twilio/message.py +++ b/src/twilio/message.py @@ -2,7 +2,7 @@ # -*- coding: utf-8 -*- # Hive Twilio API -# Copyright (c) 2008-2020 Hive Solutions Lda. +# Copyright (c) 2008-2024 Hive Solutions Lda. # # This file is part of Hive Twilio API. # @@ -22,33 +22,17 @@ __author__ = "João Magalhães " """ The author(s) of the module """ -__version__ = "1.0.0" -""" The version of the module """ - -__revision__ = "$LastChangedRevision$" -""" The revision number of the module """ - -__date__ = "$LastChangedDate$" -""" The last change date of the module """ - -__copyright__ = "Copyright (c) 2008-2020 Hive Solutions Lda." +__copyright__ = "Copyright (c) 2008-2024 Hive Solutions Lda." """ The copyright for the module """ __license__ = "Apache License, Version 2.0" """ The license for the module """ + class MessageAPI(object): - def send_message(self, sender, receiver, body = None, media_url = None): + def send_message(self, sender, receiver, body=None, media_url=None): url = self.account_url + "Messages.json" - kwargs = { - "From" : sender, - "To" : receiver - } - contents = self.post( - url, - Body = body, - MediaUrl = media_url, - **kwargs - ) + kwargs = {"From": sender, "To": receiver} + contents = self.post(url, Body=body, MediaUrl=media_url, **kwargs) return contents diff --git a/src/twilio/test/__init__.py b/src/twilio/test/__init__.py new file mode 100644 index 0000000..d048679 --- /dev/null +++ b/src/twilio/test/__init__.py @@ -0,0 +1,26 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Hive Twilio API +# Copyright (c) 2008-2024 Hive Solutions Lda. +# +# This file is part of Hive Twilio API. +# +# Hive Twilio API is free software: you can redistribute it and/or modify +# it under the terms of the Apache License as published by the Apache +# Foundation, either version 2.0 of the License, or (at your option) any +# later version. +# +# Hive Twilio API is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# Apache License for more details. +# +# You should have received a copy of the Apache License along with +# Hive Twilio API. If not, see . + +__copyright__ = "Copyright (c) 2008-2024 Hive Solutions Lda." +""" The copyright for the module """ + +__license__ = "Apache License, Version 2.0" +""" The license for the module """ diff --git a/src/twilio/test/base.py b/src/twilio/test/base.py new file mode 100644 index 0000000..4da0426 --- /dev/null +++ b/src/twilio/test/base.py @@ -0,0 +1,37 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Hive Twilio API +# Copyright (c) 2008-2024 Hive Solutions Lda. +# +# This file is part of Hive Twilio API. +# +# Hive Twilio API is free software: you can redistribute it and/or modify +# it under the terms of the Apache License as published by the Apache +# Foundation, either version 2.0 of the License, or (at your option) any +# later version. +# +# Hive Twilio API is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# Apache License for more details. +# +# You should have received a copy of the Apache License along with +# Hive Twilio API. If not, see . + +__author__ = "João Magalhães " +""" The author(s) of the module """ + +__copyright__ = "Copyright (c) 2008-2024 Hive Solutions Lda." +""" The copyright for the module """ + +__license__ = "Apache License, Version 2.0" +""" The license for the module """ + +import unittest + + +class BaseTest(unittest.TestCase): + + def test_basic(self): + self.assertEqual(1 + 1, 2)