GOSMS.GE Python SMS Send
Python client module to send SMS messages using GOSMS.GE SMS Gateway.
To use this library, you must have a valid account on https://gosms.ge.
Please note SMS messages sent with this library will be deducted by your GOSMS.GE account credits.
For any questions, please contact: info@gosms.ge
usage
Send a message with Classic type
from gosms import SMS
sms: SMS = SMS('api_key')
sms.send('995555555555', 'Hello!', 'GOSMS.GE')
Check status of message
from gosms import SMS
sms: SMS = SMS('api_key')
sms.status('message_id')
Check balance
from gosms.settings import GOSMS_SETTINGS
from gosms import sms
GOSMS_SETTINGS['api_key'] = 'your_api_key'
sms.balance()
usage in Django
# django settings file
GOSMS_SETTINGS = {
# you should have valid API key given by gosms.ge
'api_key': 'your_api_key',
# this property will have same value as DEBUG but you can override it here
'dev_mode': False,
}
# views.py
from gosms import sms
def send_message_view(request):
""" :returns {"code": string,"message": string,"message_id": number,"balance": number,"user": string} """
return sms.send('995555555555', 'Hello!', 'GOSMS.GE')
def check_status_view(request):
""" :returns { id: number,sender: string,receiver: string,message: string',message_id: string,amount: number,status: string } """
return sms.status('message_id')
def check_balance_view(request):
""" returns { balance: number, user: string } """
return sms.balance()
You can use it anywhere
# user.managers
from django.contrib.auth.base_user import BaseUserManager
class UserManager(BaseUserManager):
use_in_migrations = True
def _create_user(self, phone_number, password, **extra_fields):
"""
Creates and saves a User with the given email and password.
"""
if not phone_number:
raise ValueError('The given phone_number must be set')
user = self.model(phone_number=phone_number, **extra_fields)
user.set_password(password)
user.save(using=self._db)
return user
def create_user(self, phone_number, password=None, **extra_fields):
extra_fields.setdefault('is_superuser', False)
return self._create_user(phone_number, password, **extra_fields)
def create_superuser(self, phone_number, password, **extra_fields):
extra_fields.setdefault('is_superuser', True)
if extra_fields.get('is_superuser') is not True:
raise ValueError('Superuser must have is_superuser=True.')
return self._create_user(phone_number, password, **extra_fields)
# user.models
from django.db import models
from django.contrib.auth.models import PermissionsMixin
from django.contrib.auth.base_user import AbstractBaseUser
from django.utils.translation import ugettext_lazy as _
from user.managers import UserManager
from gosms import sms
class User(AbstractBaseUser, PermissionsMixin):
phone_number = models.CharField(_('Phone Number'), unique=True)
is_active = models.BooleanField(_('Is Active'), default=False)
objects = UserManager()
USERNAME_FIELD = 'phone_number'
REQUIRED_FIELDS = []
def save(self, *args, **kwargs):
super().save(*args, **kwargs)
sms.send(self.phone_number, 'user created', 'GOSMS.GE')
# views.py
from django.shortcuts import get_object_or_404, render
from user.models import User
from gosms import sms
def user_register(request):
user = User(
phone_number=request.POST.get('phone_number'),
)
user.set_password(request.POST.get('password'))
user.save()
sms.send_otp(user.phone_number)
def verify_user(request):
""" verify otp method raises exception if details are incorrect """
response_data = sms.verify_otp(
request.POST.get('phone_number'),
request.POST.get('hash'),
request.POST.get('code')
)
user = get_object_or_404(
User, phone_number=request.POST.get('phone_number')
)
user.is_active = True
user.save()
return render(request, 'some_template', context=response_data)
More info
You can check out our website https://www.gosms.ge
Metadata
Release files for gosmsge 1.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gosmsge-1.0.5.tar.gz | 5.5 kB | Without provenance | Details for gosmsge-1.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gosmsge-1.0.5-py3-none-any.whl | Python 3 | none | any | Details for gosmsge-1.0.5-py3-none-any.whl |
Total release size: 11.8 kB
Release files / gosmsge-1.0.5.tar.gz
| Download URL | gosmsge-1.0.5.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
35ab4713b0f6c68b6a84a0da893ed07955923b95361e97b62c96f5e579e9550f
|
|
BLAKE2b-256 checksum How to use checksums |
7ec7292e6550bbc4c355dabf778c238763537579e79c3e7c6b8bdba98f3292b4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6
|
Release files / gosmsge-1.0.5-py3-none-any.whl
| Download URL | gosmsge-1.0.5-py3-none-any.whl |
|---|---|
| Size | 6.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
66dc2696197baacb60772a7acb124952fedc5639e79ca613e7aa07c018de03c2
|
|
BLAKE2b-256 checksum How to use checksums |
33befaf08af8088001a5d309c87a51f827f266d8f95a0d034d059fd454dcb7dd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6
|
Security for gosmsge 1.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.