def message_audience(): body = request.get_json() status, missing_field = validate_body(body, ['message', 'phones']) if not status: return error_response(f'{missing_field} is missing') send_bulk_sms(body['phones'], body['message']) return response(True, 'Success', None)
def send(): body = request.get_json() status, missing_field = validate_body(body, ['to', 'message']) if not status: return error_response(f'{missing_field} is required') message_queue.put(body) return response(True, 'Queued', None)
def create(): body = request.get_json() status, missing_field = validate_body( body, ['title', 'phone', 'description', 'time']) if not status: return error_response(f'{missing_field} is required') status, error = parse_appointment(body) if not status: return error_response(error) try: apt_service.create_appointment(body) jobs.schedule_appointment(body) return response(True, 'Appointment created successfully', body) except Exception as err: print('=====> Error', err) return error_response(str(err))