Class: AdvancedBilling::AllocationPreviewLineItem

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

Overview

AllocationPreviewLineItem 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, direction: SKIP, additional_properties: {}) ⇒ AllocationPreviewLineItem

Returns a new instance of AllocationPreviewLineItem.



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

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, direction: 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
  @direction = direction unless direction == SKIP
end

Instance Attribute Details

#amount_in_centsInteger

A handle for the line item kind for allocation preview

Returns:

  • (Integer)


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

def amount_in_cents
  @amount_in_cents
end

#component_handleString

A handle for the line item kind for allocation preview

Returns:

  • (String)


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

def component_handle
  @component_handle
end

#component_idInteger

A handle for the line item kind for allocation preview

Returns:

  • (Integer)


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

def component_id
  @component_id
end

#directionAllocationPreviewDirection

Visible when using Fine-grained Component Control



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

def direction
  @direction
end

#discount_amount_in_centsInteger

A handle for the line item kind for allocation preview

Returns:

  • (Integer)


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

def discount_amount_in_cents
  @discount_amount_in_cents
end

#kindAllocationPreviewLineItemKind

A handle for the line item kind for allocation preview



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

def kind
  @kind
end

#memoString

A handle for the line item kind for allocation preview

Returns:

  • (String)


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

def memo
  @memo
end

#taxable_amount_in_centsInteger

A handle for the line item kind for allocation preview

Returns:

  • (Integer)


34
35
36
# File 'lib/advanced_billing/models/allocation_preview_line_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/allocation_preview_line_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.



105
106
107
108
109
110
111
112
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
# File 'lib/advanced_billing/models/allocation_preview_line_item.rb', line 105

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
  direction = hash.key?('direction') ? hash['direction'] : SKIP

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

  # Create object from extracted values.
  AllocationPreviewLineItem.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,
                                direction: direction,
                                additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/advanced_billing/models/allocation_preview_line_item.rb', line 49

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['direction'] = 'direction'
  @_hash
end

.nullablesObject

An array for nullable fields



79
80
81
# File 'lib/advanced_billing/models/allocation_preview_line_item.rb', line 79

def self.nullables
  []
end

.optionalsObject

An array for optional fields



64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/advanced_billing/models/allocation_preview_line_item.rb', line 64

def self.optionals
  %w[
    transaction_type
    kind
    amount_in_cents
    memo
    discount_amount_in_cents
    taxable_amount_in_cents
    component_id
    component_handle
    direction
  ]
end