dear-inventory-ruby 0.2.4 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,9 +17,6 @@ module DearInventoryRuby
17
17
  # Identifier of sale Invoice task
18
18
  attr_accessor :task_id
19
19
 
20
- # If `true` then `additional charges` lines displayed in `Lines` array
21
- attr_accessor :combine_additional_charges
22
-
23
20
  # Invoice Number (auto-generated)
24
21
  attr_accessor :invoice_number
25
22
 
@@ -51,11 +48,24 @@ module DearInventoryRuby
51
48
 
52
49
  attr_accessor :additional_charges
53
50
 
51
+ attr_accessor :payments
52
+
53
+ # Decimal with up to 4 decimal places. Sum of Invoice lines and additional charges without taxes.
54
+ attr_accessor :total_before_tax
55
+
56
+ # Decimal with up to 4 decimal places. Sum of Invoice lines and additional charges taxes.
57
+ attr_accessor :tax
58
+
59
+ # Decimal with up to 4 decimal places. Sum of Invoice lines and additional charges with taxes.
60
+ attr_accessor :total
61
+
62
+ # Decimal with up to 4 decimal places. Sum of payments.
63
+ attr_accessor :paid
64
+
54
65
  # Attribute mapping from ruby-style variable name to JSON key.
55
66
  def self.attribute_map
56
67
  {
57
68
  :'task_id' => :'TaskID',
58
- :'combine_additional_charges' => :'CombineAdditionalCharges',
59
69
  :'invoice_number' => :'InvoiceNumber',
60
70
  :'memo' => :'Memo',
61
71
  :'status' => :'Status',
@@ -66,7 +76,12 @@ module DearInventoryRuby
66
76
  :'billing_address_line2' => :'BillingAddressLine2',
67
77
  :'linked_fulfillment_number' => :'LinkedFulfillmentNumber',
68
78
  :'lines' => :'Lines',
69
- :'additional_charges' => :'AdditionalCharges'
79
+ :'additional_charges' => :'AdditionalCharges',
80
+ :'payments' => :'Payments',
81
+ :'total_before_tax' => :'TotalBeforeTax',
82
+ :'tax' => :'Tax',
83
+ :'total' => :'Total',
84
+ :'paid' => :'Paid'
70
85
  }
71
86
  end
72
87
 
@@ -74,7 +89,6 @@ module DearInventoryRuby
74
89
  def self.openapi_types
75
90
  {
76
91
  :'task_id' => :'String',
77
- :'combine_additional_charges' => :'Boolean',
78
92
  :'invoice_number' => :'String',
79
93
  :'memo' => :'String',
80
94
  :'status' => :'String',
@@ -85,7 +99,12 @@ module DearInventoryRuby
85
99
  :'billing_address_line2' => :'String',
86
100
  :'linked_fulfillment_number' => :'Integer',
87
101
  :'lines' => :'Array<SaleInvoiceLine>',
88
- :'additional_charges' => :'Array<SaleInvoiceAdditionalCharge>'
102
+ :'additional_charges' => :'Array<SaleInvoiceAdditionalCharge>',
103
+ :'payments' => :'Array<SalePaymentLine>',
104
+ :'total_before_tax' => :'Float',
105
+ :'tax' => :'Float',
106
+ :'total' => :'Float',
107
+ :'paid' => :'Float'
89
108
  }
90
109
  end
91
110
 
@@ -114,12 +133,6 @@ module DearInventoryRuby
114
133
  self.task_id = attributes[:'task_id']
115
134
  end
116
135
 
117
- if attributes.key?(:'combine_additional_charges')
118
- self.combine_additional_charges = attributes[:'combine_additional_charges']
119
- else
120
- self.combine_additional_charges = false
121
- end
122
-
123
136
  if attributes.key?(:'invoice_number')
124
137
  self.invoice_number = attributes[:'invoice_number']
125
138
  end
@@ -167,6 +180,28 @@ module DearInventoryRuby
167
180
  self.additional_charges = value
168
181
  end
169
182
  end
183
+
184
+ if attributes.key?(:'payments')
185
+ if (value = attributes[:'payments']).is_a?(Array)
186
+ self.payments = value
187
+ end
188
+ end
189
+
190
+ if attributes.key?(:'total_before_tax')
191
+ self.total_before_tax = attributes[:'total_before_tax']
192
+ end
193
+
194
+ if attributes.key?(:'tax')
195
+ self.tax = attributes[:'tax']
196
+ end
197
+
198
+ if attributes.key?(:'total')
199
+ self.total = attributes[:'total']
200
+ end
201
+
202
+ if attributes.key?(:'paid')
203
+ self.paid = attributes[:'paid']
204
+ end
170
205
  end
171
206
 
172
207
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -177,10 +212,6 @@ module DearInventoryRuby
177
212
  invalid_properties.push('invalid value for "task_id", task_id cannot be nil.')
178
213
  end
179
214
 
180
- if @combine_additional_charges.nil?
181
- invalid_properties.push('invalid value for "combine_additional_charges", combine_additional_charges cannot be nil.')
182
- end
183
-
184
215
  if @status.nil?
185
216
  invalid_properties.push('invalid value for "status", status cannot be nil.')
186
217
  end
@@ -200,7 +231,6 @@ module DearInventoryRuby
200
231
  # @return true if the model is valid
201
232
  def valid?
202
233
  return false if @task_id.nil?
203
- return false if @combine_additional_charges.nil?
204
234
  return false if @status.nil?
205
235
  return false if @invoice_date.nil?
206
236
  return false if @invoice_due_date.nil?
@@ -213,7 +243,6 @@ module DearInventoryRuby
213
243
  return true if self.equal?(o)
214
244
  self.class == o.class &&
215
245
  task_id == o.task_id &&
216
- combine_additional_charges == o.combine_additional_charges &&
217
246
  invoice_number == o.invoice_number &&
218
247
  memo == o.memo &&
219
248
  status == o.status &&
@@ -224,7 +253,12 @@ module DearInventoryRuby
224
253
  billing_address_line2 == o.billing_address_line2 &&
225
254
  linked_fulfillment_number == o.linked_fulfillment_number &&
226
255
  lines == o.lines &&
227
- additional_charges == o.additional_charges
256
+ additional_charges == o.additional_charges &&
257
+ payments == o.payments &&
258
+ total_before_tax == o.total_before_tax &&
259
+ tax == o.tax &&
260
+ total == o.total &&
261
+ paid == o.paid
228
262
  end
229
263
 
230
264
  # @see the `==` method
@@ -236,7 +270,7 @@ module DearInventoryRuby
236
270
  # Calculates hash code according to all attributes.
237
271
  # @return [Integer] Hash code
238
272
  def hash
239
- [task_id, combine_additional_charges, invoice_number, memo, status, invoice_date, invoice_due_date, currency_conversion_rate, billing_address_line1, billing_address_line2, linked_fulfillment_number, lines, additional_charges].hash
273
+ [task_id, invoice_number, memo, status, invoice_date, invoice_due_date, currency_conversion_rate, billing_address_line1, billing_address_line2, linked_fulfillment_number, lines, additional_charges, payments, total_before_tax, tax, total, paid].hash
240
274
  end
241
275
 
242
276
  # Builds the object from hash
@@ -0,0 +1,351 @@
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 SaleInvoicePartial
17
+ # Identifier of sale Invoice task
18
+ attr_accessor :task_id
19
+
20
+ # If `true` then `additional charges` lines displayed in `Lines` array
21
+ attr_accessor :combine_additional_charges
22
+
23
+ # Invoice Number (auto-generated)
24
+ attr_accessor :invoice_number
25
+
26
+ # Additional information for Invoice.
27
+ attr_accessor :memo
28
+
29
+ # Invoice status. Possible Values are values. For POST available values are DRAFT, AUTHORISED
30
+ attr_accessor :status
31
+
32
+ # Invoice Date.
33
+ attr_accessor :invoice_date
34
+
35
+ # Invoice Due Date.
36
+ attr_accessor :invoice_due_date
37
+
38
+ # Decimal with up to 4 decimal places
39
+ attr_accessor :currency_conversion_rate
40
+
41
+ # Billing Address Line 1
42
+ attr_accessor :billing_address_line1
43
+
44
+ # Billing Address Line 2
45
+ attr_accessor :billing_address_line2
46
+
47
+ # Number of Fulfilment linked to this invoice
48
+ attr_accessor :linked_fulfillment_number
49
+
50
+ attr_accessor :lines
51
+
52
+ attr_accessor :additional_charges
53
+
54
+ # Attribute mapping from ruby-style variable name to JSON key.
55
+ def self.attribute_map
56
+ {
57
+ :'task_id' => :'TaskID',
58
+ :'combine_additional_charges' => :'CombineAdditionalCharges',
59
+ :'invoice_number' => :'InvoiceNumber',
60
+ :'memo' => :'Memo',
61
+ :'status' => :'Status',
62
+ :'invoice_date' => :'InvoiceDate',
63
+ :'invoice_due_date' => :'InvoiceDueDate',
64
+ :'currency_conversion_rate' => :'CurrencyConversionRate',
65
+ :'billing_address_line1' => :'BillingAddressLine1',
66
+ :'billing_address_line2' => :'BillingAddressLine2',
67
+ :'linked_fulfillment_number' => :'LinkedFulfillmentNumber',
68
+ :'lines' => :'Lines',
69
+ :'additional_charges' => :'AdditionalCharges'
70
+ }
71
+ end
72
+
73
+ # Attribute type mapping.
74
+ def self.openapi_types
75
+ {
76
+ :'task_id' => :'String',
77
+ :'combine_additional_charges' => :'Boolean',
78
+ :'invoice_number' => :'String',
79
+ :'memo' => :'String',
80
+ :'status' => :'String',
81
+ :'invoice_date' => :'String',
82
+ :'invoice_due_date' => :'String',
83
+ :'currency_conversion_rate' => :'Float',
84
+ :'billing_address_line1' => :'String',
85
+ :'billing_address_line2' => :'String',
86
+ :'linked_fulfillment_number' => :'Integer',
87
+ :'lines' => :'Array<SaleInvoiceLine>',
88
+ :'additional_charges' => :'Array<SaleInvoiceAdditionalCharge>'
89
+ }
90
+ end
91
+
92
+ # List of attributes with nullable: true
93
+ def self.openapi_nullable
94
+ Set.new([
95
+ ])
96
+ end
97
+
98
+ # Initializes the object
99
+ # @param [Hash] attributes Model attributes in the form of hash
100
+ def initialize(attributes = {})
101
+ if (!attributes.is_a?(Hash))
102
+ fail ArgumentError, "The input argument (attributes) must be a hash in `DearInventoryRuby::SaleInvoicePartial` initialize method"
103
+ end
104
+
105
+ # check to see if the attribute exists and convert string to symbol for hash key
106
+ attributes = attributes.each_with_object({}) { |(k, v), h|
107
+ if (!self.class.attribute_map.key?(k.to_sym))
108
+ fail ArgumentError, "`#{k}` is not a valid attribute in `DearInventoryRuby::SaleInvoicePartial`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
109
+ end
110
+ h[k.to_sym] = v
111
+ }
112
+
113
+ if attributes.key?(:'task_id')
114
+ self.task_id = attributes[:'task_id']
115
+ end
116
+
117
+ if attributes.key?(:'combine_additional_charges')
118
+ self.combine_additional_charges = attributes[:'combine_additional_charges']
119
+ else
120
+ self.combine_additional_charges = false
121
+ end
122
+
123
+ if attributes.key?(:'invoice_number')
124
+ self.invoice_number = attributes[:'invoice_number']
125
+ end
126
+
127
+ if attributes.key?(:'memo')
128
+ self.memo = attributes[:'memo']
129
+ end
130
+
131
+ if attributes.key?(:'status')
132
+ self.status = attributes[:'status']
133
+ end
134
+
135
+ if attributes.key?(:'invoice_date')
136
+ self.invoice_date = attributes[:'invoice_date']
137
+ end
138
+
139
+ if attributes.key?(:'invoice_due_date')
140
+ self.invoice_due_date = attributes[:'invoice_due_date']
141
+ end
142
+
143
+ if attributes.key?(:'currency_conversion_rate')
144
+ self.currency_conversion_rate = attributes[:'currency_conversion_rate']
145
+ end
146
+
147
+ if attributes.key?(:'billing_address_line1')
148
+ self.billing_address_line1 = attributes[:'billing_address_line1']
149
+ end
150
+
151
+ if attributes.key?(:'billing_address_line2')
152
+ self.billing_address_line2 = attributes[:'billing_address_line2']
153
+ end
154
+
155
+ if attributes.key?(:'linked_fulfillment_number')
156
+ self.linked_fulfillment_number = attributes[:'linked_fulfillment_number']
157
+ end
158
+
159
+ if attributes.key?(:'lines')
160
+ if (value = attributes[:'lines']).is_a?(Array)
161
+ self.lines = value
162
+ end
163
+ end
164
+
165
+ if attributes.key?(:'additional_charges')
166
+ if (value = attributes[:'additional_charges']).is_a?(Array)
167
+ self.additional_charges = value
168
+ end
169
+ end
170
+ end
171
+
172
+ # Show invalid properties with the reasons. Usually used together with valid?
173
+ # @return Array for valid properties with the reasons
174
+ def list_invalid_properties
175
+ invalid_properties = Array.new
176
+ if @task_id.nil?
177
+ invalid_properties.push('invalid value for "task_id", task_id cannot be nil.')
178
+ end
179
+
180
+ if @status.nil?
181
+ invalid_properties.push('invalid value for "status", status cannot be nil.')
182
+ end
183
+
184
+ if @invoice_date.nil?
185
+ invalid_properties.push('invalid value for "invoice_date", invoice_date cannot be nil.')
186
+ end
187
+
188
+ if @invoice_due_date.nil?
189
+ invalid_properties.push('invalid value for "invoice_due_date", invoice_due_date cannot be nil.')
190
+ end
191
+
192
+ invalid_properties
193
+ end
194
+
195
+ # Check to see if the all the properties in the model are valid
196
+ # @return true if the model is valid
197
+ def valid?
198
+ return false if @task_id.nil?
199
+ return false if @status.nil?
200
+ return false if @invoice_date.nil?
201
+ return false if @invoice_due_date.nil?
202
+ true
203
+ end
204
+
205
+ # Checks equality by comparing each attribute.
206
+ # @param [Object] Object to be compared
207
+ def ==(o)
208
+ return true if self.equal?(o)
209
+ self.class == o.class &&
210
+ task_id == o.task_id &&
211
+ combine_additional_charges == o.combine_additional_charges &&
212
+ invoice_number == o.invoice_number &&
213
+ memo == o.memo &&
214
+ status == o.status &&
215
+ invoice_date == o.invoice_date &&
216
+ invoice_due_date == o.invoice_due_date &&
217
+ currency_conversion_rate == o.currency_conversion_rate &&
218
+ billing_address_line1 == o.billing_address_line1 &&
219
+ billing_address_line2 == o.billing_address_line2 &&
220
+ linked_fulfillment_number == o.linked_fulfillment_number &&
221
+ lines == o.lines &&
222
+ additional_charges == o.additional_charges
223
+ end
224
+
225
+ # @see the `==` method
226
+ # @param [Object] Object to be compared
227
+ def eql?(o)
228
+ self == o
229
+ end
230
+
231
+ # Calculates hash code according to all attributes.
232
+ # @return [Integer] Hash code
233
+ def hash
234
+ [task_id, combine_additional_charges, invoice_number, memo, status, invoice_date, invoice_due_date, currency_conversion_rate, billing_address_line1, billing_address_line2, linked_fulfillment_number, lines, additional_charges].hash
235
+ end
236
+
237
+ # Builds the object from hash
238
+ # @param [Hash] attributes Model attributes in the form of hash
239
+ # @return [Object] Returns the model itself
240
+ def self.build_from_hash(attributes)
241
+ new.build_from_hash(attributes)
242
+ end
243
+
244
+ # Builds the object from hash
245
+ # @param [Hash] attributes Model attributes in the form of hash
246
+ # @return [Object] Returns the model itself
247
+ def build_from_hash(attributes)
248
+ return nil unless attributes.is_a?(Hash)
249
+ self.class.openapi_types.each_pair do |key, type|
250
+ if type =~ /\AArray<(.*)>/i
251
+ # check to ensure the input is an array given that the attribute
252
+ # is documented as an array but the input is not
253
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
254
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
255
+ end
256
+ elsif !attributes[self.class.attribute_map[key]].nil?
257
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
258
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
259
+ end
260
+
261
+ self
262
+ end
263
+
264
+ # Deserializes the data based on type
265
+ # @param string type Data type
266
+ # @param string value Value to be deserialized
267
+ # @return [Object] Deserialized data
268
+ def _deserialize(type, value)
269
+ case type.to_sym
270
+ when :DateTime
271
+ DateTime.parse(value)
272
+ when :Date
273
+ Date.parse(value)
274
+ when :String
275
+ value.to_s
276
+ when :Integer
277
+ value.to_i
278
+ when :Float
279
+ value.to_f
280
+ when :Boolean
281
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
282
+ true
283
+ else
284
+ false
285
+ end
286
+ when :Object
287
+ # generic object (usually a Hash), return directly
288
+ value
289
+ when /\AArray<(?<inner_type>.+)>\z/
290
+ inner_type = Regexp.last_match[:inner_type]
291
+ value.map { |v| _deserialize(inner_type, v) }
292
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
293
+ k_type = Regexp.last_match[:k_type]
294
+ v_type = Regexp.last_match[:v_type]
295
+ {}.tap do |hash|
296
+ value.each do |k, v|
297
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
298
+ end
299
+ end
300
+ else # model
301
+ DearInventoryRuby.const_get(type).build_from_hash(value)
302
+ end
303
+ end
304
+
305
+ # Returns the string representation of the object
306
+ # @return [String] String presentation of the object
307
+ def to_s
308
+ to_hash.to_s
309
+ end
310
+
311
+ # to_body is an alias to to_hash (backward compatibility)
312
+ # @return [Hash] Returns the object in the form of hash
313
+ def to_body
314
+ to_hash
315
+ end
316
+
317
+ # Returns the object in the form of hash
318
+ # @return [Hash] Returns the object in the form of hash
319
+ def to_hash
320
+ hash = {}
321
+ self.class.attribute_map.each_pair do |attr, param|
322
+ value = self.send(attr)
323
+ if value.nil?
324
+ is_nullable = self.class.openapi_nullable.include?(attr)
325
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
326
+ end
327
+
328
+ hash[param] = _to_hash(value)
329
+ end
330
+ hash
331
+ end
332
+
333
+ # Outputs non-array value in the form of hash
334
+ # For object, use to_hash. Otherwise, just return the value
335
+ # @param [Object] value Any valid value
336
+ # @return [Hash] Returns the value in the form of hash
337
+ def _to_hash(value)
338
+ if value.is_a?(Array)
339
+ value.compact.map { |v| _to_hash(v) }
340
+ elsif value.is_a?(Hash)
341
+ {}.tap do |hash|
342
+ value.each { |k, v| hash[k] = _to_hash(v) }
343
+ end
344
+ elsif value.respond_to? :to_hash
345
+ value.to_hash
346
+ else
347
+ value
348
+ end
349
+ end
350
+ end
351
+ end
@@ -32,7 +32,7 @@ module DearInventoryRuby
32
32
  def self.openapi_types
33
33
  {
34
34
  :'sale_id' => :'String',
35
- :'invoices' => :'Array<SaleInvoice>'
35
+ :'invoices' => :'Array<SaleInvoicePartial>'
36
36
  }
37
37
  end
38
38