Class: Authentication
- Inherits:
-
Object
- Object
- Authentication
- Defined in:
- lib/domain/authentication.rb
Overview
Authentication model conatining token generation attributes
Instance Attribute Summary collapse
-
#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.
-
.get_payload_with_client_info(auth_data) ⇒ Json
Gets Json represenatation of authentication object with client details.
Instance Method Summary collapse
-
#as_json(options = {}) ⇒ Hash
Converts Authentication object to Hash and deletes null value fields.
-
#initialize(grant_type: nil, username: nil, password: nil, token: nil, refresh_token: nil) ⇒ Authentication
constructor
Inialise the authentication model.
Constructor Details
#initialize(grant_type: nil, username: nil, password: nil, token: nil, refresh_token: nil) ⇒ Authentication
Inialise the authentication model
22 23 24 25 26 27 28 |
# File 'lib/domain/authentication.rb', line 22 def initialize(grant_type: nil, username: nil, password: nil, token: nil, refresh_token: nil) self.grant_type = grant_type self.username = username self.password = password self.token = token self.refresh_token = refresh_token end |
Instance Attribute Details
#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.
9 10 11 |
# File 'lib/domain/authentication.rb', line 9 def password @password end |
#refresh_token ⇒ Object
Returns the value of attribute refresh_token.
11 12 13 |
# File 'lib/domain/authentication.rb', line 11 def refresh_token @refresh_token end |
#token ⇒ Object
Returns the value of attribute token.
10 11 12 |
# File 'lib/domain/authentication.rb', line 10 def token @token end |
#username ⇒ Object
Returns the value of attribute username.
8 9 10 |
# File 'lib/domain/authentication.rb', line 8 def username @username end |
Class Method Details
.get_payload(auth_data) ⇒ Json
Gets Json represenatation of authentication object
57 58 59 |
# File 'lib/domain/authentication.rb', line 57 def self.get_payload(auth_data) auth_data.as_json.to_json end |
.get_payload_with_client_info(auth_data) ⇒ Json
Gets Json represenatation of authentication object with client details
68 69 70 |
# File 'lib/domain/authentication.rb', line 68 def self.get_payload_with_client_info(auth_data) auth_data.as_json.merge!({ 'client_id' => ApplicationConfig.client_id, 'client_secret' => ApplicationConfig.client_secret }).to_json end |
Instance Method Details
#as_json(options = {}) ⇒ Hash
Converts Authentication object to Hash and deletes null value fields
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/domain/authentication.rb', line 37 def as_json( = {}) hash_data = { grant_type: @grant_type, username: @username, password: @password, token: @token, refresh_token: @refresh_token } hash_data.delete_if { |k, v| v.nil? || v.empty? } hash_data end |