Class: Picasa::API::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/picasa/api/base.rb

Direct Known Subclasses

Album, Comment, Photo, Tag

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(credentials = {}) ⇒ Base

Returns a new instance of Base

Options Hash (credentials):

  • :user_id (String)

    google username/email

  • :access_token (String)

    token for authorizing requests


9
10
11
12
13
# File 'lib/picasa/api/base.rb', line 9

def initialize(credentials = {})
  @user_id  = credentials.fetch(:user_id)
  @access_token = credentials[:access_token]
  @authorization_header = credentials[:authorization_header]
end

Instance Attribute Details

#access_tokenObject (readonly)

Returns the value of attribute access_token


4
5
6
# File 'lib/picasa/api/base.rb', line 4

def access_token
  @access_token
end

#authorization_headerObject (readonly)

Returns the value of attribute authorization_header


4
5
6
# File 'lib/picasa/api/base.rb', line 4

def authorization_header
  @authorization_header
end

#user_idObject (readonly)

Returns the value of attribute user_id


4
5
6
# File 'lib/picasa/api/base.rb', line 4

def user_id
  @user_id
end

Instance Method Details

#auth_headerObject


15
16
17
18
19
20
21
22
23
24
25
# File 'lib/picasa/api/base.rb', line 15

def auth_header
  {}.tap do |header|
    token = if access_token
      "Bearer #{access_token}"
    elsif authorization_header
      authorization_header
    end

    header["Authorization"] = token if token
  end
end