Class: Picasa::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(credentials = {}) ⇒ Client

Returns a new instance of Client

Parameters:

  • credentials (Hash) (defaults to: {})

Options Hash (credentials):

  • :user_id (String)

    google username/email

  • :authorization_header (String)

    custom authorization header (i.e. taken from OAuth2)

  • :access_token (String)

    picasa OAuth2 access token


10
11
12
13
14
15
16
17
18
19
20
# File 'lib/picasa/client.rb', line 10

def initialize(credentials = {})
  if credentials[:password]
    raise(ArgumentError, "Providing password has no effect as google login by password API is not active anymore https://developers.google.com/accounts/docs/AuthForInstalledApps")
  end
  @user_id      = credentials[:user_id] || raise(ArgumentError, "You must specify user_id")
  @access_token = credentials[:access_token]
  if credentials[:authorization_header]
    puts "Passing authorization_header is deprecated. Please pass access_token"
  end
  @authorization_header = credentials[:authorization_header]
end

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token


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

def access_token
  @access_token
end

#authorization_headerObject

Returns the value of attribute authorization_header


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

def authorization_header
  @authorization_header
end

#user_idObject (readonly)

Returns the value of attribute user_id


3
4
5
# File 'lib/picasa/client.rb', line 3

def user_id
  @user_id
end

Instance Method Details

#albumAPI::Album

Examples:

client = Picasa::Client.new(user_id: "[email protected]")
album_list = client.album.list
album_list.title
# => "My album"

Returns:


29
30
31
# File 'lib/picasa/client.rb', line 29

def album
  API::Album.new(credentials)
end

#commentAPI::Comment

Examples:

client = Picasa::Client.new(user_id: "[email protected]")
comment_list = client.comment.list(album_id: "988", photo_id: "123")
comment_list.entries.map &:content
# => "nice photo!"

Returns:


62
63
64
# File 'lib/picasa/client.rb', line 62

def comment
  API::Comment.new(credentials)
end

#photoAPI::Photo

Examples:

client = Picasa::Client.new(user_id: "[email protected]", password: "secret")
photo = client.photo.create("album-id", title: "My picture", binary: "image-binary-data", content_type: "image/jpeg")
photo.id
# => "4322232322421"

Returns:


40
41
42
# File 'lib/picasa/client.rb', line 40

def photo
  API::Photo.new(credentials)
end

#tagAPI::Tag

Examples:

client = Picasa::Client.new(user_id: "[email protected]")
tag_list = client.tag.list(album_id: "988", photo_id: "123")
tag_list.title
# => "holidays"

Returns:


51
52
53
# File 'lib/picasa/client.rb', line 51

def tag
  API::Tag.new(credentials)
end