Class: SourceLicenseSDK::LicenseValidationResult

Inherits:
Object
  • Object
show all
Defined in:
lib/source_license_sdk/license_validator.rb

Overview

Represents the result of a license validation or activation request

Instance Attribute Summary collapse

Instance Method Summary collapse

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_remainingObject (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_codeObject (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_messageObject (readonly)

Returns the value of attribute error_message.



7
8
9
# File 'lib/source_license_sdk/license_validator.rb', line 7

def error_message
  @error_message
end

#expires_atObject (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_remainingObject (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_atObject (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_afterObject (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

#successObject (readonly)

Returns the value of attribute success.



7
8
9
# File 'lib/source_license_sdk/license_validator.rb', line 7

def success
  @success
end

#timestampObject (readonly)

Returns the value of attribute timestamp.



7
8
9
# File 'lib/source_license_sdk/license_validator.rb', line 7

def timestamp
  @timestamp
end

#tokenObject (readonly)

Returns the value of attribute token.



7
8
9
# File 'lib/source_license_sdk/license_validator.rb', line 7

def token
  @token
end

#validObject (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

Returns:

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

#inspectObject



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

Returns:

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

Returns:

  • (Boolean)


24
25
26
# File 'lib/source_license_sdk/license_validator.rb', line 24

def success?
  @success == true
end

#to_hObject



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

Returns:

  • (Boolean)


20
21
22
# File 'lib/source_license_sdk/license_validator.rb', line 20

def valid?
  @valid == true
end