Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
“ADandyGuyInSpace” committed Feb 12, 2025
1 parent 64e1c23 commit 24265d7
Show file tree
Hide file tree
Showing 25 changed files with 110 additions and 69 deletions.
3 changes: 1 addition & 2 deletions .github/scripts/lint.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
if [[ $PYTHON_VERSION == '2.7' ]]; then make lint; fi
if [[ $PYTHON_VERSION == '3.7' ]]; then make fmtcheck; fi
if [[ $PYTHON_VERSION == '3.12' ]]; then make fmtcheck; fi
40 changes: 22 additions & 18 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Python
name: Python CI
on: [push]
jobs:
test:
Expand All @@ -10,26 +10,30 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v2
- name: Checkout Code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- uses: gabrielfalcao/pyenv-action@v7
with:
command: install
- uses: dschep/install-pipenv-action@v1
- name: setup-telnyx-prism-mock
run: source ./.github/scripts/before_install.sh
- name: init

- name: Install Pipenv
run: pip install pipenv

- name: Setup Telnyx Prism Mock
run: bash ./.github/scripts/before_install.sh

- name: Initialize Project
run: make init
- name: lint
run: source ./.github/scripts/lint.sh
env:
PYTHON_VERSION: ${{ matrix.python-version }}
- name: ci

- name: Lint Code
run: bash ./.github/scripts/lint.sh

- name: Run CI Tests
run: make ci
- name: coveralls
run: make coveralls

- name: Upload to Coveralls
run: make coveralls
36 changes: 36 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Publish Python Package

on:
release:
types: [published]

permissions:
contents: read

jobs:
deploy:
name: Build and Publish to PyPI
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
- name: Build package
run: python -m build

- name: Publish package to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: twine upload dist/*
25 changes: 0 additions & 25 deletions .github/workflows/tweet-release.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ name = "pypi"
[packages]
telnyx = {path = ".", editable = true}
PyNaCl = "*"
isort = "*"
pylint = "*"
six = "*"
setuptools = "*"
isort = "*"

[dev-packages]
pytest = ">=4"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ into using https://www.piwheels.org/ for ARM compiled wheels.

### Requirements

- Python 3.8+ (PyPy supported)
- Python 3.9+ (PyPy supported)

#### Additional Requirements for Source Install

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.3
2.1.5
11 changes: 3 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def run_tests(self):

setup(
name="telnyx",
version="2.1.3",
version="2.1.5",
description="Python bindings for the Telnyx API",
long_description=long_description,
long_description_content_type="text/markdown",
Expand All @@ -47,12 +47,8 @@ def run_tests(self):
keywords="telnyx telephony sip networking callcontrol messaging sms mms",
packages=find_packages(exclude=["tests", "tests.*"]),
zip_safe=False,
install_requires=[
"requests >= 2.20",
"six >= 1.16.0",
"PyNaCl"
],
python_requires=">=3.8",
install_requires=["requests >= 2.20", "six >= 1.16.0", "PyNaCl"],
python_requires=">=3.9",
tests_require=[
"pytest >= 4",
"pytest-mock >= 1.7",
Expand All @@ -67,7 +63,6 @@ def run_tests(self):
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand Down
2 changes: 1 addition & 1 deletion telnyx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
log = None


__version__ = "2.1.3"
__version__ = "2.1.5"


# Sets some basic information about the running application that's sent along
Expand Down
16 changes: 14 additions & 2 deletions telnyx/api_resources/abstract/nested_resource_class_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,21 @@ def nested_resource_url(cls, id, nested_id=None):
parts.append(quote_plus(id, safe=util.telnyx_valid_id_parts))
if id is not None:
if "phone_number" in path:
parts.append(path.format(phone_number=quote_plus(id, safe=util.telnyx_valid_id_parts + '+')))
parts.append(
path.format(
phone_number=quote_plus(
id, safe=util.telnyx_valid_id_parts + "+"
)
)
)
elif "verification_id" in path:
parts.append(path.format(verification_id=quote_plus(id, safe=util.telnyx_valid_id_parts)))
parts.append(
path.format(
verification_id=quote_plus(
id, safe=util.telnyx_valid_id_parts
)
)
)
else:
parts.append(path)
else:
Expand Down
4 changes: 3 additions & 1 deletion telnyx/api_resources/verification.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
"whatsapp", path="/v2/verifications/whatsapp", operations=["create"]
)
@nested_resource_class_methods(
"verify_by_phone_number", path="by_phone_number/{phone_number}/actions/verify", operations=["create"]
"verify_by_phone_number",
path="by_phone_number/{phone_number}/actions/verify",
operations=["create"],
)
@nested_resource_class_methods(
"verify_by_id", path="actions/verify", operations=["create"]
Expand Down
10 changes: 8 additions & 2 deletions telnyx/api_resources/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@

@nested_resource_class_methods("sms", path="verifications/sms", operations=["create"])
@nested_resource_class_methods("call", path="verifications/call", operations=["create"])
@nested_resource_class_methods("flashcall", path="verifications/flashcall", operations=["create"])
@nested_resource_class_methods("verify", path="verifications/{verification_id}/actions/verify", operations=["create"])
@nested_resource_class_methods(
"flashcall", path="verifications/flashcall", operations=["create"]
)
@nested_resource_class_methods(
"verify",
path="verifications/{verification_id}/actions/verify",
operations=["create"],
)
class Verify(
CreateableAPIResource,
DeletableAPIResource,
Expand Down
1 change: 1 addition & 0 deletions tests/api_resources/test_address.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import absolute_import, division, print_function

import pytest

import telnyx

TEST_RESOURCE_ID = "1293384261075731499"
Expand Down
1 change: 1 addition & 0 deletions tests/api_resources/test_call.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import absolute_import, division, print_function

import pytest

import telnyx

CALL_CONTROL_ID = "AgDIxmoRX6QMuaIj_uXRXnPAXP0QlNfXczRrZvZakpWxBlpw48KyZQ=="
Expand Down
1 change: 1 addition & 0 deletions tests/api_resources/test_call_control_application.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import absolute_import, division, print_function

import pytest

import telnyx

TEST_RESOURCE_ID = "1293384261075731499"
Expand Down
1 change: 1 addition & 0 deletions tests/api_resources/test_credential_connection.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import absolute_import, division, print_function

import pytest

import telnyx

TEST_RESOURCE_ID = "6a09cdc3-8948-47f0-aa62-74ac943d6c58"
Expand Down
1 change: 1 addition & 0 deletions tests/api_resources/test_dynamic_emergency_address.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import absolute_import, division, print_function

import pytest

import telnyx

TEST_RESOURCE_ID = "0ccc7b54-4df3-4bca-a65a-3da1ecc777f1"
Expand Down
1 change: 1 addition & 0 deletions tests/api_resources/test_fax_applications.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import absolute_import, division, print_function

import pytest

import telnyx

TEST_RESOURCE_ID = "1293384261075731499"
Expand Down
1 change: 1 addition & 0 deletions tests/api_resources/test_fqdn.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import absolute_import, division, print_function

import pytest

import telnyx

TEST_RESOURCE_ID = "1293384261075731499"
Expand Down
1 change: 1 addition & 0 deletions tests/api_resources/test_ip_connection.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import absolute_import, division, print_function

import pytest

import telnyx

TEST_RESOURCE_ID = "6a09cdc3-8948-47f0-aa62-74ac943d6c58"
Expand Down
1 change: 1 addition & 0 deletions tests/api_resources/test_outbound_voice_profiles.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import absolute_import, division, print_function

import pytest

import telnyx

TEST_RESOURCE_ID = "1293384261075731499"
Expand Down
1 change: 1 addition & 0 deletions tests/api_resources/test_sim_card_group.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import absolute_import, division, print_function

import pytest

import telnyx

TEST_RESOURCE_ID = "6a09cdc3-8948-47f0-aa62-74ac943d6c58"
Expand Down
5 changes: 4 additions & 1 deletion tests/api_resources/test_verification.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest

import telnyx

TEST_RESOURCE_ID = "12ade33a-21c0-473b-b055-b3c836e1c292"
Expand Down Expand Up @@ -37,7 +38,9 @@ def test_can_verify_by_id(self, request_mock):

def test_can_list_verifications(self, request_mock):
resources = telnyx.Verification.by_phone_number(TEST_PHONE_NUMBER)
request_mock.assert_requested("get", "/v2/verifications/by_phone_number/%s" %TEST_PHONE_NUMBER)
request_mock.assert_requested(
"get", "/v2/verifications/by_phone_number/%s" % TEST_PHONE_NUMBER
)
assert isinstance(resources.data, list)
assert isinstance(resources.data[0], telnyx.Verification)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_api_requestor.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ def test_invalid_method(self, requestor):

def test_raw_request_with_file_param(self, requestor, mock_response):
test_file = tempfile.NamedTemporaryFile()
test_file.write("\u263A".encode("utf-16"))
test_file.write("\u263a".encode("utf-16"))
test_file.seek(0)
params = {"file": test_file, "purpose": "dispute_evidence"}
supplied_headers = {"Content-Type": "multipart/form-data"}
Expand Down
9 changes: 4 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
# and then run "tox" from this directory.

[tox]
envlist = py38,
py39,
envlist = py39,
py310,
py311,
py312,
Expand All @@ -24,12 +23,12 @@ deps =
black
isort
commands =
isort --recursive --atomic . {posargs}
isort --atomic . {posargs}
black . {posargs}

[testenv:lint]
description = run static analysis and style check using flake8, isort and pylint
basepython = python3.8
basepython = python3.9
deps =
flake8
isort
Expand All @@ -41,7 +40,7 @@ commands =

[testenv:pylint]
description = run static analysis and style check using pylint
basepython = python3.8
basepython = python3.9
deps = pylint
commands =
pylint telnyx
Expand Down

0 comments on commit 24265d7

Please sign in to comment.