Class: AdvancedBilling::RenewalPreviewLineItem

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

Overview

RenewalPreviewLineItem Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#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, product_id = SKIP, product_name = SKIP, component_id = SKIP, component_handle = SKIP, component_name = SKIP, product_handle = SKIP) ⇒ RenewalPreviewLineItem

Returns a new instance of RenewalPreviewLineItem.



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/advanced_billing/models/renewal_preview_line_item.rb', line 101

def initialize(transaction_type = SKIP, kind = SKIP, amount_in_cents = SKIP,
               memo = SKIP, discount_amount_in_cents = SKIP,
               taxable_amount_in_cents = SKIP, product_id = SKIP,
               product_name = SKIP, component_id = SKIP,
               component_handle = SKIP, component_name = SKIP,
               product_handle = SKIP)
  @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
  @product_id = product_id unless product_id == SKIP
  @product_name = product_name unless product_name == 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_handle = product_handle unless product_handle == SKIP
end

Instance Attribute Details

#amount_in_centsInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def amount_in_cents
  @amount_in_cents
end

#component_handleString

TODO: Write general description for this method

Returns:

  • (String)


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

def component_handle
  @component_handle
end

#component_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def component_id
  @component_id
end

#component_nameString

TODO: Write general description for this method

Returns:

  • (String)


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

def component_name
  @component_name
end

#discount_amount_in_centsInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def discount_amount_in_cents
  @discount_amount_in_cents
end

#kindString

TODO: Write general description for this method

Returns:

  • (String)


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

def kind
  @kind
end

#memoString

TODO: Write general description for this method

Returns:

  • (String)


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

def memo
  @memo
end

#product_handleString

TODO: Write general description for this method

Returns:

  • (String)


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

def product_handle
  @product_handle
end

#product_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def product_id
  @product_id
end

#product_nameString

TODO: Write general description for this method

Returns:

  • (String)


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

def product_name
  @product_name
end

#taxable_amount_in_centsInteger

TODO: Write general description for this method

Returns:

  • (Integer)


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

def taxable_amount_in_cents
  @taxable_amount_in_cents
end

#transaction_typeString

TODO: Write general description for this method

Returns:

  • (String)


14
15
16
# File 'lib/advanced_billing/models/renewal_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.



122
123
124
125
126
127
128
129
130
131
132
133
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
# File 'lib/advanced_billing/models/renewal_preview_line_item.rb', line 122

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

  # Create object from extracted values.

  RenewalPreviewLineItem.new(transaction_type,
                             kind,
                             amount_in_cents,
                             memo,
                             discount_amount_in_cents,
                             taxable_amount_in_cents,
                             product_id,
                             product_name,
                             component_id,
                             component_handle,
                             component_name,
                             product_handle)
end

.namesObject

A mapping from model property names to API property names.



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

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['product_id'] = 'product_id'
  @_hash['product_name'] = 'product_name'
  @_hash['component_id'] = 'component_id'
  @_hash['component_handle'] = 'component_handle'
  @_hash['component_name'] = 'component_name'
  @_hash['product_handle'] = 'product_handle'
  @_hash
end

.nullablesObject

An array for nullable fields



97
98
99
# File 'lib/advanced_billing/models/renewal_preview_line_item.rb', line 97

def self.nullables
  []
end

.optionalsObject

An array for optional fields



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/advanced_billing/models/renewal_preview_line_item.rb', line 79

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