Class: Picasa::API::Album
Instance Attribute Summary
Attributes inherited from Base
#access_token, #authorization_header, #user_id
Instance Method Summary collapse
-
#create(params = {}) ⇒ Presenter::Album
Creates album.
-
#destroy(album_id, options = {}) ⇒ true
(also: #delete)
Destroys given album.
-
#list(options = {}) ⇒ Presenter::AlbumList
Returns album list.
-
#show(album_id, options = {}) ⇒ Presenter::Album
Returns photo list for given album.
-
#update(album_id, params = {}) ⇒ Presenter::Album
Update properties of given album.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Picasa::API::Base
Instance Method Details
#create(params = {}) ⇒ Presenter::Album
Creates album
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/picasa/api/album.rb', line 49 def create(params = {}) params[:title] || raise(ArgumentError, "You must specify title") # API takes timestamp with milliseconds params[:timestamp] = (params[:timestamp] || Time.now.to_i) * 1000 params[:access] ||= "private" template = Template.new(:new_album, params) path = "/data/feed/api/user/#{user_id}" response = Connection.new.post(path: path, body: template.render, headers: auth_header) Presenter::Album.new(response.parsed_response["entry"]) end |
#destroy(album_id, options = {}) ⇒ true Also known as: delete
Destroys given album
97 98 99 100 101 102 |
# File 'lib/picasa/api/album.rb', line 97 def destroy(album_id, = {}) headers = auth_header.merge({"If-Match" => .fetch(:etag, "*")}) path = "/data/entry/api/user/#{user_id}/albumid/#{album_id}" Connection.new.delete(path: path, headers: headers) true end |
#list(options = {}) ⇒ Presenter::AlbumList
Returns album list
15 16 17 18 19 20 |
# File 'lib/picasa/api/album.rb', line 15 def list( = {}) path = "/data/feed/api/user/#{user_id}" response = Connection.new.get(path: path, query: , headers: auth_header) Presenter::AlbumList.new(response.parsed_response["feed"]) end |
#show(album_id, options = {}) ⇒ Presenter::Album
Returns photo list for given album
32 33 34 35 36 37 |
# File 'lib/picasa/api/album.rb', line 32 def show(album_id, = {}) path = "/data/feed/api/user/#{user_id}/albumid/#{album_id}" response = Connection.new.get(path: path, query: , headers: auth_header) Presenter::Album.new(response.parsed_response["feed"]) end |
#update(album_id, params = {}) ⇒ Presenter::Album
Update properties of given album
75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/picasa/api/album.rb', line 75 def update(album_id, params = {}) if params.has_key?(:timestamp) params[:timestamp] = params[:timestamp].to_i * 1000 end headers = auth_header.merge({"If-Match" => params.fetch(:etag, "*")}) template = Template.new(:new_album, params) path = "/data/entry/api/user/#{user_id}/albumid/#{album_id}" response = Connection.new.patch(path: path, body: template.render, headers: headers) Presenter::Album.new(response.parsed_response["entry"]) end |