Class: Azure::TTS::Token
- Inherits:
-
Object
- Object
- Azure::TTS::Token
- Defined in:
- lib/azure/tts/token.rb
Instance Attribute Summary collapse
-
#obtained_at ⇒ Object
readonly
Returns the value of attribute obtained_at.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
Instance Attribute Details
#obtained_at ⇒ Object (readonly)
Returns the value of attribute obtained_at.
6 7 8 |
# File 'lib/azure/tts/token.rb', line 6 def obtained_at @obtained_at end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
6 7 8 |
# File 'lib/azure/tts/token.rb', line 6 def token @token end |
Instance Method Details
#needs_refreshing? ⇒ Boolean
18 19 20 |
# File 'lib/azure/tts/token.rb', line 18 def needs_refreshing? (Time.now.to_i - obtained_at.to_i) > 600 end |
#refresh ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/azure/tts/token.rb', line 8 def refresh return unless needs_refreshing? response = Azure::TTS.api.tokens.post raise RequestError, response unless response.success? @token = response.body @obtained_at = Time.now.to_i end |
#to_s ⇒ Object
22 23 24 |
# File 'lib/azure/tts/token.rb', line 22 def to_s token end |