Class: SourceLicenseSDK::LicenseValidationResult
- Inherits:
-
Object
- Object
- SourceLicenseSDK::LicenseValidationResult
- Defined in:
- lib/source_license_sdk/license_validator.rb
Overview
Represents the result of a license validation or activation request
Instance Attribute Summary collapse
-
#activations_remaining ⇒ Object
readonly
Returns the value of attribute activations_remaining.
-
#error_code ⇒ Object
readonly
Returns the value of attribute error_code.
-
#error_message ⇒ Object
readonly
Returns the value of attribute error_message.
-
#expires_at ⇒ Object
readonly
Returns the value of attribute expires_at.
-
#rate_limit_remaining ⇒ Object
readonly
Returns the value of attribute rate_limit_remaining.
-
#rate_limit_reset_at ⇒ Object
readonly
Returns the value of attribute rate_limit_reset_at.
-
#retry_after ⇒ Object
readonly
Returns the value of attribute retry_after.
-
#success ⇒ Object
readonly
Returns the value of attribute success.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
-
#valid ⇒ Object
readonly
Returns the value of attribute valid.
Instance Method Summary collapse
- #expired? ⇒ Boolean
-
#initialize(data) ⇒ LicenseValidationResult
constructor
A new instance of LicenseValidationResult.
- #inspect ⇒ Object
- #rate_limited? ⇒ Boolean
- #success? ⇒ Boolean
- #to_h ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(data) ⇒ LicenseValidationResult
Returns a new instance of LicenseValidationResult.
11 12 13 14 15 16 17 18 |
# File 'lib/source_license_sdk/license_validator.rb', line 11 def initialize(data) @data = data initialize_validation_fields initialize_activation_fields initialize_common_fields initialize_rate_limit_fields end |
Instance Attribute Details
#activations_remaining ⇒ Object (readonly)
Returns the value of attribute activations_remaining.
7 8 9 |
# File 'lib/source_license_sdk/license_validator.rb', line 7 def activations_remaining @activations_remaining end |
#error_code ⇒ Object (readonly)
Returns the value of attribute error_code.
7 8 9 |
# File 'lib/source_license_sdk/license_validator.rb', line 7 def error_code @error_code end |
#error_message ⇒ Object (readonly)
Returns the value of attribute error_message.
7 8 9 |
# File 'lib/source_license_sdk/license_validator.rb', line 7 def @error_message end |
#expires_at ⇒ Object (readonly)
Returns the value of attribute expires_at.
7 8 9 |
# File 'lib/source_license_sdk/license_validator.rb', line 7 def expires_at @expires_at end |
#rate_limit_remaining ⇒ Object (readonly)
Returns the value of attribute rate_limit_remaining.
7 8 9 |
# File 'lib/source_license_sdk/license_validator.rb', line 7 def rate_limit_remaining @rate_limit_remaining end |
#rate_limit_reset_at ⇒ Object (readonly)
Returns the value of attribute rate_limit_reset_at.
7 8 9 |
# File 'lib/source_license_sdk/license_validator.rb', line 7 def rate_limit_reset_at @rate_limit_reset_at end |
#retry_after ⇒ Object (readonly)
Returns the value of attribute retry_after.
7 8 9 |
# File 'lib/source_license_sdk/license_validator.rb', line 7 def retry_after @retry_after end |
#success ⇒ Object (readonly)
Returns the value of attribute success.
7 8 9 |
# File 'lib/source_license_sdk/license_validator.rb', line 7 def success @success end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
7 8 9 |
# File 'lib/source_license_sdk/license_validator.rb', line 7 def @timestamp end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
7 8 9 |
# File 'lib/source_license_sdk/license_validator.rb', line 7 def token @token end |
#valid ⇒ Object (readonly)
Returns the value of attribute valid.
7 8 9 |
# File 'lib/source_license_sdk/license_validator.rb', line 7 def valid @valid end |
Instance Method Details
#expired? ⇒ Boolean
28 29 30 31 32 |
# File 'lib/source_license_sdk/license_validator.rb', line 28 def expired? return false unless @expires_at @expires_at < Time.now end |
#inspect ⇒ Object
55 56 57 |
# File 'lib/source_license_sdk/license_validator.rb', line 55 def inspect "#<#{self.class.name} valid=#{@valid} success=#{@success} error='#{@error_message}'>" end |
#rate_limited? ⇒ Boolean
34 35 36 37 |
# File 'lib/source_license_sdk/license_validator.rb', line 34 def rate_limited? @error_message&.downcase&.include?('rate limit') || @error_code == 'RATE_LIMIT_EXCEEDED' end |
#success? ⇒ Boolean
24 25 26 |
# File 'lib/source_license_sdk/license_validator.rb', line 24 def success? @success == true end |
#to_h ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/source_license_sdk/license_validator.rb', line 39 def to_h { valid: @valid, success: @success, error_message: @error_message, error_code: @error_code, expires_at: @expires_at, activations_remaining: @activations_remaining, retry_after: @retry_after, token: @token, timestamp: @timestamp, rate_limit_remaining: @rate_limit_remaining, rate_limit_reset_at: @rate_limit_reset_at, } end |
#valid? ⇒ Boolean
20 21 22 |
# File 'lib/source_license_sdk/license_validator.rb', line 20 def valid? @valid == true end |