Class: Nexo::Integration
- Inherits:
-
ApplicationRecord
- Object
- ApplicationRecord
- ApplicationRecord
- Nexo::Integration
- Defined in:
- app/models/nexo/integration.rb
Instance Method Summary collapse
- #credentials ⇒ Object
- #expires_in ⇒ Object
- #external_api_scope ⇒ Object
- #token? ⇒ Boolean
- #token_status ⇒ Object
Instance Method Details
#credentials ⇒ Object
61 62 63 64 |
# File 'app/models/nexo/integration.rb', line 61 def credentials service = ServiceBuilder.instance.build_auth_service(self) @credentials ||= service.get_credentials end |
#expires_in ⇒ Object
39 40 41 42 43 |
# File 'app/models/nexo/integration.rb', line 39 def expires_in return unless credentials.present? (credentials.expires_at - Time.current).to_i end |
#external_api_scope ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'app/models/nexo/integration.rb', line 29 def external_api_scope if scope.blank? # :nocov: borderline raise "scope must be present" # :nocov: end scope.map { || client.service_scopes[.to_sym] } end |
#token? ⇒ Boolean
57 58 59 |
# File 'app/models/nexo/integration.rb', line 57 def token? token_status.in? [ :active_token, :expired_token ] end |
#token_status ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/models/nexo/integration.rb', line 45 def token_status if credentials.present? if credentials.expires_at > Time.current :active_token else :expired_token end else :no_token end end |