Class: Zoro::Lead
- Inherits:
-
Object
- Object
- Zoro::Lead
- Defined in:
- lib/zoro/lead.rb
Constant Summary collapse
- ZOHO_MODULE =
"Leads"
Instance Attribute Summary collapse
-
#api ⇒ Object
Returns the value of attribute api.
-
#fields ⇒ Object
Returns the value of attribute fields.
Instance Method Summary collapse
- #add_field(field_name, value) ⇒ Object
-
#initialize(data = {}) ⇒ Lead
constructor
A new instance of Lead.
- #save! ⇒ Object
- #to_xml ⇒ Object
- #zoho_module ⇒ Object
Constructor Details
#initialize(data = {}) ⇒ Lead
Returns a new instance of Lead.
6 7 8 |
# File 'lib/zoro/lead.rb', line 6 def initialize(data = {}) @fields = {}.merge(data) end |
Instance Attribute Details
#api ⇒ Object
Returns the value of attribute api.
4 5 6 |
# File 'lib/zoro/lead.rb', line 4 def api @api end |
#fields ⇒ Object
Returns the value of attribute fields.
4 5 6 |
# File 'lib/zoro/lead.rb', line 4 def fields @fields end |
Instance Method Details
#add_field(field_name, value) ⇒ Object
18 19 20 |
# File 'lib/zoro/lead.rb', line 18 def add_field(field_name, value) @fields[field_name] = value end |
#save! ⇒ Object
10 11 12 |
# File 'lib/zoro/lead.rb', line 10 def save! api.insert_records(self) end |
#to_xml ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/zoro/lead.rb', line 26 def to_xml xml_map = Hash.new xml_map['row'] = { 'no' => '1', 'FL' => @fields.map do |k, v| { 'val' => k, 'content' => v} end } XmlSimple.xml_out(xml_map, :RootName => ZOHO_MODULE) end |
#zoho_module ⇒ Object
22 23 24 |
# File 'lib/zoro/lead.rb', line 22 def zoho_module ZOHO_MODULE end |