Class: Scanii::AuthToken
- Inherits:
-
Object
- Object
- Scanii::AuthToken
- Defined in:
- lib/scanii/auth_token.rb
Overview
Short-lived auth token returned by Client#create_auth_token and Client#retrieve_auth_token.
Pass id back as the token: keyword argument when constructing a Client to authenticate using the token instead of API key + secret.
Instance Attribute Summary collapse
-
#creation_date ⇒ Object
readonly
Returns the value of attribute creation_date.
-
#expiration_date ⇒ Object
readonly
Returns the value of attribute expiration_date.
-
#host_id ⇒ Object
readonly
Returns the value of attribute host_id.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#raw_response ⇒ Object
readonly
Returns the value of attribute raw_response.
-
#request_id ⇒ Object
readonly
Returns the value of attribute request_id.
-
#resource_location ⇒ Object
readonly
Returns the value of attribute resource_location.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id:, creation_date:, expiration_date:, request_id:, host_id:, resource_location:, raw_response:) ⇒ AuthToken
constructor
A new instance of AuthToken.
Constructor Details
#initialize(id:, creation_date:, expiration_date:, request_id:, host_id:, resource_location:, raw_response:) ⇒ AuthToken
Returns a new instance of AuthToken.
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/scanii/auth_token.rb', line 15 def initialize(id:, creation_date:, expiration_date:, request_id:, host_id:, resource_location:, raw_response:) @id = id @creation_date = creation_date @expiration_date = expiration_date @request_id = request_id @host_id = host_id @resource_location = resource_location @raw_response = raw_response end |
Instance Attribute Details
#creation_date ⇒ Object (readonly)
Returns the value of attribute creation_date.
12 13 14 |
# File 'lib/scanii/auth_token.rb', line 12 def creation_date @creation_date end |
#expiration_date ⇒ Object (readonly)
Returns the value of attribute expiration_date.
12 13 14 |
# File 'lib/scanii/auth_token.rb', line 12 def expiration_date @expiration_date end |
#host_id ⇒ Object (readonly)
Returns the value of attribute host_id.
12 13 14 |
# File 'lib/scanii/auth_token.rb', line 12 def host_id @host_id end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
12 13 14 |
# File 'lib/scanii/auth_token.rb', line 12 def id @id end |
#raw_response ⇒ Object (readonly)
Returns the value of attribute raw_response.
12 13 14 |
# File 'lib/scanii/auth_token.rb', line 12 def raw_response @raw_response end |
#request_id ⇒ Object (readonly)
Returns the value of attribute request_id.
12 13 14 |
# File 'lib/scanii/auth_token.rb', line 12 def request_id @request_id end |
#resource_location ⇒ Object (readonly)
Returns the value of attribute resource_location.
12 13 14 |
# File 'lib/scanii/auth_token.rb', line 12 def resource_location @resource_location end |
Class Method Details
.from_response(body, headers) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/scanii/auth_token.rb', line 26 def self.from_response(body, headers) json = body.nil? || body.empty? ? {} : JSON.parse(body) new( id: (json["id"] || "").to_s, creation_date: json["creation_date"]&.to_s, expiration_date: json["expiration_date"]&.to_s, request_id: headers["x-scanii-request-id"], host_id: headers["x-scanii-host-id"], resource_location: headers["location"], raw_response: body ) end |