From 5ba73fd46dbc7baef6745c9226c13eb5190834a6 Mon Sep 17 00:00:00 2001 From: Frederick Yin Date: Tue, 22 Feb 2022 21:36:13 +0800 Subject: Impl return_success and remind_overdue SMS --- jimbrella/sms.py | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/jimbrella/sms.py b/jimbrella/sms.py index c8f013c..3ad9583 100644 --- a/jimbrella/sms.py +++ b/jimbrella/sms.py @@ -30,7 +30,7 @@ class SMS: """Call API to send generic SMS""" req = dysmsapi_models.SendSmsRequest( phone_numbers=phone_number, - sign_name="JIBelief", + sign_name=config.get("sms", "signature"), template_code=template_code, template_param=json.dumps(template_param), ) @@ -49,8 +49,29 @@ class SMS: ${name}同学,您已于${date}成功借用${umbid}号信用伞,请在三日内归还 """ self._send( - phone, "SMS_234140902", {"name": name, "date": date, "umbid": umbid} + phone, + config.get("sms", "template_borrow_success"), + {"name": name, "date": date, "umbid": umbid}, + ) + + def return_success(self, phone: str, name: str, date: str, umbid: int): + """Current template: jimbrella_giveback_0 + + ${name}同学,您已于${date}成功归还${umbid}号信用伞 + """ + self._send( + phone, + config.get("sms", "template_return_success"), + {"name": name, "date": date, "umbid": umbid}, ) def remind_overdue(self, phone: str, name: str, date: str, umbid: int): - self._send(phone, "TBD", {"name": name, "date": date, "umbid": umbid}) + """Current template: jimbrella_overdue_0 + + ${name}同学,您在${date}借用的${umbid}号信用伞已超过3天时限,请及时归还 + """ + self._send( + phone, + config.get("sms", "template_remind_overdue"), + {"name": name, "date": date, "umbid": umbid}, + ) -- cgit v1.2.3