class Rubspot::Deal

Attributes

companies[RW]
dealname[RW]
id[RW]
portal_id[RW]
vids[RW]

Public Class Methods

new(opts = {}) click to toggle source
# File lib/rubspot/models/deal.rb, line 9
def initialize(opts = {})
  opts.each do |opt|
    instance_variable_set("@#{opt[0]}", opt[1])
  end
end

Public Instance Methods

save() click to toggle source

def self.find(id)

uri = "https://api.hubapi.com/deals/v1/deal/#{id}?hapikey=#{Rubspot::API_KEY}&portalId=#{Rubspot::PORTAL_ID}"
response = Rubspot::Base::get uri
return nil unless response.ok?

end

# File lib/rubspot/models/deal.rb, line 21
def save
  params = { 'associations' => {'associatedCompanyIds' => companies, 'associatedVids' => vids }, 'portalId' => portal_id, 'properties' => []}
  uri = "https://api.hubapi.com/deals/v1/deal?hapikey=#{Rubspot::API_KEY}&portalId=#{Rubspot::PORTAL_ID}"
  response = Rubspot::Base::post uri, params.to_json
  return false unless response.ok?
  populate_attributes_from response
  true
end

Private Instance Methods

populate_attributes_from(response) click to toggle source
# File lib/rubspot/models/deal.rb, line 31
def populate_attributes_from(response)
  Rubspot::DealRepresentation.new(self).from_json response.body
end