Class: Dropbox::API::Connection

Inherits:
Object
  • Object
show all
Includes:
Requests
Defined in:
lib/dropbox-api/connection.rb,
lib/dropbox-api/connection/requests.rb

Defined Under Namespace

Modules: Requests

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Requests

#get, #get_raw, #post, #put, #request

Constructor Details

#initialize(options = {}) ⇒ Connection

Returns a new instance of Connection.



13
14
15
16
17
18
19
20
21
# File 'lib/dropbox-api/connection.rb', line 13

def initialize(options = {})
  @options   = options
  @consumers = {}
  @tokens    = {}
  Dropbox::API::Config.endpoints.each do |endpoint, url|
    @consumers[endpoint] = Dropbox::API::OAuth.consumer(endpoint)
    @tokens[endpoint]    = Dropbox::API::OAuth.access_token(@consumers[endpoint], options)
  end
end

Instance Attribute Details

#consumersObject

Returns the value of attribute consumers.



10
11
12
# File 'lib/dropbox-api/connection.rb', line 10

def consumers
  @consumers
end

#tokensObject

Returns the value of attribute tokens.



11
12
13
# File 'lib/dropbox-api/connection.rb', line 11

def tokens
  @tokens
end

Instance Method Details

#consumer(endpoint = :main) ⇒ Object



23
24
25
# File 'lib/dropbox-api/connection.rb', line 23

def consumer(endpoint = :main)
  @consumers[endpoint]
end

#token(endpoint = :main) ⇒ Object



27
28
29
# File 'lib/dropbox-api/connection.rb', line 27

def token(endpoint = :main)
  @tokens[endpoint]
end