Class: MistApi::ApiUsage
- Defined in:
- lib/mist_api/models/api_usage.rb
Overview
ApiUsage Model.
Instance Attribute Summary collapse
-
#request_limit ⇒ Integer
max number of request permitted.
-
#requests ⇒ Integer
num of request made in the current hour.
-
#seconds ⇒ Float
num of request made in the current hour.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(request_limit = 5000, requests = nil, seconds = SKIP) ⇒ ApiUsage
constructor
A new instance of ApiUsage.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
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_limit ⇒ Integer
max number of request permitted
14 15 16 |
# File 'lib/mist_api/models/api_usage.rb', line 14 def request_limit @request_limit end |
#requests ⇒ Integer
num of request made in the current hour
18 19 20 |
# File 'lib/mist_api/models/api_usage.rb', line 18 def requests @requests end |
#seconds ⇒ Float
num of request made in the current hour
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 |
.names ⇒ Object
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 |
.nullables ⇒ Object
An array for nullable fields
41 42 43 |
# File 'lib/mist_api/models/api_usage.rb', line 41 def self.nullables [] end |
.optionals ⇒ Object
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
#inspect ⇒ Object
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_s ⇒ Object
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 |