Class: DropboxApi::ConnectionBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/dropbox_api/connection_builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(oauth_bearer) ⇒ ConnectionBuilder

Returns a new instance of ConnectionBuilder.


3
4
5
# File 'lib/dropbox_api/connection_builder.rb', line 3

def initialize(oauth_bearer)
  @oauth_bearer = oauth_bearer
end

Instance Method Details

#build(url) ⇒ Object


11
12
13
14
15
16
17
18
19
# File 'lib/dropbox_api/connection_builder.rb', line 11

def build(url)
  Faraday.new(url) do |connection|
    middleware.apply(connection) do
      connection.authorization :Bearer, @oauth_bearer

      yield connection
    end
  end
end

#middlewareObject


7
8
9
# File 'lib/dropbox_api/connection_builder.rb', line 7

def middleware
  @middleware ||= MiddleWare::Stack.new
end