Class: OneRoster::Connection
- Inherits:
-
Object
- Object
- OneRoster::Connection
- Defined in:
- lib/one_roster/connection.rb
Constant Summary collapse
- OPEN_TIMEOUT =
60
- TIMEOUT =
120
Instance Method Summary collapse
- #connection ⇒ Object
- #execute(path, method = :get, params = nil, body = nil, content_type = nil) ⇒ Object
-
#initialize(client, oauth_strategy = 'oauth') ⇒ Connection
constructor
A new instance of Connection.
- #log(message = '') ⇒ Object
- #set_auth_headers(token, cookie) ⇒ Object
Constructor Details
#initialize(client, oauth_strategy = 'oauth') ⇒ Connection
Returns a new instance of Connection.
8 9 10 11 |
# File 'lib/one_roster/connection.rb', line 8 def initialize(client, oauth_strategy = 'oauth') @client = client @oauth_strategy = oauth_strategy end |
Instance Method Details
#connection ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/one_roster/connection.rb', line 22 def connection return @connection if @connection @connection = if @oauth_strategy == 'oauth2' oauth2_connection else oauth_connection end end |
#execute(path, method = :get, params = nil, body = nil, content_type = nil) ⇒ Object
13 14 15 |
# File 'lib/one_roster/connection.rb', line 13 def execute(path, method = :get, params = nil, body = nil, content_type = nil) Response.new(raw_request(path, method, params, body, content_type)) end |
#log(message = '') ⇒ Object
32 33 34 35 36 |
# File 'lib/one_roster/connection.rb', line 32 def log( = '') return unless @client.logger @client.logger.info end |
#set_auth_headers(token, cookie) ⇒ Object
17 18 19 20 |
# File 'lib/one_roster/connection.rb', line 17 def set_auth_headers(token, ) connection. :Bearer, token @cookie = end |