Class: Flickr::PhotoSets

Inherits:
APIBase show all
Defined in:
lib/flickr/photosets.rb

Instance Attribute Summary

Attributes inherited from APIBase

#flickr

Instance Method Summary collapse

Methods inherited from APIBase

#initialize

Constructor Details

This class inherits a constructor from Flickr::APIBase

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



6
7
8
9
10
11
12
# File 'lib/flickr/photosets.rb', line 6

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



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/flickr/photosets.rb', line 14

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



30
31
32
33
34
# File 'lib/flickr/photosets.rb', line 30

def delete(photoset)
	photoset = photoset.id if photoset.class == Flickr::PhotoSet
	@flickr.call_method('flickr.photosets.delete',
		'photoset_id' => photoset)
end

#editMeta(photoset, title, description = nil) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/flickr/photosets.rb', line 36

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



44
45
46
47
48
49
50
51
52
53
# File 'lib/flickr/photosets.rb', line 44

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



55
56
57
58
59
60
61
# File 'lib/flickr/photosets.rb', line 55

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



91
92
93
94
95
96
# File 'lib/flickr/photosets.rb', line 91

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



63
64
65
66
67
68
69
70
71
72
73
# File 'lib/flickr/photosets.rb', line 63

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



82
83
84
85
86
87
88
89
# File 'lib/flickr/photosets.rb', line 82

def getPhotos(photoset,extras=nil)
	photoset = photoset.id if photoset.class == Flickr::PhotoSet
	extras = extras.join(',') if extras.class == Array
	args = { 'photoset_id' => photoset }
	args['extras'] = extras if extras
	res = @flickr.call_method('flickr.photosets.getPhotos',args)
	return Flickr::PhotoSet.from_xml(res.root,@flickr)
end

#orderSets(photosets) ⇒ Object



98
99
100
101
102
103
# File 'lib/flickr/photosets.rb', line 98

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



75
76
77
78
79
80
# File 'lib/flickr/photosets.rb', line 75

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