Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Ruby wrapper for PipelineDeals API
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
README
pipelinedeals.rb

README

So far, this is completely untested, not sure if it works, but wanted to go ahead and get it out there...

Ok, so this works now. Overcame error with response from PipelineDeals API by over-writing ActiveResource's instantiate_collection method.

You can now make API calls such as the following with this library:

users = PipelineDeals::User.find(:all)
sources = PipelineDeals::LeadSource.find(:all)
contacts = PipelineDeals::Contact.find(:all, :params => {:userId => 1})

Make sure that all objects other than User and LeadSource have a userId passed in the params field.

However, I'm still quite confused as to why this returns nil:
contacts = PipelineDeals::Contact.find(:one, :params => {:userId => 1})

Apparently with ActiveResource, the Object.find methods have the following behavior:
Possible find methods for activeresource:
.find         => calls find_single => calls element_path, then instantiate record
.find(:all)   => calls find_every  => calls instantiate_collection if options[:from] is Symbol
                                   => calls custom path, then instantiate_collection if options[:from] is String
                                   => calls collection_path, then instantiate_collection if options[:from] is not Symbol or String
.find(:first) => calls find_every.first
.find(:one)   => calls instantiate_record if options[:from] is Symbol
              => calls custom path, then instantiate_record if options[:from] is String
              => does nothing and returns nil if options[:from] is not Symbol or String (including if it's left blank)

I don't understand why the following function does not have an 'else' statement:
# File active_resource/base.rb, line 462
def find_one(options)
  case from = options[:from]
  when Symbol
    instantiate_record(get(from, options[:params]))
  when String
    path = "#{from}#{query_string(options[:params])}"
    instantiate_record(connection.get(path, headers))
  end
end

It doesn't seem to me that you should have to define the :from parameter in Object.find(:one) when AR assumes this in both .find(:all) and .find(:first)

At any rate, this code all still needs a lot of testing.

New create method works. You can now create a new entries like this:
contact = PipelineDeals::Contact.create(:userId => 1, :firstName => 'Tester', :lastName => 'From API', :companyName => "API Created")
note = PipelineDeals::Note.create(:userId => 1, :title => 'this is a test', :content => 'This was created using my new ruby wrapper', :personId => 99)
todo = PipelineDeals::Todo.create(:userId => 1, :dueDate => 'Wed Jul 16 18:32:50 UTC 2008', :description => "Finish this ruby wrapper by last year please", :eventAssignableType => 'Contact', :eventAssignableId => 99, :ownerId => 2, :complete => 1, :eventCategory => 'Milestone')
Something went wrong with that request. Please try again.