Class: SlackWebApi::AuthorizationCodeAuthCredentials
- Inherits:
-
Object
- Object
- SlackWebApi::AuthorizationCodeAuthCredentials
- Defined in:
- lib/slack_web_api/http/auth/oauth_2.rb
Overview
Data class for AuthorizationCodeAuthCredentials.
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_redirect_uri ⇒ Object
readonly
Returns the value of attribute oauth_redirect_uri.
-
#oauth_scopes ⇒ Object
readonly
Returns the value of attribute oauth_scopes.
-
#oauth_token ⇒ Object
readonly
Returns the value of attribute oauth_token.
Class Method Summary collapse
Instance Method Summary collapse
- #clone_with(oauth_client_id: nil, oauth_client_secret: nil, oauth_redirect_uri: nil, oauth_token: nil, oauth_scopes: nil) ⇒ Object
-
#initialize(oauth_client_id:, oauth_client_secret:, oauth_redirect_uri:, oauth_token: nil, oauth_scopes: nil) ⇒ AuthorizationCodeAuthCredentials
constructor
A new instance of AuthorizationCodeAuthCredentials.
Constructor Details
#initialize(oauth_client_id:, oauth_client_secret:, oauth_redirect_uri:, oauth_token: nil, oauth_scopes: nil) ⇒ AuthorizationCodeAuthCredentials
Returns a new instance of AuthorizationCodeAuthCredentials.
116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/slack_web_api/http/auth/oauth_2.rb', line 116 def initialize(oauth_client_id:, oauth_client_secret:, oauth_redirect_uri:, oauth_token: nil, oauth_scopes: nil) 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? raise ArgumentError, 'oauth_redirect_uri cannot be nil' if oauth_redirect_uri.nil? @oauth_client_id = oauth_client_id @oauth_client_secret = oauth_client_secret @oauth_redirect_uri = oauth_redirect_uri @oauth_token = oauth_token @oauth_scopes = oauth_scopes end |
Instance Attribute Details
#oauth_client_id ⇒ Object (readonly)
Returns the value of attribute oauth_client_id.
113 114 115 |
# File 'lib/slack_web_api/http/auth/oauth_2.rb', line 113 def oauth_client_id @oauth_client_id end |
#oauth_client_secret ⇒ Object (readonly)
Returns the value of attribute oauth_client_secret.
113 114 115 |
# File 'lib/slack_web_api/http/auth/oauth_2.rb', line 113 def oauth_client_secret @oauth_client_secret end |
#oauth_redirect_uri ⇒ Object (readonly)
Returns the value of attribute oauth_redirect_uri.
113 114 115 |
# File 'lib/slack_web_api/http/auth/oauth_2.rb', line 113 def oauth_redirect_uri @oauth_redirect_uri end |
#oauth_scopes ⇒ Object (readonly)
Returns the value of attribute oauth_scopes.
113 114 115 |
# File 'lib/slack_web_api/http/auth/oauth_2.rb', line 113 def oauth_scopes @oauth_scopes end |
#oauth_token ⇒ Object (readonly)
Returns the value of attribute oauth_token.
113 114 115 |
# File 'lib/slack_web_api/http/auth/oauth_2.rb', line 113 def oauth_token @oauth_token end |
Class Method Details
.from_env ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/slack_web_api/http/auth/oauth_2.rb', line 129 def self.from_env oauth_client_id = ENV['OAUTH_CLIENT_ID'] oauth_client_secret = ENV['OAUTH_CLIENT_SECRET'] oauth_redirect_uri = ENV['OAUTH_REDIRECT_URI'] oauth_scopes = ENV['OAUTH_SCOPES'] all_nil = [ oauth_client_id, oauth_client_secret, oauth_redirect_uri ].all?(&:nil?) return nil if all_nil new(oauth_client_id: oauth_client_id, oauth_client_secret: oauth_client_secret, oauth_redirect_uri: oauth_redirect_uri, oauth_scopes: oauth_scopes) end |
Instance Method Details
#clone_with(oauth_client_id: nil, oauth_client_secret: nil, oauth_redirect_uri: nil, oauth_token: nil, oauth_scopes: nil) ⇒ Object
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/slack_web_api/http/auth/oauth_2.rb', line 146 def clone_with(oauth_client_id: nil, oauth_client_secret: nil, oauth_redirect_uri: nil, oauth_token: nil, oauth_scopes: nil) oauth_client_id ||= self.oauth_client_id oauth_client_secret ||= self.oauth_client_secret oauth_redirect_uri ||= self.oauth_redirect_uri oauth_token ||= self.oauth_token oauth_scopes ||= self.oauth_scopes AuthorizationCodeAuthCredentials.new( oauth_client_id: oauth_client_id, oauth_client_secret: oauth_client_secret, oauth_redirect_uri: oauth_redirect_uri, oauth_token: oauth_token, oauth_scopes: oauth_scopes ) end |