Class: AdvancedBilling::BillingManifestItem

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

Overview

BillingManifestItem Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(transaction_type: SKIP, kind: SKIP, amount_in_cents: SKIP, memo: SKIP, discount_amount_in_cents: SKIP, taxable_amount_in_cents: SKIP, component_id: SKIP, component_handle: SKIP, component_name: SKIP, product_id: SKIP, product_handle: SKIP, product_name: SKIP, period_range_start: SKIP, period_range_end: SKIP, additional_properties: {}) ⇒ BillingManifestItem

Returns a new instance of BillingManifestItem.



113
114
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/billing_manifest_item.rb', line 113

def initialize(transaction_type: SKIP, kind: SKIP, amount_in_cents: SKIP,
               memo: SKIP, discount_amount_in_cents: SKIP,
               taxable_amount_in_cents: SKIP, component_id: SKIP,
               component_handle: SKIP, component_name: SKIP,
               product_id: SKIP, product_handle: SKIP, product_name: SKIP,
               period_range_start: SKIP, period_range_end: SKIP,
               additional_properties: {})
  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end

  @transaction_type = transaction_type unless transaction_type == SKIP
  @kind = kind unless kind == SKIP
  @amount_in_cents = amount_in_cents unless amount_in_cents == SKIP
  @memo = memo unless memo == SKIP
  @discount_amount_in_cents = discount_amount_in_cents unless discount_amount_in_cents == SKIP
  @taxable_amount_in_cents = taxable_amount_in_cents unless taxable_amount_in_cents == SKIP
  @component_id = component_id unless component_id == SKIP
  @component_handle = component_handle unless component_handle == SKIP
  @component_name = component_name unless component_name == SKIP
  @product_id = product_id unless product_id == SKIP
  @product_handle = product_handle unless product_handle == SKIP
  @product_name = product_name unless product_name == SKIP
  @period_range_start = period_range_start unless period_range_start == SKIP
  @period_range_end = period_range_end unless period_range_end == SKIP
end

Instance Attribute Details

#amount_in_centsInteger

A handle for the billing manifest line item kind

Returns:

  • (Integer)


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

def amount_in_cents
  @amount_in_cents
end

#component_handleString

A handle for the billing manifest line item kind

Returns:

  • (String)


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

def component_handle
  @component_handle
end

#component_idInteger

A handle for the billing manifest line item kind

Returns:

  • (Integer)


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

def component_id
  @component_id
end

#component_nameString

A handle for the billing manifest line item kind

Returns:

  • (String)


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

def component_name
  @component_name
end

#discount_amount_in_centsInteger

A handle for the billing manifest line item kind

Returns:

  • (Integer)


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

def discount_amount_in_cents
  @discount_amount_in_cents
end

#kindBillingManifestLineItemKind

A handle for the billing manifest line item kind



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

def kind
  @kind
end

#memoString

A handle for the billing manifest line item kind

Returns:

  • (String)


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

def memo
  @memo
end

#period_range_endString

A handle for the billing manifest line item kind

Returns:

  • (String)


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

def period_range_end
  @period_range_end
end

#period_range_startString

A handle for the billing manifest line item kind

Returns:

  • (String)


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

def period_range_start
  @period_range_start
end

#product_handleString

A handle for the billing manifest line item kind

Returns:

  • (String)


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

def product_handle
  @product_handle
end

#product_idInteger

A handle for the billing manifest line item kind

Returns:

  • (Integer)


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

def product_id
  @product_id
end

#product_nameString

A handle for the billing manifest line item kind

Returns:

  • (String)


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

def product_name
  @product_name
end

#taxable_amount_in_centsInteger

A handle for the billing manifest line item kind

Returns:

  • (Integer)


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

def taxable_amount_in_cents
  @taxable_amount_in_cents
end

#transaction_typeLineItemTransactionType

A handle for the line item transaction type



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

def transaction_type
  @transaction_type
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
186
187
188
189
# File 'lib/advanced_billing/models/billing_manifest_item.rb', line 142

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  transaction_type =
    hash.key?('transaction_type') ? hash['transaction_type'] : SKIP
  kind = hash.key?('kind') ? hash['kind'] : SKIP
  amount_in_cents =
    hash.key?('amount_in_cents') ? hash['amount_in_cents'] : SKIP
  memo = hash.key?('memo') ? hash['memo'] : SKIP
  discount_amount_in_cents =
    hash.key?('discount_amount_in_cents') ? hash['discount_amount_in_cents'] : SKIP
  taxable_amount_in_cents =
    hash.key?('taxable_amount_in_cents') ? hash['taxable_amount_in_cents'] : SKIP
  component_id = hash.key?('component_id') ? hash['component_id'] : SKIP
  component_handle =
    hash.key?('component_handle') ? hash['component_handle'] : SKIP
  component_name =
    hash.key?('component_name') ? hash['component_name'] : SKIP
  product_id = hash.key?('product_id') ? hash['product_id'] : SKIP
  product_handle =
    hash.key?('product_handle') ? hash['product_handle'] : SKIP
  product_name = hash.key?('product_name') ? hash['product_name'] : 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

  # Clean out expected properties from Hash.
  additional_properties = hash.reject { |k, _| names.value?(k) }

  # Create object from extracted values.
  BillingManifestItem.new(transaction_type: transaction_type,
                          kind: kind,
                          amount_in_cents: amount_in_cents,
                          memo: memo,
                          discount_amount_in_cents: discount_amount_in_cents,
                          taxable_amount_in_cents: taxable_amount_in_cents,
                          component_id: component_id,
                          component_handle: component_handle,
                          component_name: component_name,
                          product_id: product_id,
                          product_handle: product_handle,
                          product_name: product_name,
                          period_range_start: period_range_start,
                          period_range_end: period_range_end,
                          additional_properties: additional_properties)
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/billing_manifest_item.rb', line 69

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['transaction_type'] = 'transaction_type'
  @_hash['kind'] = 'kind'
  @_hash['amount_in_cents'] = 'amount_in_cents'
  @_hash['memo'] = 'memo'
  @_hash['discount_amount_in_cents'] = 'discount_amount_in_cents'
  @_hash['taxable_amount_in_cents'] = 'taxable_amount_in_cents'
  @_hash['component_id'] = 'component_id'
  @_hash['component_handle'] = 'component_handle'
  @_hash['component_name'] = 'component_name'
  @_hash['product_id'] = 'product_id'
  @_hash['product_handle'] = 'product_handle'
  @_hash['product_name'] = 'product_name'
  @_hash['period_range_start'] = 'period_range_start'
  @_hash['period_range_end'] = 'period_range_end'
  @_hash
end

.nullablesObject

An array for nullable fields



109
110
111
# File 'lib/advanced_billing/models/billing_manifest_item.rb', line 109

def self.nullables
  []
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/billing_manifest_item.rb', line 89

def self.optionals
  %w[
    transaction_type
    kind
    amount_in_cents
    memo
    discount_amount_in_cents
    taxable_amount_in_cents
    component_id
    component_handle
    component_name
    product_id
    product_handle
    product_name
    period_range_start
    period_range_end
  ]
end