Class: ShopsavvyDataApi::UsageInfo
- Inherits:
-
Object
- Object
- ShopsavvyDataApi::UsageInfo
- Defined in:
- lib/shopsavvy_data_api/models.rb
Overview
API usage information
Instance Attribute Summary collapse
-
#billing_period_end ⇒ Object
readonly
Returns the value of attribute billing_period_end.
-
#billing_period_start ⇒ Object
readonly
Returns the value of attribute billing_period_start.
-
#credits_remaining ⇒ Object
readonly
Returns the value of attribute credits_remaining.
-
#credits_total ⇒ Object
readonly
Returns the value of attribute credits_total.
-
#credits_used ⇒ Object
readonly
Returns the value of attribute credits_used.
-
#plan_name ⇒ Object
readonly
Returns the value of attribute plan_name.
Instance Method Summary collapse
- #credits_percentage_remaining ⇒ Object
- #credits_percentage_used ⇒ Object
-
#initialize(data) ⇒ UsageInfo
constructor
A new instance of UsageInfo.
- #to_h ⇒ Object
Constructor Details
#initialize(data) ⇒ UsageInfo
Returns a new instance of UsageInfo.
214 215 216 217 218 219 220 221 |
# File 'lib/shopsavvy_data_api/models.rb', line 214 def initialize(data) @credits_used = data["credits_used"].to_i @credits_remaining = data["credits_remaining"].to_i @credits_total = data["credits_total"].to_i @billing_period_start = data["billing_period_start"] @billing_period_end = data["billing_period_end"] @plan_name = data["plan_name"] end |
Instance Attribute Details
#billing_period_end ⇒ Object (readonly)
Returns the value of attribute billing_period_end.
211 212 213 |
# File 'lib/shopsavvy_data_api/models.rb', line 211 def billing_period_end @billing_period_end end |
#billing_period_start ⇒ Object (readonly)
Returns the value of attribute billing_period_start.
211 212 213 |
# File 'lib/shopsavvy_data_api/models.rb', line 211 def billing_period_start @billing_period_start end |
#credits_remaining ⇒ Object (readonly)
Returns the value of attribute credits_remaining.
211 212 213 |
# File 'lib/shopsavvy_data_api/models.rb', line 211 def credits_remaining @credits_remaining end |
#credits_total ⇒ Object (readonly)
Returns the value of attribute credits_total.
211 212 213 |
# File 'lib/shopsavvy_data_api/models.rb', line 211 def credits_total @credits_total end |
#credits_used ⇒ Object (readonly)
Returns the value of attribute credits_used.
211 212 213 |
# File 'lib/shopsavvy_data_api/models.rb', line 211 def credits_used @credits_used end |
#plan_name ⇒ Object (readonly)
Returns the value of attribute plan_name.
211 212 213 |
# File 'lib/shopsavvy_data_api/models.rb', line 211 def plan_name @plan_name end |
Instance Method Details
#credits_percentage_remaining ⇒ Object
240 241 242 |
# File 'lib/shopsavvy_data_api/models.rb', line 240 def credits_percentage_remaining 100 - credits_percentage_used end |
#credits_percentage_used ⇒ Object
234 235 236 237 238 |
# File 'lib/shopsavvy_data_api/models.rb', line 234 def credits_percentage_used return 0 if credits_total.zero? (credits_used.to_f / credits_total * 100).round(2) end |
#to_h ⇒ Object
223 224 225 226 227 228 229 230 231 232 |
# File 'lib/shopsavvy_data_api/models.rb', line 223 def to_h { credits_used: credits_used, credits_remaining: credits_remaining, credits_total: credits_total, billing_period_start: billing_period_start, billing_period_end: billing_period_end, plan_name: plan_name } end |