Class: MyInfo::V3::AuthoriseUrl

Inherits:
Object
  • Object
show all
Extended by:
Callable
Defined in:
lib/myinfo/v3/authorise_url.rb

Overview

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(purpose:, state:, nric_fin: nil, authmode: 'SINGPASS', login_type: 'SINGPASS', attributes: nil) ⇒ AuthoriseUrl

Returns a new instance of AuthoriseUrl.



11
12
13
14
15
16
17
18
# File 'lib/myinfo/v3/authorise_url.rb', line 11

def initialize(purpose:, state:, nric_fin: nil, authmode: 'SINGPASS', login_type: 'SINGPASS', attributes: nil)
  @nric_fin = nric_fin
  @attributes = Attributes.parse(attributes)
  @purpose = purpose
  @authmode = authmode
  @login_type = 
  @state = state
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



9
10
11
# File 'lib/myinfo/v3/authorise_url.rb', line 9

def attributes
  @attributes
end

#authmodeObject

Returns the value of attribute authmode.



9
10
11
# File 'lib/myinfo/v3/authorise_url.rb', line 9

def authmode
  @authmode
end

#login_typeObject

Returns the value of attribute login_type.



9
10
11
# File 'lib/myinfo/v3/authorise_url.rb', line 9

def 
  @login_type
end

#nric_finObject

Returns the value of attribute nric_fin.



9
10
11
# File 'lib/myinfo/v3/authorise_url.rb', line 9

def nric_fin
  @nric_fin
end

#purposeObject

Returns the value of attribute purpose.



9
10
11
# File 'lib/myinfo/v3/authorise_url.rb', line 9

def purpose
  @purpose
end

#stateObject

Returns the value of attribute state.



9
10
11
# File 'lib/myinfo/v3/authorise_url.rb', line 9

def state
  @state
end

Instance Method Details

#callObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/myinfo/v3/authorise_url.rb', line 20

def call
  query_string = {
    authmode: authmode,
    login_type: ,
    purpose: purpose,
    client_id: config.client_id,
    attributes: attributes,
    sp_esvcId: config.singpass_eservice_id,
    state: state,
    redirect_uri: config.redirect_uri
  }.compact.to_param

  endpoint(query_string)
end

#configObject



49
50
51
# File 'lib/myinfo/v3/authorise_url.rb', line 49

def config
  MyInfo.configuration
end

#endpoint(query_string) ⇒ Object



35
36
37
38
39
40
41
# File 'lib/myinfo/v3/authorise_url.rb', line 35

def endpoint(query_string)
  if config.public?
    "#{config.base_url_with_protocol}/#{slug}/?#{query_string}"
  else
    "#{config.base_url_with_protocol}/#{slug}/#{nric_fin}/?#{query_string}"
  end
end

#slugObject



43
44
45
46
47
# File 'lib/myinfo/v3/authorise_url.rb', line 43

def slug
  slug_prefix = config.public? ? 'com' : 'gov'

  "#{slug_prefix}/v3/authorise"
end