Class: Verizon::OAuth2Credentials

Inherits:
Object
  • Object
show all
Defined in:
lib/verizon/http/auth/oauth_2.rb

Overview

Data class for OAuth2Credentials.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(oauth_client_id:, oauth_client_secret:, oauth_token: nil, oauth_scopes: nil) ⇒ OAuth2Credentials

Returns a new instance of OAuth2Credentials.

Raises:

  • (ArgumentError)


73
74
75
76
77
78
79
80
81
82
# File 'lib/verizon/http/auth/oauth_2.rb', line 73

def initialize(oauth_client_id:, oauth_client_secret:, 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?

  @oauth_client_id = oauth_client_id
  @oauth_client_secret = oauth_client_secret
  @oauth_token = oauth_token
  @oauth_scopes = oauth_scopes
end

Instance Attribute Details

#oauth_client_idObject (readonly)

Returns the value of attribute oauth_client_id.



70
71
72
# File 'lib/verizon/http/auth/oauth_2.rb', line 70

def oauth_client_id
  @oauth_client_id
end

#oauth_client_secretObject (readonly)

Returns the value of attribute oauth_client_secret.



70
71
72
# File 'lib/verizon/http/auth/oauth_2.rb', line 70

def oauth_client_secret
  @oauth_client_secret
end

#oauth_scopesObject (readonly)

Returns the value of attribute oauth_scopes.



70
71
72
# File 'lib/verizon/http/auth/oauth_2.rb', line 70

def oauth_scopes
  @oauth_scopes
end

#oauth_tokenObject (readonly)

Returns the value of attribute oauth_token.



70
71
72
# File 'lib/verizon/http/auth/oauth_2.rb', line 70

def oauth_token
  @oauth_token
end

Instance Method Details

#clone_with(oauth_client_id: nil, oauth_client_secret: nil, oauth_token: nil, oauth_scopes: nil) ⇒ Object



84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/verizon/http/auth/oauth_2.rb', line 84

def clone_with(oauth_client_id: nil, oauth_client_secret: nil,
               oauth_token: nil, oauth_scopes: 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

  OAuth2Credentials.new(oauth_client_id: oauth_client_id,
                        oauth_client_secret: oauth_client_secret,
                        oauth_token: oauth_token,
                        oauth_scopes: oauth_scopes)
end