Class: PlentyClient::Config
- Inherits:
-
Object
- Object
- PlentyClient::Config
- Defined in:
- lib/plenty_client/config.rb
Defined Under Namespace
Classes: InvalidCredentials, NoCredentials, NoPlentyId, NoToken
Constant Summary collapse
- LOGIN_RENEW_BUFFER =
When expiry_date is less than this many seconds from now, it should renew API keys
60
- ATTEMPT_COUNT =
3
Class Attribute Summary collapse
-
.access_token ⇒ Object
Returns the value of attribute access_token.
-
.api_password ⇒ Object
Returns the value of attribute api_password.
-
.api_user ⇒ Object
Returns the value of attribute api_user.
- .attempt_count ⇒ Object
-
.expiry_date ⇒ Object
Returns the value of attribute expiry_date.
-
.log ⇒ Object
Returns the value of attribute log.
-
.plenty_id ⇒ Object
Returns the value of attribute plenty_id.
-
.refresh_token ⇒ Object
Returns the value of attribute refresh_token.
-
.site_url ⇒ Object
Returns the value of attribute site_url.
Class Method Summary collapse
Class Attribute Details
.access_token ⇒ Object
Returns the value of attribute access_token.
13 14 15 |
# File 'lib/plenty_client/config.rb', line 13 def access_token @access_token end |
.api_password ⇒ Object
Returns the value of attribute api_password.
13 14 15 |
# File 'lib/plenty_client/config.rb', line 13 def api_password @api_password end |
.api_user ⇒ Object
Returns the value of attribute api_user.
13 14 15 |
# File 'lib/plenty_client/config.rb', line 13 def api_user @api_user end |
.attempt_count ⇒ Object
24 25 26 |
# File 'lib/plenty_client/config.rb', line 24 def attempt_count @attempt_count || ATTEMPT_COUNT end |
.expiry_date ⇒ Object
Returns the value of attribute expiry_date.
13 14 15 |
# File 'lib/plenty_client/config.rb', line 13 def expiry_date @expiry_date end |
.log ⇒ Object
Returns the value of attribute log.
13 14 15 |
# File 'lib/plenty_client/config.rb', line 13 def log @log end |
.plenty_id ⇒ Object
Returns the value of attribute plenty_id.
13 14 15 |
# File 'lib/plenty_client/config.rb', line 13 def plenty_id @plenty_id end |
.refresh_token ⇒ Object
Returns the value of attribute refresh_token.
13 14 15 |
# File 'lib/plenty_client/config.rb', line 13 def refresh_token @refresh_token end |
.site_url ⇒ Object
Returns the value of attribute site_url.
13 14 15 |
# File 'lib/plenty_client/config.rb', line 13 def site_url @site_url end |
Class Method Details
.tokens_present? ⇒ Boolean
20 21 22 |
# File 'lib/plenty_client/config.rb', line 20 def tokens_present? !access_token.nil? && !refresh_token.nil? end |
.tokens_valid? ⇒ Boolean
28 29 30 31 32 33 |
# File 'lib/plenty_client/config.rb', line 28 def tokens_valid? tokens_present? && expiry_date.instance_of?(Time) && expiry_date > Time.now && (expiry_date - Time.now > LOGIN_RENEW_BUFFER) end |
.validate_credentials ⇒ Object
16 17 18 |
# File 'lib/plenty_client/config.rb', line 16 def validate_credentials raise NoCredentials if site_url.nil? || api_user.nil? || api_password.nil? end |