Class: Authentication

Inherits:
Object
  • Object
show all
Defined in:
lib/domain/authentication.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(grant_type: nil, client_id: nil, client_secret: nil, username: nil, password: nil, token: nil, refresh_token: nil) ⇒ Authentication

Returns a new instance of Authentication.



11
12
13
14
# File 'lib/domain/authentication.rb', line 11

def initialize grant_type: nil, client_id: nil, client_secret: nil, username: nil, password: nil, token:nil, refresh_token:nil
 self.grant_type, self.client_id, self.client_secret, self.username, self.password, self.token, self.refresh_token =
 grant_type, client_id, client_secret, username, password, token, refresh_token
end

Instance Attribute Details

#client_idObject

Returns the value of attribute client_id.



4
5
6
# File 'lib/domain/authentication.rb', line 4

def client_id
  @client_id
end

#client_secretObject

Returns the value of attribute client_secret.



5
6
7
# File 'lib/domain/authentication.rb', line 5

def client_secret
  @client_secret
end

#grant_typeObject

Returns the value of attribute grant_type.



3
4
5
# File 'lib/domain/authentication.rb', line 3

def grant_type
  @grant_type
end

#passwordObject

Returns the value of attribute password.



7
8
9
# File 'lib/domain/authentication.rb', line 7

def password
  @password
end

#refresh_tokenObject

Returns the value of attribute refresh_token.



9
10
11
# File 'lib/domain/authentication.rb', line 9

def refresh_token
  @refresh_token
end

#tokenObject

Returns the value of attribute token.



8
9
10
# File 'lib/domain/authentication.rb', line 8

def token
  @token
end

#usernameObject

Returns the value of attribute username.



6
7
8
# File 'lib/domain/authentication.rb', line 6

def username
  @username
end

Class Method Details

.get_payload(auth_data) ⇒ Object



43
44
45
# File 'lib/domain/authentication.rb', line 43

def self.get_payload(auth_data)
  return auth_data.to_json
end

.json_create(o) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/domain/authentication.rb', line 31

def self.json_create(o)
  b_from_json = new
  b_from_json.grant_type = o['grant_type']
  b_from_json.client_id = o['client_id']
  b_from_json.client_secret = o['client_secret']
  b_from_json.username = o['username']
  b_from_json.password = o['password']
  b_from_json.token = o['token']
  b_from_json.refresh_token = o['refresh_token']
  b_from_json
end

Instance Method Details

#to_json(*a) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/domain/authentication.rb', line 17

def to_json(*a)
  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(*a)
end