Sha256: aa5e27003773c6de60f51b7abf4f3e423d40acde1e3a5aad799f34c464286651

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

module Garb
  module Management
    class Profile

      include ProfileReports

      attr_reader :session, :path
      attr_reader :id, :title, :account_id, :web_property_id

      def self.all(session = Session, path = '/accounts/~all/webproperties/~all/profiles')
        feed = Feed.new(session, path)
        feed.entries.map {|entry| new(entry, session)}
      end

      def self.for_account(account)
        all(account.session, account.path+'/webproperties/~all/profiles')
      end

      def self.for_web_property(web_property)
        all(web_property.session, web_property.path+'/profiles')
      end

      def initialize(entry, session)
        @session = session
        @path = Garb.parse_link(entry, "self").gsub(Feed::BASE_URL, '')
        @title = entry['title'].gsub('Google Analytics Profile ', '')

        properties = Garb.parse_properties(entry)
        @id = properties['profile_id']
        @account_id = properties['account_id']
        @web_property_id = properties['web_property_id']
      end

      # def path
      #   ['/accounts', self.account_id, 'webproperties', self.web_property_id, 'profiles', self.id].join('/')
      # end

      # def goals
      # end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
garb-0.8.1 lib/garb/management/profile.rb