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
@@ -14,8 +14,11 @@ require 'date'
14
14
 
15
15
  module DearInventoryRuby
16
16
  class Address
17
- # If passed in PUT method, entry will be searched by id, found entry will be updated, otherwise created
18
- attr_accessor :id
17
+ # Address Line 1 as displayed on Sale form. = Line1 + Line2
18
+ attr_accessor :display_address_line1
19
+
20
+ # Address Line 2 as displayed on Sale form. = City + State/Region + Zip/Postcode + Country
21
+ attr_accessor :display_address_line2
19
22
 
20
23
  # Address Line 1
21
24
  attr_accessor :line1
@@ -23,51 +26,43 @@ module DearInventoryRuby
23
26
  # Address Line 2
24
27
  attr_accessor :line2
25
28
 
26
- # City / Suburb
29
+ # City
27
30
  attr_accessor :city
28
31
 
29
- # State / Province
32
+ # State
30
33
  attr_accessor :state
31
34
 
32
- # Zip / PostCode
35
+ # PostCode
33
36
  attr_accessor :post_code
34
37
 
35
- # Country name
38
+ # Country
36
39
  attr_accessor :country
37
40
 
38
- # Address Type. Should be one of the following values: `Billing`, `Business` or `Shipping`.
39
- attr_accessor :type
40
-
41
- # Points that Address is used as default for chosen Type. `false` as default.
42
- attr_accessor :default_for_type
43
-
44
41
  # Attribute mapping from ruby-style variable name to JSON key.
45
42
  def self.attribute_map
46
43
  {
47
- :'id' => :'ID',
44
+ :'display_address_line1' => :'DisplayAddressLine1',
45
+ :'display_address_line2' => :'DisplayAddressLine2',
48
46
  :'line1' => :'Line1',
49
47
  :'line2' => :'Line2',
50
48
  :'city' => :'City',
51
49
  :'state' => :'State',
52
50
  :'post_code' => :'PostCode',
53
- :'country' => :'Country',
54
- :'type' => :'Type',
55
- :'default_for_type' => :'DefaultForType'
51
+ :'country' => :'Country'
56
52
  }
57
53
  end
58
54
 
59
55
  # Attribute type mapping.
60
56
  def self.openapi_types
61
57
  {
62
- :'id' => :'String',
58
+ :'display_address_line1' => :'String',
59
+ :'display_address_line2' => :'String',
63
60
  :'line1' => :'String',
64
61
  :'line2' => :'String',
65
62
  :'city' => :'String',
66
63
  :'state' => :'String',
67
64
  :'post_code' => :'String',
68
- :'country' => :'String',
69
- :'type' => :'String',
70
- :'default_for_type' => :'Boolean'
65
+ :'country' => :'String'
71
66
  }
72
67
  end
73
68
 
@@ -92,8 +87,12 @@ module DearInventoryRuby
92
87
  h[k.to_sym] = v
93
88
  }
94
89
 
95
- if attributes.key?(:'id')
96
- self.id = attributes[:'id']
90
+ if attributes.key?(:'display_address_line1')
91
+ self.display_address_line1 = attributes[:'display_address_line1']
92
+ end
93
+
94
+ if attributes.key?(:'display_address_line2')
95
+ self.display_address_line2 = attributes[:'display_address_line2']
97
96
  end
98
97
 
99
98
  if attributes.key?(:'line1')
@@ -119,130 +118,44 @@ module DearInventoryRuby
119
118
  if attributes.key?(:'country')
120
119
  self.country = attributes[:'country']
121
120
  end
122
-
123
- if attributes.key?(:'type')
124
- self.type = attributes[:'type']
125
- end
126
-
127
- if attributes.key?(:'default_for_type')
128
- self.default_for_type = attributes[:'default_for_type']
129
- else
130
- self.default_for_type = false
131
- end
132
121
  end
133
122
 
134
123
  # Show invalid properties with the reasons. Usually used together with valid?
135
124
  # @return Array for valid properties with the reasons
136
125
  def list_invalid_properties
137
126
  invalid_properties = Array.new
138
- if !@line1.nil? && @line1.to_s.length > 256
139
- invalid_properties.push('invalid value for "line1", the character length must be smaller than or equal to 256.')
140
- end
141
-
142
- if !@line2.nil? && @line2.to_s.length > 256
143
- invalid_properties.push('invalid value for "line2", the character length must be smaller than or equal to 256.')
144
- end
145
-
146
- if !@city.nil? && @city.to_s.length > 256
147
- invalid_properties.push('invalid value for "city", the character length must be smaller than or equal to 256.')
148
- end
149
-
150
- if !@state.nil? && @state.to_s.length > 256
151
- invalid_properties.push('invalid value for "state", the character length must be smaller than or equal to 256.')
152
- end
153
-
154
- if !@post_code.nil? && @post_code.to_s.length > 20
155
- invalid_properties.push('invalid value for "post_code", the character length must be smaller than or equal to 20.')
127
+ if @line1.nil?
128
+ invalid_properties.push('invalid value for "line1", line1 cannot be nil.')
156
129
  end
157
130
 
158
131
  if @country.nil?
159
132
  invalid_properties.push('invalid value for "country", country cannot be nil.')
160
133
  end
161
134
 
162
- if @type.nil?
163
- invalid_properties.push('invalid value for "type", type cannot be nil.')
164
- end
165
-
166
135
  invalid_properties
167
136
  end
168
137
 
169
138
  # Check to see if the all the properties in the model are valid
170
139
  # @return true if the model is valid
171
140
  def valid?
172
- return false if !@line1.nil? && @line1.to_s.length > 256
173
- return false if !@line2.nil? && @line2.to_s.length > 256
174
- return false if !@city.nil? && @city.to_s.length > 256
175
- return false if !@state.nil? && @state.to_s.length > 256
176
- return false if !@post_code.nil? && @post_code.to_s.length > 20
141
+ return false if @line1.nil?
177
142
  return false if @country.nil?
178
- return false if @type.nil?
179
143
  true
180
144
  end
181
145
 
182
- # Custom attribute writer method with validation
183
- # @param [Object] line1 Value to be assigned
184
- def line1=(line1)
185
- if !line1.nil? && line1.to_s.length > 256
186
- fail ArgumentError, 'invalid value for "line1", the character length must be smaller than or equal to 256.'
187
- end
188
-
189
- @line1 = line1
190
- end
191
-
192
- # Custom attribute writer method with validation
193
- # @param [Object] line2 Value to be assigned
194
- def line2=(line2)
195
- if !line2.nil? && line2.to_s.length > 256
196
- fail ArgumentError, 'invalid value for "line2", the character length must be smaller than or equal to 256.'
197
- end
198
-
199
- @line2 = line2
200
- end
201
-
202
- # Custom attribute writer method with validation
203
- # @param [Object] city Value to be assigned
204
- def city=(city)
205
- if !city.nil? && city.to_s.length > 256
206
- fail ArgumentError, 'invalid value for "city", the character length must be smaller than or equal to 256.'
207
- end
208
-
209
- @city = city
210
- end
211
-
212
- # Custom attribute writer method with validation
213
- # @param [Object] state Value to be assigned
214
- def state=(state)
215
- if !state.nil? && state.to_s.length > 256
216
- fail ArgumentError, 'invalid value for "state", the character length must be smaller than or equal to 256.'
217
- end
218
-
219
- @state = state
220
- end
221
-
222
- # Custom attribute writer method with validation
223
- # @param [Object] post_code Value to be assigned
224
- def post_code=(post_code)
225
- if !post_code.nil? && post_code.to_s.length > 20
226
- fail ArgumentError, 'invalid value for "post_code", the character length must be smaller than or equal to 20.'
227
- end
228
-
229
- @post_code = post_code
230
- end
231
-
232
146
  # Checks equality by comparing each attribute.
233
147
  # @param [Object] Object to be compared
234
148
  def ==(o)
235
149
  return true if self.equal?(o)
236
150
  self.class == o.class &&
237
- id == o.id &&
151
+ display_address_line1 == o.display_address_line1 &&
152
+ display_address_line2 == o.display_address_line2 &&
238
153
  line1 == o.line1 &&
239
154
  line2 == o.line2 &&
240
155
  city == o.city &&
241
156
  state == o.state &&
242
157
  post_code == o.post_code &&
243
- country == o.country &&
244
- type == o.type &&
245
- default_for_type == o.default_for_type
158
+ country == o.country
246
159
  end
247
160
 
248
161
  # @see the `==` method
@@ -254,7 +167,7 @@ module DearInventoryRuby
254
167
  # Calculates hash code according to all attributes.
255
168
  # @return [Integer] Hash code
256
169
  def hash
257
- [id, line1, line2, city, state, post_code, country, type, default_for_type].hash
170
+ [display_address_line1, display_address_line2, line1, line2, city, state, post_code, country].hash
258
171
  end
259
172
 
260
173
  # Builds the object from hash
@@ -181,7 +181,7 @@ module DearInventoryRuby
181
181
  :'additional_attribute9' => :'String',
182
182
  :'additional_attribute10' => :'String',
183
183
  :'last_modified_on' => :'String',
184
- :'addresses' => :'Array<Address>',
184
+ :'addresses' => :'Array<SupplierCustomerAddress>',
185
185
  :'contacts' => :'Array<Contact>'
186
186
  }
187
187
  end
@@ -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 ExternalHeader
17
+ # Key
18
+ attr_accessor :key
19
+
20
+ # Value
21
+ attr_accessor :value
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :'key' => :'Key',
27
+ :'value' => :'Value'
28
+ }
29
+ end
30
+
31
+ # Attribute type mapping.
32
+ def self.openapi_types
33
+ {
34
+ :'key' => :'String',
35
+ :'value' => :'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::ExternalHeader` 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::ExternalHeader`. 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?(:'key')
61
+ self.key = attributes[:'key']
62
+ end
63
+
64
+ if attributes.key?(:'value')
65
+ self.value = attributes[:'value']
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
+ key == o.key &&
88
+ value == o.value
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
+ [key, value].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