<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Mandarin Soda &#187; Programming</title>
	<atom:link href="http://mandarinsoda.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://mandarinsoda.com</link>
	<description>Random Musings, Sometimes Programming.</description>
	<lastBuildDate>Fri, 12 Jun 2009 02:28:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Accessing FedEx Web Services From Ruby/Rails</title>
		<link>http://mandarinsoda.com/2009/02/09/accessing-fedex-web-services-from-rubyrails/</link>
		<comments>http://mandarinsoda.com/2009/02/09/accessing-fedex-web-services-from-rubyrails/#comments</comments>
		<pubDate>Mon, 09 Feb 2009 21:45:17 +0000</pubDate>
		<dc:creator>Matt Carlson</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[miscellaneous]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[Shipping]]></category>

		<guid isPermaLink="false">http://mandarinsoda.com/?p=224</guid>
		<description><![CDATA[I recently played around with adding FedEx shipping services to the active_shipping plugin and found a bit of confusion online in regards to how to hit FedEx depending upon the style of service being exposed. Somewhat confusingly, FedEx has non-SOAP services as well as SOAP services that you can hit restfully in an HTTPS Post. [...]]]></description>
			<content:encoded><![CDATA[<p>I recently played around with adding FedEx shipping services to the <a href="http://github.com/Shopify/active_shipping/tree/master">active_shipping</a> plugin and found a bit of confusion online in regards to how to hit FedEx depending upon the style of service being exposed.  Somewhat confusingly, FedEx has non-SOAP services as well as SOAP services that you can hit restfully in an HTTPS Post.  For the SOAP service, FedEx has very specific requirements about how to formulate the payload and HTTP headers that took a bit of tinkering to get working.  Non-SOAP FedEx support was recently added to active_shipping prior to the completion of my work, but I figured I would post if for those who want to use what I think are newer SOAP services.</p>
<p>Without much further ado, here are the basics for creating a tracking request:</p>
<pre>
<code>
TEST_DOMAIN = 'gatewaybeta.fedex.com'

def find_tracking_info(tracking_number, options={})
        options = @options.update(options)
        tracking_request = build_tracking_request(tracking_number, options)
        response = commit(:track, save_request(tracking_request),
                          (options[:test] || false))
        parse_tracking_response(response, options)
  end

protected
   def build_access_request
        xml_request = XmlNode.new('ns:WebAuthenticationDetail') do |access|
          access << XmlNode.new('ns:UserCredential') do |user|
             user << XmlNode.new('ns:Key', @options[:key])
             user << XmlNode.new('ns:Password', @options[:password])
          end
        end
        xml_request
      end

      def build_client_detail
        xml_request = XmlNode.new('ns:ClientDetail') do |client_detail|
          client_detail << XmlNode.new('ns:AccountNumber', @options[:account])
          client_detail << XmlNode.new('ns:MeterNumber', @options[:meter])
        end
        xml_request
      end

     def build_tracking_request(tracking_number, options={})
        xml_request = XmlNode.new('ns:TrackRequest',
                         :'xmlns:ns'=>"http://fedex.com/ws/track/v2",
                         :'xmlns:xsi'=>"http://www.w3.org/2001/XMLSchema-instance",
                         :'xsi:schemaLocation'=>"http://fedex.com/ws/track/v2") do |root_node|
          root_node << build_access_request
          root_node << build_client_detail
          root_node << XmlNode.new('ns:TransactionDetail') do |detail|
            detail << XmlNode.new('ns:CustomerTransactionId', 'Ground Track')
          end
          root_node <<  XmlNode.new('ns:Version') do |version|
            version << XmlNode.new('ns:ServiceId', 'trck')
            version << XmlNode.new('ns:Major', '2')
            version << XmlNode.new('ns:Intermediate', '0')
            version << XmlNode.new('ns:Minor', '0')
          end
           root_node <<  XmlNode.new('ns:PackageIdentifier') do |package|
              package << XmlNode.new('ns:Value', tracking_number.to_s)
              package << XmlNode.new('ns:Type', "TRACKING_NUMBER_OR_DOORTAG")
          end
        end
        xml_request.to_xml
      end

     def commit(action, request, test = false)
        http = Net::HTTP.new((test ? TEST_DOMAIN : LIVE_DOMAIN),
                                (USE_SSL[action] ? 443 : 80 ))
        http.use_ssl = USE_SSL[action]

        headers = {
          'Referer' => 'me',
          'Port' => '443',
          'Accept' => "image/gif, image/jpeg, image/pjpeg, text/plain, text/html, */*",
          'Content-Type' => 'image/gif'
        }

        http.verify_mode = OpenSSL::SSL::VERIFY_NONE if USE_SSL[action]
        response = http.start do |http|
          http.request_post ('/xml', request, headers)
        end
        response.body
      end
</pre>
<p></code></p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fmandarinsoda.com%2F2009%2F02%2F09%2Faccessing-fedex-web-services-from-rubyrails%2F&amp;title=Accessing+FedEx+Web+Services+From+Ruby%2FRails" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fmandarinsoda.com%2F2009%2F02%2F09%2Faccessing-fedex-web-services-from-rubyrails%2F&amp;title=Accessing+FedEx+Web+Services+From+Ruby%2FRails" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fmandarinsoda.com%2F2009%2F02%2F09%2Faccessing-fedex-web-services-from-rubyrails%2F&amp;title=Accessing+FedEx+Web+Services+From+Ruby%2FRails" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fmandarinsoda.com%2F2009%2F02%2F09%2Faccessing-fedex-web-services-from-rubyrails%2F&amp;title=Accessing+FedEx+Web+Services+From+Ruby%2FRails" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fmandarinsoda.com%2F2009%2F02%2F09%2Faccessing-fedex-web-services-from-rubyrails%2F&amp;title=Accessing+FedEx+Web+Services+From+Ruby%2FRails', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fmandarinsoda.com%2F2009%2F02%2F09%2Faccessing-fedex-web-services-from-rubyrails%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fmandarinsoda.com%2F2009%2F02%2F09%2Faccessing-fedex-web-services-from-rubyrails%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fmandarinsoda.com%2F2009%2F02%2F09%2Faccessing-fedex-web-services-from-rubyrails%2F&amp;title=Accessing+FedEx+Web+Services+From+Ruby%2FRails" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fmandarinsoda.com%2F2009%2F02%2F09%2Faccessing-fedex-web-services-from-rubyrails%2F&amp;title=Accessing+FedEx+Web+Services+From+Ruby%2FRails" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://mandarinsoda.com/2009/02/09/accessing-fedex-web-services-from-rubyrails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Netflix API Authentication with the Ruby Oauth Gem</title>
		<link>http://mandarinsoda.com/2008/10/19/netflix-authentication-with-ruby-oauth/</link>
		<comments>http://mandarinsoda.com/2008/10/19/netflix-authentication-with-ruby-oauth/#comments</comments>
		<pubDate>Mon, 20 Oct 2008 00:24:16 +0000</pubDate>
		<dc:creator>Matt Carlson</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://mandarinsoda.com/?p=204</guid>
		<description><![CDATA[For any folks out there struggling to get the Ruby OAuth gem working with Netflix authentication, here&#8217;s a quick run down on how to get started. The 0.2.7 version of Ruby OAuth isn&#8217;t totally compatible with the Netflix authentication APIs. However, thanks to the grooviness that it is GitHub, Rob Ares graciously forked the OAuth [...]]]></description>
			<content:encoded><![CDATA[<p>For any folks out there struggling to get the Ruby OAuth gem working with Netflix authentication, here&#8217;s a quick run down on how to get started.</p>
<p>The 0.2.7 version of Ruby OAuth isn&#8217;t totally compatible with the Netflix authentication APIs.  However, thanks to the grooviness that it is <a href="http://github.com/">GitHub</a>, <a href="http://github.com/rares/oauth/tree/master">Rob Ares</a> graciously forked the OAuth gem in order to get it working.  So clone his repository and get cracking!  </p>
<p>Here&#8217;s a start:</p>
<pre>
<code>
require "oauth/consumer"
consumer = OAuth::Consumer.new(
      "developer api key",
      "developer api secret",
      {
        :site => "http://api.netflix.com",
        :request_token_url => "https://api-user.netflix.com/oauth/request_token",
        :access_token_url => "http://api.netflix.com/oauth/access_token",
        :authorize_url => "https://api-user.netflix.com/oauth/login"
      })

    request_token = consumer.get_request_token  

 request_token.authorize_url({
      <img src='http://mandarinsoda.com/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> auth_consumer_key => "you developer api key",
      :application_name => "application name",
      <img src='http://mandarinsoda.com/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> auth_callback => "optional"
    })

    access_token = request_token.get_access_token

    response = consumer.request(
      :get,
      "/users/#{access_token.response[:user_id]}",
      access_token,
      {:scheme => :query_string})
</pre>
<p></code></p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F19%2Fnetflix-authentication-with-ruby-oauth%2F&amp;title=Netflix+API+Authentication+with+the+Ruby+Oauth+Gem" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F19%2Fnetflix-authentication-with-ruby-oauth%2F&amp;title=Netflix+API+Authentication+with+the+Ruby+Oauth+Gem" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F19%2Fnetflix-authentication-with-ruby-oauth%2F&amp;title=Netflix+API+Authentication+with+the+Ruby+Oauth+Gem" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F19%2Fnetflix-authentication-with-ruby-oauth%2F&amp;title=Netflix+API+Authentication+with+the+Ruby+Oauth+Gem" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F19%2Fnetflix-authentication-with-ruby-oauth%2F&amp;title=Netflix+API+Authentication+with+the+Ruby+Oauth+Gem', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F19%2Fnetflix-authentication-with-ruby-oauth%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F19%2Fnetflix-authentication-with-ruby-oauth%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F19%2Fnetflix-authentication-with-ruby-oauth%2F&amp;title=Netflix+API+Authentication+with+the+Ruby+Oauth+Gem" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F19%2Fnetflix-authentication-with-ruby-oauth%2F&amp;title=Netflix+API+Authentication+with+the+Ruby+Oauth+Gem" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://mandarinsoda.com/2008/10/19/netflix-authentication-with-ruby-oauth/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>DataMapper Adapter for Netflix</title>
		<link>http://mandarinsoda.com/2008/10/09/datamapper-adapter-for-netflix/</link>
		<comments>http://mandarinsoda.com/2008/10/09/datamapper-adapter-for-netflix/#comments</comments>
		<pubDate>Thu, 09 Oct 2008 19:03:28 +0000</pubDate>
		<dc:creator>Matt Carlson</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[datamapper]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://mandarinsoda.com/?p=202</guid>
		<description><![CDATA[I&#8217;ve apparently caught the DM Adapter bug, as I&#8217;ve decided to write one to access Netflix while I finish up my MailChimp adapter. I&#8217;ll be posting as I go along, as I&#8217;ve been learning quite a bit about the inner workings of DataMapper while going through this process. Cheers.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve apparently caught the <a href="http://datamapper.rubyforge.org/DataMapper/Adapters/">DM Adapter</a> bug, as I&#8217;ve decided to write <a href="http://github.com/mandarinsoda/datamapper-netflix-adapter/tree/master">one to access Netflix</a> while I finish up my MailChimp adapter. </p>
<p>I&#8217;ll be posting as I go along, as I&#8217;ve been learning quite a bit about the inner workings of DataMapper while going through this process.  </p>
<p>Cheers.</p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F09%2Fdatamapper-adapter-for-netflix%2F&amp;title=DataMapper+Adapter+for+Netflix" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F09%2Fdatamapper-adapter-for-netflix%2F&amp;title=DataMapper+Adapter+for+Netflix" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F09%2Fdatamapper-adapter-for-netflix%2F&amp;title=DataMapper+Adapter+for+Netflix" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F09%2Fdatamapper-adapter-for-netflix%2F&amp;title=DataMapper+Adapter+for+Netflix" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F09%2Fdatamapper-adapter-for-netflix%2F&amp;title=DataMapper+Adapter+for+Netflix', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F09%2Fdatamapper-adapter-for-netflix%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F09%2Fdatamapper-adapter-for-netflix%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F09%2Fdatamapper-adapter-for-netflix%2F&amp;title=DataMapper+Adapter+for+Netflix" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F09%2Fdatamapper-adapter-for-netflix%2F&amp;title=DataMapper+Adapter+for+Netflix" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://mandarinsoda.com/2008/10/09/datamapper-adapter-for-netflix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Writing a DataMapper Adapter to Access MailChimp Web Services From Merb</title>
		<link>http://mandarinsoda.com/2008/10/03/writing-a-datamapper-adapter-to-access-mailchimp-web-services/</link>
		<comments>http://mandarinsoda.com/2008/10/03/writing-a-datamapper-adapter-to-access-mailchimp-web-services/#comments</comments>
		<pubDate>Fri, 03 Oct 2008 20:52:31 +0000</pubDate>
		<dc:creator>Matt Carlson</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[datamapper]]></category>
		<category><![CDATA[merb]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[MailChimp]]></category>

		<guid isPermaLink="false">http://mandarinsoda.com/?p=186</guid>
		<description><![CDATA[As I mentioned in my last post, I&#8217;ve started looking into writing DataMapper Adapters, using my MailChimp wrapper as an example. Thus far, I&#8217;ve been pretty impressed with the Adapter layer built into DataMapper and the possibilities this abstraction layer provides. A quick search over at GitHub will show you all the interesting things folks [...]]]></description>
			<content:encoded><![CDATA[<p>As I mentioned in my last post, I&#8217;ve started looking into writing DataMapper Adapters, using my <a href="http://github.com/mandarinsoda/datamapper-mailchimp-adapter/tree/master">MailChimp wrapper as an example</a>.  Thus far, I&#8217;ve been pretty impressed with the Adapter layer built into DataMapper and the possibilities this abstraction layer provides.  A <a href="http://github.com/search?q=datamapper+adapter">quick search over at GitHub</a> will show you all the interesting things folks are doing with adapters.   </p>
<p>Anyway, here&#8217;s a synopsis of what I&#8217;ve come across thus far.  As pointed out <a href="http://merbist.com/2008/09/29/write-your-own-custom-datamapper-adapter/">in this post</a> by The Merbist, a custom adapter simply inherits from <a href="http://github.com/sam/dm-core/tree/master/lib/dm-core/adapters/abstract_adapter.rb">Abstract Adapter</a> and as such, can define a number of default Adapter methods such as create, update, delete, read_one and read_many.  You also have access to an initialization method that supplies a hash with important environment information, including any parameters relevant to your adapter that a user may have setup in a database.yml file.  This allowed me to create a MailChimp client and login <a href="http://github.com/mandarinsoda/datamapper-mailchimp-adapter/tree/master/lib/dm-mailchimp-adapter.rb#L15-20">once during class initialization</a> rather than at every request, so I got that going for me.</p>
<p>Once I had a MailChimp client setup with login information, I started getting create working in my adapter.  The create method takes a collection of resources as an option which I simply loop through and call the MailChimp listSubscribe API.  So far, so good.  I now wanted to test whether any of this would work with Merb.</p>
<p>I created a merb app:</p>
<pre>
<code>
 merb-gen app campaign
 cd campaign
</code>
</pre>
<p>and set the :use_orm parameter to datamapper in the Merb init.rb.</p>
<p>Next, I ran <code>rake dm:db:database_yaml</code> in order to generate a database.yml file to specify relevant properties for my adapter.  In my case, I needed to create an entry for my mailchimp adapter:</p>
<pre>
<code>
  adapter:  mailchimp
  database:
  username: user
  password: password
  mailing_list_id: list_id
  host: localhost
</code>
</pre>
<p>.</p>
<p>I next created a resource to test the adapter with by running <code>merb-gen resource mailings</code>.  My thinking was that one could have a User stored in a relational (or other) datastore, and that User can have many mailings or some such thing, bad naming aside.  Anyway, a cool feature of DataMapper is that you can specify any number of repositories in a database.yml with different adapters, and then specify on a resource by resource basis which repository a resource belongs to like so:</p>
<pre>
<code>
 def self.default_repository_name
      :mysql
 end
</code>
</pre>
<p>After generating my resource, I went in to add the properties MailChimp would require for the create method.  </p>
<pre>
<code>
class Mailings
  include DataMapper::Resource

  property :id, String, :serial => true, :key => true, :field => :_id
  property :first_name, String
  property :last_name, String
  property :email, String
  property :mailing_list_id, String

   def build_mail_merge()
      {"EMAIL" => self.email, "FNAME" => self.first_name, "LNAME" => self.last_name }
   end
end
</code>
</pre>
<p>.</p>
<p>I also added a callback method that is used by the adapter in order to pass mail merge arguments to MailChimp.  This seemed like a sane approach given that the MailChimp mail_merge arguments are quite dynamic.</p>
<p>With a resource firmly in place, I fired up the merb console and tested to see whether I could connect to MailChimp with it.</p>
<pre>
<code>
 m = Mailing.new
 m.first_name = 'mandarin'
 m.last_name = 'soda'
 m.email = 'msoda@disney.com'
 m.mailing_list_id = '9'
 m.create
</code>
</pre>
<p>I checked my disney email, and sure enough, I had an opt-in response from MailChimp. Victory Adapter!  I could sign users up to MailChimp via the DataMapper APIs quite quickly&#8230;.not too shabby.</p>
<p>That&#8217;s where I&#8217;m at for now&#8230;still have some things to iron out, one being that DataMapper is returning false after a successful create.  Others, of course being that I need to figure out the rest of the default Adapter methods.  Feel free to follow on GitHub if you feel so inclined.</p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F03%2Fwriting-a-datamapper-adapter-to-access-mailchimp-web-services%2F&amp;title=Writing+a+DataMapper+Adapter+to+Access+MailChimp+Web+Services+From+Merb" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F03%2Fwriting-a-datamapper-adapter-to-access-mailchimp-web-services%2F&amp;title=Writing+a+DataMapper+Adapter+to+Access+MailChimp+Web+Services+From+Merb" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F03%2Fwriting-a-datamapper-adapter-to-access-mailchimp-web-services%2F&amp;title=Writing+a+DataMapper+Adapter+to+Access+MailChimp+Web+Services+From+Merb" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F03%2Fwriting-a-datamapper-adapter-to-access-mailchimp-web-services%2F&amp;title=Writing+a+DataMapper+Adapter+to+Access+MailChimp+Web+Services+From+Merb" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F03%2Fwriting-a-datamapper-adapter-to-access-mailchimp-web-services%2F&amp;title=Writing+a+DataMapper+Adapter+to+Access+MailChimp+Web+Services+From+Merb', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F03%2Fwriting-a-datamapper-adapter-to-access-mailchimp-web-services%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F03%2Fwriting-a-datamapper-adapter-to-access-mailchimp-web-services%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F03%2Fwriting-a-datamapper-adapter-to-access-mailchimp-web-services%2F&amp;title=Writing+a+DataMapper+Adapter+to+Access+MailChimp+Web+Services+From+Merb" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F10%2F03%2Fwriting-a-datamapper-adapter-to-access-mailchimp-web-services%2F&amp;title=Writing+a+DataMapper+Adapter+to+Access+MailChimp+Web+Services+From+Merb" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://mandarinsoda.com/2008/10/03/writing-a-datamapper-adapter-to-access-mailchimp-web-services/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DataMapper Adapter for MailChimp</title>
		<link>http://mandarinsoda.com/2008/09/29/datamapper-adapter-for-mailchimp/</link>
		<comments>http://mandarinsoda.com/2008/09/29/datamapper-adapter-for-mailchimp/#comments</comments>
		<pubDate>Tue, 30 Sep 2008 00:53:38 +0000</pubDate>
		<dc:creator>Matt Carlson</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[merb]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[datamapper]]></category>
		<category><![CDATA[MailChimp]]></category>

		<guid isPermaLink="false">http://mandarinsoda.com/?p=181</guid>
		<description><![CDATA[Inspired by this post by The Merbist, I&#8217;ve decided to begin writing a Datamapper Adapter for MailChimp as a follow up to my post about creating a Merb web service. Look here for updates. Just an empty shell at the moment, but I&#8217;ll remedy that shortly.]]></description>
			<content:encoded><![CDATA[<p>Inspired by <a href="http://merbist.com/2008/09/29/write-your-own-custom-datamapper-adapter/">this post</a> by <a href="http://merbist.com/">The Merbist</a>, I&#8217;ve decided to begin writing a Datamapper Adapter for MailChimp as a follow up to my post about creating a Merb web service.  Look <a href="http://github.com/mandarinsoda/datamapper-mailchimp-adapter/tree/master">here</a> for updates.  Just an empty shell at the moment, but I&#8217;ll remedy that shortly.  </p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F29%2Fdatamapper-adapter-for-mailchimp%2F&amp;title=DataMapper+Adapter+for+MailChimp" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F29%2Fdatamapper-adapter-for-mailchimp%2F&amp;title=DataMapper+Adapter+for+MailChimp" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F29%2Fdatamapper-adapter-for-mailchimp%2F&amp;title=DataMapper+Adapter+for+MailChimp" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F29%2Fdatamapper-adapter-for-mailchimp%2F&amp;title=DataMapper+Adapter+for+MailChimp" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F29%2Fdatamapper-adapter-for-mailchimp%2F&amp;title=DataMapper+Adapter+for+MailChimp', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F29%2Fdatamapper-adapter-for-mailchimp%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F29%2Fdatamapper-adapter-for-mailchimp%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F29%2Fdatamapper-adapter-for-mailchimp%2F&amp;title=DataMapper+Adapter+for+MailChimp" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F29%2Fdatamapper-adapter-for-mailchimp%2F&amp;title=DataMapper+Adapter+for+MailChimp" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://mandarinsoda.com/2008/09/29/datamapper-adapter-for-mailchimp/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Zeep SMS Gem Configuration for Rails</title>
		<link>http://mandarinsoda.com/2008/09/20/zeep-sms-gem-configuration-for-rails/</link>
		<comments>http://mandarinsoda.com/2008/09/20/zeep-sms-gem-configuration-for-rails/#comments</comments>
		<pubDate>Sat, 20 Sep 2008 16:31:07 +0000</pubDate>
		<dc:creator>Matt Carlson</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[sms]]></category>

		<guid isPermaLink="false">http://mandarinsoda.com/?p=167</guid>
		<description><![CDATA[For whatever reason, I can rarely remember the myriad syntax for managing gem dependencies in Rails. I&#8217;ve visited this page quite a bit during various projects. When trying to install the zeep messaging gem recently, sure enough I struggled a bit with getting the syntax correct. Anyway, without further ado, here is what worked: config.gem [...]]]></description>
			<content:encoded><![CDATA[<p>For whatever reason, I can rarely remember the myriad syntax for managing gem dependencies in Rails.  I&#8217;ve visited <a href="http://ryandaigle.com/articles/2008/4/1/what-s-new-in-edge-rails-gem-dependencies">this page</a> quite a bit during various projects.  </p>
<p>When trying to install the <a href="http://code.google.com/p/zeep-messaging/downloads/detail?name=zeep-messaging-0.1.5.gem&#038;can=2&#038;q=">zeep messaging gem</a> recently, sure enough I struggled a bit with getting the syntax correct.  </p>
<p>Anyway, without further ado, here is what worked:<br />
<code>config.gem "zeep-messaging", :lib => "zeep/messaging", :version => "0.1.5"</code></p>
<p>Kinda nice sending SMS messages from the console, I have to admit.  </p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F20%2Fzeep-sms-gem-configuration-for-rails%2F&amp;title=Zeep+SMS+Gem+Configuration+for+Rails" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F20%2Fzeep-sms-gem-configuration-for-rails%2F&amp;title=Zeep+SMS+Gem+Configuration+for+Rails" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F20%2Fzeep-sms-gem-configuration-for-rails%2F&amp;title=Zeep+SMS+Gem+Configuration+for+Rails" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F20%2Fzeep-sms-gem-configuration-for-rails%2F&amp;title=Zeep+SMS+Gem+Configuration+for+Rails" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F20%2Fzeep-sms-gem-configuration-for-rails%2F&amp;title=Zeep+SMS+Gem+Configuration+for+Rails', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F20%2Fzeep-sms-gem-configuration-for-rails%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F20%2Fzeep-sms-gem-configuration-for-rails%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F20%2Fzeep-sms-gem-configuration-for-rails%2F&amp;title=Zeep+SMS+Gem+Configuration+for+Rails" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F20%2Fzeep-sms-gem-configuration-for-rails%2F&amp;title=Zeep+SMS+Gem+Configuration+for+Rails" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://mandarinsoda.com/2008/09/20/zeep-sms-gem-configuration-for-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Writing a Simple MailChimp Web Service Using Merb</title>
		<link>http://mandarinsoda.com/2008/09/08/writing-a-simple-mailchimp-web-service-using-merb/</link>
		<comments>http://mandarinsoda.com/2008/09/08/writing-a-simple-mailchimp-web-service-using-merb/#comments</comments>
		<pubDate>Mon, 08 Sep 2008 23:17:55 +0000</pubDate>
		<dc:creator>Matt Carlson</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software Design]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[MailChimp]]></category>
		<category><![CDATA[merb]]></category>

		<guid isPermaLink="false">http://mandarinsoda.com/?p=129</guid>
		<description><![CDATA[A while back, I was asked to build some code to help keep a businesses mailing list synchronized between SalesForce.com and their campaign management tool, which I suggested should be MailChimp and not the tool they were currently using, but I digress. The project never materialized, but I figured I would build it anyway and [...]]]></description>
			<content:encoded><![CDATA[<p>A while back, I was asked to build some code to help keep a businesses mailing list synchronized between SalesForce.com and their campaign management tool, which I suggested should be <a href="http://www.mailchimp.com/index.phtml">MailChimp</a> and not the tool they were currently using, but I digress.  The project never materialized, but I figured I would build it anyway and use it as a chance to explore <a href="http://merbivore.com/">Merb</a> a bit.</p>
<p>My thinking at the time was that a standalone &#8220;wrapper&#8221; web service made sense.  While it would have complicated application administration a bit, encapsulating the mailing list functionality in a simple service that could be called synchronously or asynchronously, as well as modified and deployed independent of core site logic, sounded reasonable.</p>
<p>So, let&#8217;s start with building a minimal Merb application to serve as a foundation:<br />
<code>merb-gen app mail_chimp_service --flat</code></p>
<p>This generates one controller, a few templates (if we want to build in some templated monitoring and for xml responses) and just enough configuration to get the Merb service started.</p>
<p>To test it out, just fire up Merb with the following command: <code>merb</code> and head to <code>http://localhost:4000</code>.</p>
<p>With a foundation in place, I started looking into my MailChimp plugin to see if I should turn it into a gem or do something simpler.  I turned to <a href="http://seattlerb.rubyforge.org/hoe/">hoe</a>, thinking that making a gem would be interesting, but then decided otherwise, as I basically didn&#8217;t feel like writing that much.    So instead, I wrote a simple chimp class to do the MailChimp API work:</p>
<pre><code>require 'xmlrpc/client'
class Chimp
  cattr_accessor :client, :auth
  def add(subscriber)
    chimp_subscribe(auth, Merb::Config[:chimp_settings]['mail_chimp']['mailing_list_id'],
                            subscriber.email, subscriber.mail_merge)
  end
  private
  def chimp_subscribe(auth, mailing_list_id, email, merge_vars,
                                email_content_type="html", double_optin=true)
    begin
      client.call("listSubscribe", auth, mailing_list_id, email,
                     merge_vars, email_content_type, double_optin)
    rescue XMLRPC::FaultException =&gt; e
      Merb.logger e.faultCode
      Merb.logger e.faultString
    end
  end
end</code></pre>
<p>This class adds users to a specific MailChimp mailing list using the MailChimp APIs.  The client and auth attributes are set in the Merb init.rb class, as they really only need to be loaded once and not initialized per each request:</p>
<pre><code>
Merb::BootLoader.after_app_loads do
    Chimp.client = XMLRPC::Client.new2('http://api.mailchimp.com/1.0/')
    Chimp.auth = XMLRPC::Client.new2('http://api.mailchimp.com/1.0/').call("login",
                         Merb::Config[:chimp_settings]['mail_chimp']['username'],
                         Merb::Config[:chimp_settings]['mail_chimp']['password'])
end
</code></pre>
<p>I&#8217;m loading the MailChimp configuration parameters in the init.rb file in the config block. I&#8217;m just loading in a yaml file with the relevant information one would presumably want externalized from the application code:</p>
<pre><code>
Merb::Config.use { |c|
 .....
 c[:chimp_settings]      = YAML.load_file(Merb.root/'mailing.yml')
}
</code></pre>
<p>I then created a simple subscriber.rb class to encapsulate user elements and wired the relevant classes together in my single controller like so:</p>
<pre><code>
require 'chimp'
require 'subscriber'
class Foo &lt; Merb::Controller
  provides <img src='http://mandarinsoda.com/wp-includes/images/smilies/icon_mad.gif' alt=':x' class='wp-smiley' /> ml

  def _template_location(action, type = nil, controller = controller_name)
    controller == "layout" ? "layout.#{action}.#{type}" : "#{action}.#{type}"
  end

  def index
    subscriber = Subscriber.new(params)
    chimp = Chimp.new
    chimp.add(subscriber)
    render false
  end
end
</code></pre>
<p>I subsquently added an index.xml.erb class to my views directory in order to render successful responses, fired up my app with the merb command and then ran a test in a separate console to ensure everything was working:</p>
<pre><code>
curl -H "Accept: text/xml" -L -d
"email=matt@mandarinsoda.com&amp;first_name=swanky&amp;last_name=mango" http://localhost:4000</code></pre>
<p>It worked &#8211; the very first time!  (joking, but it did work after a bit of tinkering).  I saw the content of my index.xml.erb and received a MailChimp opt-in email. Not too shabby for a few hours of tinkering.  I&#8217;m sure there are interesting Merb features missing as well that could make this all the more compact.  More to explore later.</p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F08%2Fwriting-a-simple-mailchimp-web-service-using-merb%2F&amp;title=Writing+a+Simple+MailChimp+Web+Service+Using+Merb" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F08%2Fwriting-a-simple-mailchimp-web-service-using-merb%2F&amp;title=Writing+a+Simple+MailChimp+Web+Service+Using+Merb" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F08%2Fwriting-a-simple-mailchimp-web-service-using-merb%2F&amp;title=Writing+a+Simple+MailChimp+Web+Service+Using+Merb" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F08%2Fwriting-a-simple-mailchimp-web-service-using-merb%2F&amp;title=Writing+a+Simple+MailChimp+Web+Service+Using+Merb" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F08%2Fwriting-a-simple-mailchimp-web-service-using-merb%2F&amp;title=Writing+a+Simple+MailChimp+Web+Service+Using+Merb', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F08%2Fwriting-a-simple-mailchimp-web-service-using-merb%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F08%2Fwriting-a-simple-mailchimp-web-service-using-merb%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F08%2Fwriting-a-simple-mailchimp-web-service-using-merb%2F&amp;title=Writing+a+Simple+MailChimp+Web+Service+Using+Merb" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F09%2F08%2Fwriting-a-simple-mailchimp-web-service-using-merb%2F&amp;title=Writing+a+Simple+MailChimp+Web+Service+Using+Merb" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://mandarinsoda.com/2008/09/08/writing-a-simple-mailchimp-web-service-using-merb/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Web Site Optimization News</title>
		<link>http://mandarinsoda.com/2008/07/26/web-site-optimization-news/</link>
		<comments>http://mandarinsoda.com/2008/07/26/web-site-optimization-news/#comments</comments>
		<pubDate>Sat, 26 Jul 2008 20:44:58 +0000</pubDate>
		<dc:creator>Matt Carlson</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[miscellaneous]]></category>
		<category><![CDATA[Add new tag]]></category>

		<guid isPermaLink="false">http://mandarinsoda.com/?p=106</guid>
		<description><![CDATA[Some interesting resources and news in the world of web site optimization recently. Good stuff for those who care about this sort of thing. I look forward to clogging up my works print queue with Velocity presentations on Monday even though printing is a bit evil.]]></description>
			<content:encoded><![CDATA[<p>Some interesting <a href="http://en.oreilly.com/velocity2008/public/schedule/proceedings">resources</a> and <a href="http://">news</a> in the world of web site optimization recently.  Good stuff for those who care about this sort of thing. I look forward to clogging up my works print queue with Velocity presentations on Monday even though printing is a bit evil.    </p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F07%2F26%2Fweb-site-optimization-news%2F&amp;title=Web+Site+Optimization+News" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F07%2F26%2Fweb-site-optimization-news%2F&amp;title=Web+Site+Optimization+News" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F07%2F26%2Fweb-site-optimization-news%2F&amp;title=Web+Site+Optimization+News" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F07%2F26%2Fweb-site-optimization-news%2F&amp;title=Web+Site+Optimization+News" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F07%2F26%2Fweb-site-optimization-news%2F&amp;title=Web+Site+Optimization+News', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fmandarinsoda.com%2F2008%2F07%2F26%2Fweb-site-optimization-news%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fmandarinsoda.com%2F2008%2F07%2F26%2Fweb-site-optimization-news%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fmandarinsoda.com%2F2008%2F07%2F26%2Fweb-site-optimization-news%2F&amp;title=Web+Site+Optimization+News" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F07%2F26%2Fweb-site-optimization-news%2F&amp;title=Web+Site+Optimization+News" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://mandarinsoda.com/2008/07/26/web-site-optimization-news/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Acts_as_Chimp Updates</title>
		<link>http://mandarinsoda.com/2008/06/10/acts_as_chimp-updates/</link>
		<comments>http://mandarinsoda.com/2008/06/10/acts_as_chimp-updates/#comments</comments>
		<pubDate>Wed, 11 Jun 2008 01:38:11 +0000</pubDate>
		<dc:creator>Matt Carlson</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[MailChimp]]></category>
		<category><![CDATA[Plugins]]></category>

		<guid isPermaLink="false">http://mandarinsoda.com/?p=103</guid>
		<description><![CDATA[Fixed a sorta obvious bug and added a new feature to acts_as_chimp today. You can now specify a list of merge tags in your acts_as_chimp model declaration like so: [sourcecode language='ruby'] acts_as_chimp :mailing_list_id => 'your_list_id', :mail_merge => {"EMAIL" => :email, "FNAME" => :first_name, "LNAME" => :last_name } [/sourcecode] The plugin will read the method values [...]]]></description>
			<content:encoded><![CDATA[<p>Fixed a sorta obvious bug and added a new feature to acts_as_chimp today.  You can now specify a list of merge tags in your acts_as_chimp model declaration like so:<br />
<code>[sourcecode language='ruby']<br />
acts_as_chimp :mailing_list_id => 'your_list_id', :mail_merge => {"EMAIL" => :email, "FNAME" => :first_name, "LNAME" => :last_name }<br />
[/sourcecode]</code></p>
<p>The plugin will read the method values corresponding to the symbols above when posting to MailChimp.</p>
<p>As an aside, the kind folks at MailChimp recently added acts_as_chimp to<br />
<a href="http://www.mailchimp.com/plugins/">their plugin page</a>.   </p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F06%2F10%2Facts_as_chimp-updates%2F&amp;title=Acts_as_Chimp+Updates" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F06%2F10%2Facts_as_chimp-updates%2F&amp;title=Acts_as_Chimp+Updates" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F06%2F10%2Facts_as_chimp-updates%2F&amp;title=Acts_as_Chimp+Updates" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F06%2F10%2Facts_as_chimp-updates%2F&amp;title=Acts_as_Chimp+Updates" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F06%2F10%2Facts_as_chimp-updates%2F&amp;title=Acts_as_Chimp+Updates', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fmandarinsoda.com%2F2008%2F06%2F10%2Facts_as_chimp-updates%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fmandarinsoda.com%2F2008%2F06%2F10%2Facts_as_chimp-updates%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fmandarinsoda.com%2F2008%2F06%2F10%2Facts_as_chimp-updates%2F&amp;title=Acts_as_Chimp+Updates" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F06%2F10%2Facts_as_chimp-updates%2F&amp;title=Acts_as_Chimp+Updates" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://mandarinsoda.com/2008/06/10/acts_as_chimp-updates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Braintree and ActiveResource</title>
		<link>http://mandarinsoda.com/2008/06/04/braintree-and-activeresource/</link>
		<comments>http://mandarinsoda.com/2008/06/04/braintree-and-activeresource/#comments</comments>
		<pubDate>Thu, 05 Jun 2008 01:26:02 +0000</pubDate>
		<dc:creator>Matt Carlson</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[braintree]]></category>

		<guid isPermaLink="false">http://mandarinsoda.com/?p=101</guid>
		<description><![CDATA[Been playing around with accessing Braintree transactions from ActiveResource, using the Query API in particular. Thanks to the folks over at QuarkRuby, getting started was quite easy, so I figured I might as well post what I have for the uninitiated. pastie To get started using the API, use commands like the following: t = [...]]]></description>
			<content:encoded><![CDATA[<p>Been playing around with accessing <a href="http://www.braintreepaymentsolutions.com/">Braintree transactions</a> from ActiveResource, using the Query API in particular.  Thanks to the folks over at <a href="http://www.quarkruby.com/2008/1/15/activeresource-and-youtube">QuarkRuby</a>, getting started was quite easy, so I figured I might as well post what I have for the uninitiated.</p>
<p><a href="http://www.pastie.org/220814">pastie</a></p>
<p>To get started using the API, use commands like the following:</p>
<p><code><br />
t = Braintree.find(:all, :params =&gt; {:username =&gt; 'btdemo', :password =&gt; 'btdemo123', :last_name =&gt; 'Lin'})<br />
</code></p>
<p><code><br />
t.each do |transaction|<br />
transaction.gimme_my_money<br />
end<br />
</code></p>
<p>Pretty straightforward stuff if you want to incorporate this into your Rails app, either for integration test verification or some admin pages.</p>

<span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F06%2F04%2Fbraintree-and-activeresource%2F&amp;title=Braintree+and+ActiveResource" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F06%2F04%2Fbraintree-and-activeresource%2F&amp;title=Braintree+and+ActiveResource" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F06%2F04%2Fbraintree-and-activeresource%2F&amp;title=Braintree+and+ActiveResource" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F06%2F04%2Fbraintree-and-activeresource%2F&amp;title=Braintree+and+ActiveResource" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F06%2F04%2Fbraintree-and-activeresource%2F&amp;title=Braintree+and+ActiveResource', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://images.del.icio.us/static/img/delicious.small.gif" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fmandarinsoda.com%2F2008%2F06%2F04%2Fbraintree-and-activeresource%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fmandarinsoda.com%2F2008%2F06%2F04%2Fbraintree-and-activeresource%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fmandarinsoda.com%2F2008%2F06%2F04%2Fbraintree-and-activeresource%2F&amp;title=Braintree+and+ActiveResource" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fmandarinsoda.com%2F2008%2F06%2F04%2Fbraintree-and-activeresource%2F&amp;title=Braintree+and+ActiveResource" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
</span>]]></content:encoded>
			<wfw:commentRss>http://mandarinsoda.com/2008/06/04/braintree-and-activeresource/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
