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