Skip to content

Commit

Permalink
chore: major code re-structure
Browse files Browse the repository at this point in the history
Removes travis and replaced with github actions.
Ran black to format the code.
Updated the README.md file to include the new changes.
  • Loading branch information
joamag committed Nov 9, 2024
1 parent 8f3e2e2 commit 1ca55e6
Show file tree
Hide file tree
Showing 16 changed files with 202 additions and 162 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -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 }}
55 changes: 55 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -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'
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

session.shelve*

/.venv

/dist
/build
/src/twilio_api.egg-info
25 changes: 0 additions & 25 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/)
3 changes: 3 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[pytest]
python_files = *.py
testpaths = src/twilio/test
54 changes: 21 additions & 33 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand All @@ -22,16 +22,7 @@
__author__ = "João Magalhães <[email protected]>"
""" 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"
Expand All @@ -41,25 +32,20 @@
import setuptools

setuptools.setup(
name = "twilio-api",
version = "0.1.2",
author = "Hive Solutions Lda.",
author_email = "[email protected]",
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="[email protected]",
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",
Expand All @@ -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",
)
13 changes: 2 additions & 11 deletions src/examples/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand All @@ -19,16 +19,7 @@
# You should have received a copy of the Apache License along with
# Hive Twilio API. If not, see <http://www.apache.org/licenses/>.

__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"
Expand Down
21 changes: 5 additions & 16 deletions src/examples/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand All @@ -22,16 +22,7 @@
__author__ = "João Magalhães <[email protected]>"
""" 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"
Expand All @@ -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):
Expand All @@ -72,6 +60,7 @@ def message(self):
def get_api(self):
return base.get_api()


if __name__ == "__main__":
app = TwilioApp()
app.serve()
Expand Down
17 changes: 4 additions & 13 deletions src/examples/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand All @@ -22,16 +22,7 @@
__author__ = "João Magalhães <[email protected]>"
""" 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"
Expand All @@ -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")
)
13 changes: 2 additions & 11 deletions src/twilio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand All @@ -19,16 +19,7 @@
# You should have received a copy of the Apache License along with
# Hive Twilio API. If not, see <http://www.apache.org/licenses/>.

__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"
Expand Down
16 changes: 4 additions & 12 deletions src/twilio/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand All @@ -22,24 +22,16 @@
__author__ = "João Magalhães <[email protected]>"
""" 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
Loading

0 comments on commit 1ca55e6

Please sign in to comment.