Exception: Whatsapp::RateLimited
- Defined in:
- lib/whatsapp/errors.rb
Overview
Raised when a rate limit threshold is exceeded.
Instance Attribute Summary collapse
-
#current ⇒ Integer
readonly
Current message count.
-
#limit ⇒ Integer
readonly
Maximum allowed messages in the period.
-
#period ⇒ Symbol
readonly
The rate limit window (:minute, :hour, :day, :bridge).
-
#recipient ⇒ String?
readonly
Specific recipient if per-recipient limit.
Instance Method Summary collapse
-
#initialize(period:, limit:, current:, recipient: nil) ⇒ RateLimited
constructor
A new instance of RateLimited.
Constructor Details
#initialize(period:, limit:, current:, recipient: nil) ⇒ RateLimited
Returns a new instance of RateLimited.
89 90 91 92 93 94 95 96 97 |
# File 'lib/whatsapp/errors.rb', line 89 def initialize(period:, limit:, current:, recipient: nil) @period = period @limit = limit @current = current @recipient = recipient target = recipient ? "to #{recipient} " : "" super("Rate limited: #{current}/#{limit} messages #{target}per #{period}") end |
Instance Attribute Details
#current ⇒ Integer (readonly)
Returns current message count.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/whatsapp/errors.rb', line 82 class RateLimited < Error attr_reader :period, :limit, :current, :recipient # @param period [Symbol] the rate limit window # @param limit [Integer] maximum messages in period # @param current [Integer] current message count # @param recipient [String, nil] recipient phone number def initialize(period:, limit:, current:, recipient: nil) @period = period @limit = limit @current = current @recipient = recipient target = recipient ? "to #{recipient} " : "" super("Rate limited: #{current}/#{limit} messages #{target}per #{period}") end end |
#limit ⇒ Integer (readonly)
Returns maximum allowed messages in the period.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/whatsapp/errors.rb', line 82 class RateLimited < Error attr_reader :period, :limit, :current, :recipient # @param period [Symbol] the rate limit window # @param limit [Integer] maximum messages in period # @param current [Integer] current message count # @param recipient [String, nil] recipient phone number def initialize(period:, limit:, current:, recipient: nil) @period = period @limit = limit @current = current @recipient = recipient target = recipient ? "to #{recipient} " : "" super("Rate limited: #{current}/#{limit} messages #{target}per #{period}") end end |
#period ⇒ Symbol (readonly)
Returns the rate limit window (:minute, :hour, :day, :bridge).
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/whatsapp/errors.rb', line 82 class RateLimited < Error attr_reader :period, :limit, :current, :recipient # @param period [Symbol] the rate limit window # @param limit [Integer] maximum messages in period # @param current [Integer] current message count # @param recipient [String, nil] recipient phone number def initialize(period:, limit:, current:, recipient: nil) @period = period @limit = limit @current = current @recipient = recipient target = recipient ? "to #{recipient} " : "" super("Rate limited: #{current}/#{limit} messages #{target}per #{period}") end end |
#recipient ⇒ String? (readonly)
Returns specific recipient if per-recipient limit.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/whatsapp/errors.rb', line 82 class RateLimited < Error attr_reader :period, :limit, :current, :recipient # @param period [Symbol] the rate limit window # @param limit [Integer] maximum messages in period # @param current [Integer] current message count # @param recipient [String, nil] recipient phone number def initialize(period:, limit:, current:, recipient: nil) @period = period @limit = limit @current = current @recipient = recipient target = recipient ? "to #{recipient} " : "" super("Rate limited: #{current}/#{limit} messages #{target}per #{period}") end end |