Package: gosmsge
GOSMS.GE Python SMS SendPython client module to send SMS messages using GOSMS.GE SMS Gateway.To use this library, you must have a valid account onhttps://gosms.ge.Please noteSMS messages sent with this library will be deducted by your GOSMS.GE account credits.For any questions, please contact:info@gosms.geusageSend a message with Classic typefromgosmsimportSMSsms:SMS=SMS('api_key')sms.send('995555555555','Hello!','GOSMS.GE')Check status of messagefromgosmsimportSMSsms:SMS=SMS('api_key')sms.status('message_id')Check balancefromgosms.settingsimportGOSMS_SETTINGSfromgosmsimportsmsGOSMS_SETTINGS['api_key']='your_api_key'sms.balance()usage in Django# django settings fileGOSMS_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.pyfromgosmsimportsmsdefsend_message_view(request):""" :returns {"code": string,"message": string,"message_id": number,"balance": number,"user": string} """returnsms.send('995555555555','Hello!','GOSMS.GE')defcheck_status_view(request):""" :returns { id: number,sender: string,receiver: string,message: string',message_id: string,amount: number,status: string } """returnsms.status('message_id')defcheck_balance_view(request):""" returns { balance: number, user: string } """returnsms.balance()You can use it anywhere# user.managersfromdjango.contrib.auth.base_userimportBaseUserManagerclassUserManager(BaseUserManager):use_in_migrations=Truedef_create_user(self,phone_number,password,**extra_fields):"""Creates and saves a User with the given email and password."""ifnotphone_number:raiseValueError('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)returnuserdefcreate_user(self,phone_number,password=None,**extra_fields):extra_fields.setdefault('is_superuser',False)returnself._create_user(phone_number,password,**extra_fields)defcreate_superuser(self,phone_number,password,**extra_fields):extra_fields.setdefault('is_superuser',True)ifextra_fields.get('is_superuser')isnotTrue:raiseValueError('Superuser must have is_superuser=True.')returnself._create_user(phone_number,password,**extra_fields)# user.modelsfromdjango.dbimportmodelsfromdjango.contrib.auth.modelsimportPermissionsMixinfromdjango.contrib.auth.base_userimportAbstractBaseUserfromdjango.utils.translationimportugettext_lazyas_fromuser.managersimportUserManagerfromgosmsimportsmsclassUser(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=[]defsave(self,*args,**kwargs):super().save(*args,**kwargs)sms.send(self.phone_number,'user created','GOSMS.GE')# views.pyfromdjango.shortcutsimportget_object_or_404,renderfromuser.modelsimportUserfromgosmsimportsmsdefuser_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)defverify_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=Trueuser.save()returnrender(request,'some_template',context=response_data)More infoYou can check out our websitehttps://www.gosms.ge