Class: YandexTracker::Configuration
- Inherits:
-
Object
- Object
- YandexTracker::Configuration
- Defined in:
- lib/yandex_tracker/configuration.rb
Overview
Handles API client configuration and validation
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#client_id ⇒ Object
Returns the value of attribute client_id.
-
#client_secret ⇒ Object
Returns the value of attribute client_secret.
-
#cloud_org_id ⇒ Object
Returns the value of attribute cloud_org_id.
-
#org_id ⇒ Object
Returns the value of attribute org_id.
-
#refresh_token ⇒ Object
Returns the value of attribute refresh_token.
Instance Method Summary collapse
- #additional_headers ⇒ Object
- #can_perform_oauth? ⇒ Boolean
- #can_refresh? ⇒ Boolean
- #token_expired? ⇒ Boolean
- #update_tokens(access_token:, refresh_token:, expires_in:) ⇒ Object
- #validate! ⇒ Object
Instance Attribute Details
#access_token ⇒ Object
Returns the value of attribute access_token.
8 9 10 |
# File 'lib/yandex_tracker/configuration.rb', line 8 def access_token @access_token end |
#client_id ⇒ Object
Returns the value of attribute client_id.
8 9 10 |
# File 'lib/yandex_tracker/configuration.rb', line 8 def client_id @client_id end |
#client_secret ⇒ Object
Returns the value of attribute client_secret.
8 9 10 |
# File 'lib/yandex_tracker/configuration.rb', line 8 def client_secret @client_secret end |
#cloud_org_id ⇒ Object
Returns the value of attribute cloud_org_id.
8 9 10 |
# File 'lib/yandex_tracker/configuration.rb', line 8 def cloud_org_id @cloud_org_id end |
#org_id ⇒ Object
Returns the value of attribute org_id.
8 9 10 |
# File 'lib/yandex_tracker/configuration.rb', line 8 def org_id @org_id end |
#refresh_token ⇒ Object
Returns the value of attribute refresh_token.
8 9 10 |
# File 'lib/yandex_tracker/configuration.rb', line 8 def refresh_token @refresh_token end |
Instance Method Details
#additional_headers ⇒ Object
33 34 35 36 37 38 |
# File 'lib/yandex_tracker/configuration.rb', line 33 def additional_headers headers = {} headers["X-Cloud-Org-ID"] = cloud_org_id if cloud_org_id headers["X-Org-Id"] = org_id if org_id && !cloud_org_id headers end |
#can_perform_oauth? ⇒ Boolean
40 41 42 |
# File 'lib/yandex_tracker/configuration.rb', line 40 def can_perform_oauth? valid_oauth_auth? end |
#can_refresh? ⇒ Boolean
29 30 31 |
# File 'lib/yandex_tracker/configuration.rb', line 29 def can_refresh? !@refresh_token.nil? end |
#token_expired? ⇒ Boolean
23 24 25 26 27 |
# File 'lib/yandex_tracker/configuration.rb', line 23 def token_expired? return false unless @token_expires_at Time.now >= (@token_expires_at - 300) end |
#update_tokens(access_token:, refresh_token:, expires_in:) ⇒ Object
17 18 19 20 21 |
# File 'lib/yandex_tracker/configuration.rb', line 17 def update_tokens(access_token:, refresh_token:, expires_in:) @access_token = access_token @refresh_token = refresh_token @token_expires_at = Time.now + expires_in end |
#validate! ⇒ Object
12 13 14 15 |
# File 'lib/yandex_tracker/configuration.rb', line 12 def validate! validate_org_configuration! validate_auth_configuration! end |