Class: AdvancedBilling::SubscriptionGroupItem

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/advanced_billing/models/subscription_group_item.rb

Overview

SubscriptionGroupItem Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(id: SKIP, reference: SKIP, product_id: SKIP, product_handle: SKIP, product_price_point_id: SKIP, product_price_point_handle: SKIP, currency: SKIP, coupon_code: SKIP, total_revenue_in_cents: SKIP, balance_in_cents: SKIP, additional_properties: {}) ⇒ SubscriptionGroupItem

Returns a new instance of SubscriptionGroupItem.



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/advanced_billing/models/subscription_group_item.rb', line 93

def initialize(id: SKIP, reference: SKIP, product_id: SKIP,
               product_handle: SKIP, product_price_point_id: SKIP,
               product_price_point_handle: SKIP, currency: SKIP,
               coupon_code: SKIP, total_revenue_in_cents: SKIP,
               balance_in_cents: SKIP, additional_properties: {})
  @id = id unless id == SKIP
  @reference = reference unless reference == SKIP
  @product_id = product_id unless product_id == SKIP
  @product_handle = product_handle unless product_handle == SKIP
  @product_price_point_id = product_price_point_id unless product_price_point_id == SKIP
  unless product_price_point_handle == SKIP
    @product_price_point_handle =
      product_price_point_handle
  end
  @currency = currency unless currency == SKIP
  @coupon_code = coupon_code unless coupon_code == SKIP
  @total_revenue_in_cents = total_revenue_in_cents unless total_revenue_in_cents == SKIP
  @balance_in_cents = balance_in_cents unless balance_in_cents == SKIP

  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end
end

Instance Attribute Details

#balance_in_centsInteger

TODO: Write general description for this method

Returns:

  • (Integer)


50
51
52
# File 'lib/advanced_billing/models/subscription_group_item.rb', line 50

def balance_in_cents
  @balance_in_cents
end

#coupon_codeString

TODO: Write general description for this method

Returns:

  • (String)


42
43
44
# File 'lib/advanced_billing/models/subscription_group_item.rb', line 42

def coupon_code
  @coupon_code
end

#currencyString

TODO: Write general description for this method

Returns:

  • (String)


38
39
40
# File 'lib/advanced_billing/models/subscription_group_item.rb', line 38

def currency
  @currency
end

#idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


14
15
16
# File 'lib/advanced_billing/models/subscription_group_item.rb', line 14

def id
  @id
end

#product_handleString

TODO: Write general description for this method

Returns:

  • (String)


26
27
28
# File 'lib/advanced_billing/models/subscription_group_item.rb', line 26

def product_handle
  @product_handle
end

#product_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


22
23
24
# File 'lib/advanced_billing/models/subscription_group_item.rb', line 22

def product_id
  @product_id
end

#product_price_point_handleString

TODO: Write general description for this method

Returns:

  • (String)


34
35
36
# File 'lib/advanced_billing/models/subscription_group_item.rb', line 34

def product_price_point_handle
  @product_price_point_handle
end

#product_price_point_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


30
31
32
# File 'lib/advanced_billing/models/subscription_group_item.rb', line 30

def product_price_point_id
  @product_price_point_id
end

#referenceString

TODO: Write general description for this method

Returns:

  • (String)


18
19
20
# File 'lib/advanced_billing/models/subscription_group_item.rb', line 18

def reference
  @reference
end

#total_revenue_in_centsInteger

TODO: Write general description for this method

Returns:

  • (Integer)


46
47
48
# File 'lib/advanced_billing/models/subscription_group_item.rb', line 46

def total_revenue_in_cents
  @total_revenue_in_cents
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/advanced_billing/models/subscription_group_item.rb', line 119

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : SKIP
  reference = hash.key?('reference') ? hash['reference'] : SKIP
  product_id = hash.key?('product_id') ? hash['product_id'] : SKIP
  product_handle =
    hash.key?('product_handle') ? hash['product_handle'] : SKIP
  product_price_point_id =
    hash.key?('product_price_point_id') ? hash['product_price_point_id'] : SKIP
  product_price_point_handle =
    hash.key?('product_price_point_handle') ? hash['product_price_point_handle'] : SKIP
  currency = hash.key?('currency') ? hash['currency'] : SKIP
  coupon_code = hash.key?('coupon_code') ? hash['coupon_code'] : SKIP
  total_revenue_in_cents =
    hash.key?('total_revenue_in_cents') ? hash['total_revenue_in_cents'] : SKIP
  balance_in_cents =
    hash.key?('balance_in_cents') ? hash['balance_in_cents'] : SKIP

  # Clean out expected properties from Hash.
  names.each_value { |k| hash.delete(k) }

  # Create object from extracted values.
  SubscriptionGroupItem.new(id: id,
                            reference: reference,
                            product_id: product_id,
                            product_handle: product_handle,
                            product_price_point_id: product_price_point_id,
                            product_price_point_handle: product_price_point_handle,
                            currency: currency,
                            coupon_code: coupon_code,
                            total_revenue_in_cents: total_revenue_in_cents,
                            balance_in_cents: balance_in_cents,
                            additional_properties: hash)
end

.namesObject

A mapping from model property names to API property names.



53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/advanced_billing/models/subscription_group_item.rb', line 53

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['reference'] = 'reference'
  @_hash['product_id'] = 'product_id'
  @_hash['product_handle'] = 'product_handle'
  @_hash['product_price_point_id'] = 'product_price_point_id'
  @_hash['product_price_point_handle'] = 'product_price_point_handle'
  @_hash['currency'] = 'currency'
  @_hash['coupon_code'] = 'coupon_code'
  @_hash['total_revenue_in_cents'] = 'total_revenue_in_cents'
  @_hash['balance_in_cents'] = 'balance_in_cents'
  @_hash
end

.nullablesObject

An array for nullable fields



85
86
87
88
89
90
91
# File 'lib/advanced_billing/models/subscription_group_item.rb', line 85

def self.nullables
  %w[
    reference
    product_handle
    coupon_code
  ]
end

.optionalsObject

An array for optional fields



69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/advanced_billing/models/subscription_group_item.rb', line 69

def self.optionals
  %w[
    id
    reference
    product_id
    product_handle
    product_price_point_id
    product_price_point_handle
    currency
    coupon_code
    total_revenue_in_cents
    balance_in_cents
  ]
end