Class: AdvancedBilling::AllocationPreviewItem

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

Overview

AllocationPreviewItem Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(component_id = SKIP, subscription_id = SKIP, quantity = SKIP, previous_quantity = SKIP, memo = SKIP, timestamp = SKIP, proration_upgrade_scheme = SKIP, proration_downgrade_scheme = SKIP, accrue_charge = SKIP, upgrade_charge = SKIP, downgrade_credit = SKIP, price_point_id = SKIP, previous_price_point_id = SKIP, component_handle = SKIP) ⇒ AllocationPreviewItem



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/advanced_billing/models/allocation_preview_item.rb', line 115

def initialize(component_id = SKIP, subscription_id = SKIP, quantity = SKIP,
               previous_quantity = SKIP, memo = SKIP, timestamp = SKIP,
               proration_upgrade_scheme = SKIP,
               proration_downgrade_scheme = SKIP, accrue_charge = SKIP,
               upgrade_charge = SKIP, downgrade_credit = SKIP,
               price_point_id = SKIP, previous_price_point_id = SKIP,
               component_handle = SKIP)
  @component_id = component_id unless component_id == SKIP
  @subscription_id = subscription_id unless subscription_id == SKIP
  @quantity = quantity unless quantity == SKIP
  @previous_quantity = previous_quantity unless previous_quantity == SKIP
  @memo = memo unless memo == SKIP
  @timestamp = timestamp unless timestamp == SKIP
  @proration_upgrade_scheme = proration_upgrade_scheme unless proration_upgrade_scheme == SKIP
  unless proration_downgrade_scheme == SKIP
    @proration_downgrade_scheme =
      proration_downgrade_scheme
  end
  @accrue_charge = accrue_charge unless accrue_charge == SKIP
  @upgrade_charge = upgrade_charge unless upgrade_charge == SKIP
  @downgrade_credit = downgrade_credit unless downgrade_credit == SKIP
  @price_point_id = price_point_id unless price_point_id == SKIP
  @previous_price_point_id = previous_price_point_id unless previous_price_point_id == SKIP
  @component_handle = component_handle unless component_handle == SKIP
end

Instance Attribute Details

#accrue_chargeTrueClass | FalseClass

TODO: Write general description for this method



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

def accrue_charge
  @accrue_charge
end

#component_handleString

TODO: Write general description for this method



66
67
68
# File 'lib/advanced_billing/models/allocation_preview_item.rb', line 66

def component_handle
  @component_handle
end

#component_idInteger

TODO: Write general description for this method



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

def component_id
  @component_id
end

#downgrade_creditString

TODO: Write general description for this method



54
55
56
# File 'lib/advanced_billing/models/allocation_preview_item.rb', line 54

def downgrade_credit
  @downgrade_credit
end

#memoString

TODO: Write general description for this method



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

def memo
  @memo
end

#previous_price_point_idInteger

TODO: Write general description for this method



62
63
64
# File 'lib/advanced_billing/models/allocation_preview_item.rb', line 62

def previous_price_point_id
  @previous_price_point_id
end

#previous_quantityInteger

TODO: Write general description for this method



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

def previous_quantity
  @previous_quantity
end

#price_point_idInteger

TODO: Write general description for this method



58
59
60
# File 'lib/advanced_billing/models/allocation_preview_item.rb', line 58

def price_point_id
  @price_point_id
end

#proration_downgrade_schemeString

TODO: Write general description for this method



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

def proration_downgrade_scheme
  @proration_downgrade_scheme
end

#proration_upgrade_schemeString

TODO: Write general description for this method



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

def proration_upgrade_scheme
  @proration_upgrade_scheme
end

#quantityFloat

TODO: Write general description for this method



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

def quantity
  @quantity
end

#subscription_idInteger

TODO: Write general description for this method



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

def subscription_id
  @subscription_id
end

#timestampString

TODO: Write general description for this method



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

def timestamp
  @timestamp
end

#upgrade_chargeString

TODO: Write general description for this method



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

def upgrade_charge
  @upgrade_charge
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/advanced_billing/models/allocation_preview_item.rb', line 142

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  component_id = hash.key?('component_id') ? hash['component_id'] : SKIP
  subscription_id =
    hash.key?('subscription_id') ? hash['subscription_id'] : SKIP
  quantity = hash.key?('quantity') ? hash['quantity'] : SKIP
  previous_quantity =
    hash.key?('previous_quantity') ? hash['previous_quantity'] : SKIP
  memo = hash.key?('memo') ? hash['memo'] : SKIP
  timestamp = hash.key?('timestamp') ? hash['timestamp'] : SKIP
  proration_upgrade_scheme =
    hash.key?('proration_upgrade_scheme') ? hash['proration_upgrade_scheme'] : SKIP
  proration_downgrade_scheme =
    hash.key?('proration_downgrade_scheme') ? hash['proration_downgrade_scheme'] : SKIP
  accrue_charge = hash.key?('accrue_charge') ? hash['accrue_charge'] : SKIP
  upgrade_charge =
    hash.key?('upgrade_charge') ? hash['upgrade_charge'] : SKIP
  downgrade_credit =
    hash.key?('downgrade_credit') ? hash['downgrade_credit'] : SKIP
  price_point_id =
    hash.key?('price_point_id') ? hash['price_point_id'] : SKIP
  previous_price_point_id =
    hash.key?('previous_price_point_id') ? hash['previous_price_point_id'] : SKIP
  component_handle =
    hash.key?('component_handle') ? hash['component_handle'] : SKIP

  # Create object from extracted values.
  AllocationPreviewItem.new(component_id,
                            subscription_id,
                            quantity,
                            previous_quantity,
                            memo,
                            timestamp,
                            proration_upgrade_scheme,
                            proration_downgrade_scheme,
                            accrue_charge,
                            upgrade_charge,
                            downgrade_credit,
                            price_point_id,
                            previous_price_point_id,
                            component_handle)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['component_id'] = 'component_id'
  @_hash['subscription_id'] = 'subscription_id'
  @_hash['quantity'] = 'quantity'
  @_hash['previous_quantity'] = 'previous_quantity'
  @_hash['memo'] = 'memo'
  @_hash['timestamp'] = 'timestamp'
  @_hash['proration_upgrade_scheme'] = 'proration_upgrade_scheme'
  @_hash['proration_downgrade_scheme'] = 'proration_downgrade_scheme'
  @_hash['accrue_charge'] = 'accrue_charge'
  @_hash['upgrade_charge'] = 'upgrade_charge'
  @_hash['downgrade_credit'] = 'downgrade_credit'
  @_hash['price_point_id'] = 'price_point_id'
  @_hash['previous_price_point_id'] = 'previous_price_point_id'
  @_hash['component_handle'] = 'component_handle'
  @_hash
end

.nullablesObject

An array for nullable fields



109
110
111
112
113
# File 'lib/advanced_billing/models/allocation_preview_item.rb', line 109

def self.nullables
  %w[
    timestamp
  ]
end

.optionalsObject

An array for optional fields



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/advanced_billing/models/allocation_preview_item.rb', line 89

def self.optionals
  %w[
    component_id
    subscription_id
    quantity
    previous_quantity
    memo
    timestamp
    proration_upgrade_scheme
    proration_downgrade_scheme
    accrue_charge
    upgrade_charge
    downgrade_credit
    price_point_id
    previous_price_point_id
    component_handle
  ]
end