class Picasa::Client

Attributes

access_token[RW]
authorization_header[RW]
user_id[R]

Public Class Methods

new(credentials = {}) click to toggle source

@param [Hash] credentials @option credentials [String] :user_id google username/email @option credentials [String] :authorization_header custom authorization header (i.e. taken from OAuth2) @option credentials [String] :access_token picasa OAuth2 access token

# 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

Public Instance Methods

album() click to toggle source

@return [API::Album]

@example

client = Picasa::Client.new(user_id: "my.email@google.com")
album_list = client.album.list
album_list.title
# => "My album"
# File lib/picasa/client.rb, line 29
def album
  API::Album.new(credentials)
end
comment() click to toggle source

@return [API::Comment]

@example

client = Picasa::Client.new(user_id: "my.email@google.com")
comment_list = client.comment.list(album_id: "988", photo_id: "123")
comment_list.entries.map &:content
# => "nice photo!"
# File lib/picasa/client.rb, line 62
def comment
  API::Comment.new(credentials)
end
photo() click to toggle source

@return [API::Photo]

@example

client = Picasa::Client.new(user_id: "my.email@google.com", password: "secret")
photo = client.photo.create("album-id", title: "My picture", binary: "image-binary-data", content_type: "image/jpeg")
photo.id
# => "4322232322421"
# File lib/picasa/client.rb, line 40
def photo
  API::Photo.new(credentials)
end
tag() click to toggle source

@return [API::Tag]

@example

client = Picasa::Client.new(user_id: "my.email@google.com")
tag_list = client.tag.list(album_id: "988", photo_id: "123")
tag_list.title
# => "holidays"
# File lib/picasa/client.rb, line 51
def tag
  API::Tag.new(credentials)
end

Private Instance Methods

credentials() click to toggle source
# File lib/picasa/client.rb, line 68
def credentials
  {user_id: user_id}.tap do |credentials|
    credentials[:access_token]         = access_token         if access_token
    credentials[:authorization_header] = authorization_header if authorization_header
  end
end