Class: Mobiscroll::Connect::TokenResponse
- Inherits:
-
Struct
- Object
- Struct
- Mobiscroll::Connect::TokenResponse
- Defined in:
- lib/mobiscroll/connect/models.rb
Overview
OAuth2 token payload returned by the API.
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#expires_in ⇒ Object
Returns the value of attribute expires_in.
-
#refresh_token ⇒ Object
Returns the value of attribute refresh_token.
-
#token_type ⇒ Object
Returns the value of attribute token_type.
Class Method Summary collapse
Instance Method Summary collapse
-
#merged_with(incoming) ⇒ Object
Overlay ‘incoming` on top of self, preserving the existing refresh_token if `incoming` omits one.
- #to_h ⇒ Object
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token
6 7 8 |
# File 'lib/mobiscroll/connect/models.rb', line 6 def access_token @access_token end |
#expires_in ⇒ Object
Returns the value of attribute expires_in
6 7 8 |
# File 'lib/mobiscroll/connect/models.rb', line 6 def expires_in @expires_in end |
#refresh_token ⇒ Object
Returns the value of attribute refresh_token
6 7 8 |
# File 'lib/mobiscroll/connect/models.rb', line 6 def refresh_token @refresh_token end |
#token_type ⇒ Object
Returns the value of attribute token_type
6 7 8 |
# File 'lib/mobiscroll/connect/models.rb', line 6 def token_type @token_type end |
Class Method Details
.from_h(hash) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/mobiscroll/connect/models.rb', line 7 def self.from_h(hash) return nil if hash.nil? new( access_token: hash['access_token'] || hash[:access_token], token_type: hash['token_type'] || hash[:token_type], expires_in: hash['expires_in'] || hash[:expires_in], refresh_token: hash['refresh_token'] || hash[:refresh_token] ) end |
Instance Method Details
#merged_with(incoming) ⇒ Object
Overlay ‘incoming` on top of self, preserving the existing refresh_token if `incoming` omits one.
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/mobiscroll/connect/models.rb', line 20 def merged_with(incoming) return incoming if nil? rt = incoming.refresh_token rt = refresh_token if rt.nil? || rt.empty? TokenResponse.new( access_token: incoming.access_token, token_type: incoming.token_type || token_type, expires_in: incoming.expires_in || expires_in, refresh_token: rt ) end |
#to_h ⇒ Object
33 34 35 |
# File 'lib/mobiscroll/connect/models.rb', line 33 def to_h super.compact end |