Sha256: 3292273b5d02485a12d6da3fefb78f64b30666811d6645efac85cd8857ee78e5

Contents?: true

Size: 813 Bytes

Versions: 2

Compression:

Stored size: 813 Bytes

Contents

module Garb
  class Profile

    include ProfileReports

    attr_reader :session, :table_id, :title, :account_name, :account_id, :web_property_id, :goals

    def initialize(entry, session)
      @session = session
      @title = entry['title']
      @table_id = entry['dxp:tableId']
      @goals = (entry[Garb.to_ga('goal')] || []).map {|g| Goal.new(g)}

      entry['dxp:property'].each do |p|
        instance_variable_set :"@#{Garb.from_ga(p['name'])}", p['value']
      end
    end

    def id
      Garb.from_ga(@table_id)
    end

    def self.all(session = Session)
      AccountFeedRequest.new(session).entries.map {|entry| new(entry, session)}
    end

    def self.first(id, session = Session)
      all(session).detect {|profile| profile.id == id || profile.web_property_id == id }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
garb-0.8.0 lib/garb/profile.rb
garb-0.7.6 lib/garb/profile.rb