Coder Social home page Coder Social logo

jtszalay / django-easy-eddie Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dreipol/django-easy-eddie

0.0 1.0 0.0 21 KB

This Django package sends your text messages (SMS) through Amazon SNS and provides reporting helpers.

License: MIT License

Makefile 7.89% Python 92.11%

django-easy-eddie's Introduction

django-easy-eddie

This Django package sends your text messages (SMS) through Amazon SNS and provides reporting helpers.

Sending SMS using the famous boto3 package is easy. Creating usage and billing reports can become tricky especially if you are using multiple projects on the same AWS account or if you need to split cost in any another way.

Using this package's send_sms() function stores an SMS event with the message id in your database and allows you to fetch meta data (incl. price) through CloudWatch after the submission with a management command. An admin action allows you to export all events as CSV file.

Quickstart

Install django-easy-eddie:

pip install django-easy-eddie

Add it to your INSTALLED_APPS:

INSTALLED_APPS = (
    ...
    'easy_eddie',
    ...
)

Configure settings:

# OPTIONALLY SET EASYEDDIE_USE_AWS_PROFILE = True to use local profile and not have to set the next three vars.

AWS_DEFAULT_REGION = 'eu-west-1'
AWS_ACCESS_KEY_ID = 'foo'
AWS_SECRET_ACCESS_KEY = 'bar'

EASYEDDIE_CLOUD_WATCH_LOG_GROUP_NAMES = [
    'sns/eu-west-1/000000000000/DirectPublishToPhoneNumber',
    'sns/eu-west-1/000000000000/DirectPublishToPhoneNumber/Failure'
]

Migrate your database:

$ python manage.py migrate easy_eddie

Sending text messages (SMS):

from easy_eddie.sms import send_sms

send_sms(sender='your_SNS_sender_id', phone_number='your_phone_number', message='foo')

Fetching CloudWatch logs of unprocessed SMS events:

from easy_eddie.report_fetchers import fetch_logs_of_unprocessed_sms_events

fetch_logs_of_unprocessed_sms_events()

Management Command

This management command can be used to fetch log data from CloudWatch for SMS events. It is probably a good idea to use it in any scheduled way (e.g. crontab, celery beat, etc.):

$ python manage.py fetch_cloud_watch_log_events

AWS CloudWatch

For more information about setting up CloudWatch logging in AWS, see Viewing Amazon CloudWatch Metrics and Logs for SMS Deliveries

Credits

Tools used in rendering this package:

Trivia

In line with many dreipol projects named after real or fictional characters of the italian mob in america, the name of this package is inspired by Edward Easy Eddie J.`O'Hare.

It is believed O'Hare directed investigator Wilson to the Capone bookkeeper who became a key witness at the 1931 trial, and also helped break the code used in the ledgers by Capone's bookkeepers.*

*Wikipedia

django-easy-eddie's People

Contributors

chschuermann avatar jtszalay avatar philipplaeubli avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.