Class: Markety::Lead
- Inherits:
-
Object
- Object
- Markety::Lead
- Defined in:
- lib/markety/lead.rb
Overview
Represents a record of the data known about a lead within Marketo
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#email ⇒ Object
Returns the value of attribute email.
-
#foreign_sys_person_id ⇒ Object
Returns the value of attribute foreign_sys_person_id.
-
#idnum ⇒ Object
readonly
Returns the value of attribute idnum.
-
#types ⇒ Object
readonly
Returns the value of attribute types.
Class Method Summary collapse
-
.from_hash(savon_hash) ⇒ Object
hydrates an instance from a savon hash returned from the marketo API.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#get_attribute(name) ⇒ Object
get the value for the named attribute.
-
#get_attribute_type(name) ⇒ Object
get the type of the named attribute.
-
#initialize(email: nil, idnum: nil, foreign_sys_person_id: nil) ⇒ Lead
constructor
A new instance of Lead.
-
#set_attribute(name, value, type = "string") ⇒ Object
update the value of the named attribute.
- #synchronisation_hash ⇒ Object
Constructor Details
#initialize(email: nil, idnum: nil, foreign_sys_person_id: nil) ⇒ Lead
Returns a new instance of Lead.
7 8 9 10 11 12 13 |
# File 'lib/markety/lead.rb', line 7 def initialize(email:nil, idnum:nil, foreign_sys_person_id:nil) @idnum = idnum @foreign_sys_person_id = foreign_sys_person_id @email = email @attributes = {} @types = {} end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
4 5 6 |
# File 'lib/markety/lead.rb', line 4 def attributes @attributes end |
#email ⇒ Object
Returns the value of attribute email.
5 6 7 |
# File 'lib/markety/lead.rb', line 5 def email @email end |
#foreign_sys_person_id ⇒ Object
Returns the value of attribute foreign_sys_person_id.
5 6 7 |
# File 'lib/markety/lead.rb', line 5 def foreign_sys_person_id @foreign_sys_person_id end |
#idnum ⇒ Object (readonly)
Returns the value of attribute idnum.
4 5 6 |
# File 'lib/markety/lead.rb', line 4 def idnum @idnum end |
#types ⇒ Object (readonly)
Returns the value of attribute types.
4 5 6 |
# File 'lib/markety/lead.rb', line 4 def types @types end |
Class Method Details
.from_hash(savon_hash) ⇒ Object
hydrates an instance from a savon hash returned from the marketo API
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/markety/lead.rb', line 24 def self.from_hash(savon_hash) lead = Lead.new(email: savon_hash[:email], idnum:savon_hash[:id].to_i) unless savon_hash[:lead_attribute_list].nil? if savon_hash[:lead_attribute_list][:attribute].kind_of? Hash attributes = [savon_hash[:lead_attribute_list][:attribute]] else attributes = savon_hash[:lead_attribute_list][:attribute] end attributes.each do |attribute| lead.set_attribute(attribute[:attr_name], attribute[:attr_value], attribute[:attr_type]) end end lead end |
Instance Method Details
#==(other) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/markety/lead.rb', line 15 def ==(other) other.is_a?(Lead) && @attributes==other.send(:attributes) && @idnum==other.idnum && @email==other.email && @foreign_sys_person_id==other.foreign_sys_person_id end |
#get_attribute(name) ⇒ Object
get the value for the named attribute
50 51 52 |
# File 'lib/markety/lead.rb', line 50 def get_attribute(name) @attributes[name] end |
#get_attribute_type(name) ⇒ Object
get the type of the named attribute
55 56 57 |
# File 'lib/markety/lead.rb', line 55 def get_attribute_type(name) @types[name] end |
#set_attribute(name, value, type = "string") ⇒ Object
update the value of the named attribute
44 45 46 47 |
# File 'lib/markety/lead.rb', line 44 def set_attribute(name, value, type = "string") @attributes[name] = value @types[name] = type end |
#synchronisation_hash ⇒ Object
59 60 61 |
# File 'lib/markety/lead.rb', line 59 def synchronisation_hash keys_hash.merge({"leadAttributeList" => {"attribute" => attributes_soap_array}}) end |