Class: Caboodle::FlickrAPI

Inherits:
Weary::Base
  • Object
show all
Defined in:
lib/caboodle/kits/flickr/flickr.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ FlickrAPI

Returns a new instance of FlickrAPI.



20
21
22
# File 'lib/caboodle/kits/flickr/flickr.rb', line 20

def initialize(opts={})
  self.defaults = {:api_key => Site.flickr_api_key}
end

Class Method Details

.flickr_user_idObject



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/caboodle/kits/flickr/flickr.rb', line 8

def self.flickr_user_id
  return Site.flickr_user_id unless Site.flickr_user_id.blank?
  unless Site.flickr_username.blank?
    url = "http://query.yahooapis.com/v1/public/yql?q=use%20%22http%3A%2F%2Fisithackday.com%2Fapi%2Fflickr.whois.xml%22%20as%20flickr.whois%3Bselect%20*%20from%20flickr.whois%20where%20owner%3D%22#{Site.flickr_username}%22&format=xml"
    doc = ::Nokogiri::XML.parse(open(url).read)
    val = doc.css("owner").first.attributes["nsid"].value
    Site.flickr_user_id = val
    Caboodle::Kit.dump_config
  end
  Site.flickr_user_id
end

.photoset_info(id) ⇒ Object



36
37
38
# File 'lib/caboodle/kits/flickr/flickr.rb', line 36

def self.photoset_info(id)
  Caboodle.mash(new.photoset({:photoset_id=>id,:method=>"flickr.photosets.getInfo"})).rsp.photoset
end

.photoset_photos(id) ⇒ Object



40
41
42
# File 'lib/caboodle/kits/flickr/flickr.rb', line 40

def self.photoset_photos(id)
  Caboodle.mash(new.photoset({:photoset_id=>id,:method=>"flickr.photosets.getPhotos"})).rsp.photoset.photo
end

.photosetsObject



44
45
46
# File 'lib/caboodle/kits/flickr/flickr.rb', line 44

def self.photosets
  Caboodle.mash(new.photosets).rsp.photosets.photoset
end