Class: FattureInCloud_Ruby_Sdk::OAuth2Manager
- Inherits:
-
Object
- Object
- FattureInCloud_Ruby_Sdk::OAuth2Manager
- Defined in:
- lib/fattureincloud_ruby_sdk/oauth2/oauth2.rb
Overview
The OAuth2Manager class is used to manage the OAuth2 flow.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#base_uri ⇒ Object
Returns the value of attribute base_uri.
-
#client_id ⇒ Object
Returns the value of attribute client_id.
Class Method Summary collapse
-
.get_scope_string(scopes) ⇒ String
Build the scopes string.
Instance Method Summary collapse
-
#execute_post(url, body) ⇒ Object
Get the access token.
-
#initialize(client_id, base_uri = 'https://api-v2.fattureincloud.it') ⇒ OAuth2Manager
constructor
Initializes a new instance of the OAuth2Manager class.
Constructor Details
#initialize(client_id, base_uri = 'https://api-v2.fattureincloud.it') ⇒ OAuth2Manager
Initializes a new instance of the OAuth2Manager class.
12 13 14 15 |
# File 'lib/fattureincloud_ruby_sdk/oauth2/oauth2.rb', line 12 def initialize(client_id, base_uri = 'https://api-v2.fattureincloud.it') @client_id = client_id @base_uri = base_uri end |
Instance Attribute Details
#base_uri ⇒ Object
Returns the value of attribute base_uri.
7 8 9 |
# File 'lib/fattureincloud_ruby_sdk/oauth2/oauth2.rb', line 7 def base_uri @base_uri end |
#client_id ⇒ Object
Returns the value of attribute client_id.
7 8 9 |
# File 'lib/fattureincloud_ruby_sdk/oauth2/oauth2.rb', line 7 def client_id @client_id end |
Class Method Details
.get_scope_string(scopes) ⇒ String
Build the scopes string.
32 33 34 |
# File 'lib/fattureincloud_ruby_sdk/oauth2/oauth2.rb', line 32 def self.get_scope_string(scopes) scopes.map { |scope| scope.to_s }.join(' ') end |
Instance Method Details
#execute_post(url, body) ⇒ Object
Get the access token.
21 22 23 24 25 26 27 |
# File 'lib/fattureincloud_ruby_sdk/oauth2/oauth2.rb', line 21 def execute_post(url, body) res = Typhoeus.post(url, body: body) if res.response_code != 200 raise "Error fetching token: #{res.response_body}" end JSON.parse(res.body) end |