class Gateway(object): def __init__(self, username, password): self.client = Client(username, password) def send_one_sms(self, user, msisdn, smstext): resp = self.client.send_sms(to_msisdn=msisdn, from_msisdn='0', message=smstext).pop() send_sms = SendSMS() send_sms.user = user send_sms.msisdn = msisdn send_sms.smstext = smstext send_sms.delivery = datetime.now() send_sms.expiry = datetime.now() + timedelta(days=1) send_sms.priority = 'standard' send_sms.receipt = 'Y' send_sms.identifier = str(resp.id) send_sms.save() return send_sms def send_sms(self, user, msisdns, smstexts): responses = [] for msisdn, smstext in zip(msisdns, smstexts): send_sms = self.send_one_sms(user, msisdn, smstext) responses.append(send_sms.pk) return SendSMS.objects.filter(pk__in=responses)
def __init__(self, username, password): self.client = Client(username, password)
def send_password_reset(msisdn, new_password): message = "Ummeli on YAL :) Your new password is: %s" % new_password client = Client("ummeli", "4mm3l1") client.send_sms(to_msisdn=msisdn, from_msisdn="1", message=message)