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
# 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



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

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



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

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



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

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



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

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



89
90
91
92
93
94
# File 'lib/flickr/photosets.rb', line 89

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



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

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



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

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



96
97
98
99
100
101
# File 'lib/flickr/photosets.rb', line 96

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



73
74
75
76
77
78
# File 'lib/flickr/photosets.rb', line 73

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