Sha256: e4e3e49b2de5331dd73e91208b2aa95c62028fe459a8a98331c82740f5345159

Contents?: true

Size: 1.36 KB

Versions: 7

Compression:

Stored size: 1.36 KB

Contents

module Pardot
  module Objects
    
    module Opportunities
      
      def opportunities
        @opportunities ||= Opportunities.new self
      end
      
      class Opportunities
        
        def initialize client
          @client = client
        end
        
        def query params
          result = get "/do/query", params, "result"
          result["total_results"] = result["total_results"].to_i if result["total_results"]
          result
        end
        
        def create_by_email email, params = {}
          post "/do/create/prospect_email/#{email}", params
        end
        
        def create_by_id prospect_id, params = {}
          post "/do/create/prospect_id/#{prospect_id}", params
        end
        
        def read_by_id id, params = {}
          post "/do/read/id/#{id}", params
        end
        
        def update_by_id id, params = {}
          post "/do/update/id/#{id}", params
        end
        
        protected
        
        def get path, params = {}, result = "opportunity"
          response = @client.get "opportunity", path, params
          result ? response[result] : response
        end
        
        def post path, params = {}, result = "opportunity"
          response = @client.post "opportunity", path, params
          result ? response[result] : response
        end
        
      end
      
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ruby-pardot-1.3.2 lib/pardot/objects/opportunities.rb
ruby-pardot-1.3.1 lib/pardot/objects/opportunities.rb
ruby-pardot-1.3.0 lib/pardot/objects/opportunities.rb
ruby-pardot-1.2.0 lib/pardot/objects/opportunities.rb
ruby-pardot-1.1.0 lib/pardot/objects/opportunities.rb
ruby-pardot-1.0.2 lib/pardot/objects/opportunities.rb
ruby-pardot-1.0 lib/pardot/objects/opportunities.rb