Class: AdvancedBilling::InvoiceIssued

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

Overview

InvoiceIssued 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(uid:, number:, role:, due_date:, issue_date:, paid_date:, due_amount:, paid_amount:, tax_amount:, refund_amount:, total_amount:, status_amount:, product_name:, consolidation_level:, line_items:, additional_properties: {}) ⇒ InvoiceIssued

Returns a new instance of InvoiceIssued.



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
# File 'lib/advanced_billing/models/invoice_issued.rb', line 105

def initialize(uid:, number:, role:, due_date:, issue_date:, paid_date:,
               due_amount:, paid_amount:, tax_amount:, refund_amount:,
               total_amount:, status_amount:, product_name:,
               consolidation_level:, line_items:, additional_properties: {})
  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end

  @uid = uid
  @number = number
  @role = role
  @due_date = due_date
  @issue_date = issue_date
  @paid_date = paid_date
  @due_amount = due_amount
  @paid_amount = paid_amount
  @tax_amount = tax_amount
  @refund_amount = refund_amount
  @total_amount = total_amount
  @status_amount = status_amount
  @product_name = product_name
  @consolidation_level = consolidation_level
  @line_items = line_items
end

Instance Attribute Details

#consolidation_levelString

Paid date. Can be an empty string if value is missing.

Returns:

  • (String)


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

def consolidation_level
  @consolidation_level
end

#due_amountString

Paid date. Can be an empty string if value is missing.

Returns:

  • (String)


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

def due_amount
  @due_amount
end

#due_dateDate

TODO: Write general description for this method

Returns:

  • (Date)


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

def due_date
  @due_date
end

#issue_dateString

Invoice issue date. Can be an empty string if value is missing.

Returns:

  • (String)


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

def issue_date
  @issue_date
end

#line_itemsArray[InvoiceLineItemEventData]

Paid date. Can be an empty string if value is missing.

Returns:



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

def line_items
  @line_items
end

#numberString

TODO: Write general description for this method

Returns:

  • (String)


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

def number
  @number
end

Paid date. Can be an empty string if value is missing.

Returns:

  • (String)


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

def paid_amount
  @paid_amount
end

Paid date. Can be an empty string if value is missing.

Returns:

  • (String)


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

def paid_date
  @paid_date
end

#product_nameString

Paid date. Can be an empty string if value is missing.

Returns:

  • (String)


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

def product_name
  @product_name
end

#refund_amountString

Paid date. Can be an empty string if value is missing.

Returns:

  • (String)


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

def refund_amount
  @refund_amount
end

#roleString

TODO: Write general description for this method

Returns:

  • (String)


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

def role
  @role
end

#status_amountString

Paid date. Can be an empty string if value is missing.

Returns:

  • (String)


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

def status_amount
  @status_amount
end

#tax_amountString

Paid date. Can be an empty string if value is missing.

Returns:

  • (String)


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

def tax_amount
  @tax_amount
end

#total_amountString

Paid date. Can be an empty string if value is missing.

Returns:

  • (String)


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

def total_amount
  @total_amount
end

#uidString

TODO: Write general description for this method

Returns:

  • (String)


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

def uid
  @uid
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
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/invoice_issued.rb', line 132

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  uid = hash.key?('uid') ? hash['uid'] : nil
  number = hash.key?('number') ? hash['number'] : nil
  role = hash.key?('role') ? hash['role'] : nil
  due_date = hash.key?('due_date') ? hash['due_date'] : nil
  issue_date = hash.key?('issue_date') ? hash['issue_date'] : nil
  paid_date = hash.key?('paid_date') ? hash['paid_date'] : nil
  due_amount = hash.key?('due_amount') ? hash['due_amount'] : nil
  paid_amount = hash.key?('paid_amount') ? hash['paid_amount'] : nil
  tax_amount = hash.key?('tax_amount') ? hash['tax_amount'] : nil
  refund_amount = hash.key?('refund_amount') ? hash['refund_amount'] : nil
  total_amount = hash.key?('total_amount') ? hash['total_amount'] : nil
  status_amount = hash.key?('status_amount') ? hash['status_amount'] : nil
  product_name = hash.key?('product_name') ? hash['product_name'] : nil
  consolidation_level =
    hash.key?('consolidation_level') ? hash['consolidation_level'] : nil
  # Parameter is an array, so we need to iterate through it
  line_items = nil
  unless hash['line_items'].nil?
    line_items = []
    hash['line_items'].each do |structure|
      line_items << (InvoiceLineItemEventData.from_hash(structure) if structure)
    end
  end

  line_items = nil unless hash.key?('line_items')

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

  # Create object from extracted values.
  InvoiceIssued.new(uid: uid,
                    number: number,
                    role: role,
                    due_date: due_date,
                    issue_date: issue_date,
                    paid_date: paid_date,
                    due_amount: due_amount,
                    paid_amount: paid_amount,
                    tax_amount: tax_amount,
                    refund_amount: refund_amount,
                    total_amount: total_amount,
                    status_amount: status_amount,
                    product_name: product_name,
                    consolidation_level: consolidation_level,
                    line_items: line_items,
                    additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/advanced_billing/models/invoice_issued.rb', line 73

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['uid'] = 'uid'
  @_hash['number'] = 'number'
  @_hash['role'] = 'role'
  @_hash['due_date'] = 'due_date'
  @_hash['issue_date'] = 'issue_date'
  @_hash['paid_date'] = 'paid_date'
  @_hash['due_amount'] = 'due_amount'
  @_hash['paid_amount'] = 'paid_amount'
  @_hash['tax_amount'] = 'tax_amount'
  @_hash['refund_amount'] = 'refund_amount'
  @_hash['total_amount'] = 'total_amount'
  @_hash['status_amount'] = 'status_amount'
  @_hash['product_name'] = 'product_name'
  @_hash['consolidation_level'] = 'consolidation_level'
  @_hash['line_items'] = 'line_items'
  @_hash
end

.nullablesObject

An array for nullable fields



99
100
101
102
103
# File 'lib/advanced_billing/models/invoice_issued.rb', line 99

def self.nullables
  %w[
    due_date
  ]
end

.optionalsObject

An array for optional fields



94
95
96
# File 'lib/advanced_billing/models/invoice_issued.rb', line 94

def self.optionals
  []
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (InvoiceIssued | Hash)

    value against the validation is performed.



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

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.uid,
                            ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.number,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.role,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.due_date,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.issue_date,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.paid_date,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.due_amount,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.paid_amount,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.tax_amount,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.refund_amount,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.total_amount,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.status_amount,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.product_name,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.consolidation_level,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.line_items,
                              ->(val) { InvoiceLineItemEventData.validate(val) },
                              is_model_hash: true,
                              is_inner_model_hash: true)
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['uid'],
                          ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['number'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['role'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['due_date'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['issue_date'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['paid_date'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['due_amount'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['paid_amount'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['tax_amount'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['refund_amount'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['total_amount'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['status_amount'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['product_name'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['consolidation_level'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['line_items'],
                            ->(val) { InvoiceLineItemEventData.validate(val) },
                            is_model_hash: true,
                            is_inner_model_hash: true)
  )
end