class GoodDataMarketo::Activity

Public Class Methods

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

attr_accessor :client

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

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

  @activity = {
      :id => data[:id],
      :activity_date_time => data[:activity_date_time].to_s, # Force this to be ADS DATETIME
      :activity_type => data[:activity_type],
      :mktg_asset_name => data[:mktg_asset_name],
      :raw => data
  }

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

  attributes = data[:activity_attributes][: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

activity_date_time()
Alias for: time
activity_type()
Alias for: type
attributes(a = nil) click to toggle source
# File lib/gooddata_marketo/models/child/activity.rb, line 82
def attributes a = nil

  if a
    @attributes[a]
  else
    @attributes
  end

end
columns()
Alias for: headers
date() click to toggle source
# File lib/gooddata_marketo/models/child/activity.rb, line 70
def date
  @activity[:date]
end
headers() click to toggle source
# File lib/gooddata_marketo/models/child/activity.rb, line 64
def headers
  @headers.map { |h| h.scan(/\w+/).join.downcase }
end
Also aliased as: columns
id() click to toggle source
# File lib/gooddata_marketo/models/child/activity.rb, line 74
def id
  @activity[:id]
end
json()
Alias for: raw
name() click to toggle source
# File lib/gooddata_marketo/models/child/activity.rb, line 78
def name
  @activity[:mktg_asset_name]
end
raw() click to toggle source
# File lib/gooddata_marketo/models/child/activity.rb, line 92
def raw
  @activity[:raw]
end
Also aliased as: json
time() click to toggle source
# File lib/gooddata_marketo/models/child/activity.rb, line 46
def time
  @activity[:activity_date_time]
end
Also aliased as: activity_date_time
to_a()
Alias for: to_row
to_row() click to toggle source
# File lib/gooddata_marketo/models/child/activity.rb, line 54
def to_row
  row = [self.id,self.time,self.type,self.name]
  @attributes.each do |attr|
    row << attr[1]
  end
  row.map! { |i| i.to_s }
end
Also aliased as: to_a, to_a
type() click to toggle source
# File lib/gooddata_marketo/models/child/activity.rb, line 50
def type
  @activity[:activity_type]
end
Also aliased as: activity_type
values() click to toggle source
# File lib/gooddata_marketo/models/child/activity.rb, line 34
def values
  hash = Hash.new
  hash['id'] = self.id
  hash['activity_date_time'] = self.time
  hash['activity_type'] = self.type
  hash['mktg_asset_name'] = self.name
  @attributes.each do |attr|
    hash[attr[0].scan(/\w+/).join] = attr[1]
  end
  hash
end