Sha256: 3e83e1bc317e284fbda3c3d31961c24686c5d20d578fb4b215588178c909d61f

Contents?: true

Size: 1.14 KB

Versions: 11

Compression:

Stored size: 1.14 KB

Contents

module Legato
  module Management
    class Goal

      extend Finder

      def self.default_path
        "/accounts/~all/webproperties/~all/profiles/~all/goals"
      end

      def path
        self.class.default_path + "/" + id.to_s
      end

      attr_accessor :id, :name, :account_id, :web_property_id, :profile_id, :user, :attributes

      def initialize(attributes, user)
        self.user = user
        self.id = attributes['id']
        self.name = attributes['name']
        self.account_id = attributes['accountId']
        self.web_property_id = attributes['webPropertyId']
        self.profile_id = attributes['profileId']

        ['id', 'name', 'accountId', 'webPropertyId', 'profileId'].each { |key| attributes.delete(key) }
        self.attributes = attributes
      end

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

      def self.for_web_property(web_property)
        all(web_property.user, web_property.path+'/profiles/~all/goals')
      end

      def self.for_profile(profile)
        all(profile.user, profile.path+'/goals')
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
legato-0.6.2 lib/legato/management/goal.rb
legato-0.6.1 lib/legato/management/goal.rb
legato-0.6.0 lib/legato/management/goal.rb
legato-0.5.2 lib/legato/management/goal.rb
legato-0.5.1 lib/legato/management/goal.rb
legato-0.5.0 lib/legato/management/goal.rb
legato-0.4.0 lib/legato/management/goal.rb
legato-0.3.3 lib/legato/management/goal.rb
legato-0.3.2 lib/legato/management/goal.rb
legato-0.3.1 lib/legato/management/goal.rb
legato-0.3.0 lib/legato/management/goal.rb