Class: ShopsavvyDataApi::UsageInfo
- Inherits:
-
Object
- Object
- ShopsavvyDataApi::UsageInfo
- Defined in:
- lib/shopsavvy_data_api/models.rb
Overview
API usage information
Instance Attribute Summary collapse
-
#current_period ⇒ Object
readonly
Returns the value of attribute current_period.
-
#usage_percentage ⇒ Object
readonly
Returns the value of attribute usage_percentage.
Instance Method Summary collapse
-
#billing_period_end ⇒ Object
deprecated
Deprecated.
Use ‘current_period.end_date` instead
-
#billing_period_start ⇒ Object
deprecated
Deprecated.
Use ‘current_period.start_date` instead
- #credits_percentage_remaining ⇒ Object
- #credits_percentage_used ⇒ Object
-
#credits_remaining ⇒ Object
deprecated
Deprecated.
Use ‘current_period.credits_remaining` instead
-
#credits_total ⇒ Object
deprecated
Deprecated.
Use ‘current_period.credits_limit` instead
-
#credits_used ⇒ Object
deprecated
Deprecated.
Use ‘current_period.credits_used` instead
-
#initialize(data) ⇒ UsageInfo
constructor
A new instance of UsageInfo.
- #to_h ⇒ Object
Constructor Details
#initialize(data) ⇒ UsageInfo
Returns a new instance of UsageInfo.
318 319 320 321 |
# File 'lib/shopsavvy_data_api/models.rb', line 318 def initialize(data) @current_period = UsagePeriod.new(data["current_period"] || {}) @usage_percentage = data["usage_percentage"]&.to_f || 0 end |
Instance Attribute Details
#current_period ⇒ Object (readonly)
Returns the value of attribute current_period.
316 317 318 |
# File 'lib/shopsavvy_data_api/models.rb', line 316 def current_period @current_period end |
#usage_percentage ⇒ Object (readonly)
Returns the value of attribute usage_percentage.
316 317 318 |
# File 'lib/shopsavvy_data_api/models.rb', line 316 def usage_percentage @usage_percentage end |
Instance Method Details
#billing_period_end ⇒ Object
Deprecated.
Use ‘current_period.end_date` instead
344 345 346 |
# File 'lib/shopsavvy_data_api/models.rb', line 344 def billing_period_end current_period.end_date end |
#billing_period_start ⇒ Object
Deprecated.
Use ‘current_period.start_date` instead
339 340 341 |
# File 'lib/shopsavvy_data_api/models.rb', line 339 def billing_period_start current_period.start_date end |
#credits_percentage_remaining ⇒ Object
361 362 363 |
# File 'lib/shopsavvy_data_api/models.rb', line 361 def credits_percentage_remaining 100 - credits_percentage_used end |
#credits_percentage_used ⇒ Object
355 356 357 358 359 |
# File 'lib/shopsavvy_data_api/models.rb', line 355 def credits_percentage_used return 0 if current_period.credits_limit.zero? (current_period.credits_used.to_f / current_period.credits_limit * 100).round(2) end |
#credits_remaining ⇒ Object
Deprecated.
Use ‘current_period.credits_remaining` instead
329 330 331 |
# File 'lib/shopsavvy_data_api/models.rb', line 329 def credits_remaining current_period.credits_remaining end |
#credits_total ⇒ Object
Deprecated.
Use ‘current_period.credits_limit` instead
334 335 336 |
# File 'lib/shopsavvy_data_api/models.rb', line 334 def credits_total current_period.credits_limit end |
#credits_used ⇒ Object
Deprecated.
Use ‘current_period.credits_used` instead
324 325 326 |
# File 'lib/shopsavvy_data_api/models.rb', line 324 def credits_used current_period.credits_used end |
#to_h ⇒ Object
348 349 350 351 352 353 |
# File 'lib/shopsavvy_data_api/models.rb', line 348 def to_h { current_period: current_period.to_h, usage_percentage: usage_percentage } end |