dear-inventory-ruby 0.1.18 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +30 -10
  3. data/README.md +32 -5
  4. data/docs/Address.md +10 -12
  5. data/docs/Customer.md +1 -1
  6. data/docs/ExternalHeader.md +19 -0
  7. data/docs/InventoryApi.md +1021 -161
  8. data/docs/SaleAdditionalCharge.md +31 -0
  9. data/docs/SaleInvoice.md +1 -1
  10. data/docs/SaleInvoiceAdditionalCharge.md +3 -3
  11. data/docs/SaleInvoiceDelete.md +19 -0
  12. data/docs/SaleInvoiceLine.md +2 -2
  13. data/docs/SaleInvoicePost.md +41 -0
  14. data/docs/SaleOrder.md +35 -0
  15. data/docs/SaleOrderLine.md +41 -0
  16. data/docs/SalePayment.md +43 -0
  17. data/docs/SaleQuote.md +33 -0
  18. data/docs/SaleQuoteLine.md +37 -0
  19. data/docs/ShippingAddress.md +37 -0
  20. data/docs/SupplierCustomerAddress.md +33 -0
  21. data/docs/Webhook.md +35 -0
  22. data/docs/Webhooks.md +17 -0
  23. data/lib/dear-inventory-ruby/api/inventory_api.rb +988 -119
  24. data/lib/dear-inventory-ruby/models/address.rb +28 -115
  25. data/lib/dear-inventory-ruby/models/customer.rb +1 -1
  26. data/lib/dear-inventory-ruby/models/external_header.rb +217 -0
  27. data/lib/dear-inventory-ruby/models/sale_additional_charge.rb +302 -0
  28. data/lib/dear-inventory-ruby/models/sale_invoice.rb +1 -1
  29. data/lib/dear-inventory-ruby/models/sale_invoice_additional_charge.rb +3 -3
  30. data/lib/dear-inventory-ruby/models/sale_invoice_delete.rb +224 -0
  31. data/lib/dear-inventory-ruby/models/sale_invoice_line.rb +0 -10
  32. data/lib/dear-inventory-ruby/models/sale_invoice_post.rb +361 -0
  33. data/lib/dear-inventory-ruby/models/sale_order.rb +336 -0
  34. data/lib/dear-inventory-ruby/models/sale_order_line.rb +342 -0
  35. data/lib/dear-inventory-ruby/models/sale_payment.rb +337 -0
  36. data/lib/dear-inventory-ruby/models/sale_quote.rb +326 -0
  37. data/lib/dear-inventory-ruby/models/sale_quote_line.rb +322 -0
  38. data/lib/dear-inventory-ruby/models/shipping_address.rb +317 -0
  39. data/lib/dear-inventory-ruby/models/supplier_customer_address.rb +374 -0
  40. data/lib/dear-inventory-ruby/models/webhook.rb +319 -0
  41. data/lib/dear-inventory-ruby/models/webhooks.rb +209 -0
  42. data/lib/dear-inventory-ruby/version.rb +1 -1
  43. data/lib/dear-inventory-ruby.rb +13 -0
  44. data/spec/api/inventory_api_spec.rb +166 -0
  45. data/spec/models/address_spec.rb +7 -13
  46. data/spec/models/external_header_spec.rb +47 -0
  47. data/spec/models/sale_additional_charge_spec.rb +83 -0
  48. data/spec/models/sale_invoice_delete_spec.rb +47 -0
  49. data/spec/models/sale_invoice_post_spec.rb +113 -0
  50. data/spec/models/sale_order_line_spec.rb +113 -0
  51. data/spec/models/sale_order_spec.rb +95 -0
  52. data/spec/models/sale_payment_spec.rb +119 -0
  53. data/spec/models/sale_quote_line_spec.rb +101 -0
  54. data/spec/models/sale_quote_spec.rb +89 -0
  55. data/spec/models/shipping_address_spec.rb +101 -0
  56. data/spec/models/supplier_customer_address_spec.rb +89 -0
  57. data/spec/models/webhook_spec.rb +95 -0
  58. data/spec/models/webhooks_spec.rb +41 -0
  59. metadata +55 -4
  60. data/spec/.DS_Store +0 -0
@@ -0,0 +1,302 @@
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 SaleAdditionalCharge
17
+ # Name of Service Product referenced by this Line
18
+ attr_accessor :description
19
+
20
+ # Decimal with up to 4 decimal places. Price per unit in Customer currency
21
+ attr_accessor :price
22
+
23
+ # Decimal with up to 4 decimal places. Product or service quantity. Minimal value is 1.
24
+ attr_accessor :quantity
25
+
26
+ # Decimal with up to 2 decimal places. Discount. Value between 0 and 100. For free items discount is 100. Default value is 0
27
+ attr_accessor :discount
28
+
29
+ # Decimal with up to 4 decimal places. Tax.
30
+ attr_accessor :tax
31
+
32
+ # Decimal with up to 4 decimal places. Line Total. For validation
33
+ attr_accessor :total
34
+
35
+ # Line Tax Rule name.
36
+ attr_accessor :tax_rule
37
+
38
+ # Comment
39
+ attr_accessor :comment
40
+
41
+ # Attribute mapping from ruby-style variable name to JSON key.
42
+ def self.attribute_map
43
+ {
44
+ :'description' => :'Description',
45
+ :'price' => :'Price',
46
+ :'quantity' => :'Quantity',
47
+ :'discount' => :'Discount',
48
+ :'tax' => :'Tax',
49
+ :'total' => :'Total',
50
+ :'tax_rule' => :'TaxRule',
51
+ :'comment' => :'Comment'
52
+ }
53
+ end
54
+
55
+ # Attribute type mapping.
56
+ def self.openapi_types
57
+ {
58
+ :'description' => :'String',
59
+ :'price' => :'Float',
60
+ :'quantity' => :'Float',
61
+ :'discount' => :'Float',
62
+ :'tax' => :'Float',
63
+ :'total' => :'Float',
64
+ :'tax_rule' => :'String',
65
+ :'comment' => :'Float'
66
+ }
67
+ end
68
+
69
+ # List of attributes with nullable: true
70
+ def self.openapi_nullable
71
+ Set.new([
72
+ ])
73
+ end
74
+
75
+ # Initializes the object
76
+ # @param [Hash] attributes Model attributes in the form of hash
77
+ def initialize(attributes = {})
78
+ if (!attributes.is_a?(Hash))
79
+ fail ArgumentError, "The input argument (attributes) must be a hash in `DearInventoryRuby::SaleAdditionalCharge` initialize method"
80
+ end
81
+
82
+ # check to see if the attribute exists and convert string to symbol for hash key
83
+ attributes = attributes.each_with_object({}) { |(k, v), h|
84
+ if (!self.class.attribute_map.key?(k.to_sym))
85
+ fail ArgumentError, "`#{k}` is not a valid attribute in `DearInventoryRuby::SaleAdditionalCharge`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
86
+ end
87
+ h[k.to_sym] = v
88
+ }
89
+
90
+ if attributes.key?(:'description')
91
+ self.description = attributes[:'description']
92
+ end
93
+
94
+ if attributes.key?(:'price')
95
+ self.price = attributes[:'price']
96
+ end
97
+
98
+ if attributes.key?(:'quantity')
99
+ self.quantity = attributes[:'quantity']
100
+ end
101
+
102
+ if attributes.key?(:'discount')
103
+ self.discount = attributes[:'discount']
104
+ end
105
+
106
+ if attributes.key?(:'tax')
107
+ self.tax = attributes[:'tax']
108
+ end
109
+
110
+ if attributes.key?(:'total')
111
+ self.total = attributes[:'total']
112
+ end
113
+
114
+ if attributes.key?(:'tax_rule')
115
+ self.tax_rule = attributes[:'tax_rule']
116
+ end
117
+
118
+ if attributes.key?(:'comment')
119
+ self.comment = attributes[:'comment']
120
+ end
121
+ end
122
+
123
+ # Show invalid properties with the reasons. Usually used together with valid?
124
+ # @return Array for valid properties with the reasons
125
+ def list_invalid_properties
126
+ invalid_properties = Array.new
127
+ if @description.nil?
128
+ invalid_properties.push('invalid value for "description", description cannot be nil.')
129
+ end
130
+
131
+ if @price.nil?
132
+ invalid_properties.push('invalid value for "price", price cannot be nil.')
133
+ end
134
+
135
+ if @quantity.nil?
136
+ invalid_properties.push('invalid value for "quantity", quantity cannot be nil.')
137
+ end
138
+
139
+ if @tax.nil?
140
+ invalid_properties.push('invalid value for "tax", tax cannot be nil.')
141
+ end
142
+
143
+ if @tax_rule.nil?
144
+ invalid_properties.push('invalid value for "tax_rule", tax_rule cannot be nil.')
145
+ end
146
+
147
+ invalid_properties
148
+ end
149
+
150
+ # Check to see if the all the properties in the model are valid
151
+ # @return true if the model is valid
152
+ def valid?
153
+ return false if @description.nil?
154
+ return false if @price.nil?
155
+ return false if @quantity.nil?
156
+ return false if @tax.nil?
157
+ return false if @tax_rule.nil?
158
+ true
159
+ end
160
+
161
+ # Checks equality by comparing each attribute.
162
+ # @param [Object] Object to be compared
163
+ def ==(o)
164
+ return true if self.equal?(o)
165
+ self.class == o.class &&
166
+ description == o.description &&
167
+ price == o.price &&
168
+ quantity == o.quantity &&
169
+ discount == o.discount &&
170
+ tax == o.tax &&
171
+ total == o.total &&
172
+ tax_rule == o.tax_rule &&
173
+ comment == o.comment
174
+ end
175
+
176
+ # @see the `==` method
177
+ # @param [Object] Object to be compared
178
+ def eql?(o)
179
+ self == o
180
+ end
181
+
182
+ # Calculates hash code according to all attributes.
183
+ # @return [Integer] Hash code
184
+ def hash
185
+ [description, price, quantity, discount, tax, total, tax_rule, comment].hash
186
+ end
187
+
188
+ # Builds the object from hash
189
+ # @param [Hash] attributes Model attributes in the form of hash
190
+ # @return [Object] Returns the model itself
191
+ def self.build_from_hash(attributes)
192
+ new.build_from_hash(attributes)
193
+ end
194
+
195
+ # Builds the object from hash
196
+ # @param [Hash] attributes Model attributes in the form of hash
197
+ # @return [Object] Returns the model itself
198
+ def build_from_hash(attributes)
199
+ return nil unless attributes.is_a?(Hash)
200
+ self.class.openapi_types.each_pair do |key, type|
201
+ if type =~ /\AArray<(.*)>/i
202
+ # check to ensure the input is an array given that the attribute
203
+ # is documented as an array but the input is not
204
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
205
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
206
+ end
207
+ elsif !attributes[self.class.attribute_map[key]].nil?
208
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
209
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
210
+ end
211
+
212
+ self
213
+ end
214
+
215
+ # Deserializes the data based on type
216
+ # @param string type Data type
217
+ # @param string value Value to be deserialized
218
+ # @return [Object] Deserialized data
219
+ def _deserialize(type, value)
220
+ case type.to_sym
221
+ when :DateTime
222
+ DateTime.parse(value)
223
+ when :Date
224
+ Date.parse(value)
225
+ when :String
226
+ value.to_s
227
+ when :Integer
228
+ value.to_i
229
+ when :Float
230
+ value.to_f
231
+ when :Boolean
232
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
233
+ true
234
+ else
235
+ false
236
+ end
237
+ when :Object
238
+ # generic object (usually a Hash), return directly
239
+ value
240
+ when /\AArray<(?<inner_type>.+)>\z/
241
+ inner_type = Regexp.last_match[:inner_type]
242
+ value.map { |v| _deserialize(inner_type, v) }
243
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
244
+ k_type = Regexp.last_match[:k_type]
245
+ v_type = Regexp.last_match[:v_type]
246
+ {}.tap do |hash|
247
+ value.each do |k, v|
248
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
249
+ end
250
+ end
251
+ else # model
252
+ DearInventoryRuby.const_get(type).build_from_hash(value)
253
+ end
254
+ end
255
+
256
+ # Returns the string representation of the object
257
+ # @return [String] String presentation of the object
258
+ def to_s
259
+ to_hash.to_s
260
+ end
261
+
262
+ # to_body is an alias to to_hash (backward compatibility)
263
+ # @return [Hash] Returns the object in the form of hash
264
+ def to_body
265
+ to_hash
266
+ end
267
+
268
+ # Returns the object in the form of hash
269
+ # @return [Hash] Returns the object in the form of hash
270
+ def to_hash
271
+ hash = {}
272
+ self.class.attribute_map.each_pair do |attr, param|
273
+ value = self.send(attr)
274
+ if value.nil?
275
+ is_nullable = self.class.openapi_nullable.include?(attr)
276
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
277
+ end
278
+
279
+ hash[param] = _to_hash(value)
280
+ end
281
+ hash
282
+ end
283
+
284
+ # Outputs non-array value in the form of hash
285
+ # For object, use to_hash. Otherwise, just return the value
286
+ # @param [Object] value Any valid value
287
+ # @return [Hash] Returns the value in the form of hash
288
+ def _to_hash(value)
289
+ if value.is_a?(Array)
290
+ value.compact.map { |v| _to_hash(v) }
291
+ elsif value.is_a?(Hash)
292
+ {}.tap do |hash|
293
+ value.each { |k, v| hash[k] = _to_hash(v) }
294
+ end
295
+ elsif value.respond_to? :to_hash
296
+ value.to_hash
297
+ else
298
+ value
299
+ end
300
+ end
301
+ end
302
+ end
@@ -17,7 +17,7 @@ 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
20
+ # If `true` then `additional charges` lines displayed in `Lines` array
21
21
  attr_accessor :combine_additional_charges
22
22
 
23
23
  # Invoice Number (auto-generated)
@@ -65,9 +65,9 @@ module DearInventoryRuby
65
65
  :'discount' => :'Float',
66
66
  :'tax' => :'Float',
67
67
  :'total' => :'Float',
68
- :'tax_rule' => :'Float',
69
- :'account' => :'Float',
70
- :'comment' => :'Float'
68
+ :'tax_rule' => :'String',
69
+ :'account' => :'String',
70
+ :'comment' => :'String'
71
71
  }
72
72
  end
73
73
 
@@ -0,0 +1,224 @@
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 SaleInvoiceDelete
17
+ # ID of Sale task to Void or Undo
18
+ attr_accessor :task_id
19
+
20
+ # Default false
21
+ attr_accessor :void
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :'task_id' => :'TaskID',
27
+ :'void' => :'Void'
28
+ }
29
+ end
30
+
31
+ # Attribute type mapping.
32
+ def self.openapi_types
33
+ {
34
+ :'task_id' => :'String',
35
+ :'void' => :'Boolean'
36
+ }
37
+ end
38
+
39
+ # List of attributes with nullable: true
40
+ def self.openapi_nullable
41
+ Set.new([
42
+ ])
43
+ end
44
+
45
+ # Initializes the object
46
+ # @param [Hash] attributes Model attributes in the form of hash
47
+ def initialize(attributes = {})
48
+ if (!attributes.is_a?(Hash))
49
+ fail ArgumentError, "The input argument (attributes) must be a hash in `DearInventoryRuby::SaleInvoiceDelete` initialize method"
50
+ end
51
+
52
+ # check to see if the attribute exists and convert string to symbol for hash key
53
+ attributes = attributes.each_with_object({}) { |(k, v), h|
54
+ if (!self.class.attribute_map.key?(k.to_sym))
55
+ fail ArgumentError, "`#{k}` is not a valid attribute in `DearInventoryRuby::SaleInvoiceDelete`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
56
+ end
57
+ h[k.to_sym] = v
58
+ }
59
+
60
+ if attributes.key?(:'task_id')
61
+ self.task_id = attributes[:'task_id']
62
+ end
63
+
64
+ if attributes.key?(:'void')
65
+ self.void = attributes[:'void']
66
+ else
67
+ self.void = false
68
+ end
69
+ end
70
+
71
+ # Show invalid properties with the reasons. Usually used together with valid?
72
+ # @return Array for valid properties with the reasons
73
+ def list_invalid_properties
74
+ invalid_properties = Array.new
75
+ if @task_id.nil?
76
+ invalid_properties.push('invalid value for "task_id", task_id cannot be nil.')
77
+ end
78
+
79
+ invalid_properties
80
+ end
81
+
82
+ # Check to see if the all the properties in the model are valid
83
+ # @return true if the model is valid
84
+ def valid?
85
+ return false if @task_id.nil?
86
+ true
87
+ end
88
+
89
+ # Checks equality by comparing each attribute.
90
+ # @param [Object] Object to be compared
91
+ def ==(o)
92
+ return true if self.equal?(o)
93
+ self.class == o.class &&
94
+ task_id == o.task_id &&
95
+ void == o.void
96
+ end
97
+
98
+ # @see the `==` method
99
+ # @param [Object] Object to be compared
100
+ def eql?(o)
101
+ self == o
102
+ end
103
+
104
+ # Calculates hash code according to all attributes.
105
+ # @return [Integer] Hash code
106
+ def hash
107
+ [task_id, void].hash
108
+ end
109
+
110
+ # Builds the object from hash
111
+ # @param [Hash] attributes Model attributes in the form of hash
112
+ # @return [Object] Returns the model itself
113
+ def self.build_from_hash(attributes)
114
+ new.build_from_hash(attributes)
115
+ end
116
+
117
+ # Builds the object from hash
118
+ # @param [Hash] attributes Model attributes in the form of hash
119
+ # @return [Object] Returns the model itself
120
+ def build_from_hash(attributes)
121
+ return nil unless attributes.is_a?(Hash)
122
+ self.class.openapi_types.each_pair do |key, type|
123
+ if type =~ /\AArray<(.*)>/i
124
+ # check to ensure the input is an array given that the attribute
125
+ # is documented as an array but the input is not
126
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
127
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
128
+ end
129
+ elsif !attributes[self.class.attribute_map[key]].nil?
130
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
131
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
132
+ end
133
+
134
+ self
135
+ end
136
+
137
+ # Deserializes the data based on type
138
+ # @param string type Data type
139
+ # @param string value Value to be deserialized
140
+ # @return [Object] Deserialized data
141
+ def _deserialize(type, value)
142
+ case type.to_sym
143
+ when :DateTime
144
+ DateTime.parse(value)
145
+ when :Date
146
+ Date.parse(value)
147
+ when :String
148
+ value.to_s
149
+ when :Integer
150
+ value.to_i
151
+ when :Float
152
+ value.to_f
153
+ when :Boolean
154
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
155
+ true
156
+ else
157
+ false
158
+ end
159
+ when :Object
160
+ # generic object (usually a Hash), return directly
161
+ value
162
+ when /\AArray<(?<inner_type>.+)>\z/
163
+ inner_type = Regexp.last_match[:inner_type]
164
+ value.map { |v| _deserialize(inner_type, v) }
165
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
166
+ k_type = Regexp.last_match[:k_type]
167
+ v_type = Regexp.last_match[:v_type]
168
+ {}.tap do |hash|
169
+ value.each do |k, v|
170
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
171
+ end
172
+ end
173
+ else # model
174
+ DearInventoryRuby.const_get(type).build_from_hash(value)
175
+ end
176
+ end
177
+
178
+ # Returns the string representation of the object
179
+ # @return [String] String presentation of the object
180
+ def to_s
181
+ to_hash.to_s
182
+ end
183
+
184
+ # to_body is an alias to to_hash (backward compatibility)
185
+ # @return [Hash] Returns the object in the form of hash
186
+ def to_body
187
+ to_hash
188
+ end
189
+
190
+ # Returns the object in the form of hash
191
+ # @return [Hash] Returns the object in the form of hash
192
+ def to_hash
193
+ hash = {}
194
+ self.class.attribute_map.each_pair do |attr, param|
195
+ value = self.send(attr)
196
+ if value.nil?
197
+ is_nullable = self.class.openapi_nullable.include?(attr)
198
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
199
+ end
200
+
201
+ hash[param] = _to_hash(value)
202
+ end
203
+ hash
204
+ end
205
+
206
+ # Outputs non-array value in the form of hash
207
+ # For object, use to_hash. Otherwise, just return the value
208
+ # @param [Object] value Any valid value
209
+ # @return [Hash] Returns the value in the form of hash
210
+ def _to_hash(value)
211
+ if value.is_a?(Array)
212
+ value.compact.map { |v| _to_hash(v) }
213
+ elsif value.is_a?(Hash)
214
+ {}.tap do |hash|
215
+ value.each { |k, v| hash[k] = _to_hash(v) }
216
+ end
217
+ elsif value.respond_to? :to_hash
218
+ value.to_hash
219
+ else
220
+ value
221
+ end
222
+ end
223
+ end
224
+ end
@@ -160,14 +160,6 @@ module DearInventoryRuby
160
160
  # @return Array for valid properties with the reasons
161
161
  def list_invalid_properties
162
162
  invalid_properties = Array.new
163
- if @product_id.nil?
164
- invalid_properties.push('invalid value for "product_id", product_id cannot be nil.')
165
- end
166
-
167
- if @sku.nil?
168
- invalid_properties.push('invalid value for "sku", sku cannot be nil.')
169
- end
170
-
171
163
  if @name.nil?
172
164
  invalid_properties.push('invalid value for "name", name cannot be nil.')
173
165
  end
@@ -186,8 +178,6 @@ module DearInventoryRuby
186
178
  # Check to see if the all the properties in the model are valid
187
179
  # @return true if the model is valid
188
180
  def valid?
189
- return false if @product_id.nil?
190
- return false if @sku.nil?
191
181
  return false if @name.nil?
192
182
  return false if @quantity.nil?
193
183
  return false if @price.nil?