SnailMailer is a Ruby on Rails plugin that provides a wrapper for interacting with the MailFinch snail mail service API.
script/plugin install [email protected]:paulsingh/snailmailer.git
You will need a MailFinch account. Once you have your MailFinch account set up, you will need to obtain your API key in order to get started using SnailMailer.
SnailMailer is intended to be a complete Ruby wrapper for working with the MailFinch API. All methods available from the MailFinch API are available.
You will need to pass your MailFinch API key to get started:
apiauth = SnailMailer::APIAuth.new("YOUR_API_KEY")
base = SnailMailer::Base.new(apiauth)
Once you have created a SnailMailer object, you can begin interacting with the MailFinch account that your API key is associated with.
We have provided some methods to make working with your mailing lists easier.
To see all letters associated with your account:
base.show_all_letters
To create a new letter:
data = Hash.new data[:letter] = Hash.new data[:letter][:sender_attributes] = Hash.new data[:letter][:recipient_attributes] = Hash.new
data[:mailing_year]=“2011”
data[:mailing_month]=“01”
data[:mailing_day]=“15”
data[:letter][:pdf_remote_url]=“http://www.irs.gov/pub/irs-pdf/fw4.pdf”
data[:letter][:sender_attributes][:name]=“Some Dude”
data[:letter][:sender_attributes][:street1]=“123 Any Street”
data[:letter][:sender_attributes][:city]=“Ashburn”
data[:letter][:sender_attributes][:state]=“VA”
data[:letter][:sender_attributes][:zip]=“20148”
data[:letter][:recipient_attributes][:name]=“That Guy”
data[:letter][:recipient_attributes][:street1]=“789 Some Dr”
data[:letter][:recipient_attributes][:city]=“San Antonio”
data[:letter][:recipient_attributes][:state]=“TX”
data[:letter][:recipient_attributes][:zip]=“99999”
base.create_letter(data)
To show an existing letter with :id=ID
base.show_letter(ID)
To update an existing letter with :id=ID
data = Hash.new data[:letter] = Hash.new data[:letter][:sender_attributes] = Hash.new
data[:mailing_year]=“2011”
data[:mailing_month]=“01”
data[:mailing_day]=“01”
data[:letter][:sender_attributes][:country]=“USA”
base.update_letter(ID, data)
To purchase an existing letter with :id=ID
base.purchase_letter(ID)
- Fork the project.
- Make your feature addition or bug fix.
- Add tests for it. This is important so I don’t break it in a future version unintentionally.
- Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
- Send me a pull request. Bonus points for topic branches.
Copyright © 2010 Paul Singh, released under the MIT license