Class: Authentication
- Inherits:
-
Object
- Object
- Authentication
- Defined in:
- lib/domain/authentication.rb
Overview
Authentication model conatining token generation attributes
Instance Attribute Summary collapse
-
#client_id ⇒ Object
Returns the value of attribute client_id.
-
#client_secret ⇒ Object
Returns the value of attribute client_secret.
-
#grant_type ⇒ Object
Returns the value of attribute grant_type.
-
#password ⇒ Object
Returns the value of attribute password.
-
#refresh_token ⇒ Object
Returns the value of attribute refresh_token.
-
#token ⇒ Object
Returns the value of attribute token.
-
#username ⇒ Object
Returns the value of attribute username.
Class Method Summary collapse
-
.get_payload(auth_data) ⇒ Json
Gets Json represenatation of authentication object.
Instance Method Summary collapse
-
#initialize(grant_type: nil, client_id: nil, client_secret: nil, username: nil, password: nil, token: nil, refresh_token: nil) ⇒ Authentication
constructor
Inialise the authentication model.
-
#to_json(*data) ⇒ Json
Converts Authentication object to Json object.
Constructor Details
#initialize(grant_type: nil, client_id: nil, client_secret: nil, username: nil, password: nil, token: nil, refresh_token: nil) ⇒ Authentication
Inialise the authentication model
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/domain/authentication.rb', line 26 def initialize(grant_type: nil, client_id: nil, client_secret: nil, username: nil, password: nil, token: nil, refresh_token: nil) self.grant_type = grant_type self.client_id = client_id self.client_secret = client_secret self.username = username self.password = password self.token = token self.refresh_token = refresh_token end |
Instance Attribute Details
#client_id ⇒ Object
Returns the value of attribute client_id.
8 9 10 |
# File 'lib/domain/authentication.rb', line 8 def client_id @client_id end |
#client_secret ⇒ Object
Returns the value of attribute client_secret.
9 10 11 |
# File 'lib/domain/authentication.rb', line 9 def client_secret @client_secret end |
#grant_type ⇒ Object
Returns the value of attribute grant_type.
7 8 9 |
# File 'lib/domain/authentication.rb', line 7 def grant_type @grant_type end |
#password ⇒ Object
Returns the value of attribute password.
11 12 13 |
# File 'lib/domain/authentication.rb', line 11 def password @password end |
#refresh_token ⇒ Object
Returns the value of attribute refresh_token.
13 14 15 |
# File 'lib/domain/authentication.rb', line 13 def refresh_token @refresh_token end |
#token ⇒ Object
Returns the value of attribute token.
12 13 14 |
# File 'lib/domain/authentication.rb', line 12 def token @token end |
#username ⇒ Object
Returns the value of attribute username.
10 11 12 |
# File 'lib/domain/authentication.rb', line 10 def username @username end |
Class Method Details
.get_payload(auth_data) ⇒ Json
Gets Json represenatation of authentication object
65 66 67 |
# File 'lib/domain/authentication.rb', line 65 def self.get_payload(auth_data) auth_data.to_json end |
Instance Method Details
#to_json(*data) ⇒ Json
Converts Authentication object to Json object
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/domain/authentication.rb', line 44 def to_json(*data) hash = { grant_type: @grant_type, client_id: @client_id, client_secret: @client_secret, username: @username, password: @password, token: @token, refresh_token: @refresh_token } hash.delete_if { |k, v| v.nil? || v.empty? } hash.to_json(*data) end |