diff --git a/backend/account/views.py b/backend/account/views.py index c4bb2d0..b28eaf2 100644 --- a/backend/account/views.py +++ b/backend/account/views.py @@ -41,20 +41,34 @@ class SendOTPView(APIView): try: user, created = User.objects.get_or_create(phone=phone) otp = user.set_otp() - message = f"""به فروشگاه هی ملز خوش اومدی!!❤ 🤖 -کد تایید شما : -Code: {otp}""" sms_api = ghasedak_sms.Ghasedak(api_key="1227eaaddcba72bcb0169b37032cf16ae9ac6ed8b3b7c2768b74e2ee351d1b52gyRe3AGomZRPTNEd") - response = sms_api.send_single_sms( - ghasedak_sms.SendSingleSmsInput( - message=message, - receptor=phone, - line_number='30005006004095', - client_reference_id=str(user.pk) + # response = sms_api.send_single_sms( + # ghasedak_sms.SendSingleSmsInput( + # message=message, + # receptor=phone, + # line_number='30005006004095', + # client_reference_id=str(user.pk) + # ) + # ) + + newotpcommand = ghasedak_sms.SendOtpInput( + receptors=[ + ghasedak_sms.SendOtpReceptorDto( + mobile=user.phone, + client_reference_id=str(user.pk) + ) + ], + template_name='Heymlzshop', + inputs=[ + ghasedak_sms.SendOtpInput.OtpInput(param='Code', value=f'{otp}'), + # ghasedak_sms.SendOtpInput.OtpInput(param='Name', value='name') + ], + udh=False ) - ) + response = sms_api.send_otp_sms(newotpcommand) + if response['statusCode'] == 200: return Response({'detail': f'OTP sent successfully {otp}'}, status=status.HTTP_200_OK)