Class: AdvancedBilling::ProformaInvoiceIssued

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

Overview

ProformaInvoiceIssued Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(uid:, number:, role:, delivery_date:, created_at:, due_amount:, paid_amount:, tax_amount:, total_amount:, product_name:, line_items:, additional_properties: {}) ⇒ ProformaInvoiceIssued

Returns a new instance of ProformaInvoiceIssued.



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

def initialize(uid:, number:, role:, delivery_date:, created_at:,
               due_amount:, paid_amount:, tax_amount:, total_amount:,
               product_name:, line_items:, additional_properties: {})
  @uid = uid
  @number = number
  @role = role
  @delivery_date = delivery_date
  @created_at = created_at
  @due_amount = due_amount
  @paid_amount = paid_amount
  @tax_amount = tax_amount
  @total_amount = total_amount
  @product_name = product_name
  @line_items = line_items

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

Instance Attribute Details

#created_atDateTime

TODO: Write general description for this method

Returns:

  • (DateTime)


31
32
33
# File 'lib/advanced_billing/models/proforma_invoice_issued.rb', line 31

def created_at
  @created_at
end

#delivery_dateDate

TODO: Write general description for this method

Returns:

  • (Date)


27
28
29
# File 'lib/advanced_billing/models/proforma_invoice_issued.rb', line 27

def delivery_date
  @delivery_date
end

#due_amountString

TODO: Write general description for this method

Returns:

  • (String)


35
36
37
# File 'lib/advanced_billing/models/proforma_invoice_issued.rb', line 35

def due_amount
  @due_amount
end

#line_itemsArray[InvoiceLineItemEventData]

TODO: Write general description for this method

Returns:



55
56
57
# File 'lib/advanced_billing/models/proforma_invoice_issued.rb', line 55

def line_items
  @line_items
end

#numberString

TODO: Write general description for this method

Returns:

  • (String)


19
20
21
# File 'lib/advanced_billing/models/proforma_invoice_issued.rb', line 19

def number
  @number
end

TODO: Write general description for this method

Returns:

  • (String)


39
40
41
# File 'lib/advanced_billing/models/proforma_invoice_issued.rb', line 39

def paid_amount
  @paid_amount
end

#product_nameString

TODO: Write general description for this method

Returns:

  • (String)


51
52
53
# File 'lib/advanced_billing/models/proforma_invoice_issued.rb', line 51

def product_name
  @product_name
end

#roleString

TODO: Write general description for this method

Returns:

  • (String)


23
24
25
# File 'lib/advanced_billing/models/proforma_invoice_issued.rb', line 23

def role
  @role
end

#tax_amountString

TODO: Write general description for this method

Returns:

  • (String)


43
44
45
# File 'lib/advanced_billing/models/proforma_invoice_issued.rb', line 43

def tax_amount
  @tax_amount
end

#total_amountString

TODO: Write general description for this method

Returns:

  • (String)


47
48
49
# File 'lib/advanced_billing/models/proforma_invoice_issued.rb', line 47

def total_amount
  @total_amount
end

#uidString

TODO: Write general description for this method

Returns:

  • (String)


15
16
17
# File 'lib/advanced_billing/models/proforma_invoice_issued.rb', line 15

def uid
  @uid
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/advanced_billing/models/proforma_invoice_issued.rb', line 106

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
  delivery_date = hash.key?('delivery_date') ? hash['delivery_date'] : nil
  created_at = if hash.key?('created_at')
                 (DateTimeHelper.from_rfc3339(hash['created_at']) if hash['created_at'])
               end
  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
  total_amount = hash.key?('total_amount') ? hash['total_amount'] : nil
  product_name = hash.key?('product_name') ? hash['product_name'] : 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.
  names.each_value { |k| hash.delete(k) }

  # Create object from extracted values.
  ProformaInvoiceIssued.new(uid: uid,
                            number: number,
                            role: role,
                            delivery_date: delivery_date,
                            created_at: created_at,
                            due_amount: due_amount,
                            paid_amount: paid_amount,
                            tax_amount: tax_amount,
                            total_amount: total_amount,
                            product_name: product_name,
                            line_items: line_items,
                            additional_properties: hash)
end

.namesObject

A mapping from model property names to API property names.



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/advanced_billing/models/proforma_invoice_issued.rb', line 58

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['uid'] = 'uid'
  @_hash['number'] = 'number'
  @_hash['role'] = 'role'
  @_hash['delivery_date'] = 'delivery_date'
  @_hash['created_at'] = 'created_at'
  @_hash['due_amount'] = 'due_amount'
  @_hash['paid_amount'] = 'paid_amount'
  @_hash['tax_amount'] = 'tax_amount'
  @_hash['total_amount'] = 'total_amount'
  @_hash['product_name'] = 'product_name'
  @_hash['line_items'] = 'line_items'
  @_hash
end

.nullablesObject

An array for nullable fields



80
81
82
# File 'lib/advanced_billing/models/proforma_invoice_issued.rb', line 80

def self.nullables
  []
end

.optionalsObject

An array for optional fields



75
76
77
# File 'lib/advanced_billing/models/proforma_invoice_issued.rb', line 75

def self.optionals
  []
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



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

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.delivery_date,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.created_at,
                              ->(val) { val.instance_of? DateTime }) 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.total_amount,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.product_name,
                              ->(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['delivery_date'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['created_at'],
                            ->(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['total_amount'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['product_name'],
                            ->(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

Instance Method Details

#to_custom_created_atObject



151
152
153
# File 'lib/advanced_billing/models/proforma_invoice_issued.rb', line 151

def to_custom_created_at
  DateTimeHelper.to_rfc3339(created_at)
end