Metadata-Version: 2.4
Name: django-anexia-sms-gateway
Version: 1.2.0
Summary: A Django module that allows to send short messages via the Anexia SMS gateway.
Author-email: Anexia <opensource@anexia-it.com>
License: The MIT License (MIT)
        
        Copyright (c) 2021-2026 Anexia
        
        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.
        
Project-URL: Homepage, https://github.com/anexia/django-anexia-sms-gateway
Classifier: Development Status :: 5 - Production/Stable
Classifier: Framework :: Django
Classifier: Framework :: Django :: 5.2
Classifier: Framework :: Django :: 6.0
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: django>=5.2
Requires-Dist: requests>=2.32
Provides-Extra: test
Requires-Dist: coverage>=7.13.2; extra == "test"
Provides-Extra: dev
Requires-Dist: pre-commit<4.6,>=4.5; extra == "dev"
Provides-Extra: build
Requires-Dist: build>=1.4.0; extra == "build"
Requires-Dist: twine>=6.2.0; extra == "build"
Requires-Dist: wheel>=0.46.3; extra == "build"
Dynamic: license-file

# Django Anexia SMS Gateway

[![PyPI](https://badge.fury.io/py/django-anexia-sms-gateway.svg)](https://pypi.org/project/django-anexia-sms-gateway/)
[![Test Status](https://github.com/anexia/django-anexia-sms-gateway/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/anexia/django-anexia-sms-gateway/actions/workflows/test.yml)
[![Codecov](https://codecov.io/gh/anexia/django-anexia-sms-gateway/branch/main/graph/badge.svg)](https://codecov.io/gh/anexia/django-anexia-sms-gateway)

A django module to send short messages via
the [Anexia SMS gateway (ASGW)](https://www.anexia-engine.com/de/modul/sms-plattform-und-gateway).
It requires an active [Anexia Engine](https://www.anexia-engine.com/) subscription and a "ready to use" configured "
sender" within [your web service](https://engine.anexia-it.com/sms/senders).

## Installation

Install using pip:

```
pip install django-anexia-sms-gateway
```

In the project's settings.py add the access token configuration:

```
# Anexia SMS Gateway settings (ASGW)
ASGW_ACTIVE = True
ASGW_API_TOKEN = "your-asgw-api-token"
```

## Usage

Call the `send_sms` method wherever you want to trigger a short message:

```
from django_anexia_sms_gateway.sms import send_sms

send_sms(message="SMS content", destination="+43123456789")
```

### Translation (message)

If you provide a translatable message string be sure to use `ugettext` ("gettext_lazy" would not be triggered on time):

```
from django.utils.translation import ugettext
from django_anexia_sms_gateway.sms import send_sms

send_sms(message=ugettext("Translatable SMS content"), destination="+43123456789")
```

### Recipient phone number (destination)

The recipient's phone number (=`destination`) must consist of prefix `+` followed by 1 to 14 digits. Otherwise the ASGW
API will return an error.

#### Phone number on model

In case you store the phone number on a model (e.g. `User`), we recommend direct validation via `RegexValidator`, e.g.:

```
from django.core.validators import RegexValidator
from django.db.models import CharField
from django.utils.translation import gettext_lazy as _

phone = CharField(
    _("phone number"),
    max_length=15,
    blank=True,
    help_text=_("Prefix '+' followed by 1-14 digits, e.g. '+436641234'"),
    validators=[
        RegexValidator(
            r"^\+\d{1,14}$",
            _("Phone number must be entered in the format: '+123456789'. Prefix '+' with 1 to 14 digits allowed."),
        )
    ],
)
```
