def send_helpdesk_response(ticket): # Make a session to Vumi sender = HttpApiSender( account_key=settings.VUMI_GO_ACCOUNT_KEY, conversation_key=settings.VUMI_GO_CONVERSATION_KEY, conversation_token=settings.VUMI_GO_CONVERSATION_TOKEN) # Send message response = sender.send_text(ticket.msisdn, ticket.response) # TODO: Log outbound send metric return response
def send(ctx, conversation, token, csv, json): """ Send messages via an HTTP API (nostream) conversation. """ if not all((ctx.obj.account_key, conversation, token)): raise click.UsageError( "Please specify all of the account key, conversation key" " and conversation authentication token. See --help.") if not any((csv, json)): raise click.UsageError("Please specify either --csv or --json.") http_api = HttpApiSender(ctx.obj.account_key, conversation, token) if csv: for msg in messages_from_csv(csv): click.echo("Sending message to %(to_addr)s." % msg) http_api.send_text(**msg) if json: for msg in messages_from_json(json): click.echo("Sending message to %(to_addr)s." % msg) http_api.send_text(**msg)
def vumi_client(self): return HttpApiSender(api_url=settings.VUMI_API_URL, account_key=settings.VUMI_ACCOUNT_KEY, conversation_key=settings.VUMI_CONVERSATION_KEY, conversation_token=settings.VUMI_ACCOUNT_TOKEN)
def create_vumi_client(cls, channel): return HttpApiSender( channel.configuration.get("VUMI_ACCOUNT_KEY"), channel.configuration.get("VUMI_CONVERSATION_KEY"), channel.configuration.get("VUMI_ACCOUNT_TOKEN"), api_url=channel.configuration.get("VUMI_API_URL"))