Class: SplititWebApiV4::Oauth2Credentials
- Inherits:
-
Object
- Object
- SplititWebApiV4::Oauth2Credentials
- Defined in:
- lib/splitit_web_api_v4/http/auth/oauth_2.rb
Overview
Data class for Oauth2Credentials.
Instance Attribute Summary collapse
-
#oauth_client_id ⇒ Object
readonly
Returns the value of attribute oauth_client_id.
-
#oauth_client_secret ⇒ Object
readonly
Returns the value of attribute oauth_client_secret.
-
#oauth_clock_skew ⇒ Object
readonly
Returns the value of attribute oauth_clock_skew.
-
#oauth_on_token_update ⇒ Object
readonly
Returns the value of attribute oauth_on_token_update.
-
#oauth_scopes ⇒ Object
readonly
Returns the value of attribute oauth_scopes.
-
#oauth_token ⇒ Object
readonly
Returns the value of attribute oauth_token.
-
#oauth_token_provider ⇒ Object
readonly
Returns the value of attribute oauth_token_provider.
Class Method Summary collapse
Instance Method Summary collapse
- #clone_with(oauth_client_id: nil, oauth_client_secret: nil, oauth_token: nil, oauth_scopes: nil, oauth_token_provider: nil, oauth_on_token_update: nil, oauth_clock_skew: nil) ⇒ Object
-
#initialize(oauth_client_id:, oauth_client_secret:, oauth_token: nil, oauth_scopes: nil, oauth_token_provider: nil, oauth_on_token_update: nil, oauth_clock_skew: 0) ⇒ Oauth2Credentials
constructor
A new instance of Oauth2Credentials.
Constructor Details
#initialize(oauth_client_id:, oauth_client_secret:, oauth_token: nil, oauth_scopes: nil, oauth_token_provider: nil, oauth_on_token_update: nil, oauth_clock_skew: 0) ⇒ Oauth2Credentials
Returns a new instance of Oauth2Credentials.
104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/splitit_web_api_v4/http/auth/oauth_2.rb', line 104 def initialize(oauth_client_id:, oauth_client_secret:, oauth_token: nil, oauth_scopes: nil, oauth_token_provider: nil, oauth_on_token_update: nil, oauth_clock_skew: 0) raise ArgumentError, 'oauth_client_id cannot be nil' if oauth_client_id.nil? raise ArgumentError, 'oauth_client_secret cannot be nil' if oauth_client_secret.nil? @oauth_client_id = oauth_client_id @oauth_client_secret = oauth_client_secret @oauth_token = oauth_token @oauth_scopes = oauth_scopes @oauth_token_provider = oauth_token_provider @oauth_on_token_update = oauth_on_token_update @oauth_clock_skew = oauth_clock_skew end |
Instance Attribute Details
#oauth_client_id ⇒ Object (readonly)
Returns the value of attribute oauth_client_id.
100 101 102 |
# File 'lib/splitit_web_api_v4/http/auth/oauth_2.rb', line 100 def oauth_client_id @oauth_client_id end |
#oauth_client_secret ⇒ Object (readonly)
Returns the value of attribute oauth_client_secret.
100 101 102 |
# File 'lib/splitit_web_api_v4/http/auth/oauth_2.rb', line 100 def oauth_client_secret @oauth_client_secret end |
#oauth_clock_skew ⇒ Object (readonly)
Returns the value of attribute oauth_clock_skew.
100 101 102 |
# File 'lib/splitit_web_api_v4/http/auth/oauth_2.rb', line 100 def oauth_clock_skew @oauth_clock_skew end |
#oauth_on_token_update ⇒ Object (readonly)
Returns the value of attribute oauth_on_token_update.
100 101 102 |
# File 'lib/splitit_web_api_v4/http/auth/oauth_2.rb', line 100 def oauth_on_token_update @oauth_on_token_update end |
#oauth_scopes ⇒ Object (readonly)
Returns the value of attribute oauth_scopes.
100 101 102 |
# File 'lib/splitit_web_api_v4/http/auth/oauth_2.rb', line 100 def oauth_scopes @oauth_scopes end |
#oauth_token ⇒ Object (readonly)
Returns the value of attribute oauth_token.
100 101 102 |
# File 'lib/splitit_web_api_v4/http/auth/oauth_2.rb', line 100 def oauth_token @oauth_token end |
#oauth_token_provider ⇒ Object (readonly)
Returns the value of attribute oauth_token_provider.
100 101 102 |
# File 'lib/splitit_web_api_v4/http/auth/oauth_2.rb', line 100 def oauth_token_provider @oauth_token_provider end |
Class Method Details
.from_env ⇒ Object
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/splitit_web_api_v4/http/auth/oauth_2.rb', line 119 def self.from_env oauth_client_id = ENV['OAUTH_2_OAUTH_CLIENT_ID'] oauth_client_secret = ENV['OAUTH_2_OAUTH_CLIENT_SECRET'] oauth_scopes = ENV['OAUTH_2_OAUTH_SCOPES'] oauth_clock_skew = ENV['OAUTH_2_OAUTH_CLOCK_SKEW'] all_nil = [ oauth_client_id, oauth_client_secret ].all?(&:nil?) return nil if all_nil new(oauth_client_id: oauth_client_id, oauth_client_secret: oauth_client_secret, oauth_scopes: oauth_scopes, oauth_clock_skew: oauth_clock_skew) end |
Instance Method Details
#clone_with(oauth_client_id: nil, oauth_client_secret: nil, oauth_token: nil, oauth_scopes: nil, oauth_token_provider: nil, oauth_on_token_update: nil, oauth_clock_skew: nil) ⇒ Object
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/splitit_web_api_v4/http/auth/oauth_2.rb', line 135 def clone_with(oauth_client_id: nil, oauth_client_secret: nil, oauth_token: nil, oauth_scopes: nil, oauth_token_provider: nil, oauth_on_token_update: nil, oauth_clock_skew: nil) oauth_client_id ||= self.oauth_client_id oauth_client_secret ||= self.oauth_client_secret oauth_token ||= self.oauth_token oauth_scopes ||= self.oauth_scopes oauth_token_provider ||= self.oauth_token_provider oauth_on_token_update ||= self.oauth_on_token_update oauth_clock_skew ||= self.oauth_clock_skew Oauth2Credentials.new(oauth_client_id: oauth_client_id, oauth_client_secret: oauth_client_secret, oauth_token: oauth_token, oauth_scopes: oauth_scopes, oauth_token_provider: oauth_token_provider, oauth_on_token_update: oauth_on_token_update, oauth_clock_skew: oauth_clock_skew) end |