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



11767
11768
11769
11770
11771
11772
11773
11774
11775
11776
11777
# File 'lib/models/porcelain.rb', line 11767

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.



11758
11759
11760
# File 'lib/models/porcelain.rb', line 11758

def bucket
  @bucket
end

#limitObject

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



11761
11762
11763
# File 'lib/models/porcelain.rb', line 11761

def limit
  @limit
end

#remainingObject

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



11763
11764
11765
# File 'lib/models/porcelain.rb', line 11763

def remaining
  @remaining
end

#reset_atObject

The time when remaining will be reset to limit.



11765
11766
11767
# File 'lib/models/porcelain.rb', line 11765

def reset_at
  @reset_at
end

Instance Method Details

#to_json(options = {}) ⇒ Object



11779
11780
11781
11782
11783
11784
11785
# File 'lib/models/porcelain.rb', line 11779

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