Class: Flickr::PhotoSets
Instance Attribute Summary
Attributes inherited from APIBase
#flickr
Instance Method Summary
collapse
-
#addPhoto(photoset, photo) ⇒ Object
photoset can be a PhotoSet or a a photoset id photo can be a Photo or a photo id.
-
#create(title, primary_photo, description = nil) ⇒ Object
-
#delete(photoset) ⇒ Object
-
#editMeta(photoset, title, description = nil) ⇒ Object
-
#editPhotos(photoset, primary_photo, photos) ⇒ Object
-
#getContext(photo, photoset) ⇒ Object
-
#getInfo(photoset) ⇒ Object
-
#getList(user = nil) ⇒ Object
-
#getPhotos(photoset, extras = nil) ⇒ Object
-
#orderSets(photosets) ⇒ Object
-
#removePhoto(photoset, photo) ⇒ Object
Methods inherited from APIBase
#initialize
Instance Method Details
#addPhoto(photoset, photo) ⇒ Object
photoset can be a PhotoSet or a a photoset id photo can be a Photo or a photo id
26
27
28
29
30
31
32
|
# File 'lib/flickr/photosets.rb', line 26
def addPhoto(photoset,photo)
photo = photo.id if photo.class == Flickr::Photo
photoset = photoset.id if photoset.class == Flickr::PhotoSet
@flickr.call_method('flickr.photosets.addPhoto',
'photoset_id' => photoset, 'photo_id' => photo)
end
|
#create(title, primary_photo, description = nil) ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/flickr/photosets.rb', line 34
def create(title,primary_photo, description = nil)
primary_photo = primary_photo.id if
primary_photo.class == Flickr::Photo
args = { 'title' => title, 'primary_photo_id' =>
primary_photo}
args['description'] = description if description
res = @flickr.call_method('flickr.photosets.create',args)
id = res.elements['/photoset'].attributes['id']
url = res.elements['/photoset'].attributes['url']
set = Flickr::PhotoSet.new(id,@flickr)
set.title = title
set.url = url
@flickr.photoset_cache_store(set)
return set
end
|
#delete(photoset) ⇒ Object
50
51
52
53
54
|
# File 'lib/flickr/photosets.rb', line 50
def delete(photoset)
photoset = photoset.id if photoset.class == Flickr::PhotoSet
@flickr.call_method('flickr.photosets.delete',
'photoset_id' => photoset)
end
|
56
57
58
59
60
61
62
|
# File 'lib/flickr/photosets.rb', line 56
def editMeta(photoset,title,description=nil)
photoset = photoset.id if photoset.class == Flickr::PhotoSet
args = {'photoset_id' => photoset,
'title' => title}
args['description' ] = description if description
@flickr.call_method('flickr.photosets.editMeta',args)
end
|
#editPhotos(photoset, primary_photo, photos) ⇒ Object
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/flickr/photosets.rb', line 64
def editPhotos(photoset,primary_photo,photos)
photoset = photoset.id if photoset.class == Flickr::PhotoSet
primary_photo = primary_photo.id if
primary_photo.class == Flickr::Photo
photos=photos.map{|p| p.id if p.class==Flickr::Photo}.join(',')
args = {'photoset_id' => photoset,
'primary_photo_id' => primary_photo,
'photo_ids' => photos }
@flickr.call_method('flickr.photosets.editPhotos',args)
end
|
#getContext(photo, photoset) ⇒ Object
75
76
77
78
79
80
81
|
# File 'lib/flickr/photosets.rb', line 75
def getContext(photo,photoset)
photoset = photoset.id if photoset.class == Flickr::PhotoSet
photo = photo.id if photo.class == Flickr::Photo
res = @flickr.call_method('flickr.photosets.getContext',
'photo_id' => photo, 'photoset_id' => photoset)
return Flickr::Context.from_xml(res,@flickr)
end
|
#getInfo(photoset) ⇒ Object
111
112
113
114
115
116
|
# File 'lib/flickr/photosets.rb', line 111
def getInfo(photoset)
photoset = photoset.id if photoset.class == Flickr::PhotoSet
res = @flickr.call_method('flickr.photosets.getInfo',
'photoset_id' => photoset)
return Flickr::PhotoSet.from_xml(res.root,@flickr)
end
|
#getList(user = nil) ⇒ Object
83
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/flickr/photosets.rb', line 83
def getList(user=nil)
user = user.nsid if user.respond_to?(:nsid)
args = {}
args['user_id'] = user if user
res = @flickr.call_method('flickr.photosets.getList',args)
list = []
res.elements['/photosets'].each_element do |el|
list << Flickr::PhotoSet.from_xml(el,@flickr)
end
return list
end
|
#getPhotos(photoset, extras = nil) ⇒ Object
102
103
104
105
106
107
108
109
|
# File 'lib/flickr/photosets.rb', line 102
def getPhotos(photoset,=nil)
photoset = photoset.id if photoset.class == Flickr::PhotoSet
= .join(',') if .class == Array
args = { 'photoset_id' => photoset }
args['extras'] = if
res = @flickr.call_method('flickr.photosets.getPhotos',args)
return Flickr::PhotoSet.from_xml(res.root,@flickr)
end
|
#orderSets(photosets) ⇒ Object
118
119
120
121
122
123
|
# File 'lib/flickr/photosets.rb', line 118
def orderSets(photosets)
photosets=photosets.map { |ps|
(ps.class==Flickr::PhotoSet) ? ps.id : ps}.join(',')
@flickr.call_method('flickr.photosets.orderSets',
'photoset_ids' => photosets)
end
|
#removePhoto(photoset, photo) ⇒ Object
95
96
97
98
99
100
|
# File 'lib/flickr/photosets.rb', line 95
def removePhoto(photoset,photo)
photoset = photoset.id if photoset.class == Flickr::PhotoSet
photo = photo.id if photo.class == Flickr::Photo
@flickr.call_method('flickr.photosets.removePhoto',
'photo_id' => photo, 'photoset_id' => photoset)
end
|