Class: AdvancedBilling::CreateInvoiceItem

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

Overview

CreateInvoiceItem Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(title: SKIP, quantity: SKIP, unit_price: SKIP, taxable: SKIP, tax_code: SKIP, period_range_start: SKIP, period_range_end: SKIP, product_id: SKIP, component_id: SKIP, price_point_id: SKIP, product_price_point_id: SKIP, description: SKIP, additional_properties: {}) ⇒ CreateInvoiceItem

Returns a new instance of CreateInvoiceItem.



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/advanced_billing/models/create_invoice_item.rb', line 109

def initialize(title: SKIP, quantity: SKIP, unit_price: SKIP, taxable: SKIP,
               tax_code: SKIP, period_range_start: SKIP,
               period_range_end: SKIP, product_id: SKIP, component_id: SKIP,
               price_point_id: SKIP, product_price_point_id: SKIP,
               description: SKIP, additional_properties: {})
  @title = title unless title == SKIP
  @quantity = quantity unless quantity == SKIP
  @unit_price = unit_price unless unit_price == SKIP
  @taxable = taxable unless taxable == SKIP
  @tax_code = tax_code unless tax_code == SKIP
  @period_range_start = period_range_start unless period_range_start == SKIP
  @period_range_end = period_range_end unless period_range_end == SKIP
  @product_id = product_id unless product_id == SKIP
  @component_id = component_id unless component_id == SKIP
  @price_point_id = price_point_id unless price_point_id == SKIP
  @product_price_point_id = product_price_point_id unless product_price_point_id == SKIP
  @description = description unless description == SKIP

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

Instance Attribute Details

#component_idObject

Component handle or component id.

Returns:

  • (Object)


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

def component_id
  @component_id
end

#descriptionString

Price point handle or id. For component.

Returns:

  • (String)


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

def description
  @description
end

#period_range_endString

YYYY-MM-DD

Returns:

  • (String)


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

def period_range_end
  @period_range_end
end

#period_range_startString

YYYY-MM-DD

Returns:

  • (String)


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

def period_range_start
  @period_range_start
end

#price_point_idObject

Price point handle or id. For component.

Returns:

  • (Object)


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

def price_point_id
  @price_point_id
end

#product_idObject

Product handle or product id.

Returns:

  • (Object)


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

def product_id
  @product_id
end

#product_price_point_idObject

Price point handle or id. For component.

Returns:

  • (Object)


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

def product_price_point_id
  @product_price_point_id
end

#quantityObject

The quantity can contain up to 8 decimal places. i.e. 1.00 or 0.0012 or 0.00000065. If you submit a value with more than 8 decimal places, we will round it down to the 8th decimal place.

Returns:

  • (Object)


20
21
22
# File 'lib/advanced_billing/models/create_invoice_item.rb', line 20

def quantity
  @quantity
end

#tax_codeString

Set to true to automatically calculate taxes. Site must be configured to use and calculate taxes. If using Avalara, a tax_code parameter must also be sent.

Returns:

  • (String)


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

def tax_code
  @tax_code
end

#taxableTrueClass | FalseClass

Set to true to automatically calculate taxes. Site must be configured to use and calculate taxes. If using Avalara, a tax_code parameter must also be sent.

Returns:

  • (TrueClass | FalseClass)


32
33
34
# File 'lib/advanced_billing/models/create_invoice_item.rb', line 32

def taxable
  @taxable
end

#titleString

TODO: Write general description for this method

Returns:

  • (String)


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

def title
  @title
end

#unit_priceObject

The unit_price can contain up to 8 decimal places. i.e. 1.00 or 0.0012 or 0.00000065. If you submit a value with more than 8 decimal places, we will round it down to the 8th decimal place.

Returns:

  • (Object)


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

def unit_price
  @unit_price
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



134
135
136
137
138
139
140
141
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
# File 'lib/advanced_billing/models/create_invoice_item.rb', line 134

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  title = hash.key?('title') ? hash['title'] : SKIP
  quantity = hash.key?('quantity') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:CreateInvoiceItemQuantity), hash['quantity']
  ) : SKIP
  unit_price = hash.key?('unit_price') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:CreateInvoiceItemUnitPrice), hash['unit_price']
  ) : SKIP
  taxable = hash.key?('taxable') ? hash['taxable'] : SKIP
  tax_code = hash.key?('tax_code') ? hash['tax_code'] : 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
  product_id = hash.key?('product_id') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:CreateInvoiceItemProductId), hash['product_id']
  ) : SKIP
  component_id = hash.key?('component_id') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:CreateInvoiceItemComponentId), hash['component_id']
  ) : SKIP
  price_point_id = hash.key?('price_point_id') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:CreateInvoiceItemPricePointId), hash['price_point_id']
  ) : SKIP
  product_price_point_id = hash.key?('product_price_point_id') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:CreateInvoiceItemProductPricePointId), hash['product_price_point_id']
  ) : SKIP
  description = hash.key?('description') ? hash['description'] : SKIP

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

  # Create object from extracted values.
  CreateInvoiceItem.new(title: title,
                        quantity: quantity,
                        unit_price: unit_price,
                        taxable: taxable,
                        tax_code: tax_code,
                        period_range_start: period_range_start,
                        period_range_end: period_range_end,
                        product_id: product_id,
                        component_id: component_id,
                        price_point_id: price_point_id,
                        product_price_point_id: product_price_point_id,
                        description: description,
                        additional_properties: hash)
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
# File 'lib/advanced_billing/models/create_invoice_item.rb', line 69

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['title'] = 'title'
  @_hash['quantity'] = 'quantity'
  @_hash['unit_price'] = 'unit_price'
  @_hash['taxable'] = 'taxable'
  @_hash['tax_code'] = 'tax_code'
  @_hash['period_range_start'] = 'period_range_start'
  @_hash['period_range_end'] = 'period_range_end'
  @_hash['product_id'] = 'product_id'
  @_hash['component_id'] = 'component_id'
  @_hash['price_point_id'] = 'price_point_id'
  @_hash['product_price_point_id'] = 'product_price_point_id'
  @_hash['description'] = 'description'
  @_hash
end

.nullablesObject

An array for nullable fields



105
106
107
# File 'lib/advanced_billing/models/create_invoice_item.rb', line 105

def self.nullables
  []
end

.optionalsObject

An array for optional fields



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/advanced_billing/models/create_invoice_item.rb', line 87

def self.optionals
  %w[
    title
    quantity
    unit_price
    taxable
    tax_code
    period_range_start
    period_range_end
    product_id
    component_id
    price_point_id
    product_price_point_id
    description
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



186
187
188
189
190
191
192
# File 'lib/advanced_billing/models/create_invoice_item.rb', line 186

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

  return false unless value.instance_of? Hash

  true
end