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 = nil, number = nil, role = nil, delivery_date = nil, created_at = nil, due_amount = nil, paid_amount = nil, tax_amount = nil, total_amount = nil, product_name = nil, line_items = nil) ⇒ ProformaInvoiceIssued

Returns a new instance of ProformaInvoiceIssued.



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

def initialize(uid = nil, number = nil, role = nil, delivery_date = nil,
               created_at = nil, due_amount = nil, paid_amount = nil,
               tax_amount = nil, total_amount = nil, product_name = nil,
               line_items = nil)
  @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
end

Instance Attribute Details

#created_atString

TODO: Write general description for this method

Returns:

  • (String)


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

def created_at
  @created_at
end

#delivery_dateString

TODO: Write general description for this method

Returns:

  • (String)


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

def delivery_date
  @delivery_date
end

#due_amountString

TODO: Write general description for this method

Returns:

  • (String)


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

def due_amount
  @due_amount
end

#line_itemsArray[InvoiceLineItemEventData]

TODO: Write general description for this method

Returns:



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

def line_items
  @line_items
end

#numberString

TODO: Write general description for this method

Returns:

  • (String)


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

def number
  @number
end

TODO: Write general description for this method

Returns:

  • (String)


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

def paid_amount
  @paid_amount
end

#product_nameString

TODO: Write general description for this method

Returns:

  • (String)


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

def product_name
  @product_name
end

#roleString

TODO: Write general description for this method

Returns:

  • (String)


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

def role
  @role
end

#tax_amountString

TODO: Write general description for this method

Returns:

  • (String)


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

def tax_amount
  @tax_amount
end

#total_amountString

TODO: Write general description for this method

Returns:

  • (String)


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

def total_amount
  @total_amount
end

#uidString

TODO: Write general description for this method

Returns:

  • (String)


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



101
102
103
104
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/proforma_invoice_issued.rb', line 101

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

  # Create object from extracted values.

  ProformaInvoiceIssued.new(uid,
                            number,
                            role,
                            delivery_date,
                            created_at,
                            due_amount,
                            paid_amount,
                            tax_amount,
                            total_amount,
                            product_name,
                            line_items)
end

.namesObject

A mapping from model property names to API property names.



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

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



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

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  []
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



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
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/advanced_billing/models/proforma_invoice_issued.rb', line 142

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? 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

  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