Class: MyInfo::V3::AuthoriseUrl
- Inherits:
-
Object
- Object
- MyInfo::V3::AuthoriseUrl
- Extended by:
- Callable
- Defined in:
- lib/myinfo/v3/authorise_url.rb
Overview
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#authmode ⇒ Object
Returns the value of attribute authmode.
-
#login_type ⇒ Object
Returns the value of attribute login_type.
-
#nric_fin ⇒ Object
Returns the value of attribute nric_fin.
-
#purpose ⇒ Object
Returns the value of attribute purpose.
-
#state ⇒ Object
Returns the value of attribute state.
Instance Method Summary collapse
- #call ⇒ Object
- #config ⇒ Object
- #endpoint(query_string) ⇒ Object
-
#initialize(purpose:, state:, nric_fin: nil, authmode: 'SINGPASS', login_type: 'SINGPASS', attributes: nil) ⇒ AuthoriseUrl
constructor
A new instance of AuthoriseUrl.
- #slug ⇒ Object
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 = login_type @state = state end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
9 10 11 |
# File 'lib/myinfo/v3/authorise_url.rb', line 9 def attributes @attributes end |
#authmode ⇒ Object
Returns the value of attribute authmode.
9 10 11 |
# File 'lib/myinfo/v3/authorise_url.rb', line 9 def authmode @authmode end |
#login_type ⇒ Object
Returns the value of attribute login_type.
9 10 11 |
# File 'lib/myinfo/v3/authorise_url.rb', line 9 def login_type @login_type end |
#nric_fin ⇒ Object
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 |
#purpose ⇒ Object
Returns the value of attribute purpose.
9 10 11 |
# File 'lib/myinfo/v3/authorise_url.rb', line 9 def purpose @purpose end |
#state ⇒ Object
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
#call ⇒ Object
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: 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 |
#config ⇒ Object
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 |
#slug ⇒ Object
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 |