def handle_request(active_form, form): if active_form == 'smsmt': success, msg = send_sms( to_addr=form.cleaned_data.get('destination_address'), message=form.cleaned_data.get('content'), as_addr=form.cleaned_data.get('sender_name') or get_config('default_sender_name')) handle_smsmt(msg) return success, "Sent {}".format(msg) elif active_form == 'fsmsmt': msg = SMSMessage.create_mt( destination_address=form.cleaned_data.get( 'destination_address'), content=form.cleaned_data.get('content'), sender_address=form.cleaned_data.get('sender_address'), sending_status=form.cleaned_data.get('status')) handle_smsmo(msg) return True, "Sent {}".format(msg) elif active_form == 'fsmsmo': msg = SMSMessage.create_mo_from_payload({ 'senderAddress': "tel:{}".format( form.cleaned_data.get('sender_address')), 'destinationAddress': form.cleaned_data.get( 'destination_address'), 'messageId': form.cleaned_data.get('message_id') or None, 'message': form.cleaned_data.get('content'), 'dateTime': datetime_to_iso( form.cleaned_data.get('created_on')) }) handle_smsmo(msg) return True, "Received {}".format(msg) elif active_form == 'fsmsdr': msg = SMSMessage.record_dr_from_payload({ 'callbackData': form.cleaned_data.get('uuid'), 'delivery_status_on': datetime_to_iso( form.cleaned_data.get('delivery_on')), 'deliveryInfo': { 'deliveryStatus': form.cleaned_data.get('status') } }) return True, "Updated {}".format(msg) else: return False, "Unknown action `{}`".format(active_form)
def reply(self, text, as_addr): from orangeapisms.utils import send_sms return send_sms(to_addr=self.sender_address, message=text, as_addr=as_addr)