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
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.
-
.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.
12 13 14 |
# File 'lib/plenty_client/config.rb', line 12 def access_token @access_token end |
.api_password ⇒ Object
Returns the value of attribute api_password.
12 13 14 |
# File 'lib/plenty_client/config.rb', line 12 def api_password @api_password end |
.api_user ⇒ Object
Returns the value of attribute api_user.
12 13 14 |
# File 'lib/plenty_client/config.rb', line 12 def api_user @api_user end |
.expiry_date ⇒ Object
Returns the value of attribute expiry_date.
12 13 14 |
# File 'lib/plenty_client/config.rb', line 12 def expiry_date @expiry_date end |
.log ⇒ Object
Returns the value of attribute log.
12 13 14 |
# File 'lib/plenty_client/config.rb', line 12 def log @log end |
.plenty_id ⇒ Object
Returns the value of attribute plenty_id.
12 13 14 |
# File 'lib/plenty_client/config.rb', line 12 def plenty_id @plenty_id end |
.refresh_token ⇒ Object
Returns the value of attribute refresh_token.
12 13 14 |
# File 'lib/plenty_client/config.rb', line 12 def refresh_token @refresh_token end |
.site_url ⇒ Object
Returns the value of attribute site_url.
12 13 14 |
# File 'lib/plenty_client/config.rb', line 12 def site_url @site_url end |
Class Method Details
.tokens_present? ⇒ Boolean
18 19 20 |
# File 'lib/plenty_client/config.rb', line 18 def tokens_present? !access_token.nil? && !refresh_token.nil? end |
.tokens_valid? ⇒ Boolean
22 23 24 25 26 27 |
# File 'lib/plenty_client/config.rb', line 22 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
14 15 16 |
# File 'lib/plenty_client/config.rb', line 14 def validate_credentials raise NoCredentials if site_url.nil? || api_user.nil? || api_password.nil? end |