Class: Cloudpt::API::Connection
- Inherits:
-
Object
- Object
- Cloudpt::API::Connection
- Includes:
- Requests
- Defined in:
- lib/cloudpt-api/connection.rb,
lib/cloudpt-api/connection/requests.rb
Defined Under Namespace
Modules: Requests
Instance Attribute Summary collapse
-
#consumers ⇒ Object
Returns the value of attribute consumers.
-
#tokens ⇒ Object
Returns the value of attribute tokens.
Instance Method Summary collapse
- #consumer(endpoint = :main) ⇒ Object
-
#initialize(options = {}) ⇒ Connection
constructor
A new instance of Connection.
- #token(endpoint = :main) ⇒ Object
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/cloudpt-api/connection.rb', line 13 def initialize( = {}) @options = @consumers = {} @tokens = {} Cloudpt::API::Config.endpoints.each do |endpoint, url| @consumers[endpoint] = Cloudpt::API::OAuth.consumer(endpoint) @tokens[endpoint] = Cloudpt::API::OAuth.access_token(@consumers[endpoint], ) end end |
Instance Attribute Details
#consumers ⇒ Object
Returns the value of attribute consumers.
10 11 12 |
# File 'lib/cloudpt-api/connection.rb', line 10 def consumers @consumers end |
#tokens ⇒ Object
Returns the value of attribute tokens.
11 12 13 |
# File 'lib/cloudpt-api/connection.rb', line 11 def tokens @tokens end |
Instance Method Details
#consumer(endpoint = :main) ⇒ Object
23 24 25 |
# File 'lib/cloudpt-api/connection.rb', line 23 def consumer(endpoint = :main) @consumers[endpoint] end |
#token(endpoint = :main) ⇒ Object
27 28 29 |
# File 'lib/cloudpt-api/connection.rb', line 27 def token(endpoint = :main) @tokens[endpoint] end |