dear-inventory-ruby 0.1.16 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +34 -10
- data/README.md +32 -7
- data/dear-inventory-ruby.gemspec +1 -1
- data/docs/Address.md +10 -12
- data/docs/Customer.md +1 -1
- data/docs/ExternalHeader.md +19 -0
- data/docs/InventoryApi.md +1021 -161
- data/docs/Me.md +1 -1
- data/docs/SaleAdditionalCharge.md +31 -0
- data/docs/SaleInvoice.md +1 -1
- data/docs/SaleInvoiceAdditionalCharge.md +3 -3
- data/docs/SaleInvoiceDelete.md +19 -0
- data/docs/SaleInvoiceLine.md +2 -2
- data/docs/SaleInvoicePost.md +41 -0
- data/docs/SaleOrder.md +35 -0
- data/docs/SaleOrderLine.md +41 -0
- data/docs/SalePayment.md +43 -0
- data/docs/SaleQuote.md +33 -0
- data/docs/SaleQuoteLine.md +37 -0
- data/docs/ShippingAddress.md +37 -0
- data/docs/SupplierCustomerAddress.md +33 -0
- data/docs/Webhook.md +35 -0
- data/docs/Webhooks.md +17 -0
- data/lib/dear-inventory-ruby/api/inventory_api.rb +988 -119
- data/lib/dear-inventory-ruby/models/account.rb +0 -34
- data/lib/dear-inventory-ruby/models/address.rb +28 -115
- data/lib/dear-inventory-ruby/models/customer.rb +1 -35
- data/lib/dear-inventory-ruby/models/external_header.rb +217 -0
- data/lib/dear-inventory-ruby/models/me.rb +2 -1
- data/lib/dear-inventory-ruby/models/payment_term.rb +0 -34
- data/lib/dear-inventory-ruby/models/sale_additional_charge.rb +302 -0
- data/lib/dear-inventory-ruby/models/sale_invoice.rb +1 -1
- data/lib/dear-inventory-ruby/models/sale_invoice_additional_charge.rb +3 -3
- data/lib/dear-inventory-ruby/models/sale_invoice_delete.rb +224 -0
- data/lib/dear-inventory-ruby/models/sale_invoice_line.rb +0 -10
- data/lib/dear-inventory-ruby/models/sale_invoice_post.rb +361 -0
- data/lib/dear-inventory-ruby/models/sale_order.rb +336 -0
- data/lib/dear-inventory-ruby/models/sale_order_line.rb +342 -0
- data/lib/dear-inventory-ruby/models/sale_payment.rb +337 -0
- data/lib/dear-inventory-ruby/models/sale_quote.rb +326 -0
- data/lib/dear-inventory-ruby/models/sale_quote_line.rb +322 -0
- data/lib/dear-inventory-ruby/models/shipping_address.rb +317 -0
- data/lib/dear-inventory-ruby/models/supplier_customer_address.rb +374 -0
- data/lib/dear-inventory-ruby/models/webhook.rb +319 -0
- data/lib/dear-inventory-ruby/models/webhooks.rb +209 -0
- data/lib/dear-inventory-ruby/version.rb +1 -1
- data/lib/dear-inventory-ruby.rb +13 -2
- data/spec/api/inventory_api_spec.rb +166 -0
- data/spec/models/account_spec.rb +0 -4
- data/spec/models/address_spec.rb +7 -13
- data/spec/models/customer_spec.rb +0 -4
- data/spec/models/external_header_spec.rb +47 -0
- data/spec/models/payment_term_spec.rb +0 -4
- data/spec/models/sale_additional_charge_spec.rb +83 -0
- data/spec/models/sale_invoice_delete_spec.rb +47 -0
- data/spec/models/sale_invoice_post_spec.rb +113 -0
- data/spec/models/sale_order_line_spec.rb +113 -0
- data/spec/models/sale_order_spec.rb +95 -0
- data/spec/models/sale_payment_spec.rb +119 -0
- data/spec/models/sale_quote_line_spec.rb +101 -0
- data/spec/models/sale_quote_spec.rb +89 -0
- data/spec/models/shipping_address_spec.rb +101 -0
- data/spec/models/supplier_customer_address_spec.rb +89 -0
- data/spec/models/webhook_spec.rb +95 -0
- data/spec/models/{currency_code_spec.rb → webhooks_spec.rb} +12 -6
- metadata +63 -14
- data/docs/CurrencyCode.md +0 -16
- data/docs/DimensionsUnit.md +0 -16
- data/lib/dear-inventory-ruby/models/currency_code.rb +0 -196
- data/lib/dear-inventory-ruby/models/dimensions_unit.rb +0 -42
- data/spec/.DS_Store +0 -0
- data/spec/models/dimensions_unit_spec.rb +0 -35
@@ -0,0 +1,342 @@
|
|
1
|
+
=begin
|
2
|
+
#DEAR Inventory API
|
3
|
+
|
4
|
+
#This specifing endpoints for DEAR Inventory API
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 2.0.0
|
7
|
+
Contact: nnhansg@gmail.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.3.1
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module DearInventoryRuby
|
16
|
+
class SaleOrderLine
|
17
|
+
# Product identifier referenced by this Line. Required If CombineAdditionalCharges param exist for this endpoint and it have values = false
|
18
|
+
attr_accessor :product_id
|
19
|
+
|
20
|
+
# Product SKU referenced by this Line. Required If CombineAdditionalCharges param exist for this endpoint and it have values = false
|
21
|
+
attr_accessor :sku
|
22
|
+
|
23
|
+
# Product Name referenced by this Line
|
24
|
+
attr_accessor :name
|
25
|
+
|
26
|
+
# Product or service quantity. Minimal value is 1.
|
27
|
+
attr_accessor :quantity
|
28
|
+
|
29
|
+
# Price per unit in Customer currency
|
30
|
+
attr_accessor :price
|
31
|
+
|
32
|
+
# Discount. Value between 0 and 100. For free items discount is 100. Default value is 0
|
33
|
+
attr_accessor :discount
|
34
|
+
|
35
|
+
# Tax
|
36
|
+
attr_accessor :tax
|
37
|
+
|
38
|
+
# Average product cost
|
39
|
+
attr_accessor :average_cost
|
40
|
+
|
41
|
+
# Line Tax Rule name.
|
42
|
+
attr_accessor :tax_rule
|
43
|
+
|
44
|
+
# Comment for this line
|
45
|
+
attr_accessor :comment
|
46
|
+
|
47
|
+
# Required if product is not a service with “Optional Drop Ship” mode. Otherwise it ignored.
|
48
|
+
attr_accessor :drop_ship
|
49
|
+
|
50
|
+
# Quantity of the ordered product on backorder. Read Only for POST
|
51
|
+
attr_accessor :backorder_quantity
|
52
|
+
|
53
|
+
# Line Total. For validation
|
54
|
+
attr_accessor :total
|
55
|
+
|
56
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
57
|
+
def self.attribute_map
|
58
|
+
{
|
59
|
+
:'product_id' => :'ProductID',
|
60
|
+
:'sku' => :'SKU',
|
61
|
+
:'name' => :'Name',
|
62
|
+
:'quantity' => :'Quantity',
|
63
|
+
:'price' => :'Price',
|
64
|
+
:'discount' => :'Discount',
|
65
|
+
:'tax' => :'Tax',
|
66
|
+
:'average_cost' => :'AverageCost',
|
67
|
+
:'tax_rule' => :'TaxRule',
|
68
|
+
:'comment' => :'Comment',
|
69
|
+
:'drop_ship' => :'DropShip',
|
70
|
+
:'backorder_quantity' => :'BackorderQuantity',
|
71
|
+
:'total' => :'Total'
|
72
|
+
}
|
73
|
+
end
|
74
|
+
|
75
|
+
# Attribute type mapping.
|
76
|
+
def self.openapi_types
|
77
|
+
{
|
78
|
+
:'product_id' => :'String',
|
79
|
+
:'sku' => :'String',
|
80
|
+
:'name' => :'String',
|
81
|
+
:'quantity' => :'Float',
|
82
|
+
:'price' => :'Float',
|
83
|
+
:'discount' => :'Float',
|
84
|
+
:'tax' => :'Float',
|
85
|
+
:'average_cost' => :'Float',
|
86
|
+
:'tax_rule' => :'String',
|
87
|
+
:'comment' => :'String',
|
88
|
+
:'drop_ship' => :'Boolean',
|
89
|
+
:'backorder_quantity' => :'Float',
|
90
|
+
:'total' => :'Float'
|
91
|
+
}
|
92
|
+
end
|
93
|
+
|
94
|
+
# List of attributes with nullable: true
|
95
|
+
def self.openapi_nullable
|
96
|
+
Set.new([
|
97
|
+
])
|
98
|
+
end
|
99
|
+
|
100
|
+
# Initializes the object
|
101
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
102
|
+
def initialize(attributes = {})
|
103
|
+
if (!attributes.is_a?(Hash))
|
104
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `DearInventoryRuby::SaleOrderLine` initialize method"
|
105
|
+
end
|
106
|
+
|
107
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
108
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
109
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
110
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `DearInventoryRuby::SaleOrderLine`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
111
|
+
end
|
112
|
+
h[k.to_sym] = v
|
113
|
+
}
|
114
|
+
|
115
|
+
if attributes.key?(:'product_id')
|
116
|
+
self.product_id = attributes[:'product_id']
|
117
|
+
end
|
118
|
+
|
119
|
+
if attributes.key?(:'sku')
|
120
|
+
self.sku = attributes[:'sku']
|
121
|
+
end
|
122
|
+
|
123
|
+
if attributes.key?(:'name')
|
124
|
+
self.name = attributes[:'name']
|
125
|
+
end
|
126
|
+
|
127
|
+
if attributes.key?(:'quantity')
|
128
|
+
self.quantity = attributes[:'quantity']
|
129
|
+
end
|
130
|
+
|
131
|
+
if attributes.key?(:'price')
|
132
|
+
self.price = attributes[:'price']
|
133
|
+
end
|
134
|
+
|
135
|
+
if attributes.key?(:'discount')
|
136
|
+
self.discount = attributes[:'discount']
|
137
|
+
end
|
138
|
+
|
139
|
+
if attributes.key?(:'tax')
|
140
|
+
self.tax = attributes[:'tax']
|
141
|
+
end
|
142
|
+
|
143
|
+
if attributes.key?(:'average_cost')
|
144
|
+
self.average_cost = attributes[:'average_cost']
|
145
|
+
end
|
146
|
+
|
147
|
+
if attributes.key?(:'tax_rule')
|
148
|
+
self.tax_rule = attributes[:'tax_rule']
|
149
|
+
end
|
150
|
+
|
151
|
+
if attributes.key?(:'comment')
|
152
|
+
self.comment = attributes[:'comment']
|
153
|
+
end
|
154
|
+
|
155
|
+
if attributes.key?(:'drop_ship')
|
156
|
+
self.drop_ship = attributes[:'drop_ship']
|
157
|
+
end
|
158
|
+
|
159
|
+
if attributes.key?(:'backorder_quantity')
|
160
|
+
self.backorder_quantity = attributes[:'backorder_quantity']
|
161
|
+
end
|
162
|
+
|
163
|
+
if attributes.key?(:'total')
|
164
|
+
self.total = attributes[:'total']
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
169
|
+
# @return Array for valid properties with the reasons
|
170
|
+
def list_invalid_properties
|
171
|
+
invalid_properties = Array.new
|
172
|
+
if @name.nil?
|
173
|
+
invalid_properties.push('invalid value for "name", name cannot be nil.')
|
174
|
+
end
|
175
|
+
|
176
|
+
if @quantity.nil?
|
177
|
+
invalid_properties.push('invalid value for "quantity", quantity cannot be nil.')
|
178
|
+
end
|
179
|
+
|
180
|
+
if @price.nil?
|
181
|
+
invalid_properties.push('invalid value for "price", price cannot be nil.')
|
182
|
+
end
|
183
|
+
|
184
|
+
invalid_properties
|
185
|
+
end
|
186
|
+
|
187
|
+
# Check to see if the all the properties in the model are valid
|
188
|
+
# @return true if the model is valid
|
189
|
+
def valid?
|
190
|
+
return false if @name.nil?
|
191
|
+
return false if @quantity.nil?
|
192
|
+
return false if @price.nil?
|
193
|
+
true
|
194
|
+
end
|
195
|
+
|
196
|
+
# Checks equality by comparing each attribute.
|
197
|
+
# @param [Object] Object to be compared
|
198
|
+
def ==(o)
|
199
|
+
return true if self.equal?(o)
|
200
|
+
self.class == o.class &&
|
201
|
+
product_id == o.product_id &&
|
202
|
+
sku == o.sku &&
|
203
|
+
name == o.name &&
|
204
|
+
quantity == o.quantity &&
|
205
|
+
price == o.price &&
|
206
|
+
discount == o.discount &&
|
207
|
+
tax == o.tax &&
|
208
|
+
average_cost == o.average_cost &&
|
209
|
+
tax_rule == o.tax_rule &&
|
210
|
+
comment == o.comment &&
|
211
|
+
drop_ship == o.drop_ship &&
|
212
|
+
backorder_quantity == o.backorder_quantity &&
|
213
|
+
total == o.total
|
214
|
+
end
|
215
|
+
|
216
|
+
# @see the `==` method
|
217
|
+
# @param [Object] Object to be compared
|
218
|
+
def eql?(o)
|
219
|
+
self == o
|
220
|
+
end
|
221
|
+
|
222
|
+
# Calculates hash code according to all attributes.
|
223
|
+
# @return [Integer] Hash code
|
224
|
+
def hash
|
225
|
+
[product_id, sku, name, quantity, price, discount, tax, average_cost, tax_rule, comment, drop_ship, backorder_quantity, total].hash
|
226
|
+
end
|
227
|
+
|
228
|
+
# Builds the object from hash
|
229
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
230
|
+
# @return [Object] Returns the model itself
|
231
|
+
def self.build_from_hash(attributes)
|
232
|
+
new.build_from_hash(attributes)
|
233
|
+
end
|
234
|
+
|
235
|
+
# Builds the object from hash
|
236
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
237
|
+
# @return [Object] Returns the model itself
|
238
|
+
def build_from_hash(attributes)
|
239
|
+
return nil unless attributes.is_a?(Hash)
|
240
|
+
self.class.openapi_types.each_pair do |key, type|
|
241
|
+
if type =~ /\AArray<(.*)>/i
|
242
|
+
# check to ensure the input is an array given that the attribute
|
243
|
+
# is documented as an array but the input is not
|
244
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
245
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
246
|
+
end
|
247
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
248
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
249
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
250
|
+
end
|
251
|
+
|
252
|
+
self
|
253
|
+
end
|
254
|
+
|
255
|
+
# Deserializes the data based on type
|
256
|
+
# @param string type Data type
|
257
|
+
# @param string value Value to be deserialized
|
258
|
+
# @return [Object] Deserialized data
|
259
|
+
def _deserialize(type, value)
|
260
|
+
case type.to_sym
|
261
|
+
when :DateTime
|
262
|
+
DateTime.parse(value)
|
263
|
+
when :Date
|
264
|
+
Date.parse(value)
|
265
|
+
when :String
|
266
|
+
value.to_s
|
267
|
+
when :Integer
|
268
|
+
value.to_i
|
269
|
+
when :Float
|
270
|
+
value.to_f
|
271
|
+
when :Boolean
|
272
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
273
|
+
true
|
274
|
+
else
|
275
|
+
false
|
276
|
+
end
|
277
|
+
when :Object
|
278
|
+
# generic object (usually a Hash), return directly
|
279
|
+
value
|
280
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
281
|
+
inner_type = Regexp.last_match[:inner_type]
|
282
|
+
value.map { |v| _deserialize(inner_type, v) }
|
283
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
284
|
+
k_type = Regexp.last_match[:k_type]
|
285
|
+
v_type = Regexp.last_match[:v_type]
|
286
|
+
{}.tap do |hash|
|
287
|
+
value.each do |k, v|
|
288
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
289
|
+
end
|
290
|
+
end
|
291
|
+
else # model
|
292
|
+
DearInventoryRuby.const_get(type).build_from_hash(value)
|
293
|
+
end
|
294
|
+
end
|
295
|
+
|
296
|
+
# Returns the string representation of the object
|
297
|
+
# @return [String] String presentation of the object
|
298
|
+
def to_s
|
299
|
+
to_hash.to_s
|
300
|
+
end
|
301
|
+
|
302
|
+
# to_body is an alias to to_hash (backward compatibility)
|
303
|
+
# @return [Hash] Returns the object in the form of hash
|
304
|
+
def to_body
|
305
|
+
to_hash
|
306
|
+
end
|
307
|
+
|
308
|
+
# Returns the object in the form of hash
|
309
|
+
# @return [Hash] Returns the object in the form of hash
|
310
|
+
def to_hash
|
311
|
+
hash = {}
|
312
|
+
self.class.attribute_map.each_pair do |attr, param|
|
313
|
+
value = self.send(attr)
|
314
|
+
if value.nil?
|
315
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
316
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
317
|
+
end
|
318
|
+
|
319
|
+
hash[param] = _to_hash(value)
|
320
|
+
end
|
321
|
+
hash
|
322
|
+
end
|
323
|
+
|
324
|
+
# Outputs non-array value in the form of hash
|
325
|
+
# For object, use to_hash. Otherwise, just return the value
|
326
|
+
# @param [Object] value Any valid value
|
327
|
+
# @return [Hash] Returns the value in the form of hash
|
328
|
+
def _to_hash(value)
|
329
|
+
if value.is_a?(Array)
|
330
|
+
value.compact.map { |v| _to_hash(v) }
|
331
|
+
elsif value.is_a?(Hash)
|
332
|
+
{}.tap do |hash|
|
333
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
334
|
+
end
|
335
|
+
elsif value.respond_to? :to_hash
|
336
|
+
value.to_hash
|
337
|
+
else
|
338
|
+
value
|
339
|
+
end
|
340
|
+
end
|
341
|
+
end
|
342
|
+
end
|
@@ -0,0 +1,337 @@
|
|
1
|
+
=begin
|
2
|
+
#DEAR Inventory API
|
3
|
+
|
4
|
+
#This specifing endpoints for DEAR Inventory API
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 2.0.0
|
7
|
+
Contact: nnhansg@gmail.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.3.1
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module DearInventoryRuby
|
16
|
+
class SalePayment
|
17
|
+
# Unique DEAR Sale ID
|
18
|
+
attr_accessor :sale_id
|
19
|
+
|
20
|
+
# Unique DEAR Sale Task ID. Available for POST
|
21
|
+
attr_accessor :task_id
|
22
|
+
|
23
|
+
# Identifier of payment. Available for PUT
|
24
|
+
attr_accessor :id
|
25
|
+
|
26
|
+
# Sale Order Number
|
27
|
+
attr_accessor :sale_order_number
|
28
|
+
|
29
|
+
# Sale Task Invoice Number
|
30
|
+
attr_accessor :invoice_number
|
31
|
+
|
32
|
+
# Sale Task Credit Note Number
|
33
|
+
attr_accessor :credit_note_number
|
34
|
+
|
35
|
+
# Available values are PREPAYMENT,PAYMENT,REFUND. Available for POST
|
36
|
+
attr_accessor :type
|
37
|
+
|
38
|
+
# Payment reference number. Available for POST/PUT
|
39
|
+
attr_accessor :reference
|
40
|
+
|
41
|
+
# Payment amount in customer currency. Available for POST/PUT
|
42
|
+
attr_accessor :amount
|
43
|
+
|
44
|
+
# Date when payment has been made. Available for POST/PUT
|
45
|
+
attr_accessor :date_paid
|
46
|
+
|
47
|
+
# Account Code of the bank/payment account from Chart of accounts. Available for POST/PUT
|
48
|
+
attr_accessor :account
|
49
|
+
|
50
|
+
# Currency Conversion rate expressed as number of Base currency units for one Customer currency unit. Available for POST/PUT
|
51
|
+
attr_accessor :currency_rate
|
52
|
+
|
53
|
+
# Date of creation payment record.
|
54
|
+
attr_accessor :date_created
|
55
|
+
|
56
|
+
# Id for Sale Credit entry
|
57
|
+
attr_accessor :credit_id
|
58
|
+
|
59
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
60
|
+
def self.attribute_map
|
61
|
+
{
|
62
|
+
:'sale_id' => :'SaleID',
|
63
|
+
:'task_id' => :'TaskID',
|
64
|
+
:'id' => :'ID',
|
65
|
+
:'sale_order_number' => :'SaleOrderNumber',
|
66
|
+
:'invoice_number' => :'InvoiceNumber',
|
67
|
+
:'credit_note_number' => :'CreditNoteNumber',
|
68
|
+
:'type' => :'Type',
|
69
|
+
:'reference' => :'Reference',
|
70
|
+
:'amount' => :'Amount',
|
71
|
+
:'date_paid' => :'DatePaid',
|
72
|
+
:'account' => :'Account',
|
73
|
+
:'currency_rate' => :'CurrencyRate',
|
74
|
+
:'date_created' => :'DateCreated',
|
75
|
+
:'credit_id' => :'CreditID'
|
76
|
+
}
|
77
|
+
end
|
78
|
+
|
79
|
+
# Attribute type mapping.
|
80
|
+
def self.openapi_types
|
81
|
+
{
|
82
|
+
:'sale_id' => :'String',
|
83
|
+
:'task_id' => :'String',
|
84
|
+
:'id' => :'String',
|
85
|
+
:'sale_order_number' => :'String',
|
86
|
+
:'invoice_number' => :'String',
|
87
|
+
:'credit_note_number' => :'String',
|
88
|
+
:'type' => :'String',
|
89
|
+
:'reference' => :'String',
|
90
|
+
:'amount' => :'Float',
|
91
|
+
:'date_paid' => :'Date',
|
92
|
+
:'account' => :'String',
|
93
|
+
:'currency_rate' => :'Float',
|
94
|
+
:'date_created' => :'Date',
|
95
|
+
:'credit_id' => :'String'
|
96
|
+
}
|
97
|
+
end
|
98
|
+
|
99
|
+
# List of attributes with nullable: true
|
100
|
+
def self.openapi_nullable
|
101
|
+
Set.new([
|
102
|
+
])
|
103
|
+
end
|
104
|
+
|
105
|
+
# Initializes the object
|
106
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
107
|
+
def initialize(attributes = {})
|
108
|
+
if (!attributes.is_a?(Hash))
|
109
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `DearInventoryRuby::SalePayment` initialize method"
|
110
|
+
end
|
111
|
+
|
112
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
113
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
114
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
115
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `DearInventoryRuby::SalePayment`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
116
|
+
end
|
117
|
+
h[k.to_sym] = v
|
118
|
+
}
|
119
|
+
|
120
|
+
if attributes.key?(:'sale_id')
|
121
|
+
self.sale_id = attributes[:'sale_id']
|
122
|
+
end
|
123
|
+
|
124
|
+
if attributes.key?(:'task_id')
|
125
|
+
self.task_id = attributes[:'task_id']
|
126
|
+
end
|
127
|
+
|
128
|
+
if attributes.key?(:'id')
|
129
|
+
self.id = attributes[:'id']
|
130
|
+
end
|
131
|
+
|
132
|
+
if attributes.key?(:'sale_order_number')
|
133
|
+
self.sale_order_number = attributes[:'sale_order_number']
|
134
|
+
end
|
135
|
+
|
136
|
+
if attributes.key?(:'invoice_number')
|
137
|
+
self.invoice_number = attributes[:'invoice_number']
|
138
|
+
end
|
139
|
+
|
140
|
+
if attributes.key?(:'credit_note_number')
|
141
|
+
self.credit_note_number = attributes[:'credit_note_number']
|
142
|
+
end
|
143
|
+
|
144
|
+
if attributes.key?(:'type')
|
145
|
+
self.type = attributes[:'type']
|
146
|
+
end
|
147
|
+
|
148
|
+
if attributes.key?(:'reference')
|
149
|
+
self.reference = attributes[:'reference']
|
150
|
+
end
|
151
|
+
|
152
|
+
if attributes.key?(:'amount')
|
153
|
+
self.amount = attributes[:'amount']
|
154
|
+
end
|
155
|
+
|
156
|
+
if attributes.key?(:'date_paid')
|
157
|
+
self.date_paid = attributes[:'date_paid']
|
158
|
+
end
|
159
|
+
|
160
|
+
if attributes.key?(:'account')
|
161
|
+
self.account = attributes[:'account']
|
162
|
+
end
|
163
|
+
|
164
|
+
if attributes.key?(:'currency_rate')
|
165
|
+
self.currency_rate = attributes[:'currency_rate']
|
166
|
+
end
|
167
|
+
|
168
|
+
if attributes.key?(:'date_created')
|
169
|
+
self.date_created = attributes[:'date_created']
|
170
|
+
end
|
171
|
+
|
172
|
+
if attributes.key?(:'credit_id')
|
173
|
+
self.credit_id = attributes[:'credit_id']
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
178
|
+
# @return Array for valid properties with the reasons
|
179
|
+
def list_invalid_properties
|
180
|
+
invalid_properties = Array.new
|
181
|
+
invalid_properties
|
182
|
+
end
|
183
|
+
|
184
|
+
# Check to see if the all the properties in the model are valid
|
185
|
+
# @return true if the model is valid
|
186
|
+
def valid?
|
187
|
+
true
|
188
|
+
end
|
189
|
+
|
190
|
+
# Checks equality by comparing each attribute.
|
191
|
+
# @param [Object] Object to be compared
|
192
|
+
def ==(o)
|
193
|
+
return true if self.equal?(o)
|
194
|
+
self.class == o.class &&
|
195
|
+
sale_id == o.sale_id &&
|
196
|
+
task_id == o.task_id &&
|
197
|
+
id == o.id &&
|
198
|
+
sale_order_number == o.sale_order_number &&
|
199
|
+
invoice_number == o.invoice_number &&
|
200
|
+
credit_note_number == o.credit_note_number &&
|
201
|
+
type == o.type &&
|
202
|
+
reference == o.reference &&
|
203
|
+
amount == o.amount &&
|
204
|
+
date_paid == o.date_paid &&
|
205
|
+
account == o.account &&
|
206
|
+
currency_rate == o.currency_rate &&
|
207
|
+
date_created == o.date_created &&
|
208
|
+
credit_id == o.credit_id
|
209
|
+
end
|
210
|
+
|
211
|
+
# @see the `==` method
|
212
|
+
# @param [Object] Object to be compared
|
213
|
+
def eql?(o)
|
214
|
+
self == o
|
215
|
+
end
|
216
|
+
|
217
|
+
# Calculates hash code according to all attributes.
|
218
|
+
# @return [Integer] Hash code
|
219
|
+
def hash
|
220
|
+
[sale_id, task_id, id, sale_order_number, invoice_number, credit_note_number, type, reference, amount, date_paid, account, currency_rate, date_created, credit_id].hash
|
221
|
+
end
|
222
|
+
|
223
|
+
# Builds the object from hash
|
224
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
225
|
+
# @return [Object] Returns the model itself
|
226
|
+
def self.build_from_hash(attributes)
|
227
|
+
new.build_from_hash(attributes)
|
228
|
+
end
|
229
|
+
|
230
|
+
# Builds the object from hash
|
231
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
232
|
+
# @return [Object] Returns the model itself
|
233
|
+
def build_from_hash(attributes)
|
234
|
+
return nil unless attributes.is_a?(Hash)
|
235
|
+
self.class.openapi_types.each_pair do |key, type|
|
236
|
+
if type =~ /\AArray<(.*)>/i
|
237
|
+
# check to ensure the input is an array given that the attribute
|
238
|
+
# is documented as an array but the input is not
|
239
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
240
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
241
|
+
end
|
242
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
243
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
244
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
245
|
+
end
|
246
|
+
|
247
|
+
self
|
248
|
+
end
|
249
|
+
|
250
|
+
# Deserializes the data based on type
|
251
|
+
# @param string type Data type
|
252
|
+
# @param string value Value to be deserialized
|
253
|
+
# @return [Object] Deserialized data
|
254
|
+
def _deserialize(type, value)
|
255
|
+
case type.to_sym
|
256
|
+
when :DateTime
|
257
|
+
DateTime.parse(value)
|
258
|
+
when :Date
|
259
|
+
Date.parse(value)
|
260
|
+
when :String
|
261
|
+
value.to_s
|
262
|
+
when :Integer
|
263
|
+
value.to_i
|
264
|
+
when :Float
|
265
|
+
value.to_f
|
266
|
+
when :Boolean
|
267
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
268
|
+
true
|
269
|
+
else
|
270
|
+
false
|
271
|
+
end
|
272
|
+
when :Object
|
273
|
+
# generic object (usually a Hash), return directly
|
274
|
+
value
|
275
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
276
|
+
inner_type = Regexp.last_match[:inner_type]
|
277
|
+
value.map { |v| _deserialize(inner_type, v) }
|
278
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
279
|
+
k_type = Regexp.last_match[:k_type]
|
280
|
+
v_type = Regexp.last_match[:v_type]
|
281
|
+
{}.tap do |hash|
|
282
|
+
value.each do |k, v|
|
283
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
284
|
+
end
|
285
|
+
end
|
286
|
+
else # model
|
287
|
+
DearInventoryRuby.const_get(type).build_from_hash(value)
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
291
|
+
# Returns the string representation of the object
|
292
|
+
# @return [String] String presentation of the object
|
293
|
+
def to_s
|
294
|
+
to_hash.to_s
|
295
|
+
end
|
296
|
+
|
297
|
+
# to_body is an alias to to_hash (backward compatibility)
|
298
|
+
# @return [Hash] Returns the object in the form of hash
|
299
|
+
def to_body
|
300
|
+
to_hash
|
301
|
+
end
|
302
|
+
|
303
|
+
# Returns the object in the form of hash
|
304
|
+
# @return [Hash] Returns the object in the form of hash
|
305
|
+
def to_hash
|
306
|
+
hash = {}
|
307
|
+
self.class.attribute_map.each_pair do |attr, param|
|
308
|
+
value = self.send(attr)
|
309
|
+
if value.nil?
|
310
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
311
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
312
|
+
end
|
313
|
+
|
314
|
+
hash[param] = _to_hash(value)
|
315
|
+
end
|
316
|
+
hash
|
317
|
+
end
|
318
|
+
|
319
|
+
# Outputs non-array value in the form of hash
|
320
|
+
# For object, use to_hash. Otherwise, just return the value
|
321
|
+
# @param [Object] value Any valid value
|
322
|
+
# @return [Hash] Returns the value in the form of hash
|
323
|
+
def _to_hash(value)
|
324
|
+
if value.is_a?(Array)
|
325
|
+
value.compact.map { |v| _to_hash(v) }
|
326
|
+
elsif value.is_a?(Hash)
|
327
|
+
{}.tap do |hash|
|
328
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
329
|
+
end
|
330
|
+
elsif value.respond_to? :to_hash
|
331
|
+
value.to_hash
|
332
|
+
else
|
333
|
+
value
|
334
|
+
end
|
335
|
+
end
|
336
|
+
end
|
337
|
+
end
|