Class: DnB::Direct::Two
- Inherits:
-
Object
- Object
- DnB::Direct::Two
- Defined in:
- lib/dnb/direct/two.rb
Constant Summary collapse
- BASE_URL =
'https://direct.dnb.com'.freeze
Class Attribute Summary collapse
-
.api_base_url ⇒ Object
Returns the value of attribute api_base_url.
-
.conn ⇒ Object
Returns the value of attribute conn.
-
.password ⇒ Object
Returns the value of attribute password.
-
.token ⇒ Object
Returns the value of attribute token.
-
.username ⇒ Object
Returns the value of attribute username.
Class Method Summary collapse
-
.api_token ⇒ Object
Fetches the token from the authorization service.
Class Attribute Details
.api_base_url ⇒ Object
Returns the value of attribute api_base_url.
8 9 10 |
# File 'lib/dnb/direct/two.rb', line 8 def api_base_url @api_base_url end |
.conn ⇒ Object
Returns the value of attribute conn.
8 9 10 |
# File 'lib/dnb/direct/two.rb', line 8 def conn @conn end |
.password ⇒ Object
Returns the value of attribute password.
8 9 10 |
# File 'lib/dnb/direct/two.rb', line 8 def password @password end |
.token ⇒ Object
Returns the value of attribute token.
8 9 10 |
# File 'lib/dnb/direct/two.rb', line 8 def token @token end |
.username ⇒ Object
Returns the value of attribute username.
8 9 10 |
# File 'lib/dnb/direct/two.rb', line 8 def username @username end |
Class Method Details
.api_token ⇒ Object
Fetches the token from the authorization service.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/dnb/direct/two.rb', line 11 def api_token raise ArgumentError, 'username is missing' if username.blank? raise ArgumentError, 'password is missing' if password.blank? response = connection.post do |req| req.url '/Authentication/V2.0' req.headers['x-dnb-user'] = username req.headers['x-dnb-pwd'] = password end response.headers['Authorization'] end |