class Rubspot::Contact
Attributes
email[RW]
firstname[RW]
vid[RW]
Public Class Methods
find_by_email(email)
click to toggle source
# File lib/rubspot/models/contact.rb, line 14 def self.find_by_email(email) response = Rubspot::Base::get("https://api.hubapi.com/contacts/v1/contact/email/#{email}/profile?hapikey=#{Rubspot::API_KEY}") return nil unless response.ok? Rubspot::ContactRepresentation.new(Rubspot::Contact.new).from_json response.body end
new(opts = {})
click to toggle source
# File lib/rubspot/models/contact.rb, line 8 def initialize(opts = {}) opts.each do |opt| instance_variable_set("@#{opt[0]}", opt[1]) end end
Public Instance Methods
save()
click to toggle source
# File lib/rubspot/models/contact.rb, line 20 def save params = Rubspot::ContactRepresentation.new(self).to_json response = Rubspot::Base::post("http://api.hubapi.com/contacts/v1/contact/createOrUpdate/email/#{self.email}/?hapikey=#{Rubspot::API_KEY}&portalId=#{Rubspot::PORTAL_ID}", params) 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/contact.rb, line 29 def populate_attributes_from(response) Rubspot::ContactRepresentation.new(self).from_json response.body end