Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions 31 .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Build

on:
# push:
workflow_call:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Build distributions
run: uv build

- name: Upload sdist artifact
uses: actions/upload-artifact@v4
with:
name: sdist
path: ./dist/*.tar.gz

- name: Upload wheels artifact
uses: actions/upload-artifact@v4
with:
name: wheels
path: ./dist/*.whl
31 changes: 31 additions & 0 deletions 31 .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI

on:
push:
workflow_dispatch:

concurrency:
group: ci-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
lint:
name: Lint
uses: ./.github/workflows/lint.yaml

build:
name: Build
uses: ./.github/workflows/build.yaml

test:
name: Test
uses: ./.github/workflows/test.yaml

release:
name: Release
if: startsWith(github.ref, 'refs/tags/v')
needs: [lint, build, test]
permissions:
contents: write
id-token: write
uses: ./.github/workflows/release.yaml
32 changes: 32 additions & 0 deletions 32 .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Lint

on:
# push:
# pull_request:
workflow_call:
workflow_dispatch:

concurrency: lint-${{ github.sha }}

jobs:
lint:
runs-on: ubuntu-latest
env:
PYTHON_VERSION: "3.9"
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Install the project
run: uv sync --locked --all-extras --dev

- name: Run pre-commit hooks
uses: pre-commit/action@v3.0.1
58 changes: 58 additions & 0 deletions 58 .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Release

on:
# push:
# tags:
# - v*
workflow_call:

concurrency: release-${{ github.ref }}

jobs:
release:
if: startsWith(github.ref, 'refs/tags/v')
name: Create release
runs-on: ubuntu-latest
environment: Release
permissions:
contents: write
steps:
- name: Download sdist artifact
uses: actions/download-artifact@v4
with:
name: sdist
path: ./dist

- name: Download wheels artifact
uses: actions/download-artifact@v4
with:
name: wheels
path: ./dist

- name: Create release
uses: softprops/action-gh-release@v2
with:
files: ./dist/*

publish:
if: startsWith(github.ref, 'refs/tags/v')
name: Publish package to PyPI
runs-on: ubuntu-latest
environment: Release
permissions:
id-token: write
steps:
- name: Download sdist artifact
uses: actions/download-artifact@v4
with:
name: sdist
path: ./dist

- name: Download wheels artifact
uses: actions/download-artifact@v4
with:
name: wheels
path: ./dist

- name: Upload distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
32 changes: 32 additions & 0 deletions 32 .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Test

on:
# push:
# pull_request:
workflow_call:
workflow_dispatch:

concurrency: test-${{ github.sha }}

jobs:
test:
runs-on: ubuntu-latest
env:
PYTHON_VERSION: "3.9"
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install uv
uses: astral-sh/setup-uv@v3

- name: Install the project
run: uv sync --locked --all-extras --dev

- name: Run tests
run: uv run pytest tests
6 changes: 3 additions & 3 deletions 6 .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.vscode/

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand All @@ -14,8 +16,6 @@ takeout/.DS_Store

# Test code
test.py
*.lock
*.toml

# Distribution / packaging
.Python
Expand Down Expand Up @@ -238,4 +238,4 @@ fabric.properties
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
.idea/caches/build_file_checksums.ser
22 changes: 22 additions & 0 deletions 22 .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.9
hooks:
- id: ruff
- id: ruff-format

- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.384
hooks:
- id: pyright
21 changes: 21 additions & 0 deletions 21 LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Contiguity

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.
34 changes: 26 additions & 8 deletions 34 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,22 @@
<p align='center'>Contiguity's official Python SDK.</p>

## Installation 🏗 & Setup 🛠

You can install the SDK using pip

```shell
$ pip install contiguity
pip install contiguity
```

Then, import & initialize it like this:

```js
import contiguity
client = contiguity.login("your_token_here")
```

You can also initialize it with the optional 'debug' flag:

```js
client = contiguity.login("your_token_here", True)
```
Expand All @@ -43,6 +47,7 @@ client.send.email(email_object)
```

To send an email with a text body, it's very similar. Just switch "html" to "text".

```python
email_object = {
"to": "example@example.com",
Expand All @@ -54,8 +59,9 @@ email_object = {
client.send.email(email_object)
```

### Optional fields:
- `replyTo` allows you set a reply-to email address.
### Optional fields

- `replyTo` allows you set a reply-to email address.
- `cc` allows you to CC an email address

You can also fetch a local email template using `client.template.local(file)`:
Expand Down Expand Up @@ -95,13 +101,15 @@ client.send.text(text_object)
Contiguity aims to make communications extremely simple and elegant. In doing so, we're providing an OTP API to send one time codes - for free (no additional charge, the text message is still billed / added to quota)

To send your first OTP, first create one:

```python
otp_id = client.otp.send({
'to': "+15555555555",
'language': "en",
'name': "Contiguity"
otp_id = client.otp.send({
'to': "+15555555555",
'language': "en",
'name': "Contiguity"
})
```

Contiguity supports 33 languages for OTPs, including `English (en)`, `Afrikaans (af)`, `Arabic (ar)`, `Catalan (ca)`, `Chinese / Mandarin (zh)`, `Cantonese (zh-hk)`, `Croatian (hr)`, `Czech (cs)`, `Danish (da)`, `Dutch (nl)`, `Finnish (fi)`, `French (fr)`, `German (de)`, `Greek (el)`, `Hebrew (he)`, `Hindi (hi)`, `Hungarian (hu)`, `Indonesian (id)`, `Italian (it)`, `Japanese (ja)`, `Korean (ko)`, `Malay (ms)`, `Norwegian (nb)`, `Polish (pl)`, `Portuguese - Brazil (pt-br)`, `Portuguese (pt)`, `Romanian (ro)`, `Russian (ru)`, `Spanish (es)`, `Swedish (sv)`, `Tagalog (tl)`, `Thai (th)`, `Turkish (tr)`, and `Vietnamese (vi)`

_The `name` parameter is optional, it customizes the message to say "Your \[name] code is ..."_
Expand All @@ -114,38 +122,47 @@ verify = client.otp.verify({
'otp': input # the 6 digits your user inputted.
})
```

It will return a boolean (true/false). The OTP expires 15 minutes after sending it.

Want to resend an OTP? Use `client.otp.resend()`:

```py
resend = client.otp.resend({
'otp_id': otp_id # you received this when you called client.otp.send(),
})
```

OTP expiry does not renew.

## Verify formatting

Contiguity provides two functions that verify phone number and email formatting, which are:

```py
client.verify.number("number")
```

and

```py
client.verify.email("example@example.com")
```

They return a boolean (true/false)

**Note**: _This occurs locally, and is not part of Contiguity's online verification service._

## Email analytics

If you sent an HTML email, and chose Contiguity to track it, you can fetch an email's status (delivered/read) using:

```py
client.email_analytics.retrieve("email_id")
```

## Quota

If you'd like to retrieve your quota, whether you're on our free tier or Unlimited, you can fetch it using:

```py
Expand All @@ -155,10 +172,11 @@ client.quota.retrieve()
You'll receive an object similar to the `crumbs` the API provides on completion of every request.

## Roadmap 🚦

- Contiguity Identity will be supported
- Adding support for calls
- Adding support for webhooks
- Adding support for online templates
- and way more.

### See complete examples in [examples/](https://github.com/use-contiguity/python/tree/main/examples)
### See complete examples in [examples/](https://github.com/use-contiguity/python/tree/main/examples)
6 changes: 0 additions & 6 deletions 6 contiguity/__init__.py

This file was deleted.

Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.