Class: AdvancedBilling::InvoiceLineItemEventData

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

Overview

InvoiceLineItemEventData Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(uid: SKIP, title: SKIP, description: SKIP, quantity: SKIP, quantity_delta: SKIP, unit_price: SKIP, period_range_start: SKIP, period_range_end: SKIP, amount: SKIP, line_references: SKIP, pricing_details_index: SKIP, pricing_details: SKIP, tax_code: SKIP, tax_amount: SKIP, product_id: SKIP, product_price_point_id: SKIP, price_point_id: SKIP, component_id: SKIP, billing_schedule_item_id: SKIP, custom_item: SKIP, additional_properties: {}) ⇒ InvoiceLineItemEventData

Returns a new instance of InvoiceLineItemEventData.



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
186
187
188
189
190
191
192
# File 'lib/advanced_billing/models/invoice_line_item_event_data.rb', line 158

def initialize(uid: SKIP, title: SKIP, description: SKIP, quantity: SKIP,
               quantity_delta: SKIP, unit_price: SKIP,
               period_range_start: SKIP, period_range_end: SKIP,
               amount: SKIP, line_references: SKIP,
               pricing_details_index: SKIP, pricing_details: SKIP,
               tax_code: SKIP, tax_amount: SKIP, product_id: SKIP,
               product_price_point_id: SKIP, price_point_id: SKIP,
               component_id: SKIP, billing_schedule_item_id: SKIP,
               custom_item: SKIP, additional_properties: {})
  @uid = uid unless uid == SKIP
  @title = title unless title == SKIP
  @description = description unless description == SKIP
  @quantity = quantity unless quantity == SKIP
  @quantity_delta = quantity_delta unless quantity_delta == SKIP
  @unit_price = unit_price unless unit_price == SKIP
  @period_range_start = period_range_start unless period_range_start == SKIP
  @period_range_end = period_range_end unless period_range_end == SKIP
  @amount = amount unless amount == SKIP
  @line_references = line_references unless line_references == SKIP
  @pricing_details_index = pricing_details_index unless pricing_details_index == SKIP
  @pricing_details = pricing_details unless pricing_details == SKIP
  @tax_code = tax_code unless tax_code == SKIP
  @tax_amount = tax_amount unless tax_amount == SKIP
  @product_id = product_id unless product_id == SKIP
  @product_price_point_id = product_price_point_id unless product_price_point_id == SKIP
  @price_point_id = price_point_id unless price_point_id == SKIP
  @component_id = component_id unless component_id == SKIP
  @billing_schedule_item_id = billing_schedule_item_id unless billing_schedule_item_id == SKIP
  @custom_item = custom_item unless custom_item == SKIP

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

Instance Attribute Details

#amountString

TODO: Write general description for this method

Returns:

  • (String)


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

def amount
  @amount
end

#billing_schedule_item_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


86
87
88
# File 'lib/advanced_billing/models/invoice_line_item_event_data.rb', line 86

def billing_schedule_item_id
  @billing_schedule_item_id
end

#component_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


82
83
84
# File 'lib/advanced_billing/models/invoice_line_item_event_data.rb', line 82

def component_id
  @component_id
end

#custom_itemTrueClass | FalseClass

TODO: Write general description for this method

Returns:

  • (TrueClass | FalseClass)


90
91
92
# File 'lib/advanced_billing/models/invoice_line_item_event_data.rb', line 90

def custom_item
  @custom_item
end

#descriptionString

TODO: Write general description for this method

Returns:

  • (String)


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

def description
  @description
end

#line_referencesString

TODO: Write general description for this method

Returns:

  • (String)


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

def line_references
  @line_references
end

#period_range_endString

TODO: Write general description for this method

Returns:

  • (String)


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

def period_range_end
  @period_range_end
end

#period_range_startString

TODO: Write general description for this method

Returns:

  • (String)


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

def period_range_start
  @period_range_start
end

#price_point_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


78
79
80
# File 'lib/advanced_billing/models/invoice_line_item_event_data.rb', line 78

def price_point_id
  @price_point_id
end

#pricing_detailsArray[InvoiceLineItemPricingDetail]

TODO: Write general description for this method

Returns:



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

def pricing_details
  @pricing_details
end

#pricing_details_indexInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def pricing_details_index
  @pricing_details_index
end

#product_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


70
71
72
# File 'lib/advanced_billing/models/invoice_line_item_event_data.rb', line 70

def product_id
  @product_id
end

#product_price_point_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


74
75
76
# File 'lib/advanced_billing/models/invoice_line_item_event_data.rb', line 74

def product_price_point_id
  @product_price_point_id
end

#quantityInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def quantity
  @quantity
end

#quantity_deltaInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def quantity_delta
  @quantity_delta
end

#tax_amountString

TODO: Write general description for this method

Returns:

  • (String)


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

def tax_amount
  @tax_amount
end

#tax_codeString

TODO: Write general description for this method

Returns:

  • (String)


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

def tax_code
  @tax_code
end

#titleString

TODO: Write general description for this method

Returns:

  • (String)


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

def title
  @title
end

#uidString

TODO: Write general description for this method

Returns:

  • (String)


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

def uid
  @uid
end

#unit_priceString

TODO: Write general description for this method

Returns:

  • (String)


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

def unit_price
  @unit_price
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
# File 'lib/advanced_billing/models/invoice_line_item_event_data.rb', line 195

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  uid = hash.key?('uid') ? hash['uid'] : SKIP
  title = hash.key?('title') ? hash['title'] : SKIP
  description = hash.key?('description') ? hash['description'] : SKIP
  quantity = hash.key?('quantity') ? hash['quantity'] : SKIP
  quantity_delta =
    hash.key?('quantity_delta') ? hash['quantity_delta'] : SKIP
  unit_price = hash.key?('unit_price') ? hash['unit_price'] : SKIP
  period_range_start =
    hash.key?('period_range_start') ? hash['period_range_start'] : SKIP
  period_range_end =
    hash.key?('period_range_end') ? hash['period_range_end'] : SKIP
  amount = hash.key?('amount') ? hash['amount'] : SKIP
  line_references =
    hash.key?('line_references') ? hash['line_references'] : SKIP
  pricing_details_index =
    hash.key?('pricing_details_index') ? hash['pricing_details_index'] : SKIP
  # Parameter is an array, so we need to iterate through it
  pricing_details = nil
  unless hash['pricing_details'].nil?
    pricing_details = []
    hash['pricing_details'].each do |structure|
      pricing_details << (InvoiceLineItemPricingDetail.from_hash(structure) if structure)
    end
  end

  pricing_details = SKIP unless hash.key?('pricing_details')
  tax_code = hash.key?('tax_code') ? hash['tax_code'] : SKIP
  tax_amount = hash.key?('tax_amount') ? hash['tax_amount'] : SKIP
  product_id = hash.key?('product_id') ? hash['product_id'] : SKIP
  product_price_point_id =
    hash.key?('product_price_point_id') ? hash['product_price_point_id'] : SKIP
  price_point_id =
    hash.key?('price_point_id') ? hash['price_point_id'] : SKIP
  component_id = hash.key?('component_id') ? hash['component_id'] : SKIP
  billing_schedule_item_id =
    hash.key?('billing_schedule_item_id') ? hash['billing_schedule_item_id'] : SKIP
  custom_item = hash.key?('custom_item') ? hash['custom_item'] : SKIP

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

  # Create object from extracted values.
  InvoiceLineItemEventData.new(uid: uid,
                               title: title,
                               description: description,
                               quantity: quantity,
                               quantity_delta: quantity_delta,
                               unit_price: unit_price,
                               period_range_start: period_range_start,
                               period_range_end: period_range_end,
                               amount: amount,
                               line_references: line_references,
                               pricing_details_index: pricing_details_index,
                               pricing_details: pricing_details,
                               tax_code: tax_code,
                               tax_amount: tax_amount,
                               product_id: product_id,
                               product_price_point_id: product_price_point_id,
                               price_point_id: price_point_id,
                               component_id: component_id,
                               billing_schedule_item_id: billing_schedule_item_id,
                               custom_item: custom_item,
                               additional_properties: hash)
end

.namesObject

A mapping from model property names to API property names.



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/invoice_line_item_event_data.rb', line 93

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['uid'] = 'uid'
  @_hash['title'] = 'title'
  @_hash['description'] = 'description'
  @_hash['quantity'] = 'quantity'
  @_hash['quantity_delta'] = 'quantity_delta'
  @_hash['unit_price'] = 'unit_price'
  @_hash['period_range_start'] = 'period_range_start'
  @_hash['period_range_end'] = 'period_range_end'
  @_hash['amount'] = 'amount'
  @_hash['line_references'] = 'line_references'
  @_hash['pricing_details_index'] = 'pricing_details_index'
  @_hash['pricing_details'] = 'pricing_details'
  @_hash['tax_code'] = 'tax_code'
  @_hash['tax_amount'] = 'tax_amount'
  @_hash['product_id'] = 'product_id'
  @_hash['product_price_point_id'] = 'product_price_point_id'
  @_hash['price_point_id'] = 'price_point_id'
  @_hash['component_id'] = 'component_id'
  @_hash['billing_schedule_item_id'] = 'billing_schedule_item_id'
  @_hash['custom_item'] = 'custom_item'
  @_hash
end

.nullablesObject

An array for nullable fields



145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/advanced_billing/models/invoice_line_item_event_data.rb', line 145

def self.nullables
  %w[
    quantity_delta
    pricing_details_index
    tax_code
    product_price_point_id
    price_point_id
    component_id
    billing_schedule_item_id
    custom_item
  ]
end

.optionalsObject

An array for optional fields



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/advanced_billing/models/invoice_line_item_event_data.rb', line 119

def self.optionals
  %w[
    uid
    title
    description
    quantity
    quantity_delta
    unit_price
    period_range_start
    period_range_end
    amount
    line_references
    pricing_details_index
    pricing_details
    tax_code
    tax_amount
    product_id
    product_price_point_id
    price_point_id
    component_id
    billing_schedule_item_id
    custom_item
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



266
267
268
269
270
271
272
# File 'lib/advanced_billing/models/invoice_line_item_event_data.rb', line 266

def self.validate(value)
  return true if value.instance_of? self

  return false unless value.instance_of? Hash

  true
end