Class: MistApi::ApiUsage

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/mist_api/models/api_usage.rb

Overview

ApiUsage Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(request_limit = 5000, requests = nil, seconds = SKIP) ⇒ ApiUsage

Returns a new instance of ApiUsage.



45
46
47
48
49
# File 'lib/mist_api/models/api_usage.rb', line 45

def initialize(request_limit = 5000, requests = nil, seconds = SKIP)
  @request_limit = request_limit
  @requests = requests
  @seconds = seconds unless seconds == SKIP
end

Instance Attribute Details

#request_limitInteger

max number of request permitted

Returns:

  • (Integer)


14
15
16
# File 'lib/mist_api/models/api_usage.rb', line 14

def request_limit
  @request_limit
end

#requestsInteger

num of request made in the current hour

Returns:

  • (Integer)


18
19
20
# File 'lib/mist_api/models/api_usage.rb', line 18

def requests
  @requests
end

#secondsFloat

num of request made in the current hour

Returns:

  • (Float)


22
23
24
# File 'lib/mist_api/models/api_usage.rb', line 22

def seconds
  @seconds
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/mist_api/models/api_usage.rb', line 52

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  request_limit = hash['request_limit'] ||= 5000
  requests = hash.key?('requests') ? hash['requests'] : nil
  seconds = hash.key?('seconds') ? hash['seconds'] : SKIP

  # Create object from extracted values.
  ApiUsage.new(request_limit,
               requests,
               seconds)
end

.namesObject

A mapping from model property names to API property names.



25
26
27
28
29
30
31
# File 'lib/mist_api/models/api_usage.rb', line 25

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['request_limit'] = 'request_limit'
  @_hash['requests'] = 'requests'
  @_hash['seconds'] = 'seconds'
  @_hash
end

.nullablesObject

An array for nullable fields



41
42
43
# File 'lib/mist_api/models/api_usage.rb', line 41

def self.nullables
  []
end

.optionalsObject

An array for optional fields



34
35
36
37
38
# File 'lib/mist_api/models/api_usage.rb', line 34

def self.optionals
  %w[
    seconds
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



74
75
76
77
78
# File 'lib/mist_api/models/api_usage.rb', line 74

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} request_limit: #{@request_limit.inspect}, requests: #{@requests.inspect},"\
  " seconds: #{@seconds.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



67
68
69
70
71
# File 'lib/mist_api/models/api_usage.rb', line 67

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} request_limit: #{@request_limit}, requests: #{@requests}, seconds:"\
  " #{@seconds}>"
end