picasawebalbums 1.3.3 → 1.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -3
- data/lib/PicasaWebAlbums/version.rb +1 -1
- data/lib/domain/album.rb +2 -2
- data/lib/repositories/albums_repository.rb +22 -10
- data/test/test_albums.rb +18 -15
- data/test/test_photos.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -50,6 +50,7 @@ Methods
|
|
50
50
|
- `get_album_by_title(title)`
|
51
51
|
- `get_album_by_slug(slug)`
|
52
52
|
- `create_album(album)`
|
53
|
+
- `delete_album_by_id(album_id)`
|
53
54
|
|
54
55
|
### Photo(s)
|
55
56
|
|
@@ -110,9 +111,9 @@ Coming Down the Pike
|
|
110
111
|
|
111
112
|
The goal is to completely mirror all of the Picasa Web Albums API features including
|
112
113
|
|
113
|
-
-
|
114
|
-
-
|
115
|
-
-
|
114
|
+
- Update albums
|
115
|
+
- Create, Update, Delete photos
|
116
|
+
- Create, Update, Delete tags
|
116
117
|
- CRUD comments
|
117
118
|
- CRUD geolocation data
|
118
119
|
|
data/lib/domain/album.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module PicasaWebAlbums
|
2
2
|
class Album
|
3
|
-
attr_accessor :id, :photos, :title, :slug, :date_created, :date_updated, :cover_photo_url, :description, :access, :number_of_photos, :number_of_comments, :number_of_photos_remaining, :total_bytes
|
4
|
-
|
3
|
+
attr_accessor :id, :photos, :title, :slug, :date_created, :date_updated, :cover_photo_url, :description, :access, :number_of_photos, :number_of_comments, :number_of_photos_remaining, :total_bytes, :edit_url
|
4
|
+
|
5
5
|
def initialize
|
6
6
|
@photos = []
|
7
7
|
end
|
@@ -19,6 +19,7 @@ module AlbumsRepository
|
|
19
19
|
gallery.total_bytes = entry.elements["gphoto:bytesUsed"].text.to_i
|
20
20
|
gallery.cover_photo_url = entry.elements["media:group/media:content"].attributes["url"]
|
21
21
|
gallery.description = entry.elements["media:group/media:description"].text
|
22
|
+
gallery.edit_url = get_edit_url_from_entry(entry)
|
22
23
|
albums << gallery
|
23
24
|
end
|
24
25
|
return albums
|
@@ -47,19 +48,30 @@ module AlbumsRepository
|
|
47
48
|
post_new_album(entry)
|
48
49
|
end
|
49
50
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
51
|
+
def delete_album_by_id(album_id)
|
52
|
+
album = get_album_by_id(album_id)
|
53
|
+
url = URI.parse(album.edit_url)
|
54
|
+
http = Net::HTTP.new(url.host, url.port)
|
55
|
+
http.use_ssl = (url.scheme == 'https')
|
56
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
57
|
+
req = Net::HTTP::Delete.new(url.request_uri)
|
58
|
+
req['Authorization'] = @authentication_token
|
59
|
+
res = http.request(req)
|
60
|
+
return res.code
|
61
|
+
end
|
60
62
|
|
61
63
|
private
|
62
64
|
|
65
|
+
def get_edit_url_from_entry(entry)
|
66
|
+
href = ""
|
67
|
+
entry.elements.each("link") do |link|
|
68
|
+
if (link.attributes["rel"] == "edit")
|
69
|
+
href = link.attributes["href"]
|
70
|
+
end
|
71
|
+
end
|
72
|
+
return href
|
73
|
+
end
|
74
|
+
|
63
75
|
def post_new_album(data)
|
64
76
|
uri = URI("https://picasaweb.google.com/data/feed/api/user/#{@email}")
|
65
77
|
status = ""
|
data/test/test_albums.rb
CHANGED
@@ -10,7 +10,7 @@ module PicasaWebAlbums
|
|
10
10
|
|
11
11
|
def test_get_all_albums
|
12
12
|
albums = @repo.get_all_albums
|
13
|
-
assert_equal
|
13
|
+
assert_equal 3, albums.count
|
14
14
|
end
|
15
15
|
|
16
16
|
def test_get_album_by_id
|
@@ -20,7 +20,7 @@ module PicasaWebAlbums
|
|
20
20
|
|
21
21
|
def test_get_album_by_title
|
22
22
|
album = @repo.get_album_by_title("Bio Profile Pics")
|
23
|
-
assert_equal "
|
23
|
+
assert_equal "5689734429356072049", album.id
|
24
24
|
end
|
25
25
|
|
26
26
|
def test_get_album_by_slug
|
@@ -28,20 +28,23 @@ module PicasaWebAlbums
|
|
28
28
|
assert_equal "5577380987485671713", album.id
|
29
29
|
end
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
31
|
+
def test_create_new_album
|
32
|
+
album = Album.new
|
33
|
+
album.title = "Programmatic album title"
|
34
|
+
album.description = "This is my programmatic album description!"
|
35
|
+
album.access = "private"
|
36
|
+
status_code = @repo.create_album(album)
|
37
|
+
assert_equal "201", status_code
|
38
|
+
delete_album
|
39
|
+
end
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
41
|
+
def delete_album
|
42
|
+
album = @repo.get_album_by_title("Programmatic album title")
|
43
|
+
if (album != nil)
|
44
|
+
status_code = @repo.delete_album_by_id(album.id)
|
45
|
+
assert_equal "200", status_code
|
46
|
+
end
|
47
|
+
end
|
45
48
|
|
46
49
|
end
|
47
50
|
end
|
data/test/test_photos.rb
CHANGED