Class: Zoro::Lead

Inherits:
Object
  • Object
show all
Defined in:
lib/zoro/lead.rb

Constant Summary collapse

ZOHO_MODULE =
"Leads"

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#apiObject

Returns the value of attribute api.



4
5
6
# File 'lib/zoro/lead.rb', line 4

def api
  @api
end

#fieldsObject

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_xmlObject



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_moduleObject



22
23
24
# File 'lib/zoro/lead.rb', line 22

def zoho_module
  ZOHO_MODULE
end