Created
June 4, 2010 12:53
-
-
Save paulsingh/425373 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
payload = Hash.new | |
# NOTE: Replace the text MY_API_KEY with the value of your personal API key | |
payload[:api_key] = MY_API_KEY | |
payload[:letter] = Hash.new | |
payload[:letter][:pdf] = File.new("/path/to/file") | |
payload[:letter][:sender_attributes] = { | |
:name => "Some Dude", | |
:street1 => "123 Any Street", | |
:city => "Ashburn", | |
:state => "VA", | |
:zip => "20148" | |
} | |
payload[:letter][:recipient_attributes] = { | |
:name => "That Guy", | |
:street1 => "789 That Drive", | |
:city => "San Antonio", | |
:state => "TX", | |
:zip => "99999" | |
} | |
# NOTE: The mailing information is not part of the letter payload itself | |
payload[:mailing_year] = "2010" | |
payload[:mailing_month] = "01" | |
payload[:mailing_day] = "01" | |
require "rest_client" | |
# NOTE: You will only need to make one of the following type requests, choosing either XML or JSON formatting | |
# XML request | |
RestClient.post "https://www.mailfinch.com/letters.xml", payload, :content_type => "xml" | |
# JSON request | |
RestClient.post "https://www.mailfinch.com/letters.json", payload, :content_type => "json" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment