dear-inventory-ruby 0.2.9 → 0.2.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -0
  3. data/README.md +14 -4
  4. data/docs/Bin.md +19 -0
  5. data/docs/Carrier.md +19 -0
  6. data/docs/Carriers.md +21 -0
  7. data/docs/InventoryApi.md +192 -4
  8. data/docs/Location.md +51 -0
  9. data/docs/Locations.md +21 -0
  10. data/docs/MeContact.md +33 -0
  11. data/docs/MeContacts.md +21 -0
  12. data/lib/dear-inventory-ruby/api/inventory_api.rb +193 -4
  13. data/lib/dear-inventory-ruby/models/account.rb +0 -76
  14. data/lib/dear-inventory-ruby/models/bin.rb +217 -0
  15. data/lib/dear-inventory-ruby/models/carrier.rb +217 -0
  16. data/lib/dear-inventory-ruby/models/carriers.rb +229 -0
  17. data/lib/dear-inventory-ruby/models/contact.rb +0 -94
  18. data/lib/dear-inventory-ruby/models/customer.rb +0 -34
  19. data/lib/dear-inventory-ruby/models/location.rb +391 -0
  20. data/lib/dear-inventory-ruby/models/locations.rb +229 -0
  21. data/lib/dear-inventory-ruby/models/me_contact.rb +289 -0
  22. data/lib/dear-inventory-ruby/models/me_contacts.rb +229 -0
  23. data/lib/dear-inventory-ruby/models/payment_term.rb +0 -19
  24. data/lib/dear-inventory-ruby/models/supplier_customer_address.rb +0 -75
  25. data/lib/dear-inventory-ruby/models/tax_component.rb +0 -19
  26. data/lib/dear-inventory-ruby/version.rb +1 -1
  27. data/lib/dear-inventory-ruby.rb +7 -0
  28. data/spec/.DS_Store +0 -0
  29. data/spec/api/inventory_api_spec.rb +41 -2
  30. data/spec/models/bin_spec.rb +47 -0
  31. data/spec/models/carrier_spec.rb +47 -0
  32. data/spec/models/carriers_spec.rb +53 -0
  33. data/spec/models/location_spec.rb +143 -0
  34. data/spec/models/locations_spec.rb +53 -0
  35. data/spec/models/me_contact_spec.rb +89 -0
  36. data/spec/models/me_contacts_spec.rb +53 -0
  37. metadata +30 -2
@@ -0,0 +1,391 @@
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 Location
17
+ # Required for `PUT` and `DELETE`, Ignored for `POST` operations
18
+ attr_accessor :id
19
+
20
+ # Location name
21
+ attr_accessor :name
22
+
23
+ # Points that location is used as default
24
+ attr_accessor :is_default
25
+
26
+ # Points that location is deprecated
27
+ attr_accessor :deprecated
28
+
29
+ # Array (ID, Name) with related Bins
30
+ attr_accessor :bins
31
+
32
+ # Points that location is used as Fixed Asset
33
+ attr_accessor :fixed_assets_location
34
+
35
+ # Parent ID (used for Bins)
36
+ attr_accessor :parent_id
37
+
38
+ # Reference linked to current location
39
+ attr_accessor :reference_count
40
+
41
+ # Address line
42
+ attr_accessor :address_line1
43
+
44
+ # Address line second
45
+ attr_accessor :address_line2
46
+
47
+ # City suburb
48
+ attr_accessor :address_city_suburb
49
+
50
+ # State province
51
+ attr_accessor :address_state_province
52
+
53
+ # Zip post code
54
+ attr_accessor :address_zip_post_code
55
+
56
+ # Country
57
+ attr_accessor :address_country
58
+
59
+ # Pick zones
60
+ attr_accessor :pick_zones
61
+
62
+ # Points that location is shopfloor
63
+ attr_accessor :is_shopfloor
64
+
65
+ # Points that location is location of co-manufacturer
66
+ attr_accessor :is_co_man
67
+
68
+ # Points that location is staging. It is used only for Bins
69
+ attr_accessor :is_staging
70
+
71
+ # Attribute mapping from ruby-style variable name to JSON key.
72
+ def self.attribute_map
73
+ {
74
+ :'id' => :'ID',
75
+ :'name' => :'Name',
76
+ :'is_default' => :'IsDefault',
77
+ :'deprecated' => :'Deprecated',
78
+ :'bins' => :'Bins',
79
+ :'fixed_assets_location' => :'FixedAssetsLocation',
80
+ :'parent_id' => :'ParentID',
81
+ :'reference_count' => :'ReferenceCount',
82
+ :'address_line1' => :'AddressLine1',
83
+ :'address_line2' => :'AddressLine2',
84
+ :'address_city_suburb' => :'AddressCitySuburb',
85
+ :'address_state_province' => :'AddressStateProvince',
86
+ :'address_zip_post_code' => :'AddressZipPostCode',
87
+ :'address_country' => :'AddressCountry',
88
+ :'pick_zones' => :'PickZones',
89
+ :'is_shopfloor' => :'IsShopfloor',
90
+ :'is_co_man' => :'IsCoMan',
91
+ :'is_staging' => :'IsStaging'
92
+ }
93
+ end
94
+
95
+ # Attribute type mapping.
96
+ def self.openapi_types
97
+ {
98
+ :'id' => :'String',
99
+ :'name' => :'String',
100
+ :'is_default' => :'Boolean',
101
+ :'deprecated' => :'Boolean',
102
+ :'bins' => :'Array<Bin>',
103
+ :'fixed_assets_location' => :'Boolean',
104
+ :'parent_id' => :'String',
105
+ :'reference_count' => :'Integer',
106
+ :'address_line1' => :'String',
107
+ :'address_line2' => :'String',
108
+ :'address_city_suburb' => :'String',
109
+ :'address_state_province' => :'String',
110
+ :'address_zip_post_code' => :'String',
111
+ :'address_country' => :'String',
112
+ :'pick_zones' => :'String',
113
+ :'is_shopfloor' => :'Boolean',
114
+ :'is_co_man' => :'Boolean',
115
+ :'is_staging' => :'Boolean'
116
+ }
117
+ end
118
+
119
+ # List of attributes with nullable: true
120
+ def self.openapi_nullable
121
+ Set.new([
122
+ ])
123
+ end
124
+
125
+ # Initializes the object
126
+ # @param [Hash] attributes Model attributes in the form of hash
127
+ def initialize(attributes = {})
128
+ if (!attributes.is_a?(Hash))
129
+ fail ArgumentError, "The input argument (attributes) must be a hash in `DearInventoryRuby::Location` initialize method"
130
+ end
131
+
132
+ # check to see if the attribute exists and convert string to symbol for hash key
133
+ attributes = attributes.each_with_object({}) { |(k, v), h|
134
+ if (!self.class.attribute_map.key?(k.to_sym))
135
+ fail ArgumentError, "`#{k}` is not a valid attribute in `DearInventoryRuby::Location`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
136
+ end
137
+ h[k.to_sym] = v
138
+ }
139
+
140
+ if attributes.key?(:'id')
141
+ self.id = attributes[:'id']
142
+ end
143
+
144
+ if attributes.key?(:'name')
145
+ self.name = attributes[:'name']
146
+ end
147
+
148
+ if attributes.key?(:'is_default')
149
+ self.is_default = attributes[:'is_default']
150
+ else
151
+ self.is_default = false
152
+ end
153
+
154
+ if attributes.key?(:'deprecated')
155
+ self.deprecated = attributes[:'deprecated']
156
+ else
157
+ self.deprecated = false
158
+ end
159
+
160
+ if attributes.key?(:'bins')
161
+ if (value = attributes[:'bins']).is_a?(Array)
162
+ self.bins = value
163
+ end
164
+ end
165
+
166
+ if attributes.key?(:'fixed_assets_location')
167
+ self.fixed_assets_location = attributes[:'fixed_assets_location']
168
+ else
169
+ self.fixed_assets_location = false
170
+ end
171
+
172
+ if attributes.key?(:'parent_id')
173
+ self.parent_id = attributes[:'parent_id']
174
+ end
175
+
176
+ if attributes.key?(:'reference_count')
177
+ self.reference_count = attributes[:'reference_count']
178
+ end
179
+
180
+ if attributes.key?(:'address_line1')
181
+ self.address_line1 = attributes[:'address_line1']
182
+ end
183
+
184
+ if attributes.key?(:'address_line2')
185
+ self.address_line2 = attributes[:'address_line2']
186
+ end
187
+
188
+ if attributes.key?(:'address_city_suburb')
189
+ self.address_city_suburb = attributes[:'address_city_suburb']
190
+ end
191
+
192
+ if attributes.key?(:'address_state_province')
193
+ self.address_state_province = attributes[:'address_state_province']
194
+ end
195
+
196
+ if attributes.key?(:'address_zip_post_code')
197
+ self.address_zip_post_code = attributes[:'address_zip_post_code']
198
+ end
199
+
200
+ if attributes.key?(:'address_country')
201
+ self.address_country = attributes[:'address_country']
202
+ end
203
+
204
+ if attributes.key?(:'pick_zones')
205
+ self.pick_zones = attributes[:'pick_zones']
206
+ end
207
+
208
+ if attributes.key?(:'is_shopfloor')
209
+ self.is_shopfloor = attributes[:'is_shopfloor']
210
+ else
211
+ self.is_shopfloor = false
212
+ end
213
+
214
+ if attributes.key?(:'is_co_man')
215
+ self.is_co_man = attributes[:'is_co_man']
216
+ else
217
+ self.is_co_man = false
218
+ end
219
+
220
+ if attributes.key?(:'is_staging')
221
+ self.is_staging = attributes[:'is_staging']
222
+ else
223
+ self.is_staging = false
224
+ end
225
+ end
226
+
227
+ # Show invalid properties with the reasons. Usually used together with valid?
228
+ # @return Array for valid properties with the reasons
229
+ def list_invalid_properties
230
+ invalid_properties = Array.new
231
+ invalid_properties
232
+ end
233
+
234
+ # Check to see if the all the properties in the model are valid
235
+ # @return true if the model is valid
236
+ def valid?
237
+ true
238
+ end
239
+
240
+ # Checks equality by comparing each attribute.
241
+ # @param [Object] Object to be compared
242
+ def ==(o)
243
+ return true if self.equal?(o)
244
+ self.class == o.class &&
245
+ id == o.id &&
246
+ name == o.name &&
247
+ is_default == o.is_default &&
248
+ deprecated == o.deprecated &&
249
+ bins == o.bins &&
250
+ fixed_assets_location == o.fixed_assets_location &&
251
+ parent_id == o.parent_id &&
252
+ reference_count == o.reference_count &&
253
+ address_line1 == o.address_line1 &&
254
+ address_line2 == o.address_line2 &&
255
+ address_city_suburb == o.address_city_suburb &&
256
+ address_state_province == o.address_state_province &&
257
+ address_zip_post_code == o.address_zip_post_code &&
258
+ address_country == o.address_country &&
259
+ pick_zones == o.pick_zones &&
260
+ is_shopfloor == o.is_shopfloor &&
261
+ is_co_man == o.is_co_man &&
262
+ is_staging == o.is_staging
263
+ end
264
+
265
+ # @see the `==` method
266
+ # @param [Object] Object to be compared
267
+ def eql?(o)
268
+ self == o
269
+ end
270
+
271
+ # Calculates hash code according to all attributes.
272
+ # @return [Integer] Hash code
273
+ def hash
274
+ [id, name, is_default, deprecated, bins, fixed_assets_location, parent_id, reference_count, address_line1, address_line2, address_city_suburb, address_state_province, address_zip_post_code, address_country, pick_zones, is_shopfloor, is_co_man, is_staging].hash
275
+ end
276
+
277
+ # Builds the object from hash
278
+ # @param [Hash] attributes Model attributes in the form of hash
279
+ # @return [Object] Returns the model itself
280
+ def self.build_from_hash(attributes)
281
+ new.build_from_hash(attributes)
282
+ end
283
+
284
+ # Builds the object from hash
285
+ # @param [Hash] attributes Model attributes in the form of hash
286
+ # @return [Object] Returns the model itself
287
+ def build_from_hash(attributes)
288
+ return nil unless attributes.is_a?(Hash)
289
+ self.class.openapi_types.each_pair do |key, type|
290
+ if type =~ /\AArray<(.*)>/i
291
+ # check to ensure the input is an array given that the attribute
292
+ # is documented as an array but the input is not
293
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
294
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
295
+ end
296
+ elsif !attributes[self.class.attribute_map[key]].nil?
297
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
298
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
299
+ end
300
+
301
+ self
302
+ end
303
+
304
+ # Deserializes the data based on type
305
+ # @param string type Data type
306
+ # @param string value Value to be deserialized
307
+ # @return [Object] Deserialized data
308
+ def _deserialize(type, value)
309
+ case type.to_sym
310
+ when :DateTime
311
+ DateTime.parse(value)
312
+ when :Date
313
+ Date.parse(value)
314
+ when :String
315
+ value.to_s
316
+ when :Integer
317
+ value.to_i
318
+ when :Float
319
+ value.to_f
320
+ when :Boolean
321
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
322
+ true
323
+ else
324
+ false
325
+ end
326
+ when :Object
327
+ # generic object (usually a Hash), return directly
328
+ value
329
+ when /\AArray<(?<inner_type>.+)>\z/
330
+ inner_type = Regexp.last_match[:inner_type]
331
+ value.map { |v| _deserialize(inner_type, v) }
332
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
333
+ k_type = Regexp.last_match[:k_type]
334
+ v_type = Regexp.last_match[:v_type]
335
+ {}.tap do |hash|
336
+ value.each do |k, v|
337
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
338
+ end
339
+ end
340
+ else # model
341
+ DearInventoryRuby.const_get(type).build_from_hash(value)
342
+ end
343
+ end
344
+
345
+ # Returns the string representation of the object
346
+ # @return [String] String presentation of the object
347
+ def to_s
348
+ to_hash.to_s
349
+ end
350
+
351
+ # to_body is an alias to to_hash (backward compatibility)
352
+ # @return [Hash] Returns the object in the form of hash
353
+ def to_body
354
+ to_hash
355
+ end
356
+
357
+ # Returns the object in the form of hash
358
+ # @return [Hash] Returns the object in the form of hash
359
+ def to_hash
360
+ hash = {}
361
+ self.class.attribute_map.each_pair do |attr, param|
362
+ value = self.send(attr)
363
+ if value.nil?
364
+ is_nullable = self.class.openapi_nullable.include?(attr)
365
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
366
+ end
367
+
368
+ hash[param] = _to_hash(value)
369
+ end
370
+ hash
371
+ end
372
+
373
+ # Outputs non-array value in the form of hash
374
+ # For object, use to_hash. Otherwise, just return the value
375
+ # @param [Object] value Any valid value
376
+ # @return [Hash] Returns the value in the form of hash
377
+ def _to_hash(value)
378
+ if value.is_a?(Array)
379
+ value.compact.map { |v| _to_hash(v) }
380
+ elsif value.is_a?(Hash)
381
+ {}.tap do |hash|
382
+ value.each { |k, v| hash[k] = _to_hash(v) }
383
+ end
384
+ elsif value.respond_to? :to_hash
385
+ value.to_hash
386
+ else
387
+ value
388
+ end
389
+ end
390
+ end
391
+ end
@@ -0,0 +1,229 @@
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 Locations
17
+ # Total
18
+ attr_accessor :total
19
+
20
+ # Page
21
+ attr_accessor :page
22
+
23
+ # Array of Locations
24
+ attr_accessor :location_list
25
+
26
+ # Attribute mapping from ruby-style variable name to JSON key.
27
+ def self.attribute_map
28
+ {
29
+ :'total' => :'Total',
30
+ :'page' => :'Page',
31
+ :'location_list' => :'LocationList'
32
+ }
33
+ end
34
+
35
+ # Attribute type mapping.
36
+ def self.openapi_types
37
+ {
38
+ :'total' => :'Float',
39
+ :'page' => :'Float',
40
+ :'location_list' => :'Array<Location>'
41
+ }
42
+ end
43
+
44
+ # List of attributes with nullable: true
45
+ def self.openapi_nullable
46
+ Set.new([
47
+ ])
48
+ end
49
+
50
+ # Initializes the object
51
+ # @param [Hash] attributes Model attributes in the form of hash
52
+ def initialize(attributes = {})
53
+ if (!attributes.is_a?(Hash))
54
+ fail ArgumentError, "The input argument (attributes) must be a hash in `DearInventoryRuby::Locations` initialize method"
55
+ end
56
+
57
+ # check to see if the attribute exists and convert string to symbol for hash key
58
+ attributes = attributes.each_with_object({}) { |(k, v), h|
59
+ if (!self.class.attribute_map.key?(k.to_sym))
60
+ fail ArgumentError, "`#{k}` is not a valid attribute in `DearInventoryRuby::Locations`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
61
+ end
62
+ h[k.to_sym] = v
63
+ }
64
+
65
+ if attributes.key?(:'total')
66
+ self.total = attributes[:'total']
67
+ end
68
+
69
+ if attributes.key?(:'page')
70
+ self.page = attributes[:'page']
71
+ end
72
+
73
+ if attributes.key?(:'location_list')
74
+ if (value = attributes[:'location_list']).is_a?(Array)
75
+ self.location_list = value
76
+ end
77
+ end
78
+ end
79
+
80
+ # Show invalid properties with the reasons. Usually used together with valid?
81
+ # @return Array for valid properties with the reasons
82
+ def list_invalid_properties
83
+ invalid_properties = Array.new
84
+ invalid_properties
85
+ end
86
+
87
+ # Check to see if the all the properties in the model are valid
88
+ # @return true if the model is valid
89
+ def valid?
90
+ true
91
+ end
92
+
93
+ # Checks equality by comparing each attribute.
94
+ # @param [Object] Object to be compared
95
+ def ==(o)
96
+ return true if self.equal?(o)
97
+ self.class == o.class &&
98
+ total == o.total &&
99
+ page == o.page &&
100
+ location_list == o.location_list
101
+ end
102
+
103
+ # @see the `==` method
104
+ # @param [Object] Object to be compared
105
+ def eql?(o)
106
+ self == o
107
+ end
108
+
109
+ # Calculates hash code according to all attributes.
110
+ # @return [Integer] Hash code
111
+ def hash
112
+ [total, page, location_list].hash
113
+ end
114
+
115
+ # Builds the object from hash
116
+ # @param [Hash] attributes Model attributes in the form of hash
117
+ # @return [Object] Returns the model itself
118
+ def self.build_from_hash(attributes)
119
+ new.build_from_hash(attributes)
120
+ end
121
+
122
+ # Builds the object from hash
123
+ # @param [Hash] attributes Model attributes in the form of hash
124
+ # @return [Object] Returns the model itself
125
+ def build_from_hash(attributes)
126
+ return nil unless attributes.is_a?(Hash)
127
+ self.class.openapi_types.each_pair do |key, type|
128
+ if type =~ /\AArray<(.*)>/i
129
+ # check to ensure the input is an array given that the attribute
130
+ # is documented as an array but the input is not
131
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
132
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
133
+ end
134
+ elsif !attributes[self.class.attribute_map[key]].nil?
135
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
136
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
137
+ end
138
+
139
+ self
140
+ end
141
+
142
+ # Deserializes the data based on type
143
+ # @param string type Data type
144
+ # @param string value Value to be deserialized
145
+ # @return [Object] Deserialized data
146
+ def _deserialize(type, value)
147
+ case type.to_sym
148
+ when :DateTime
149
+ DateTime.parse(value)
150
+ when :Date
151
+ Date.parse(value)
152
+ when :String
153
+ value.to_s
154
+ when :Integer
155
+ value.to_i
156
+ when :Float
157
+ value.to_f
158
+ when :Boolean
159
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
160
+ true
161
+ else
162
+ false
163
+ end
164
+ when :Object
165
+ # generic object (usually a Hash), return directly
166
+ value
167
+ when /\AArray<(?<inner_type>.+)>\z/
168
+ inner_type = Regexp.last_match[:inner_type]
169
+ value.map { |v| _deserialize(inner_type, v) }
170
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
171
+ k_type = Regexp.last_match[:k_type]
172
+ v_type = Regexp.last_match[:v_type]
173
+ {}.tap do |hash|
174
+ value.each do |k, v|
175
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
176
+ end
177
+ end
178
+ else # model
179
+ DearInventoryRuby.const_get(type).build_from_hash(value)
180
+ end
181
+ end
182
+
183
+ # Returns the string representation of the object
184
+ # @return [String] String presentation of the object
185
+ def to_s
186
+ to_hash.to_s
187
+ end
188
+
189
+ # to_body is an alias to to_hash (backward compatibility)
190
+ # @return [Hash] Returns the object in the form of hash
191
+ def to_body
192
+ to_hash
193
+ end
194
+
195
+ # Returns the object in the form of hash
196
+ # @return [Hash] Returns the object in the form of hash
197
+ def to_hash
198
+ hash = {}
199
+ self.class.attribute_map.each_pair do |attr, param|
200
+ value = self.send(attr)
201
+ if value.nil?
202
+ is_nullable = self.class.openapi_nullable.include?(attr)
203
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
204
+ end
205
+
206
+ hash[param] = _to_hash(value)
207
+ end
208
+ hash
209
+ end
210
+
211
+ # Outputs non-array value in the form of hash
212
+ # For object, use to_hash. Otherwise, just return the value
213
+ # @param [Object] value Any valid value
214
+ # @return [Hash] Returns the value in the form of hash
215
+ def _to_hash(value)
216
+ if value.is_a?(Array)
217
+ value.compact.map { |v| _to_hash(v) }
218
+ elsif value.is_a?(Hash)
219
+ {}.tap do |hash|
220
+ value.each { |k, v| hash[k] = _to_hash(v) }
221
+ end
222
+ elsif value.respond_to? :to_hash
223
+ value.to_hash
224
+ else
225
+ value
226
+ end
227
+ end
228
+ end
229
+ end