Class: FlickRaw::Flickr

Inherits:
Request show all
Defined in:
lib/flickraw.rb

Overview

Root class of the flickr api hierarchy.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Request

build_request, flickr_methods, flickr_objects, request_name

Constructor Details

#initialize(token = ) ⇒ Flickr

:nodoc:



156
157
158
159
160
# File 'lib/flickraw.rb', line 156

def initialize(token = FlickRawOptions['auth_token']) # :nodoc:
  Flickr.build(call('flickr.reflection.getMethods')) if Flickr.flickr_objects.empty?
  super self
  @token = token
end

Class Method Details

.build(methods) ⇒ Object



154
# File 'lib/flickraw.rb', line 154

def self.build(methods); methods.each { |m| build_request m } end

Instance Method Details

#call(req, args = {}, &block) ⇒ Object

This is the central method. It does the actual request to the flickr server.

Raises FailedResponse if the response status is failed.



165
166
167
168
169
170
# File 'lib/flickraw.rb', line 165

def call(req, args={}, &block)
  @token = nil if req == "flickr.auth.getFrob"
  request = EM::HttpRequest.new("http://#{FLICKR_HOST}#{REST_PATH}", :proxy => proxy_opts).post :head => {'User-Agent' => "Flickraw/#{VERSION}"},
                                                                                                :body => build_args(args, req)
  process_response(req, request.response)
end

#replace_photo(file, args = {}) ⇒ Object

Use this to replace the photo with :photo_id with the photo in file.

flickr.replace_photo '/path/to/the/photo', :photo_id => id

See www.flickr.com/services/api/replace.api.html for more information on the arguments.



184
# File 'lib/flickraw.rb', line 184

def replace_photo(file, args={}); upload_flickr(REPLACE_PATH, file, args) end

#upload_photo(file, args = {}) ⇒ Object

Use this to upload the photo in file.

flickr.upload_photo '/path/to/the/photo', :title => 'Title', :description => 'This is the description'

See www.flickr.com/services/api/upload.api.html for more information on the arguments.



177
# File 'lib/flickraw.rb', line 177

def upload_photo(file, args={}); upload_flickr(UPLOAD_PATH, file, args) end