Class: YandexTracker::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/yandex_tracker/configuration.rb

Overview

Handles API client configuration and validation

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#access_tokenObject

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_idObject

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_secretObject

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_idObject

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_idObject

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_tokenObject

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_headersObject



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

Returns:

  • (Boolean)


40
41
42
# File 'lib/yandex_tracker/configuration.rb', line 40

def can_perform_oauth?
  valid_oauth_auth?
end

#can_refresh?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/yandex_tracker/configuration.rb', line 29

def can_refresh?
  !@refresh_token.nil?
end

#token_expired?Boolean

Returns:

  • (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