Sha256: 847d2a27709fcc8874fcce8167a4fbc4ed2508367a4c604da46b2f2029c6d87d

Contents?: true

Size: 989 Bytes

Versions: 29

Compression:

Stored size: 989 Bytes

Contents

module FbGraph2
  class TokenMetadata < Node
    register_attributes(
      raw: [
        :app_id, :application, :error, :is_valid, :metadata, :profile_id, :scopes, :user_id
      ],
      timestamp: [:expires_at, :issued_at],
      custom: [:app, :user, :page]
    )

    def initialize(attributes = {})
      super :debug_token, attributes
      if app_id
        self.app = App.new app_id
      end
      if user_id
        self.user = User.new user_id
      end
      if profile_id
        self.page = Page.new profile_id
      end
    end

    def fetch(params = {}, options = {})
      attributes = get params, options
      self.class.new(attributes[:data]).authenticate access_token
    end

    def valid?
      !!is_valid
    end

    def app_token?
      app.present? && user.blank? && page.blank?
    end

    def user_token?
      app.present? && user.present? && page.blank?
    end

    def page_token?
      app.present? && user.present? && page.present?
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
fb_graph2-1.3.0 lib/fb_graph2/token_metadata.rb
fb_graph2-1.2.0 lib/fb_graph2/token_metadata.rb
fb_graph2-1.1.1 lib/fb_graph2/token_metadata.rb
fb_graph2-1.1.0 lib/fb_graph2/token_metadata.rb
fb_graph2-1.0.1 lib/fb_graph2/token_metadata.rb
fb_graph2-1.0.0 lib/fb_graph2/token_metadata.rb
fb_graph2-0.9.1 lib/fb_graph2/token_metadata.rb
fb_graph2-0.9.0 lib/fb_graph2/token_metadata.rb
fb_graph2-0.8.0 lib/fb_graph2/token_metadata.rb
fb_graph2-0.7.9 lib/fb_graph2/token_metadata.rb
fb_graph2-0.7.8 lib/fb_graph2/token_metadata.rb
fb_graph2-0.7.7 lib/fb_graph2/token_metadata.rb
fb_graph2-0.7.6 lib/fb_graph2/token_metadata.rb
fb_graph2-0.7.5 lib/fb_graph2/token_metadata.rb
fb_graph2-0.7.4 lib/fb_graph2/token_metadata.rb
fb_graph2-0.7.3 lib/fb_graph2/token_metadata.rb
fb_graph2-0.7.2 lib/fb_graph2/token_metadata.rb
fb_graph2-0.7.1 lib/fb_graph2/token_metadata.rb
fb_graph2-0.7.0 lib/fb_graph2/token_metadata.rb
fb_graph2-0.6.2 lib/fb_graph2/token_metadata.rb