Exception: Improvmx::RateLimitError

Inherits:
CommunicationError show all
Defined in:
lib/improvmx/exceptions/exceptions.rb

Instance Attribute Summary collapse

Attributes inherited from CommunicationError

#code

Attributes inherited from Error

#object

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, response = nil) ⇒ RateLimitError

Returns a new instance of RateLimitError.



52
53
54
55
56
57
# File 'lib/improvmx/exceptions/exceptions.rb', line 52

def initialize(message = nil, response = nil)
  super(message, response)

  reset_at = response&.headers[:x_ratelimit_reset] || Time.now.to_i
  @wait_seconds = reset_at.to_i - Time.now.to_i
end

Instance Attribute Details

#wait_secondsObject (readonly)

Returns the value of attribute wait_seconds.



50
51
52
# File 'lib/improvmx/exceptions/exceptions.rb', line 50

def wait_seconds
  @wait_seconds
end