dear-inventory-ruby 0.1.11 → 0.1.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +21 -0
  3. data/README.md +12 -5
  4. data/docs/Customer.md +1 -1
  5. data/docs/InventoryApi.md +118 -0
  6. data/docs/Me.md +2 -2
  7. data/docs/PriceTier.md +19 -0
  8. data/docs/PriceTiers.md +17 -0
  9. data/docs/SaleInvoice.md +41 -0
  10. data/docs/SaleInvoiceAdditionalCharge.md +33 -0
  11. data/docs/SaleInvoiceLine.md +39 -0
  12. data/docs/SaleInvoices.md +19 -0
  13. data/lib/dear-inventory-ruby.rb +6 -1
  14. data/lib/dear-inventory-ruby/api/inventory_api.rb +117 -0
  15. data/lib/dear-inventory-ruby/models/customer.rb +2 -1
  16. data/lib/dear-inventory-ruby/models/me.rb +4 -2
  17. data/lib/dear-inventory-ruby/models/price_tier.rb +217 -0
  18. data/lib/dear-inventory-ruby/models/price_tiers.rb +209 -0
  19. data/lib/dear-inventory-ruby/models/sale_invoice.rb +356 -0
  20. data/lib/dear-inventory-ruby/models/sale_invoice_additional_charge.rb +317 -0
  21. data/lib/dear-inventory-ruby/models/sale_invoice_line.rb +342 -0
  22. data/lib/dear-inventory-ruby/models/sale_invoices.rb +224 -0
  23. data/lib/dear-inventory-ruby/version.rb +1 -1
  24. data/spec/.DS_Store +0 -0
  25. data/spec/api/inventory_api_spec.rb +23 -0
  26. data/spec/models/price_tier_spec.rb +47 -0
  27. data/spec/models/{weight_unit_spec.rb → price_tiers_spec.rb} +12 -6
  28. data/spec/models/sale_invoice_additional_charge_spec.rb +89 -0
  29. data/spec/models/sale_invoice_line_spec.rb +107 -0
  30. data/spec/models/sale_invoice_spec.rb +113 -0
  31. data/spec/models/sale_invoices_spec.rb +47 -0
  32. metadata +31 -10
  33. data/docs/WeightUnit.md +0 -16
  34. data/lib/dear-inventory-ruby/models/weight_unit.rb +0 -39
@@ -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 SaleInvoiceLine
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
+ # Line Total. For validation
39
+ attr_accessor :total
40
+
41
+ # Average product cost
42
+ attr_accessor :average_cost
43
+
44
+ # Line Tax Rule name.
45
+ attr_accessor :tax_rule
46
+
47
+ # Revenue account
48
+ attr_accessor :account
49
+
50
+ # Comment for this line
51
+ attr_accessor :comment
52
+
53
+ # Attribute mapping from ruby-style variable name to JSON key.
54
+ def self.attribute_map
55
+ {
56
+ :'product_id' => :'ProductID',
57
+ :'sku' => :'SKU',
58
+ :'name' => :'Name',
59
+ :'quantity' => :'Quantity',
60
+ :'price' => :'Price',
61
+ :'discount' => :'Discount',
62
+ :'tax' => :'Tax',
63
+ :'total' => :'Total',
64
+ :'average_cost' => :'AverageCost',
65
+ :'tax_rule' => :'TaxRule',
66
+ :'account' => :'Account',
67
+ :'comment' => :'Comment'
68
+ }
69
+ end
70
+
71
+ # Attribute type mapping.
72
+ def self.openapi_types
73
+ {
74
+ :'product_id' => :'String',
75
+ :'sku' => :'String',
76
+ :'name' => :'String',
77
+ :'quantity' => :'Float',
78
+ :'price' => :'Float',
79
+ :'discount' => :'Float',
80
+ :'tax' => :'Float',
81
+ :'total' => :'Float',
82
+ :'average_cost' => :'Float',
83
+ :'tax_rule' => :'String',
84
+ :'account' => :'String',
85
+ :'comment' => :'String'
86
+ }
87
+ end
88
+
89
+ # List of attributes with nullable: true
90
+ def self.openapi_nullable
91
+ Set.new([
92
+ ])
93
+ end
94
+
95
+ # Initializes the object
96
+ # @param [Hash] attributes Model attributes in the form of hash
97
+ def initialize(attributes = {})
98
+ if (!attributes.is_a?(Hash))
99
+ fail ArgumentError, "The input argument (attributes) must be a hash in `DearInventoryRuby::SaleInvoiceLine` initialize method"
100
+ end
101
+
102
+ # check to see if the attribute exists and convert string to symbol for hash key
103
+ attributes = attributes.each_with_object({}) { |(k, v), h|
104
+ if (!self.class.attribute_map.key?(k.to_sym))
105
+ fail ArgumentError, "`#{k}` is not a valid attribute in `DearInventoryRuby::SaleInvoiceLine`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
106
+ end
107
+ h[k.to_sym] = v
108
+ }
109
+
110
+ if attributes.key?(:'product_id')
111
+ self.product_id = attributes[:'product_id']
112
+ end
113
+
114
+ if attributes.key?(:'sku')
115
+ self.sku = attributes[:'sku']
116
+ end
117
+
118
+ if attributes.key?(:'name')
119
+ self.name = attributes[:'name']
120
+ end
121
+
122
+ if attributes.key?(:'quantity')
123
+ self.quantity = attributes[:'quantity']
124
+ end
125
+
126
+ if attributes.key?(:'price')
127
+ self.price = attributes[:'price']
128
+ end
129
+
130
+ if attributes.key?(:'discount')
131
+ self.discount = attributes[:'discount']
132
+ end
133
+
134
+ if attributes.key?(:'tax')
135
+ self.tax = attributes[:'tax']
136
+ end
137
+
138
+ if attributes.key?(:'total')
139
+ self.total = attributes[:'total']
140
+ end
141
+
142
+ if attributes.key?(:'average_cost')
143
+ self.average_cost = attributes[:'average_cost']
144
+ end
145
+
146
+ if attributes.key?(:'tax_rule')
147
+ self.tax_rule = attributes[:'tax_rule']
148
+ end
149
+
150
+ if attributes.key?(:'account')
151
+ self.account = attributes[:'account']
152
+ end
153
+
154
+ if attributes.key?(:'comment')
155
+ self.comment = attributes[:'comment']
156
+ end
157
+ end
158
+
159
+ # Show invalid properties with the reasons. Usually used together with valid?
160
+ # @return Array for valid properties with the reasons
161
+ def list_invalid_properties
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
+ if @name.nil?
172
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
173
+ end
174
+
175
+ if @quantity.nil?
176
+ invalid_properties.push('invalid value for "quantity", quantity cannot be nil.')
177
+ end
178
+
179
+ if @price.nil?
180
+ invalid_properties.push('invalid value for "price", price cannot be nil.')
181
+ end
182
+
183
+ invalid_properties
184
+ end
185
+
186
+ # Check to see if the all the properties in the model are valid
187
+ # @return true if the model is valid
188
+ def valid?
189
+ return false if @product_id.nil?
190
+ return false if @sku.nil?
191
+ return false if @name.nil?
192
+ return false if @quantity.nil?
193
+ return false if @price.nil?
194
+ true
195
+ end
196
+
197
+ # Checks equality by comparing each attribute.
198
+ # @param [Object] Object to be compared
199
+ def ==(o)
200
+ return true if self.equal?(o)
201
+ self.class == o.class &&
202
+ product_id == o.product_id &&
203
+ sku == o.sku &&
204
+ name == o.name &&
205
+ quantity == o.quantity &&
206
+ price == o.price &&
207
+ discount == o.discount &&
208
+ tax == o.tax &&
209
+ total == o.total &&
210
+ average_cost == o.average_cost &&
211
+ tax_rule == o.tax_rule &&
212
+ account == o.account &&
213
+ comment == o.comment
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, total, average_cost, tax_rule, account, comment].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,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 SaleInvoices
17
+ # Unique DEAR Sale ID
18
+ attr_accessor :sale_id
19
+
20
+ # Array of Invoices
21
+ attr_accessor :invoices
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :'sale_id' => :'SaleID',
27
+ :'invoices' => :'Invoices'
28
+ }
29
+ end
30
+
31
+ # Attribute type mapping.
32
+ def self.openapi_types
33
+ {
34
+ :'sale_id' => :'String',
35
+ :'invoices' => :'Array<SaleInvoice>'
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::SaleInvoices` 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::SaleInvoices`. 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?(:'sale_id')
61
+ self.sale_id = attributes[:'sale_id']
62
+ end
63
+
64
+ if attributes.key?(:'invoices')
65
+ if (value = attributes[:'invoices']).is_a?(Array)
66
+ self.invoices = value
67
+ end
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 @sale_id.nil?
76
+ invalid_properties.push('invalid value for "sale_id", sale_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 @sale_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
+ sale_id == o.sale_id &&
95
+ invoices == o.invoices
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
+ [sale_id, invoices].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