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



5
6
7
8
9
# File 'lib/flickr/favorites.rb', line 5

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.



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/flickr/favorites.rb', line 22

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.



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

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



12
13
14
15
16
# File 'lib/flickr/favorites.rb', line 12

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