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

Constant Summary collapse

DEFAULTS =
{
  open_timeout: 8,
  timeout:      10,
}

Instance Method Summary collapse

Methods included from AutoloadHelper

autoload_dir, autoload_names

Constructor Details

#initializeClient

Returns a new instance of Client.



32
33
34
35
36
37
38
39
40
# File 'lib/flickr/client.rb', line 32

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



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

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

#post(*args, &block) ⇒ Object



46
47
48
# File 'lib/flickr/client.rb', line 46

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