Class: SecondStep::APIRequests::Request
- Inherits:
-
Object
- Object
- SecondStep::APIRequests::Request
- Defined in:
- lib/second_step/api_requests/request.rb
Direct Known Subclasses
Instance Attribute Summary collapse
Class Method Summary collapse
- .auth_url ⇒ Object
- .client ⇒ Object
- .path(*args) ⇒ Object
- .token(type = @token_type, auth_code: nil) ⇒ Object
- .token_type(type) ⇒ Object
Instance Method Summary collapse
- #path(*args) ⇒ Object
- #token(*args, **opts) ⇒ Object
- #token!(*args, **opts) ⇒ Object
- #token_cache_args(args) ⇒ Object
Instance Attribute Details
#token_cache ⇒ Object
32 33 34 |
# File 'lib/second_step/api_requests/request.rb', line 32 def token_cache @token_cache ||= {} end |
Class Method Details
.auth_url ⇒ Object
19 20 21 |
# File 'lib/second_step/api_requests/request.rb', line 19 def auth_url client.auth_code. redirect_uri: config.redirect_uri end |
.client ⇒ Object
8 9 10 |
# File 'lib/second_step/api_requests/request.rb', line 8 def client @@client ||= OAuth2::Client.new(config.client_id, config.client_secret, site: config.base_uri) end |
.path(*args) ⇒ Object
25 26 27 |
# File 'lib/second_step/api_requests/request.rb', line 25 def path(*args) PathBuilder.new(*args) end |
.token(type = @token_type, auth_code: nil) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/second_step/api_requests/request.rb', line 11 def token(type=@token_type, auth_code: nil) case type when :auth_code client.auth_code.get_token auth_code, redirect_uri: config.redirect_uri when :client_credentials client.client_credentials.get_token end end |
.token_type(type) ⇒ Object
22 23 24 |
# File 'lib/second_step/api_requests/request.rb', line 22 def token_type(type) @token_type = type end |
Instance Method Details
#path(*args) ⇒ Object
29 30 31 |
# File 'lib/second_step/api_requests/request.rb', line 29 def path(*args) PathBuilder.new(*args) end |
#token(*args, **opts) ⇒ Object
38 39 40 |
# File 'lib/second_step/api_requests/request.rb', line 38 def token(*args, **opts) token_cache_args(args)[opts] ||= self.class.token(*args, **opts) end |
#token!(*args, **opts) ⇒ Object
41 42 43 |
# File 'lib/second_step/api_requests/request.rb', line 41 def token!(*args, **opts) token_cache_args(args)[opts] = self.class.token(*args, **opts) end |
#token_cache_args(args) ⇒ Object
35 36 37 |
# File 'lib/second_step/api_requests/request.rb', line 35 def token_cache_args(args) token_cache[args] ||= {} end |