Class: Flickr::Favorites

Inherits:
APIBase show all
Defined in:
lib/flickr/favorites.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

#add(photo) ⇒ Object

photo can be either a Photo or numeric id



25
26
27
28
29
# File 'lib/flickr/favorites.rb', line 25

def add(photo)
	photo = photo.id if photo.class == Flickr::Photo
	return @flickr.call_method('flickr.favorites.add',
		'photo_id' => photo)
end

#getList(user = nil, extras = nil, per_page = nil, page = nil) ⇒ Object

This is a little weird because all the parametrs are optional, let’s go with it, ok? user can be a Person or a user NSID No caching because it’s just too hard.



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

def getList(user=nil,extras=nil,per_page=nil,page=nil)
	args = {}

	user = user.nsid if user.class == Flickr::Person
	args['user_id'] = user if user
	args['extras'] = extras.join(',') if extras.class == Array
	args['per_page'] = per_page if per_page
	args['page'] = page if page

	res = @flickr.call_method('flickr.favorites.getList',args)
	att = res.root.attributes
	return Flickr::PhotoList.from_xml(res,@flickr)
end

#getPublicList(user, extras = nil, per_page = nil, page = nil) ⇒ Object

This is a little weird because all the parametrs are optional, let’s go with it, ok? user can be a Person or a user NSID No caching because it’s just too hard.



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/flickr/favorites.rb', line 60

def getPublicList(user,extras=nil,per_page=nil,page=nil)
	args = {}

	user = user.nsid if user.class == Flickr::Person

	args['user_id'] = user if user
	args['extras'] = extras.join(',') if extras.class == Array
	args['per_page'] = per_page if per_page
	args['page'] = page if page

	res = @flickr.call_method('flickr.favorites.getPublicList',args)
	att = res.root.attributes
	list = Flickr::PhotoList.new(att['page'].to_i,att['pages'].to_i,
		att['perpage'].to_i,att['total'].to_i)
	res.elements['/photos'].each_element do |e|
		list << Flick::Photo.from_xml(e,@flickr)
	end
	return list
end

#remove(photo) ⇒ Object

photo can be either a Photo or numeric id



32
33
34
35
36
# File 'lib/flickr/favorites.rb', line 32

def remove(photo)
	photo = photo.id if photo.class == Flickr::Photo
	return @flickr.call_method('flickr.favorites.remove',
		'photo_id' => photo)
end