Class: SDM::RateLimitMetadata

Inherits:
Object
  • Object
show all
Defined in:
lib/models/porcelain.rb

Overview

RateLimitMetadata contains information about remaining requests avaialable to the user over some timeframe.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bucket: nil, limit: nil, remaining: nil, reset_at: nil) ⇒ RateLimitMetadata

Returns a new instance of RateLimitMetadata.



15041
15042
15043
15044
15045
15046
15047
15048
15049
15050
15051
# File 'lib/models/porcelain.rb', line 15041

def initialize(
  bucket: nil,
  limit: nil,
  remaining: nil,
  reset_at: nil
)
  @bucket = bucket == nil ? "" : bucket
  @limit = limit == nil ? 0 : limit
  @remaining = remaining == nil ? 0 : remaining
  @reset_at = reset_at == nil ? nil : reset_at
end

Instance Attribute Details

#bucket ⇒ Object

The bucket this user/token is associated with, which may be shared between multiple users/tokens.



15032
15033
15034
# File 'lib/models/porcelain.rb', line 15032

def bucket
  @bucket
end

#limit ⇒ Object

How many total requests the user/token is authorized to make before being rate limited.



15035
15036
15037
# File 'lib/models/porcelain.rb', line 15035

def limit
  @limit
end

#remaining ⇒ Object

How many remaining requests out of the limit are still avaialable.



15037
15038
15039
# File 'lib/models/porcelain.rb', line 15037

def remaining
  @remaining
end

#reset_at ⇒ Object

The time when remaining will be reset to limit.



15039
15040
15041
# File 'lib/models/porcelain.rb', line 15039

def reset_at
  @reset_at
end

Instance Method Details

#to_json(options = {}) ⇒ Object



15053
15054
15055
15056
15057
15058
15059
# File 'lib/models/porcelain.rb', line 15053

def to_json(options = {})
  hash = {}
  self.instance_variables.each do |var|
    hash[var.id2name.delete_prefix("@")] = self.instance_variable_get var
  end
  hash.to_json
end