Class: Caboodle::PosterousAPI

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

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ PosterousAPI

Returns a new instance of PosterousAPI.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/caboodle/kits/posterous/posterous.rb', line 16

def initialize(opts={})
  Site.posterous_password ||= ENV["posterous_password"]
  
  u = opts[:email] || Site.posterous_email
  p = opts[:password] || Site.posterous_password
  
  self.credentials(u, p)
  sitename = opts[:sitename] || Site.posterous_sitename
  unless defined?(Site.posterous_site_id)
    response = Hashie::Mash.new(getsites.perform_sleepily.parse)
    sites = response.rsp.site        
    sites.each do |site|
      if site.url.include?("http://#{Site.posterous_sitename}.posterous.com")
        Site.posterous_site_id = site.id
      end
    end
  end
  
  self.defaults = {:site_id => Site.posterous_site_id}
end