Class: Flickr::Client

Inherits:
Object
  • Object
show all
Extended by:
AutoloadHelper
Defined in:
lib/flickr/client.rb,
lib/flickr/client/data.rb,
lib/flickr/client/oauth.rb,
lib/flickr/client/upload.rb

Overview

This abstract class is the base for the client classes which communicate with the Flickr API. For example, the part of Flickr API for uploading photos need requests to be marked as multipart, while the part for querying data of photos doesn’t need it. So it’s obvious that we need separate classes.

This class just extracts the common behaviour, like including the API key in requests.

Direct Known Subclasses

Data, OAuth, Upload

Defined Under Namespace

Classes: Data, OAuth, Upload

Instance Method Summary collapse

Methods included from AutoloadHelper

autoload_dir, autoload_names

Constructor Details

#initializeClient

Returns a new instance of Client.



27
28
29
30
31
32
33
34
35
# File 'lib/flickr/client.rb', line 27

def initialize
  @connection = Faraday.new(url, connection_options) do |builder|
    builder.use Flickr::Middleware::CatchTimeout
    yield builder if block_given?
    builder.use FaradayMiddleware::Caching, Flickr.cache if Flickr.cache

    builder.adapter :net_http
  end
end

Instance Method Details

#get(*args, &block) ⇒ Object



37
38
39
# File 'lib/flickr/client.rb', line 37

def get(*args, &block)
  do_request(:get, *args, &block)
end

#post(*args, &block) ⇒ Object



41
42
43
# File 'lib/flickr/client.rb', line 41

def post(*args, &block)
  do_request(:post, *args, &block)
end