flickr-objects 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +49 -63
  3. data/lib/flickr/api/abstract/params_processor.rb +68 -0
  4. data/lib/flickr/api/abstract.rb +113 -0
  5. data/lib/flickr/api/general.rb +75 -0
  6. data/lib/flickr/api/person.rb +91 -39
  7. data/lib/flickr/api/photo.rb +213 -108
  8. data/lib/flickr/api/set.rb +114 -55
  9. data/lib/flickr/api/upload_ticket.rb +17 -6
  10. data/lib/flickr/api.rb +90 -35
  11. data/lib/flickr/attributes.rb +200 -0
  12. data/lib/flickr/base_converter.rb +29 -0
  13. data/lib/flickr/client/data.rb +47 -0
  14. data/lib/flickr/client/oauth.rb +44 -0
  15. data/lib/flickr/client/upload.rb +55 -0
  16. data/lib/flickr/client.rb +77 -33
  17. data/lib/flickr/configuration.rb +85 -14
  18. data/lib/flickr/error.rb +58 -0
  19. data/lib/flickr/middleware.rb +52 -28
  20. data/lib/flickr/oauth.rb +89 -74
  21. data/lib/flickr/object/attribute_locations/list.rb +25 -0
  22. data/lib/flickr/object/attribute_locations/location.rb +29 -0
  23. data/lib/flickr/object/attribute_locations/permissions.rb +31 -0
  24. data/lib/flickr/object/attribute_locations/person/upload_status.rb +32 -0
  25. data/lib/flickr/object/attribute_locations/person.rb +78 -0
  26. data/lib/flickr/object/attribute_locations/photo/exif.rb +29 -0
  27. data/lib/flickr/object/attribute_locations/photo/note.rb +36 -0
  28. data/lib/flickr/object/attribute_locations/photo/tag.rb +23 -0
  29. data/lib/flickr/object/attribute_locations/photo.rb +164 -0
  30. data/lib/flickr/object/attribute_locations/set.rb +53 -0
  31. data/lib/flickr/object/attribute_locations/upload_ticket.rb +30 -0
  32. data/lib/flickr/object/attribute_locations/visibility.rb +24 -0
  33. data/lib/flickr/object/list/kaminari.rb +30 -0
  34. data/lib/flickr/object/list/normal.rb +27 -0
  35. data/lib/flickr/object/list/will_paginate.rb +31 -0
  36. data/lib/flickr/object/list.rb +87 -0
  37. data/lib/flickr/object/location.rb +35 -0
  38. data/lib/flickr/object/permissions.rb +18 -0
  39. data/lib/flickr/object/person/upload_status.rb +22 -0
  40. data/lib/flickr/object/person.rb +93 -0
  41. data/lib/flickr/object/photo/exif.rb +35 -0
  42. data/lib/flickr/object/photo/note.rb +20 -0
  43. data/lib/flickr/object/photo/size.rb +67 -0
  44. data/lib/flickr/object/photo/tag.rb +23 -0
  45. data/lib/flickr/object/photo.rb +349 -0
  46. data/lib/flickr/object/set.rb +114 -0
  47. data/lib/flickr/object/upload_ticket.rb +31 -0
  48. data/lib/flickr/object/visibility.rb +16 -0
  49. data/lib/flickr/object.rb +118 -27
  50. data/lib/flickr/sanitized_file.rb +70 -0
  51. data/lib/flickr/version.rb +4 -2
  52. data/lib/flickr.rb +69 -15
  53. metadata +89 -103
  54. data/lib/flickr/api/api_methods/flickr.rb +0 -5
  55. data/lib/flickr/api/api_methods/person.rb +0 -14
  56. data/lib/flickr/api/api_methods/photo.rb +0 -26
  57. data/lib/flickr/api/api_methods/set.rb +0 -18
  58. data/lib/flickr/api/api_methods/upload_ticket.rb +0 -5
  59. data/lib/flickr/api/flickr.rb +0 -35
  60. data/lib/flickr/api_caller.rb +0 -98
  61. data/lib/flickr/client/methods_client.rb +0 -22
  62. data/lib/flickr/client/upload_client.rb +0 -62
  63. data/lib/flickr/errors.rb +0 -19
  64. data/lib/flickr/helpers/base_58.rb +0 -15
  65. data/lib/flickr/helpers/boolean.rb +0 -4
  66. data/lib/flickr/helpers/core_ext.rb +0 -5
  67. data/lib/flickr/object/attribute/converter.rb +0 -49
  68. data/lib/flickr/object/attribute/finder.rb +0 -32
  69. data/lib/flickr/object/attribute.rb +0 -45
  70. data/lib/flickr/objects/attribute_values/list.rb +0 -10
  71. data/lib/flickr/objects/attribute_values/location.rb +0 -14
  72. data/lib/flickr/objects/attribute_values/note.rb +0 -11
  73. data/lib/flickr/objects/attribute_values/permissions.rb +0 -12
  74. data/lib/flickr/objects/attribute_values/person/upload_status.rb +0 -16
  75. data/lib/flickr/objects/attribute_values/person.rb +0 -24
  76. data/lib/flickr/objects/attribute_values/photo.rb +0 -84
  77. data/lib/flickr/objects/attribute_values/set.rb +0 -17
  78. data/lib/flickr/objects/attribute_values/tag.rb +0 -9
  79. data/lib/flickr/objects/attribute_values/upload_ticket.rb +0 -9
  80. data/lib/flickr/objects/attribute_values/visibility.rb +0 -10
  81. data/lib/flickr/objects/list.rb +0 -86
  82. data/lib/flickr/objects/location.rb +0 -26
  83. data/lib/flickr/objects/note.rb +0 -14
  84. data/lib/flickr/objects/permissions.rb +0 -14
  85. data/lib/flickr/objects/person/upload_status.rb +0 -14
  86. data/lib/flickr/objects/person.rb +0 -43
  87. data/lib/flickr/objects/photo.rb +0 -113
  88. data/lib/flickr/objects/set.rb +0 -29
  89. data/lib/flickr/objects/tag.rb +0 -17
  90. data/lib/flickr/objects/upload_ticket.rb +0 -18
  91. data/lib/flickr/objects/visibility.rb +0 -12
  92. data/lib/flickr/objects.rb +0 -25
@@ -1,113 +1,218 @@
1
- require_relative "api_methods/photo"
1
+ module Flickr
2
+ module Api
3
+
4
+ class Photo < Abstract
5
+
6
+ ##
7
+ # @param params [Hash] See documentation below
8
+ # @return [Flickr::Object::List<Flickr::Object::Photo>]
9
+ # @docs [flickr.photos.search](http://www.flickr.com/services/api/flickr.photos.search.html)
10
+ #
11
+ def search(params = {})
12
+ response = get "photos.search", params
13
+ new_list(:Photo, response["photos"].delete("photo"), response["photos"])
14
+ end
15
+
16
+ ##
17
+ # @param params [Hash] See documentation below
18
+ # @return [Flickr::Object::List<Flickr::Object::Photo>]
19
+ # @docs [flickr.photos.getContactsPhotos](http://www.flickr.com/services/api/flickr.photos.getContactsPhotos.html)
20
+ #
21
+ def get_from_contacts(params = {})
22
+ response = get "photos.getContactsPhotos", params
23
+ new_list(:Photo, response["photos"].delete("photo"), response["photos"])
24
+ end
25
+
26
+ ##
27
+ # @param params [Hash] See documentation below
28
+ # @return [Flickr::Object::List<Flickr::Object::Photo>]
29
+ # @docs [flickr.photos.getNotInSet](http://www.flickr.com/services/api/flickr.photos.getNotInSet.html)
30
+ #
31
+ def get_not_in_set(params = {})
32
+ response = get "photos.getNotInSet", params
33
+ new_list(:Photo, response["photos"].delete("photo"), response["photos"])
34
+ end
35
+
36
+ ##
37
+ # @param params [Hash] See documentation below
38
+ # @return [Flickr::Object::List<Flickr::Object::Photo>]
39
+ # @docs [flickr.photos.getRecent](http://www.flickr.com/services/api/flickr.photos.getRecent.html)
40
+ #
41
+ def get_recent(params = {})
42
+ response = get "photos.getRecent", params
43
+ new_list(:Photo, response["photos"].delete("photo"), response["photos"])
44
+ end
45
+
46
+ ##
47
+ # @param params [Hash] See documentation below
48
+ # @return [Flickr::Object::List<Flickr::Object::Photo>]
49
+ # @docs [flickr.photos.getUntagged](http://www.flickr.com/services/api/flickr.photos.getUntagged.html)
50
+ #
51
+ def get_untagged(params = {})
52
+ response = get "photos.getUntagged", params
53
+ new_list(:Photo, response["photos"].delete("photo"), response["photos"])
54
+ end
55
+
56
+ ##
57
+ # @param params [Hash] See documentation below
58
+ # @return [Flickr::Object::List<Flickr::Object::Photo>]
59
+ # @docs [flickr.photos.getWithGeoData](http://www.flickr.com/services/api/flickr.photos.getWithGeoData.html)
60
+ #
61
+ def get_with_geo_data(params = {})
62
+ response = get "photos.getWithGeoData", params
63
+ new_list(:Photo, response["photos"].delete("photo"), response["photos"])
64
+ end
65
+
66
+ ##
67
+ # @param params [Hash] See documentation below
68
+ # @return [Flickr::Object::List<Flickr::Object::Photo>]
69
+ # @docs [flickr.photos.getWithoutGeoData](http://www.flickr.com/services/api/flickr.photos.getWithoutGeoData.html)
70
+ #
71
+ def get_without_geo_data(params = {})
72
+ response = get "photos.getWithoutGeoData", params
73
+ new_list(:Photo, response["photos"].delete("photo"), response["photos"])
74
+ end
75
+
76
+ ##
77
+ # @param params [Hash] See documentation below
78
+ # @return [Flickr::Object::List<Flickr::Object::Photo>]
79
+ # @docs [flickr.photos.RecentlyUpdated](http://www.flickr.com/services/api/flickr.photos.RecentlyUpdated.html)
80
+ #
81
+ def get_recently_updated(params = {})
82
+ response = get "photos.recentlyUpdated", params
83
+ new_list(:Photo, response["photos"].delete("photo"), response["photos"])
84
+ end
85
+
86
+ ##
87
+ # @param photo_id [String]
88
+ # @return [Flickr::Object::Photo]
89
+ # @docs [flickr.photos.getInfo](http://www.flickr.com/services/api/flickr.photos.getInfo.html)
90
+ #
91
+ def get_info(photo_id, params = {})
92
+ response = get "photos.getInfo", params.merge(photo_id: photo_id)
93
+ new_object(:Photo, response["photo"])
94
+ end
95
+
96
+ ##
97
+ # @param photo_id [String]
98
+ # @return [Flickr::Object::Photo]
99
+ # @docs [flickr.photos.getSizes](http://www.flickr.com/services/api/flickr.photos.getInfo.html)
100
+ #
101
+ def get_sizes(photo_id, params = {})
102
+ response = get "photos.getSizes", params.merge(photo_id: photo_id)
103
+ new_object(:Photo, response)
104
+ end
105
+
106
+ ##
107
+ # @param photo_id [String]
108
+ # @return [Flickr::Object::Photo]
109
+ # @docs [flickr.photos.getExif](http://www.flickr.com/services/api/flickr.photos.getInfo.html)
110
+ #
111
+ def get_exif(photo_id, params = {})
112
+ response = get "photos.getExif", params.merge(photo_id: photo_id)
113
+ new_object(:Photo, response["photo"])
114
+ end
115
+
116
+ ##
117
+ # @param photo_id [String]
118
+ # @return [Flickr::Object::List<Flickr::Object::Person>]
119
+ # @docs [flickr.photos.getFavorites](http://www.flickr.com/services/api/flickr.photos.getFavorites.html)
120
+ #
121
+ def get_favorites(photo_id, params = {})
122
+ response = get "photos.getFavorites", params.merge(photo_id: photo_id)
123
+ new_list(:Person, response["photo"].delete("person"), response["photo"])
124
+ end
125
+
126
+ ##
127
+ # @param photo_id [String]
128
+ # @return [response]
129
+ # @docs [flickr.photos.delete](http://www.flickr.com/services/api/flickr.photos.delete.html)
130
+ #
131
+ def delete(photo_id, params = {})
132
+ post "photos.delete", params.merge(photo_id: photo_id)
133
+ end
134
+
135
+ ##
136
+ # @param photo_id [String]
137
+ # @param content_type [String]
138
+ # @return [response]
139
+ # @docs [flickr.photos.setContentType](http://www.flickr.com/services/api/flickr.photos.setContentType.html)
140
+ #
141
+ def set_content_type(photo_id, content_type, params = {})
142
+ post "photos.setContentType", params.merge(photo_id: photo_id, content_type: content_type)
143
+ end
144
+
145
+ ##
146
+ # @param photo_id [String]
147
+ # @param tags [String] Space-delimited list of tags (see documentation below)
148
+ # @return [response]
149
+ # @docs [flickr.photos.setTags](http://www.flickr.com/services/api/flickr.photos.setTags.html)
150
+ #
151
+ def set_tags(photo_id, tags, params = {})
152
+ post "photos.setTags", params.merge(photo_id: photo_id, tags: tags)
153
+ end
154
+
155
+ ##
156
+ # @param photo_id [String]
157
+ # @param tags [String] Space-delimited list of tags (see documentation below)
158
+ # @return [response]
159
+ # @docs [flickr.photos.addTags](http://www.flickr.com/services/api/flickr.photos.addTags.html)
160
+ #
161
+ def add_tags(photo_id, tags, params = {})
162
+ post "photos.addTags", params.merge(photo_id: photo_id, tags: tags)
163
+ end
164
+
165
+ ##
166
+ # @param photo_id [String]
167
+ # @param tag_id [String]
168
+ # @return [response]
169
+ # @docs [flickr.photos.removeTag](http://www.flickr.com/services/api/flickr.photos.removeTag.html)
170
+ #
171
+ def remove_tag(photo_id, tag_id, params = {})
172
+ post "photos.removeTag", params.merge(photo_id: photo_id, tag_id: tag_id)
173
+ end
174
+
175
+ ##
176
+ # @param photo_id [String]
177
+ # @param params [Hash] See documentation below
178
+ # @return [response]
179
+ # @docs [flickr.photos.setDates](http://www.flickr.com/services/api/flickr.photos.setDates.html)
180
+ #
181
+ def set_dates(photo_id, params = {})
182
+ post "photos.setDates", params.merge(photo_id: photo_id)
183
+ end
184
+
185
+ ##
186
+ # @param photo_id [String]
187
+ # @param params [Hash] See documentation below
188
+ # @return [response]
189
+ # @docs [flickr.photos.setMeta](http://www.flickr.com/services/api/flickr.photos.setMeta.html)
190
+ #
191
+ def set_meta(photo_id, params = {})
192
+ post "photos.setMeta", params.merge(photo_id: photo_id)
193
+ end
194
+
195
+ ##
196
+ # @param photo_id [String]
197
+ # @param params [Hash] See documentation below
198
+ # @return [response]
199
+ # @docs [flickr.photos.setPerms](http://www.flickr.com/services/api/flickr.photos.setPerms.html)
200
+ #
201
+ def set_permissions(photo_id, params = {})
202
+ post "photos.setPerms", params.merge(photo_id: photo_id)
203
+ end
204
+
205
+ ##
206
+ # @param photo_id [String]
207
+ # @param params [Hash] See documentation below
208
+ # @return [response]
209
+ # @docs [flickr.photos.setSafetyLevel](http://www.flickr.com/services/api/flickr.photos.setSafetyLevel.html)
210
+ #
211
+ def set_safety_level(photo_id, params = {})
212
+ post "photos.setSafetyLevel", params.merge(photo_id: photo_id)
213
+ end
2
214
 
3
- class Flickr
4
- class Photo < Object
5
- def self.search(params = {})
6
- response = client.get f(__method__), handle_extras(params)
7
- new_list(response["photos"].delete("photo"), client, response["photos"])
8
215
  end
9
216
 
10
- def self.get_from_contacts(params = {})
11
- response = client.get f(__method__), handle_extras(params)
12
- new_list(response["photos"].delete("photo"), client, response["photos"])
13
- end
14
-
15
- def self.delete(id, params = {})
16
- find(id).delete(params)
17
- end
18
-
19
- def self.get_not_in_set(params = {})
20
- response = client.get f(__method__), handle_extras(params)
21
- new_list(response["photos"].delete("photo"), client, response["photos"])
22
- end
23
-
24
- def self.get_recent(params = {})
25
- response = client.get f(__method__), handle_extras(params)
26
- new_list(response["photos"].delete("photo"), client, response["photos"])
27
- end
28
-
29
- def self.get_untagged(params = {})
30
- response = client.get f(__method__), handle_extras(params)
31
- new_list(response["photos"].delete("photo"), client, response["photos"])
32
- end
33
-
34
- def self.get_with_geo_data(params = {})
35
- response = client.get f(__method__), handle_extras(params)
36
- new_list(response["photos"].delete("photo"), client, response["photos"])
37
- end
38
-
39
- def self.get_without_geo_data(params = {})
40
- response = client.get f(__method__), handle_extras(params)
41
- new_list(response["photos"].delete("photo"), client, response["photos"])
42
- end
43
-
44
- def self.get_recently_updated(params = {})
45
- response = client.get f(__method__), handle_extras(params)
46
- new_list(response["photos"].delete("photo"), client, response["photos"])
47
- end
48
-
49
- def get_info!(params = {})
50
- response = client.get f(__method__), params.merge(photo_id: id)
51
- @hash.update(response["photo"])
52
- self
53
- end
54
-
55
- def get_sizes!(params = {})
56
- response = client.get f(__method__), params.merge(photo_id: id)
57
- @hash.update(response["sizes"])
58
- self
59
- end
60
-
61
- def get_favorites(params = {})
62
- response = client.get f(__method__), params.merge(photo_id: id)
63
- Person.new_list(response["photo"].delete("person"), client, response["photo"])
64
- end
65
-
66
- def delete(params = {})
67
- client.post f(__method__), params.merge(photo_id: id)
68
- self
69
- end
70
-
71
- def set_content_type(content_type, params = {})
72
- client.post f(__method__), params.merge(photo_id: id, content_type: content_type)
73
- content_type
74
- end
75
- alias content_type= set_content_type
76
-
77
- def set_tags(tags, params = {})
78
- client.post f(__method__), params.merge(photo_id: id, tags: tags)
79
- tags
80
- end
81
- alias tags= set_tags
82
-
83
- def add_tags(tags, params = {})
84
- client.post f(__method__), params.merge(photo_id: id, tags: tags)
85
- tags
86
- end
87
-
88
- def remove_tag(tag_id, params = {})
89
- client.post f(__method__), params.merge(photo_id: id, tag_id: tag_id)
90
- tag_id
91
- end
92
-
93
- def set_dates(params = {})
94
- client.post f(__method__), params.merge(photo_id: id)
95
- params
96
- end
97
-
98
- def set_meta(params = {})
99
- client.post f(__method__), params.merge(photo_id: id)
100
- params
101
- end
102
-
103
- def set_permissions(params = {})
104
- client.post f(__method__), params.merge(photo_id: id)
105
- params
106
- end
107
-
108
- def set_safety_level(params = {})
109
- client.post f(__method__), params.merge(photo_id: id)
110
- params
111
- end
112
217
  end
113
218
  end
@@ -1,71 +1,130 @@
1
- require_relative "api_methods/set"
1
+ module Flickr
2
+ module Api
2
3
 
3
- class Flickr
4
- class Set < Object
5
- def self.create(params = {})
6
- response = client.post f(__method__), params
7
- new(response["photoset"], client)
8
- end
4
+ class Set < Abstract
9
5
 
10
- def self.delete(id, params = {})
11
- find(id).delete(params)
12
- end
6
+ ##
7
+ # @param params [Hash] See documentation below
8
+ # @return [Flickr::Object::Set]
9
+ # @docs [flickr.photosets.create](http://www.flickr.com/services/api/flickr.photosets.create.html)
10
+ #
11
+ def create(params = {})
12
+ response = post "photosets.create", params
13
+ new_object(:Set, response["photoset"])
14
+ end
13
15
 
14
- def self.order(set_ids, params = {})
15
- client.post f(__method__), params.merge(photoset_ids: set_ids)
16
- set_ids
17
- end
16
+ ##
17
+ # @param set_ids [String] Comma-delimited list of set IDs (see documentation below)
18
+ # @return [response]
19
+ # @docs [flickr.photosets.orderSets](http://www.flickr.com/services/api/flickr.photosets.orderSets.html)
20
+ #
21
+ def order(set_ids, params = {})
22
+ post "photosets.orderSets", params.merge(photoset_ids: set_ids)
23
+ end
18
24
 
19
- def delete(params = {})
20
- client.post f(__method__), params.merge(photoset_id: id)
21
- self
22
- end
25
+ ##
26
+ # @param set_id [String]
27
+ # @return [response]
28
+ # @docs [flickr.photosets.delete](http://www.flickr.com/services/api/flickr.photosets.delete.html)
29
+ #
30
+ def delete(set_id, params = {})
31
+ post "photosets.delete", params.merge(photoset_id: set_id)
32
+ end
23
33
 
24
- def edit_photos(params = {})
25
- client.post f(__method__), params.merge(photoset_id: id)
26
- self
27
- end
34
+ ##
35
+ # @param set_id [String]
36
+ # @param params [Hash] See documentation below
37
+ # @return [response]
38
+ # @docs [flickr.photosets.editPhotos](http://www.flickr.com/services/api/flickr.photosets.editPhotos.html)
39
+ #
40
+ def edit_photos(set_id, params = {})
41
+ post "photosets.editPhotos", params.merge(photoset_id: set_id)
42
+ end
28
43
 
29
- def get_info!(params = {})
30
- response = client.get f(__method__), params.merge(photoset_id: id)
31
- @hash.update(response["photoset"])
32
- self
33
- end
44
+ ##
45
+ # @param set_id [String]
46
+ # @param params [Hash] See documentation below
47
+ # @return [Flickr::Object::Set]
48
+ # @docs [flickr.photosets.getInfo](http://www.flickr.com/services/api/flickr.photosets.getInfo.html)
49
+ #
50
+ def get_info(set_id, params = {})
51
+ response = get "photosets.getInfo", params.merge(photoset_id: set_id)
52
+ new_object(:Set, response["photoset"])
53
+ end
34
54
 
35
- def get_photos(params = {})
36
- response = client.get f(__method__), handle_extras(params.merge(photoset_id: id))
37
- Photo.new_list(response["photoset"].delete("photo"), client, response["photoset"])
38
- end
55
+ ##
56
+ # @param set_id [String]
57
+ # @param params [Hash] See documentation below
58
+ # @return [Flickr::Object::List<Flickr::Object::Photo>]
59
+ # @docs [flickr.photosets.getPhotos](http://www.flickr.com/services/api/flickr.photosets.getPhotos.html)
60
+ #
61
+ def get_photos(set_id, params = {})
62
+ response = get "photosets.getPhotos", params.merge(photoset_id: set_id)
63
+ new_list(:Photo, response["photoset"].delete("photo").map { |h| h.merge("owner" => response["photoset"]["owner"]) }, response["photoset"])
64
+ end
39
65
 
40
- def add_photo(photo_id, params = {})
41
- client.post f(__method__), params.merge(photoset_id: id, photo_id: photo_id)
42
- photo_id
43
- end
66
+ ##
67
+ # @param set_id [String]
68
+ # @param photo_id [String]
69
+ # @param params [Hash] See documentation below
70
+ # @return [response]
71
+ # @docs [flickr.photosets.addPhoto](http://www.flickr.com/services/api/flickr.photosets.addPhoto.html)
72
+ #
73
+ def add_photo(set_id, photo_id, params = {})
74
+ post "photosets.addPhoto", params.merge(photoset_id: set_id, photo_id: photo_id)
75
+ end
44
76
 
45
- def remove_photos(photo_ids, params = {})
46
- client.post f(__method__), params.merge(photoset_id: id, photo_ids: photo_ids)
47
- photo_ids
48
- end
77
+ ##
78
+ # @param set_id [String]
79
+ # @param photo_ids [String] Comma-delimited list of photo IDs (see documentation below)
80
+ # @return [response]
81
+ # @docs [flickr.photosets.removePhotos](http://www.flickr.com/services/api/flickr.photosets.removePhotos.html)
82
+ #
83
+ def remove_photos(set_id, photo_ids, params = {})
84
+ post "photosets.removePhotos", params.merge(photoset_id: set_id, photo_ids: photo_ids)
85
+ end
49
86
 
50
- def remove_photo(photo_id, params = {})
51
- client.post f(__method__), params.merge(photoset_id: id, photo_id: photo_id)
52
- photo_id
53
- end
87
+ ##
88
+ # @param set_id [String]
89
+ # @param photo_id [String]
90
+ # @return [response]
91
+ # @docs [flickr.photosets.removePhoto](http://www.flickr.com/services/api/flickr.photosets.removePhoto.html)
92
+ #
93
+ def remove_photo(set_id, photo_id, params = {})
94
+ post "photosets.removePhoto", params.merge(photoset_id: set_id, photo_id: photo_id)
95
+ end
54
96
 
55
- def edit_meta(params = {})
56
- client.post f(__method__), params.merge(photoset_id: id)
57
- params
58
- end
97
+ ##
98
+ # @param set_id [String]
99
+ # @param params [Hash] See documentation below
100
+ # @return [response]
101
+ # @docs [flickr.photosets.editMeta](http://www.flickr.com/services/api/flickr.photosets.editMeta.html)
102
+ #
103
+ def edit_meta(set_id, params = {})
104
+ post "photosets.editMeta", params.merge(photoset_id: set_id)
105
+ end
59
106
 
60
- def reorder_photos(photo_ids, params = {})
61
- client.post f(__method__), params.merge(photoset_id: id, photo_ids: photo_ids)
62
- photo_ids
63
- end
107
+ ##
108
+ # @param set_id [String]
109
+ # @param photo_ids [String] Comma-delimited list of photo IDs (see documentation below)
110
+ # @return [response]
111
+ # @docs [flickr.photosets.reorderPhotos](http://www.flickr.com/services/api/flickr.photosets.reorderPhotos.html)
112
+ #
113
+ def reorder_photos(set_id, photo_ids, params = {})
114
+ post "photosets.reorderPhotos", params.merge(photoset_id: set_id, photo_ids: photo_ids)
115
+ end
116
+
117
+ ##
118
+ # @param set_id [String]
119
+ # @param photo_id [String]
120
+ # @return [response]
121
+ # @docs [flickr.photosets.setPrimaryPhoto](http://www.flickr.com/services/api/flickr.photosets.setPrimaryPhoto.html)
122
+ #
123
+ def set_primary_photo(set_id, photo_id, params = {})
124
+ post "photosets.setPrimaryPhoto", params.merge(photoset_id: set_id, photo_id: photo_id)
125
+ end
64
126
 
65
- def set_primary_photo(photo, params = {})
66
- client.post f(__method__), params.merge(photoset_id: id, photo_id: (photo.is_a?(Photo) ? photo.id : photo))
67
- photo
68
127
  end
69
- alias primary_photo= set_primary_photo
128
+
70
129
  end
71
130
  end
@@ -1,10 +1,21 @@
1
- require_relative "api_methods/upload_ticket"
1
+ module Flickr
2
+ module Api
3
+
4
+ class UploadTicket < Abstract
5
+
6
+ ##
7
+ # Used to check the status of a photo uploaded or replaced asynchronously.
8
+ #
9
+ # @param ticket_ids [String] Comma-delimited list of ticket IDs (see documentation below)
10
+ # @return [Flickr::Object::List<Flickr::Object::UploadTicket>]
11
+ # @docs [flickr.photos.upload.checkTickets](http://www.flickr.com/services/api/flickr.photos.upload.checkTickets.html)
12
+ #
13
+ def check(ticket_ids, params = {})
14
+ response = get "photos.upload.checkTickets", params.merge(tickets: ticket_ids)
15
+ new_list(:UploadTicket, response["uploader"].delete("ticket"), response["uploader"])
16
+ end
2
17
 
3
- class Flickr
4
- class UploadTicket < Object
5
- def self.check(tickets, params = {})
6
- response = client.get f(__method__), params.merge(tickets: tickets)
7
- new_list(response["uploader"].delete("ticket"), client, response["uploader"])
8
18
  end
19
+
9
20
  end
10
21
  end
data/lib/flickr/api.rb CHANGED
@@ -1,49 +1,104 @@
1
- require "flickr/client"
2
- require "flickr/api_caller"
1
+ module Flickr
3
2
 
4
- class Flickr
5
- include ApiCaller
3
+ module Api
6
4
 
7
- def initialize(*access_token)
8
- @access_token = access_token
9
- end
5
+ extend Flickr::AutoloadHelper
10
6
 
11
- def client
12
- @client ||= MethodsClient.new(@access_token)
13
- end
7
+ autoload_names \
8
+ :Abstract, :General, :Photo, :Person, :Set, :UploadTicket
14
9
 
15
- def upload_client
16
- @upload_client ||= UploadClient.new(@access_token)
17
- end
10
+ ##
11
+ # @return [Flickr::Api::Photo]
12
+ #
13
+ def photos
14
+ Flickr::Api::Photo.new(access_token)
15
+ end
18
16
 
19
- def self.client
20
- @client ||= MethodsClient.new(configuration.access_token)
21
- end
17
+ ##
18
+ # @return [Flickr::Api::Person]
19
+ #
20
+ def people
21
+ Flickr::Api::Person.new(access_token)
22
+ end
22
23
 
23
- def self.upload_client
24
- @upload_client ||= UploadClient.new(configuration.access_token)
25
- end
26
- end
24
+ ##
25
+ # @return [Flickr::Api::Set]
26
+ #
27
+ def sets
28
+ Flickr::Api::Set.new(access_token)
29
+ end
30
+
31
+ ##
32
+ # @return [Flickr::Api::UploadTicket]
33
+ #
34
+ def upload_tickets
35
+ Flickr::Api::UploadTicket.new(access_token)
36
+ end
37
+
38
+ ##
39
+ # @return [String]
40
+ # @see Flickr::Api::General#upload
41
+ #
42
+ def upload(photo, params = {})
43
+ api.upload(photo, params)
44
+ end
45
+
46
+ ##
47
+ # @return [String]
48
+ # @see Flickr::Api::General#replace
49
+ #
50
+ def replace(photo, photo_id, params = {})
51
+ api.replace(photo, photo_id, params)
52
+ end
53
+
54
+ ##
55
+ # @return [Flickr::Object::List<Flickr::Object::UploadTicket>]
56
+ # @deprecated Use `Flickr.upload_tickets.check` instead.
57
+ # @see Flickr::Api::UploadTicket#check
58
+ #
59
+ def check_upload_tickets(tickets, params = {})
60
+ Flickr.deprecation_warn "`Flickr.check_upload_tickets` is deprecated. Use `Flickr.upload_tickets.check` instead."
61
+ upload_tickets.check(tickets, params)
62
+ end
63
+
64
+ ##
65
+ # @return [Array<String>]
66
+ # @see Flickr::Api::General#get_methods
67
+ #
68
+ def get_methods(params = {})
69
+ api.get_methods(params)
70
+ end
71
+
72
+ ##
73
+ # @return [Hash]
74
+ # @see Flickr::Api::General#test_login
75
+ #
76
+ def test_login(params = {})
77
+ api.test_login(params)
78
+ end
27
79
 
28
- require "flickr/api/flickr"
80
+ ##
81
+ # @return [Hash]
82
+ # @see Flickr::Api::General#test_echo
83
+ #
84
+ def test_echo(params = {})
85
+ api.test_echo(params)
86
+ end
29
87
 
30
- class Flickr
31
- def self.map_interface(method, klass)
32
- define_method(method) do
33
- klass.tap do |klass|
34
- klass.instance_variable_set("@client", client)
35
- end
88
+ ##
89
+ # @return [Hash]
90
+ # @see Flickr::Api::General#test_null
91
+ #
92
+ def test_null(params = {})
93
+ api.test_null(params)
36
94
  end
37
95
 
38
- define_singleton_method(method) do
39
- klass.tap do |klass|
40
- klass.instance_variable_set("@client", client)
41
- end
96
+ private
97
+
98
+ def api
99
+ Flickr::Api::General.new(access_token)
42
100
  end
101
+
43
102
  end
44
103
 
45
- map_interface :photos, Photo
46
- map_interface :people, Person
47
- map_interface :sets, Set
48
- map_interface :upload_tickets, UploadTicket
49
104
  end