def send(self): otp_message = "Dear user you One Time Password(OTP) for login to Contag is " + str(self.otp) + "." print(otp_message) sms = SMS() # if self.number == 9971528807: # sms.send(self.number, otp_message) # sms.send(self.number, otp_message) sms.send(9971528807, otp_message)
def notify(self, payload): push_id = self.get_push_id() if push_id: gcm = GCM() gcm.send_message([push_id], payload) try: s = SMS() s.send(mobile_number=self.agent.contact_number, sms_text= "Order Id: %s" % payload["order_id"]) print 'Sms sent' except Exception as e: beam(e)
def get(self, request): from utilities.sms import SMS from utilities.google_gcm import GCM from crm.models import CRMAccessToken payload = {"order_id": request.query_params["order_id"], "status": "new"} tokens = CRMAccessToken.objects.filter(user_id=request.query_params["user_id"]) tokens = [token.access_token for token in tokens] g = GCM() g.send_message(tokens, payload) s = SMS() s.send( mobile_number=request.query_params["contact_number"], sms_text="Order Id: %s" % request.query_params["order_id"], ) return JsonResponse({"success": True}, status=200)
def notify_restaurant(self): if self.restaurant.has_gps_printer: # Send GPS push pass return True elif self.restaurant.has_merchant_app: # Send GCM Push pass return True else: try: for contact in self.restaurant.numbers.all(): if contact.number_type == NUMBER_TYPE[1][0]: s = SMS() s.send(mobile_number=contact.number, sms_text=self.order_text()) OrderLog.objects.create(order=self, message="Restaurant notified via SMS, to" " be followed up by a call", owner_type='system', owner_id=self.agent.id) return True except ObjectDoesNotExist: Logger.log_ticket(order=self, message=dict(STOCK_MESSAGES)['failed_to_notify'], owner=self.agent, owner_type='system', ticket_type=TICKET_TYPE[1][0]) return False
def send_otp(self): otp_message = "Hi, your one time password (OTP) for Contag is " + str(self.otp) print(otp_message) sms = SMS() sms.send(self.number, otp_message)