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.



7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
# File 'lib/models/porcelain.rb', line 7572

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

#bucketObject

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



7563
7564
7565
# File 'lib/models/porcelain.rb', line 7563

def bucket
  @bucket
end

#limitObject

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



7566
7567
7568
# File 'lib/models/porcelain.rb', line 7566

def limit
  @limit
end

#remainingObject

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



7568
7569
7570
# File 'lib/models/porcelain.rb', line 7568

def remaining
  @remaining
end

#reset_atObject

The time when remaining will be reset to limit.



7570
7571
7572
# File 'lib/models/porcelain.rb', line 7570

def reset_at
  @reset_at
end

Instance Method Details

#to_json(options = {}) ⇒ Object



7584
7585
7586
7587
7588
7589
7590
# File 'lib/models/porcelain.rb', line 7584

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