class GoodDataMarketo::Lead

Public Class Methods

new(data, config = {}) click to toggle source

CLIENT OBJ REMOVED DUE TO PERFORMANCE ISSUE attr_accessor :client

# File lib/gooddata_marketo/models/child/lead.rb, line 8
def initialize data, config = {}

  data = JSON.parse(data, :symbolize_names => true) unless data.is_a? Hash

  @lead = {
      :id => data[:id],
      :email => data[:email],
      :foreign_sys_person_id => data[:foreign_sys_person_id],
      :foreign_sys_type => data[:foreign_sys_type],
      :raw => data
  }

  @headers = @lead.keys.map {|k| k.to_s.capitalize! }
  @headers.pop()

  attributes = data[:lead_attribute_list][:attribute]
  attribute_map = Hash.new
  attributes.map { |attr|
    @headers << property = attr[:attr_name].gsub(" ","_").downcase!
                value = StringWizard.escape_special_characters(attr[:attr_value].to_s)
                attribute_map[property] = value
  }

  @attributes = attribute_map

end

Public Instance Methods

attributes(a = nil) click to toggle source
# File lib/gooddata_marketo/models/child/lead.rb, line 102
def attributes a = nil

  if a
    @attributes[a]
  else
    @attributes
  end

end
columns()
Alias for: headers
email() click to toggle source
# File lib/gooddata_marketo/models/child/lead.rb, line 90
def email
  @lead[:email]
end
foreign_sys_person_id() click to toggle source
# File lib/gooddata_marketo/models/child/lead.rb, line 94
def foreign_sys_person_id
  @lead[:foreign_sys_person_id]
end
foreign_sys_type() click to toggle source
# File lib/gooddata_marketo/models/child/lead.rb, line 98
def foreign_sys_type
  @lead[:foreign_sys_type]
end
headers() click to toggle source
# File lib/gooddata_marketo/models/child/lead.rb, line 43
def headers
  @headers.map { |h| h.downcase }
end
Also aliased as: columns
id() click to toggle source
# File lib/gooddata_marketo/models/child/lead.rb, line 86
def id
  @lead[:id]
end
json()
Alias for: raw
raw() click to toggle source
# File lib/gooddata_marketo/models/child/lead.rb, line 112
def raw
  @lead[:raw]
end
Also aliased as: json
to_a()
Alias for: to_row
to_row() click to toggle source
# File lib/gooddata_marketo/models/child/lead.rb, line 35
def to_row
  row = [self.id,self.email,self.foreign_sys_person_id,self.foreign_sys_type]
  @attributes.each do |attr|
    row << attr[1]
  end
  row.map! { |i| i.to_s }
end
Also aliased as: to_a
values() click to toggle source

alias :changes :get_changes

# File lib/gooddata_marketo/models/child/lead.rb, line 74
def values
  hash = Hash.new
  hash['id'] = self.id
  hash['email'] = self.email
  hash['foreign_sys_person_id'] = self.foreign_sys_person_id
  hash['foreign_sys_type'] = self.foreign_sys_type
  @attributes.each do |attr|
    hash[attr[0]] = attr[1]
  end
  hash
end