<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>examples/submission.rb</filename>
    </added>
    <added>
      <filename>lib/wufoo/client.rb</filename>
    </added>
    <added>
      <filename>lib/wufoo/submission.rb</filename>
    </added>
    <added>
      <filename>test/test_client.rb</filename>
    </added>
    <added>
      <filename>test/test_submission.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,89 +1,9 @@
+$:.unshift File.dirname(__FILE__)
+
 require 'rubygems'
 gem 'httparty', '0.2.2'
 require 'httparty'
 
-class Wufoo
-  include HTTParty
-  
-  attr_accessor :url, :api_key, :form, :params
-  
-  def initialize(url, api_key, form, params={})
-    @url, @api_key, @form = url, api_key, form
-    @params = {}.merge(params || {})
-  end
-  
-  def add_params(new_params)
-    @params.merge!(new_params)
-    self
-  end
-  
-  def process
-    data = params.merge({
-      :w_api_key =&gt; api_key,
-      :w_form =&gt; form,
-    })
-    
-    Wufoo::Response.new(self.class.post(&quot;#{@url}/api/insert/&quot;, :query =&gt; data, :format =&gt; :json))
-  end
-  
-  class Response    
-    attr_accessor :data
-    
-    def initialize(data)
-      @data = data
-      populate
-    end
-    
-    def success?
-      return false if data.nil? || data == {}
-      data['wufoo_submit'].first['success'] == 'true'
-    end
-    
-    def fail?
-      return true if data.nil? || data == {}
-      error.size &gt; 0
-    end
-    
-    def valid?
-      errors.size == 0
-    end
-    
-    def error
-      @error || ''
-    end
-    
-    def errors
-      @errors || []
-    end
-    
-    def message
-      @message || ''
-    end
-    
-    def entry_id
-      @entry_id
-    end
-    
-    private
-      def populate
-        @message  = data['wufoo_submit'].first['confirmation_message']
-        @entry_id = data['wufoo_submit'].first['entry_id']
-        @error    = data['wufoo_submit'].first['error']
-        @raw_errors   = data['wufoo_submit'].first['field_errors']
-        
-        if @raw_errors &amp;&amp; @raw_errors.size &gt; 0
-          @errors = @raw_errors.inject([]) { |acc, error| acc &lt;&lt; FieldError.new(error) }
-        end
-      end
-  end
-  
-  class FieldError
-    attr_accessor :field_id, :code, :message
-    
-    def initialize(attrs)
-      @field_id = attrs['field_id']
-      @code     = attrs['error_code']
-      @message  = attrs['error_message']
-    end
-  end
-end
\ No newline at end of file
+require 'wufoo/client'
+require 'wufoo/submission'
+require 'wufoo/version'
\ No newline at end of file</diff>
      <filename>lib/wufoo.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,3 @@
-class Wufoo
+module Wufoo
   Version = '0.1.1'
 end
\ No newline at end of file</diff>
      <filename>lib/wufoo/version.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,4 +2,31 @@ require 'rubygems'
 require 'test/unit'
 require 'context'
 require 'stump'
-require File.join(File.dirname(__FILE__), '..', 'lib', 'wufoo')
\ No newline at end of file
+require File.join(File.dirname(__FILE__), '..', 'lib', 'wufoo')
+
+def successful_response_data
+  {&quot;wufoo_submit&quot; =&gt; [{
+      &quot;confirmation_message&quot; =&gt; &quot;Success! Thanks for filling out my form!&quot;,
+      &quot;entry_id&quot;             =&gt; &quot;1025&quot;,
+      &quot;success&quot;              =&gt; &quot;true&quot;
+    }]}
+end
+
+def error_response_data
+  {&quot;wufoo_submit&quot; =&gt; [{
+      &quot;error&quot;        =&gt; &quot;The supplied form URL was not found.&quot;,
+      &quot;field_errors&quot; =&gt; [],
+      &quot;success&quot;      =&gt; &quot;false&quot;
+    }]}
+end
+
+def field_error_response_data
+  {&quot;wufoo_submit&quot; =&gt; [{
+      &quot;error&quot; =&gt; &quot;&quot;,
+      &quot;field_errors&quot; =&gt; [
+        {&quot;field_id&quot; =&gt; &quot;field0&quot;, &quot;error_message&quot; =&gt; &quot;Invalid email address.&quot;, &quot;error_code&quot; =&gt; &quot;2&quot;},
+        {&quot;field_id&quot; =&gt; &quot;field1&quot;, &quot;error_message&quot; =&gt; &quot;Field is required.&quot;, &quot;error_code&quot; =&gt; &quot;0&quot;},
+      ],
+      &quot;success&quot; =&gt; &quot;false&quot;
+    }]}
+end
\ No newline at end of file</diff>
      <filename>test/test_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,155 +1,7 @@
 require File.dirname(__FILE__) + '/test_helper'
 
 class TestWufoo &lt; Test::Unit::TestCase
-  before do
-    @successful_response_data = {
-      &quot;wufoo_submit&quot; =&gt; [{
-        &quot;confirmation_message&quot; =&gt; &quot;Success! Thanks for filling out my form!&quot;,
-        &quot;entry_id&quot;             =&gt; &quot;1025&quot;,
-        &quot;success&quot;              =&gt; &quot;true&quot;
-      }]
-    }
-    
-    @error_response_data = {
-      &quot;wufoo_submit&quot; =&gt; [{
-        &quot;error&quot;        =&gt; &quot;The supplied form URL was not found.&quot;,
-        &quot;field_errors&quot; =&gt; [],
-        &quot;success&quot;      =&gt; &quot;false&quot;
-      }]
-    }
-    
-    @field_error_response_data = {
-      &quot;wufoo_submit&quot; =&gt; [{
-        &quot;error&quot; =&gt; &quot;&quot;,
-        &quot;field_errors&quot; =&gt; [
-          {&quot;field_id&quot; =&gt; &quot;field0&quot;, &quot;error_message&quot; =&gt; &quot;Invalid email address.&quot;, &quot;error_code&quot; =&gt; &quot;2&quot;},
-          {&quot;field_id&quot; =&gt; &quot;field1&quot;, &quot;error_message&quot; =&gt; &quot;Field is required.&quot;, &quot;error_code&quot; =&gt; &quot;0&quot;},
-        ],
-        &quot;success&quot; =&gt; &quot;false&quot;
-      }]
-    }
+  test 'should have version' do
+    assert_not_nil Wufoo::Version
   end
-  
-  test 'initialize' do
-    wufoo = Wufoo.new('http://dummy.wufoo.com', 'foobar', 'my-crazy-form')
-    assert_equal('http://dummy.wufoo.com', wufoo.url)
-    assert_equal('foobar', wufoo.api_key)
-    assert_equal('my-crazy-form', wufoo.form)
-    assert_equal({}, wufoo.params)
-  end
-  
-  test 'initialize with params' do
-    wufoo = Wufoo.new('http://dummy.wufoo.com', 'foobar', 'my-crazy-form', {'0' =&gt; 'Foo'})
-    assert_equal({'0' =&gt; 'Foo'}, wufoo.params)
-  end
-  
-  test 'add_params' do
-    wufoo = Wufoo.new('http://dummy.wufoo.com', 'foobar', 'my-crazy-form').add_params('0' =&gt; 'Foo')
-    assert_equal({'0' =&gt; 'Foo'}, wufoo.params)
-  end
-  
-  test 'add_params returns self' do
-    assert_kind_of(Wufoo, Wufoo.new('http://dummy.wufoo.com', 'foobar', 'my-crazy-form').add_params('0' =&gt; 'Foo'))
-  end
-  
-  context 'processing response that was successful' do
-    before do
-      Wufoo.stub!(:post, :return =&gt; @successful_response_data)
-      wufoo = Wufoo.new('http://dummy.wufoo.com', 'foobar', 'my-crazy-form').add_params({'0' =&gt; 'Foobar!'})
-      @response = wufoo.process
-    end
-    
-    test 'should have data' do
-      assert_equal(@successful_response_data, @response.data)
-    end
-    
-    test 'should be success?' do
-      assert @response.success?
-    end
-    
-    test 'should not be fail?' do
-      assert ! @response.fail?
-    end
-    
-    test 'should be valid?' do
-      assert @response.valid?
-    end
-    
-    test 'should have message' do
-      assert_equal('Success! Thanks for filling out my form!', @response.message)
-    end
-    
-    test 'should have entry_id' do
-      assert_equal('1025', @response.entry_id)
-    end
-    
-    test 'should not have error' do
-      assert_equal('', @response.error)
-    end
-    
-    test 'should not have errors' do
-      assert_equal([], @response.errors)
-    end
-  end
-  
-  context 'processing a response that failed' do
-    before do
-      Wufoo.stub!(:post, :return =&gt; @error_response_data)
-      wufoo = Wufoo.new('http://dummy.wufoo.com', 'foobar', 'my-crazy-form').add_params({'0' =&gt; 'Foobar!'})
-      @response = wufoo.process
-    end
-    
-    test 'should have data' do
-      assert_equal(@error_response_data, @response.data)
-    end
-    
-    test 'should not be success?' do
-      assert ! @response.success?
-    end
-    
-    test 'should be a fail?' do
-      assert @response.fail?
-    end
-    
-    test 'should be valid?' do
-      assert @response.valid?
-    end
-
-    test 'should have error' do
-      assert_equal('The supplied form URL was not found.', @response.error)
-    end
-  end
-  
-  context 'processing a response with field errors' do
-    before do
-      Wufoo.stub!(:post, :return =&gt; @field_error_response_data)
-      wufoo = Wufoo.new('http://dummy.wufoo.com', 'foobar', 'my-crazy-form').add_params({'0' =&gt; 'Foobar!'})
-      @response = wufoo.process
-    end
-    
-    test 'should have data' do
-      assert_equal(@field_error_response_data, @response.data)
-    end
-    
-    test 'should not be success?' do
-      assert ! @response.success?
-    end
-    
-    test 'should not be fail?' do
-      assert ! @response.fail?
-    end
-    
-    test 'should not be valid?' do
-      assert ! @response.valid?
-    end
-    
-    test 'should have errors' do
-      field_ids = ['field0', 'field1']
-      messages = ['Invalid email address.', 'Field is required.']
-      codes = ['2', '0']
-      assert_equal(field_ids, @response.errors.collect { |e| e.field_id })
-      assert_equal(messages, @response.errors.collect { |e| e.message })
-      assert_equal(codes, @response.errors.collect { |e| e.code })
-    end
-  end        
 end
\ No newline at end of file</diff>
      <filename>test/test_wufoo.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>7eefc7496d84fedff4c182673a179a830be8727e</id>
    </parent>
  </parents>
  <author>
    <name>John Nunemaker</name>
    <email>nunemaker@gmail.com</email>
  </author>
  <url>http://github.com/jnunemaker/wufoo/commit/e5822a261a7557556c832b3503fd57ee6d9fb6a0</url>
  <id>e5822a261a7557556c832b3503fd57ee6d9fb6a0</id>
  <committed-date>2008-12-16T15:15:42-08:00</committed-date>
  <authored-date>2008-12-16T15:15:42-08:00</authored-date>
  <message>Refactored to now use client and submission so that other wufoo api pieces can be built into this gem.</message>
  <tree>a0c4411bae9f39840c7b07a94fbdd7e2a3b0bd7e</tree>
  <committer>
    <name>John Nunemaker</name>
    <email>nunemaker@gmail.com</email>
  </committer>
</commit>
