Class: AdvancedBilling::CouponUsage
- Defined in:
- lib/advanced_billing/models/coupon_usage.rb
Overview
CouponUsage Model.
Instance Attribute Summary collapse
-
#id ⇒ Integer
The Chargify id of the product.
-
#name ⇒ String
Name of the product.
-
#revenue ⇒ Integer
Total revenue of the all subscriptions that have received a discount from this coupon.
-
#revenue_in_cents ⇒ Integer
Total revenue of the all subscriptions that have received a discount from this coupon.
-
#savings ⇒ Integer
Dollar amount of customer savings as a result of the coupon.
-
#savings_in_cents ⇒ Integer
Dollar amount of customer savings as a result of the coupon.
-
#signups ⇒ Integer
Number of times the coupon has been applied.
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(id = SKIP, name = SKIP, signups = SKIP, savings = SKIP, savings_in_cents = SKIP, revenue = SKIP, revenue_in_cents = SKIP) ⇒ CouponUsage
constructor
A new instance of CouponUsage.
Methods inherited from BaseModel
Constructor Details
#initialize(id = SKIP, name = SKIP, signups = SKIP, savings = SKIP, savings_in_cents = SKIP, revenue = SKIP, revenue_in_cents = SKIP) ⇒ CouponUsage
Returns a new instance of CouponUsage.
77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/advanced_billing/models/coupon_usage.rb', line 77 def initialize(id = SKIP, name = SKIP, signups = SKIP, savings = SKIP, savings_in_cents = SKIP, revenue = SKIP, revenue_in_cents = SKIP) @id = id unless id == SKIP @name = name unless name == SKIP @signups = signups unless signups == SKIP @savings = savings unless savings == SKIP @savings_in_cents = savings_in_cents unless savings_in_cents == SKIP @revenue = revenue unless revenue == SKIP @revenue_in_cents = revenue_in_cents unless revenue_in_cents == SKIP end |
Instance Attribute Details
#id ⇒ Integer
The Chargify id of the product
14 15 16 |
# File 'lib/advanced_billing/models/coupon_usage.rb', line 14 def id @id end |
#name ⇒ String
Name of the product
18 19 20 |
# File 'lib/advanced_billing/models/coupon_usage.rb', line 18 def name @name end |
#revenue ⇒ Integer
Total revenue of the all subscriptions that have received a discount from this coupon.
35 36 37 |
# File 'lib/advanced_billing/models/coupon_usage.rb', line 35 def revenue @revenue end |
#revenue_in_cents ⇒ Integer
Total revenue of the all subscriptions that have received a discount from this coupon.
40 41 42 |
# File 'lib/advanced_billing/models/coupon_usage.rb', line 40 def revenue_in_cents @revenue_in_cents end |
#savings ⇒ Integer
Dollar amount of customer savings as a result of the coupon.
26 27 28 |
# File 'lib/advanced_billing/models/coupon_usage.rb', line 26 def savings @savings end |
#savings_in_cents ⇒ Integer
Dollar amount of customer savings as a result of the coupon.
30 31 32 |
# File 'lib/advanced_billing/models/coupon_usage.rb', line 30 def savings_in_cents @savings_in_cents end |
#signups ⇒ Integer
Number of times the coupon has been applied
22 23 24 |
# File 'lib/advanced_billing/models/coupon_usage.rb', line 22 def signups @signups end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/advanced_billing/models/coupon_usage.rb', line 90 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash.key?('id') ? hash['id'] : SKIP name = hash.key?('name') ? hash['name'] : SKIP signups = hash.key?('signups') ? hash['signups'] : SKIP savings = hash.key?('savings') ? hash['savings'] : SKIP savings_in_cents = hash.key?('savings_in_cents') ? hash['savings_in_cents'] : SKIP revenue = hash.key?('revenue') ? hash['revenue'] : SKIP revenue_in_cents = hash.key?('revenue_in_cents') ? hash['revenue_in_cents'] : SKIP # Create object from extracted values. CouponUsage.new(id, name, signups, savings, savings_in_cents, revenue, revenue_in_cents) end |
.names ⇒ Object
A mapping from model property names to API property names.
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/advanced_billing/models/coupon_usage.rb', line 43 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['name'] = 'name' @_hash['signups'] = 'signups' @_hash['savings'] = 'savings' @_hash['savings_in_cents'] = 'savings_in_cents' @_hash['revenue'] = 'revenue' @_hash['revenue_in_cents'] = 'revenue_in_cents' @_hash end |
.nullables ⇒ Object
An array for nullable fields
69 70 71 72 73 74 75 |
# File 'lib/advanced_billing/models/coupon_usage.rb', line 69 def self.nullables %w[ savings savings_in_cents revenue ] end |
.optionals ⇒ Object
An array for optional fields
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/advanced_billing/models/coupon_usage.rb', line 56 def self.optionals %w[ id name signups savings savings_in_cents revenue revenue_in_cents ] end |