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,217 @@
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 Carrier
17
+ # Unique `Carrier` ID
18
+ attr_accessor :carrier_id
19
+
20
+ # Name of `Carrier`
21
+ attr_accessor :description
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :'carrier_id' => :'CarrierID',
27
+ :'description' => :'Description'
28
+ }
29
+ end
30
+
31
+ # Attribute type mapping.
32
+ def self.openapi_types
33
+ {
34
+ :'carrier_id' => :'String',
35
+ :'description' => :'String'
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::Carrier` 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::Carrier`. 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?(:'carrier_id')
61
+ self.carrier_id = attributes[:'carrier_id']
62
+ end
63
+
64
+ if attributes.key?(:'description')
65
+ self.description = attributes[:'description']
66
+ end
67
+ end
68
+
69
+ # Show invalid properties with the reasons. Usually used together with valid?
70
+ # @return Array for valid properties with the reasons
71
+ def list_invalid_properties
72
+ invalid_properties = Array.new
73
+ invalid_properties
74
+ end
75
+
76
+ # Check to see if the all the properties in the model are valid
77
+ # @return true if the model is valid
78
+ def valid?
79
+ true
80
+ end
81
+
82
+ # Checks equality by comparing each attribute.
83
+ # @param [Object] Object to be compared
84
+ def ==(o)
85
+ return true if self.equal?(o)
86
+ self.class == o.class &&
87
+ carrier_id == o.carrier_id &&
88
+ description == o.description
89
+ end
90
+
91
+ # @see the `==` method
92
+ # @param [Object] Object to be compared
93
+ def eql?(o)
94
+ self == o
95
+ end
96
+
97
+ # Calculates hash code according to all attributes.
98
+ # @return [Integer] Hash code
99
+ def hash
100
+ [carrier_id, description].hash
101
+ end
102
+
103
+ # Builds the object from hash
104
+ # @param [Hash] attributes Model attributes in the form of hash
105
+ # @return [Object] Returns the model itself
106
+ def self.build_from_hash(attributes)
107
+ new.build_from_hash(attributes)
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 build_from_hash(attributes)
114
+ return nil unless attributes.is_a?(Hash)
115
+ self.class.openapi_types.each_pair do |key, type|
116
+ if type =~ /\AArray<(.*)>/i
117
+ # check to ensure the input is an array given that the attribute
118
+ # is documented as an array but the input is not
119
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
120
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
121
+ end
122
+ elsif !attributes[self.class.attribute_map[key]].nil?
123
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
124
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
125
+ end
126
+
127
+ self
128
+ end
129
+
130
+ # Deserializes the data based on type
131
+ # @param string type Data type
132
+ # @param string value Value to be deserialized
133
+ # @return [Object] Deserialized data
134
+ def _deserialize(type, value)
135
+ case type.to_sym
136
+ when :DateTime
137
+ DateTime.parse(value)
138
+ when :Date
139
+ Date.parse(value)
140
+ when :String
141
+ value.to_s
142
+ when :Integer
143
+ value.to_i
144
+ when :Float
145
+ value.to_f
146
+ when :Boolean
147
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
148
+ true
149
+ else
150
+ false
151
+ end
152
+ when :Object
153
+ # generic object (usually a Hash), return directly
154
+ value
155
+ when /\AArray<(?<inner_type>.+)>\z/
156
+ inner_type = Regexp.last_match[:inner_type]
157
+ value.map { |v| _deserialize(inner_type, v) }
158
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
159
+ k_type = Regexp.last_match[:k_type]
160
+ v_type = Regexp.last_match[:v_type]
161
+ {}.tap do |hash|
162
+ value.each do |k, v|
163
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
164
+ end
165
+ end
166
+ else # model
167
+ DearInventoryRuby.const_get(type).build_from_hash(value)
168
+ end
169
+ end
170
+
171
+ # Returns the string representation of the object
172
+ # @return [String] String presentation of the object
173
+ def to_s
174
+ to_hash.to_s
175
+ end
176
+
177
+ # to_body is an alias to to_hash (backward compatibility)
178
+ # @return [Hash] Returns the object in the form of hash
179
+ def to_body
180
+ to_hash
181
+ end
182
+
183
+ # Returns the object in the form of hash
184
+ # @return [Hash] Returns the object in the form of hash
185
+ def to_hash
186
+ hash = {}
187
+ self.class.attribute_map.each_pair do |attr, param|
188
+ value = self.send(attr)
189
+ if value.nil?
190
+ is_nullable = self.class.openapi_nullable.include?(attr)
191
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
192
+ end
193
+
194
+ hash[param] = _to_hash(value)
195
+ end
196
+ hash
197
+ end
198
+
199
+ # Outputs non-array value in the form of hash
200
+ # For object, use to_hash. Otherwise, just return the value
201
+ # @param [Object] value Any valid value
202
+ # @return [Hash] Returns the value in the form of hash
203
+ def _to_hash(value)
204
+ if value.is_a?(Array)
205
+ value.compact.map { |v| _to_hash(v) }
206
+ elsif value.is_a?(Hash)
207
+ {}.tap do |hash|
208
+ value.each { |k, v| hash[k] = _to_hash(v) }
209
+ end
210
+ elsif value.respond_to? :to_hash
211
+ value.to_hash
212
+ else
213
+ value
214
+ end
215
+ end
216
+ end
217
+ 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 Carriers
17
+ # Total
18
+ attr_accessor :total
19
+
20
+ # Page
21
+ attr_accessor :page
22
+
23
+ # Array of Carriers
24
+ attr_accessor :carrier_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
+ :'carrier_list' => :'CarrierList'
32
+ }
33
+ end
34
+
35
+ # Attribute type mapping.
36
+ def self.openapi_types
37
+ {
38
+ :'total' => :'Float',
39
+ :'page' => :'Float',
40
+ :'carrier_list' => :'Array<Carrier>'
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::Carriers` 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::Carriers`. 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?(:'carrier_list')
74
+ if (value = attributes[:'carrier_list']).is_a?(Array)
75
+ self.carrier_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
+ carrier_list == o.carrier_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, carrier_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
@@ -159,30 +159,6 @@ module DearInventoryRuby
159
159
  invalid_properties.push('invalid value for "name", name cannot be nil.')
160
160
  end
161
161
 
162
- if @name.to_s.length > 256
163
- invalid_properties.push('invalid value for "name", the character length must be smaller than or equal to 256.')
164
- end
165
-
166
- if !@phone.nil? && @phone.to_s.length > 50
167
- invalid_properties.push('invalid value for "phone", the character length must be smaller than or equal to 50.')
168
- end
169
-
170
- if !@fax.nil? && @fax.to_s.length > 50
171
- invalid_properties.push('invalid value for "fax", the character length must be smaller than or equal to 50.')
172
- end
173
-
174
- if !@email.nil? && @email.to_s.length > 256
175
- invalid_properties.push('invalid value for "email", the character length must be smaller than or equal to 256.')
176
- end
177
-
178
- if !@website.nil? && @website.to_s.length > 256
179
- invalid_properties.push('invalid value for "website", the character length must be smaller than or equal to 256.')
180
- end
181
-
182
- if !@comment.nil? && @comment.to_s.length > 256
183
- invalid_properties.push('invalid value for "comment", the character length must be smaller than or equal to 256.')
184
- end
185
-
186
162
  invalid_properties
187
163
  end
188
164
 
@@ -190,79 +166,9 @@ module DearInventoryRuby
190
166
  # @return true if the model is valid
191
167
  def valid?
192
168
  return false if @name.nil?
193
- return false if @name.to_s.length > 256
194
- return false if !@phone.nil? && @phone.to_s.length > 50
195
- return false if !@fax.nil? && @fax.to_s.length > 50
196
- return false if !@email.nil? && @email.to_s.length > 256
197
- return false if !@website.nil? && @website.to_s.length > 256
198
- return false if !@comment.nil? && @comment.to_s.length > 256
199
169
  true
200
170
  end
201
171
 
202
- # Custom attribute writer method with validation
203
- # @param [Object] name Value to be assigned
204
- def name=(name)
205
- if name.nil?
206
- fail ArgumentError, 'name cannot be nil'
207
- end
208
-
209
- if name.to_s.length > 256
210
- fail ArgumentError, 'invalid value for "name", the character length must be smaller than or equal to 256.'
211
- end
212
-
213
- @name = name
214
- end
215
-
216
- # Custom attribute writer method with validation
217
- # @param [Object] phone Value to be assigned
218
- def phone=(phone)
219
- if !phone.nil? && phone.to_s.length > 50
220
- fail ArgumentError, 'invalid value for "phone", the character length must be smaller than or equal to 50.'
221
- end
222
-
223
- @phone = phone
224
- end
225
-
226
- # Custom attribute writer method with validation
227
- # @param [Object] fax Value to be assigned
228
- def fax=(fax)
229
- if !fax.nil? && fax.to_s.length > 50
230
- fail ArgumentError, 'invalid value for "fax", the character length must be smaller than or equal to 50.'
231
- end
232
-
233
- @fax = fax
234
- end
235
-
236
- # Custom attribute writer method with validation
237
- # @param [Object] email Value to be assigned
238
- def email=(email)
239
- if !email.nil? && email.to_s.length > 256
240
- fail ArgumentError, 'invalid value for "email", the character length must be smaller than or equal to 256.'
241
- end
242
-
243
- @email = email
244
- end
245
-
246
- # Custom attribute writer method with validation
247
- # @param [Object] website Value to be assigned
248
- def website=(website)
249
- if !website.nil? && website.to_s.length > 256
250
- fail ArgumentError, 'invalid value for "website", the character length must be smaller than or equal to 256.'
251
- end
252
-
253
- @website = website
254
- end
255
-
256
- # Custom attribute writer method with validation
257
- # @param [Object] comment Value to be assigned
258
- def comment=(comment)
259
- if !comment.nil? && comment.to_s.length > 256
260
- fail ArgumentError, 'invalid value for "comment", the character length must be smaller than or equal to 256.'
261
- end
262
-
263
- @comment = comment
264
- end
265
-
266
172
  # Checks equality by comparing each attribute.
267
173
  # @param [Object] Object to be compared
268
174
  def ==(o)
@@ -350,10 +350,6 @@ module DearInventoryRuby
350
350
  invalid_properties.push('invalid value for "name", name cannot be nil.')
351
351
  end
352
352
 
353
- if @name.to_s.length > 256
354
- invalid_properties.push('invalid value for "name", the character length must be smaller than or equal to 256.')
355
- end
356
-
357
353
  if @status.nil?
358
354
  invalid_properties.push('invalid value for "status", status cannot be nil.')
359
355
  end
@@ -378,10 +374,6 @@ module DearInventoryRuby
378
374
  invalid_properties.push('invalid value for "tax_rule", tax_rule cannot be nil.')
379
375
  end
380
376
 
381
- if !@comments.nil? && @comments.to_s.length > 2000
382
- invalid_properties.push('invalid value for "comments", the character length must be smaller than or equal to 2000.')
383
- end
384
-
385
377
  invalid_properties
386
378
  end
387
379
 
@@ -389,41 +381,15 @@ module DearInventoryRuby
389
381
  # @return true if the model is valid
390
382
  def valid?
391
383
  return false if @name.nil?
392
- return false if @name.to_s.length > 256
393
384
  return false if @status.nil?
394
385
  return false if @currency.nil?
395
386
  return false if @payment_term.nil?
396
387
  return false if @account_receivable.nil?
397
388
  return false if @revenue_account.nil?
398
389
  return false if @tax_rule.nil?
399
- return false if !@comments.nil? && @comments.to_s.length > 2000
400
390
  true
401
391
  end
402
392
 
403
- # Custom attribute writer method with validation
404
- # @param [Object] name Value to be assigned
405
- def name=(name)
406
- if name.nil?
407
- fail ArgumentError, 'name cannot be nil'
408
- end
409
-
410
- if name.to_s.length > 256
411
- fail ArgumentError, 'invalid value for "name", the character length must be smaller than or equal to 256.'
412
- end
413
-
414
- @name = name
415
- end
416
-
417
- # Custom attribute writer method with validation
418
- # @param [Object] comments Value to be assigned
419
- def comments=(comments)
420
- if !comments.nil? && comments.to_s.length > 2000
421
- fail ArgumentError, 'invalid value for "comments", the character length must be smaller than or equal to 2000.'
422
- end
423
-
424
- @comments = comments
425
- end
426
-
427
393
  # Checks equality by comparing each attribute.
428
394
  # @param [Object] Object to be compared
429
395
  def ==(o)