Class: Rapleaf::Marketo::LeadRecord
- Inherits:
-
Object
- Object
- Rapleaf::Marketo::LeadRecord
- Defined in:
- lib/marketo/lead_record.rb
Overview
Represents a record of the data known about a lead within marketo
Class Method Summary collapse
-
.from_hash(savon_hash) ⇒ Object
hydrates an instance from a savon hash returned form the marketo API.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #attributes ⇒ Object
-
#each_attribute_pair(&block) ⇒ Object
will yield pairs of |attribute_name, attribute_value|.
-
#email ⇒ Object
get the record email.
-
#get_attribute(name) ⇒ Object
get the value for the named attribute.
-
#idnum ⇒ Object
get the record idnum.
-
#initialize(email, idnum = nil) ⇒ LeadRecord
constructor
A new instance of LeadRecord.
-
#set_attribute(name, value) ⇒ Object
update the value of the named attribute.
Constructor Details
#initialize(email, idnum = nil) ⇒ LeadRecord
Returns a new instance of LeadRecord.
5 6 7 8 9 |
# File 'lib/marketo/lead_record.rb', line 5 def initialize(email, idnum = nil) @idnum = idnum @attributes = {} set_attribute('Email', email) end |
Class Method Details
.from_hash(savon_hash) ⇒ Object
hydrates an instance from a savon hash returned form the marketo API
12 13 14 15 16 17 18 |
# File 'lib/marketo/lead_record.rb', line 12 def self.from_hash(savon_hash) lead_record = LeadRecord.new(savon_hash[:email], savon_hash[:id].to_i) savon_hash[:lead_attribute_list][:attribute].each do |attribute| lead_record.set_attribute(attribute[:attr_name], attribute[:attr_value]) end lead_record end |
Instance Method Details
#==(other) ⇒ Object
51 52 53 54 |
# File 'lib/marketo/lead_record.rb', line 51 def ==(other) @attributes == other.attributes && @idnum == other.idnum end |
#attributes ⇒ Object
30 31 32 |
# File 'lib/marketo/lead_record.rb', line 30 def attributes @attributes end |
#each_attribute_pair(&block) ⇒ Object
will yield pairs of |attribute_name, attribute_value|
45 46 47 48 49 |
# File 'lib/marketo/lead_record.rb', line 45 def each_attribute_pair(&block) @attributes.each_pair do |name, value| block.call(name, value) end end |
#email ⇒ Object
get the record email
26 27 28 |
# File 'lib/marketo/lead_record.rb', line 26 def email get_attribute('Email') end |
#get_attribute(name) ⇒ Object
get the value for the named attribute
40 41 42 |
# File 'lib/marketo/lead_record.rb', line 40 def get_attribute(name) @attributes[name] end |
#idnum ⇒ Object
get the record idnum
21 22 23 |
# File 'lib/marketo/lead_record.rb', line 21 def idnum @idnum end |
#set_attribute(name, value) ⇒ Object
update the value of the named attribute
35 36 37 |
# File 'lib/marketo/lead_record.rb', line 35 def set_attribute(name, value) @attributes[name] = value end |