dear-inventory-ruby 0.1.19.1 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -0
- data/README.md +34 -5
- data/docs/Address.md +10 -12
- data/docs/AuthorizationType.md +16 -0
- data/docs/Customer.md +1 -1
- data/docs/ExternalHeader.md +19 -0
- data/docs/InventoryApi.md +1021 -163
- 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/WebhookType.md +16 -0
- data/docs/Webhooks.md +17 -0
- data/lib/dear-inventory-ruby/api/inventory_api.rb +985 -119
- data/lib/dear-inventory-ruby/models/address.rb +28 -115
- data/lib/dear-inventory-ruby/models/authorization_type.rb +37 -0
- data/lib/dear-inventory-ruby/models/customer.rb +1 -1
- data/lib/dear-inventory-ruby/models/external_header.rb +217 -0
- 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/webhook_type.rb +54 -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 +15 -0
- data/spec/api/inventory_api_spec.rb +165 -0
- data/spec/models/address_spec.rb +7 -13
- data/spec/models/authorization_type_spec.rb +35 -0
- data/spec/models/external_header_spec.rb +47 -0
- 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/webhook_type_spec.rb +35 -0
- data/spec/models/webhooks_spec.rb +41 -0
- metadata +63 -6
- data/lib/.DS_Store +0 -0
- data/lib/dear-inventory-ruby/.DS_Store +0 -0
- data/spec/.DS_Store +0 -0
@@ -0,0 +1,317 @@
|
|
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 ShippingAddress
|
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
|
22
|
+
|
23
|
+
# Address Line 1
|
24
|
+
attr_accessor :line1
|
25
|
+
|
26
|
+
# Address Line 2
|
27
|
+
attr_accessor :line2
|
28
|
+
|
29
|
+
# City
|
30
|
+
attr_accessor :city
|
31
|
+
|
32
|
+
# State
|
33
|
+
attr_accessor :state
|
34
|
+
|
35
|
+
# Post code
|
36
|
+
attr_accessor :post_code
|
37
|
+
|
38
|
+
# Country
|
39
|
+
attr_accessor :country
|
40
|
+
|
41
|
+
# Company Name
|
42
|
+
attr_accessor :company
|
43
|
+
|
44
|
+
# Contact
|
45
|
+
attr_accessor :contact
|
46
|
+
|
47
|
+
# If false and Customer's address matching Line 1 not found, than new customer shipping address will be created.
|
48
|
+
attr_accessor :ship_to_other
|
49
|
+
|
50
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
51
|
+
def self.attribute_map
|
52
|
+
{
|
53
|
+
:'display_address_line1' => :'DisplayAddressLine1',
|
54
|
+
:'display_address_line2' => :'DisplayAddressLine2',
|
55
|
+
:'line1' => :'Line1',
|
56
|
+
:'line2' => :'Line2',
|
57
|
+
:'city' => :'City',
|
58
|
+
:'state' => :'State',
|
59
|
+
:'post_code' => :'PostCode',
|
60
|
+
:'country' => :'Country',
|
61
|
+
:'company' => :'Company',
|
62
|
+
:'contact' => :'Contact',
|
63
|
+
:'ship_to_other' => :'ShipToOther'
|
64
|
+
}
|
65
|
+
end
|
66
|
+
|
67
|
+
# Attribute type mapping.
|
68
|
+
def self.openapi_types
|
69
|
+
{
|
70
|
+
:'display_address_line1' => :'String',
|
71
|
+
:'display_address_line2' => :'String',
|
72
|
+
:'line1' => :'String',
|
73
|
+
:'line2' => :'String',
|
74
|
+
:'city' => :'String',
|
75
|
+
:'state' => :'String',
|
76
|
+
:'post_code' => :'String',
|
77
|
+
:'country' => :'String',
|
78
|
+
:'company' => :'String',
|
79
|
+
:'contact' => :'String',
|
80
|
+
:'ship_to_other' => :'Boolean'
|
81
|
+
}
|
82
|
+
end
|
83
|
+
|
84
|
+
# List of attributes with nullable: true
|
85
|
+
def self.openapi_nullable
|
86
|
+
Set.new([
|
87
|
+
])
|
88
|
+
end
|
89
|
+
|
90
|
+
# Initializes the object
|
91
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
92
|
+
def initialize(attributes = {})
|
93
|
+
if (!attributes.is_a?(Hash))
|
94
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `DearInventoryRuby::ShippingAddress` initialize method"
|
95
|
+
end
|
96
|
+
|
97
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
98
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
99
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
100
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `DearInventoryRuby::ShippingAddress`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
101
|
+
end
|
102
|
+
h[k.to_sym] = v
|
103
|
+
}
|
104
|
+
|
105
|
+
if attributes.key?(:'display_address_line1')
|
106
|
+
self.display_address_line1 = attributes[:'display_address_line1']
|
107
|
+
end
|
108
|
+
|
109
|
+
if attributes.key?(:'display_address_line2')
|
110
|
+
self.display_address_line2 = attributes[:'display_address_line2']
|
111
|
+
end
|
112
|
+
|
113
|
+
if attributes.key?(:'line1')
|
114
|
+
self.line1 = attributes[:'line1']
|
115
|
+
end
|
116
|
+
|
117
|
+
if attributes.key?(:'line2')
|
118
|
+
self.line2 = attributes[:'line2']
|
119
|
+
end
|
120
|
+
|
121
|
+
if attributes.key?(:'city')
|
122
|
+
self.city = attributes[:'city']
|
123
|
+
end
|
124
|
+
|
125
|
+
if attributes.key?(:'state')
|
126
|
+
self.state = attributes[:'state']
|
127
|
+
end
|
128
|
+
|
129
|
+
if attributes.key?(:'post_code')
|
130
|
+
self.post_code = attributes[:'post_code']
|
131
|
+
end
|
132
|
+
|
133
|
+
if attributes.key?(:'country')
|
134
|
+
self.country = attributes[:'country']
|
135
|
+
end
|
136
|
+
|
137
|
+
if attributes.key?(:'company')
|
138
|
+
self.company = attributes[:'company']
|
139
|
+
end
|
140
|
+
|
141
|
+
if attributes.key?(:'contact')
|
142
|
+
self.contact = attributes[:'contact']
|
143
|
+
end
|
144
|
+
|
145
|
+
if attributes.key?(:'ship_to_other')
|
146
|
+
self.ship_to_other = attributes[:'ship_to_other']
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
151
|
+
# @return Array for valid properties with the reasons
|
152
|
+
def list_invalid_properties
|
153
|
+
invalid_properties = Array.new
|
154
|
+
if @line1.nil?
|
155
|
+
invalid_properties.push('invalid value for "line1", line1 cannot be nil.')
|
156
|
+
end
|
157
|
+
|
158
|
+
if @country.nil?
|
159
|
+
invalid_properties.push('invalid value for "country", country cannot be nil.')
|
160
|
+
end
|
161
|
+
|
162
|
+
invalid_properties
|
163
|
+
end
|
164
|
+
|
165
|
+
# Check to see if the all the properties in the model are valid
|
166
|
+
# @return true if the model is valid
|
167
|
+
def valid?
|
168
|
+
return false if @line1.nil?
|
169
|
+
return false if @country.nil?
|
170
|
+
true
|
171
|
+
end
|
172
|
+
|
173
|
+
# Checks equality by comparing each attribute.
|
174
|
+
# @param [Object] Object to be compared
|
175
|
+
def ==(o)
|
176
|
+
return true if self.equal?(o)
|
177
|
+
self.class == o.class &&
|
178
|
+
display_address_line1 == o.display_address_line1 &&
|
179
|
+
display_address_line2 == o.display_address_line2 &&
|
180
|
+
line1 == o.line1 &&
|
181
|
+
line2 == o.line2 &&
|
182
|
+
city == o.city &&
|
183
|
+
state == o.state &&
|
184
|
+
post_code == o.post_code &&
|
185
|
+
country == o.country &&
|
186
|
+
company == o.company &&
|
187
|
+
contact == o.contact &&
|
188
|
+
ship_to_other == o.ship_to_other
|
189
|
+
end
|
190
|
+
|
191
|
+
# @see the `==` method
|
192
|
+
# @param [Object] Object to be compared
|
193
|
+
def eql?(o)
|
194
|
+
self == o
|
195
|
+
end
|
196
|
+
|
197
|
+
# Calculates hash code according to all attributes.
|
198
|
+
# @return [Integer] Hash code
|
199
|
+
def hash
|
200
|
+
[display_address_line1, display_address_line2, line1, line2, city, state, post_code, country, company, contact, ship_to_other].hash
|
201
|
+
end
|
202
|
+
|
203
|
+
# Builds the object from hash
|
204
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
205
|
+
# @return [Object] Returns the model itself
|
206
|
+
def self.build_from_hash(attributes)
|
207
|
+
new.build_from_hash(attributes)
|
208
|
+
end
|
209
|
+
|
210
|
+
# Builds the object from hash
|
211
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
212
|
+
# @return [Object] Returns the model itself
|
213
|
+
def build_from_hash(attributes)
|
214
|
+
return nil unless attributes.is_a?(Hash)
|
215
|
+
self.class.openapi_types.each_pair do |key, type|
|
216
|
+
if type =~ /\AArray<(.*)>/i
|
217
|
+
# check to ensure the input is an array given that the attribute
|
218
|
+
# is documented as an array but the input is not
|
219
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
220
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
221
|
+
end
|
222
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
223
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
224
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
225
|
+
end
|
226
|
+
|
227
|
+
self
|
228
|
+
end
|
229
|
+
|
230
|
+
# Deserializes the data based on type
|
231
|
+
# @param string type Data type
|
232
|
+
# @param string value Value to be deserialized
|
233
|
+
# @return [Object] Deserialized data
|
234
|
+
def _deserialize(type, value)
|
235
|
+
case type.to_sym
|
236
|
+
when :DateTime
|
237
|
+
DateTime.parse(value)
|
238
|
+
when :Date
|
239
|
+
Date.parse(value)
|
240
|
+
when :String
|
241
|
+
value.to_s
|
242
|
+
when :Integer
|
243
|
+
value.to_i
|
244
|
+
when :Float
|
245
|
+
value.to_f
|
246
|
+
when :Boolean
|
247
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
248
|
+
true
|
249
|
+
else
|
250
|
+
false
|
251
|
+
end
|
252
|
+
when :Object
|
253
|
+
# generic object (usually a Hash), return directly
|
254
|
+
value
|
255
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
256
|
+
inner_type = Regexp.last_match[:inner_type]
|
257
|
+
value.map { |v| _deserialize(inner_type, v) }
|
258
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
259
|
+
k_type = Regexp.last_match[:k_type]
|
260
|
+
v_type = Regexp.last_match[:v_type]
|
261
|
+
{}.tap do |hash|
|
262
|
+
value.each do |k, v|
|
263
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
264
|
+
end
|
265
|
+
end
|
266
|
+
else # model
|
267
|
+
DearInventoryRuby.const_get(type).build_from_hash(value)
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
# Returns the string representation of the object
|
272
|
+
# @return [String] String presentation of the object
|
273
|
+
def to_s
|
274
|
+
to_hash.to_s
|
275
|
+
end
|
276
|
+
|
277
|
+
# to_body is an alias to to_hash (backward compatibility)
|
278
|
+
# @return [Hash] Returns the object in the form of hash
|
279
|
+
def to_body
|
280
|
+
to_hash
|
281
|
+
end
|
282
|
+
|
283
|
+
# Returns the object in the form of hash
|
284
|
+
# @return [Hash] Returns the object in the form of hash
|
285
|
+
def to_hash
|
286
|
+
hash = {}
|
287
|
+
self.class.attribute_map.each_pair do |attr, param|
|
288
|
+
value = self.send(attr)
|
289
|
+
if value.nil?
|
290
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
291
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
292
|
+
end
|
293
|
+
|
294
|
+
hash[param] = _to_hash(value)
|
295
|
+
end
|
296
|
+
hash
|
297
|
+
end
|
298
|
+
|
299
|
+
# Outputs non-array value in the form of hash
|
300
|
+
# For object, use to_hash. Otherwise, just return the value
|
301
|
+
# @param [Object] value Any valid value
|
302
|
+
# @return [Hash] Returns the value in the form of hash
|
303
|
+
def _to_hash(value)
|
304
|
+
if value.is_a?(Array)
|
305
|
+
value.compact.map { |v| _to_hash(v) }
|
306
|
+
elsif value.is_a?(Hash)
|
307
|
+
{}.tap do |hash|
|
308
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
309
|
+
end
|
310
|
+
elsif value.respond_to? :to_hash
|
311
|
+
value.to_hash
|
312
|
+
else
|
313
|
+
value
|
314
|
+
end
|
315
|
+
end
|
316
|
+
end
|
317
|
+
end
|
@@ -0,0 +1,374 @@
|
|
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 SupplierCustomerAddress
|
17
|
+
# If passed in PUT method, entry will be searched by id, found entry will be updated, otherwise created
|
18
|
+
attr_accessor :id
|
19
|
+
|
20
|
+
# Address Line 1
|
21
|
+
attr_accessor :line1
|
22
|
+
|
23
|
+
# Address Line 2
|
24
|
+
attr_accessor :line2
|
25
|
+
|
26
|
+
# City / Suburb
|
27
|
+
attr_accessor :city
|
28
|
+
|
29
|
+
# State / Province
|
30
|
+
attr_accessor :state
|
31
|
+
|
32
|
+
# Zip / PostCode
|
33
|
+
attr_accessor :post_code
|
34
|
+
|
35
|
+
# Country name
|
36
|
+
attr_accessor :country
|
37
|
+
|
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
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
45
|
+
def self.attribute_map
|
46
|
+
{
|
47
|
+
:'id' => :'ID',
|
48
|
+
:'line1' => :'Line1',
|
49
|
+
:'line2' => :'Line2',
|
50
|
+
:'city' => :'City',
|
51
|
+
:'state' => :'State',
|
52
|
+
:'post_code' => :'PostCode',
|
53
|
+
:'country' => :'Country',
|
54
|
+
:'type' => :'Type',
|
55
|
+
:'default_for_type' => :'DefaultForType'
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
# Attribute type mapping.
|
60
|
+
def self.openapi_types
|
61
|
+
{
|
62
|
+
:'id' => :'String',
|
63
|
+
:'line1' => :'String',
|
64
|
+
:'line2' => :'String',
|
65
|
+
:'city' => :'String',
|
66
|
+
:'state' => :'String',
|
67
|
+
:'post_code' => :'String',
|
68
|
+
:'country' => :'String',
|
69
|
+
:'type' => :'String',
|
70
|
+
:'default_for_type' => :'Boolean'
|
71
|
+
}
|
72
|
+
end
|
73
|
+
|
74
|
+
# List of attributes with nullable: true
|
75
|
+
def self.openapi_nullable
|
76
|
+
Set.new([
|
77
|
+
])
|
78
|
+
end
|
79
|
+
|
80
|
+
# Initializes the object
|
81
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
82
|
+
def initialize(attributes = {})
|
83
|
+
if (!attributes.is_a?(Hash))
|
84
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `DearInventoryRuby::SupplierCustomerAddress` initialize method"
|
85
|
+
end
|
86
|
+
|
87
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
88
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
89
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
90
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `DearInventoryRuby::SupplierCustomerAddress`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
91
|
+
end
|
92
|
+
h[k.to_sym] = v
|
93
|
+
}
|
94
|
+
|
95
|
+
if attributes.key?(:'id')
|
96
|
+
self.id = attributes[:'id']
|
97
|
+
end
|
98
|
+
|
99
|
+
if attributes.key?(:'line1')
|
100
|
+
self.line1 = attributes[:'line1']
|
101
|
+
end
|
102
|
+
|
103
|
+
if attributes.key?(:'line2')
|
104
|
+
self.line2 = attributes[:'line2']
|
105
|
+
end
|
106
|
+
|
107
|
+
if attributes.key?(:'city')
|
108
|
+
self.city = attributes[:'city']
|
109
|
+
end
|
110
|
+
|
111
|
+
if attributes.key?(:'state')
|
112
|
+
self.state = attributes[:'state']
|
113
|
+
end
|
114
|
+
|
115
|
+
if attributes.key?(:'post_code')
|
116
|
+
self.post_code = attributes[:'post_code']
|
117
|
+
end
|
118
|
+
|
119
|
+
if attributes.key?(:'country')
|
120
|
+
self.country = attributes[:'country']
|
121
|
+
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
|
+
end
|
133
|
+
|
134
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
135
|
+
# @return Array for valid properties with the reasons
|
136
|
+
def list_invalid_properties
|
137
|
+
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.')
|
156
|
+
end
|
157
|
+
|
158
|
+
if @country.nil?
|
159
|
+
invalid_properties.push('invalid value for "country", country cannot be nil.')
|
160
|
+
end
|
161
|
+
|
162
|
+
if @type.nil?
|
163
|
+
invalid_properties.push('invalid value for "type", type cannot be nil.')
|
164
|
+
end
|
165
|
+
|
166
|
+
invalid_properties
|
167
|
+
end
|
168
|
+
|
169
|
+
# Check to see if the all the properties in the model are valid
|
170
|
+
# @return true if the model is valid
|
171
|
+
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
|
177
|
+
return false if @country.nil?
|
178
|
+
return false if @type.nil?
|
179
|
+
true
|
180
|
+
end
|
181
|
+
|
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
|
+
# Checks equality by comparing each attribute.
|
233
|
+
# @param [Object] Object to be compared
|
234
|
+
def ==(o)
|
235
|
+
return true if self.equal?(o)
|
236
|
+
self.class == o.class &&
|
237
|
+
id == o.id &&
|
238
|
+
line1 == o.line1 &&
|
239
|
+
line2 == o.line2 &&
|
240
|
+
city == o.city &&
|
241
|
+
state == o.state &&
|
242
|
+
post_code == o.post_code &&
|
243
|
+
country == o.country &&
|
244
|
+
type == o.type &&
|
245
|
+
default_for_type == o.default_for_type
|
246
|
+
end
|
247
|
+
|
248
|
+
# @see the `==` method
|
249
|
+
# @param [Object] Object to be compared
|
250
|
+
def eql?(o)
|
251
|
+
self == o
|
252
|
+
end
|
253
|
+
|
254
|
+
# Calculates hash code according to all attributes.
|
255
|
+
# @return [Integer] Hash code
|
256
|
+
def hash
|
257
|
+
[id, line1, line2, city, state, post_code, country, type, default_for_type].hash
|
258
|
+
end
|
259
|
+
|
260
|
+
# Builds the object from hash
|
261
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
262
|
+
# @return [Object] Returns the model itself
|
263
|
+
def self.build_from_hash(attributes)
|
264
|
+
new.build_from_hash(attributes)
|
265
|
+
end
|
266
|
+
|
267
|
+
# Builds the object from hash
|
268
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
269
|
+
# @return [Object] Returns the model itself
|
270
|
+
def build_from_hash(attributes)
|
271
|
+
return nil unless attributes.is_a?(Hash)
|
272
|
+
self.class.openapi_types.each_pair do |key, type|
|
273
|
+
if type =~ /\AArray<(.*)>/i
|
274
|
+
# check to ensure the input is an array given that the attribute
|
275
|
+
# is documented as an array but the input is not
|
276
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
277
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
278
|
+
end
|
279
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
280
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
281
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
282
|
+
end
|
283
|
+
|
284
|
+
self
|
285
|
+
end
|
286
|
+
|
287
|
+
# Deserializes the data based on type
|
288
|
+
# @param string type Data type
|
289
|
+
# @param string value Value to be deserialized
|
290
|
+
# @return [Object] Deserialized data
|
291
|
+
def _deserialize(type, value)
|
292
|
+
case type.to_sym
|
293
|
+
when :DateTime
|
294
|
+
DateTime.parse(value)
|
295
|
+
when :Date
|
296
|
+
Date.parse(value)
|
297
|
+
when :String
|
298
|
+
value.to_s
|
299
|
+
when :Integer
|
300
|
+
value.to_i
|
301
|
+
when :Float
|
302
|
+
value.to_f
|
303
|
+
when :Boolean
|
304
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
305
|
+
true
|
306
|
+
else
|
307
|
+
false
|
308
|
+
end
|
309
|
+
when :Object
|
310
|
+
# generic object (usually a Hash), return directly
|
311
|
+
value
|
312
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
313
|
+
inner_type = Regexp.last_match[:inner_type]
|
314
|
+
value.map { |v| _deserialize(inner_type, v) }
|
315
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
316
|
+
k_type = Regexp.last_match[:k_type]
|
317
|
+
v_type = Regexp.last_match[:v_type]
|
318
|
+
{}.tap do |hash|
|
319
|
+
value.each do |k, v|
|
320
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
321
|
+
end
|
322
|
+
end
|
323
|
+
else # model
|
324
|
+
DearInventoryRuby.const_get(type).build_from_hash(value)
|
325
|
+
end
|
326
|
+
end
|
327
|
+
|
328
|
+
# Returns the string representation of the object
|
329
|
+
# @return [String] String presentation of the object
|
330
|
+
def to_s
|
331
|
+
to_hash.to_s
|
332
|
+
end
|
333
|
+
|
334
|
+
# to_body is an alias to to_hash (backward compatibility)
|
335
|
+
# @return [Hash] Returns the object in the form of hash
|
336
|
+
def to_body
|
337
|
+
to_hash
|
338
|
+
end
|
339
|
+
|
340
|
+
# Returns the object in the form of hash
|
341
|
+
# @return [Hash] Returns the object in the form of hash
|
342
|
+
def to_hash
|
343
|
+
hash = {}
|
344
|
+
self.class.attribute_map.each_pair do |attr, param|
|
345
|
+
value = self.send(attr)
|
346
|
+
if value.nil?
|
347
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
348
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
349
|
+
end
|
350
|
+
|
351
|
+
hash[param] = _to_hash(value)
|
352
|
+
end
|
353
|
+
hash
|
354
|
+
end
|
355
|
+
|
356
|
+
# Outputs non-array value in the form of hash
|
357
|
+
# For object, use to_hash. Otherwise, just return the value
|
358
|
+
# @param [Object] value Any valid value
|
359
|
+
# @return [Hash] Returns the value in the form of hash
|
360
|
+
def _to_hash(value)
|
361
|
+
if value.is_a?(Array)
|
362
|
+
value.compact.map { |v| _to_hash(v) }
|
363
|
+
elsif value.is_a?(Hash)
|
364
|
+
{}.tap do |hash|
|
365
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
366
|
+
end
|
367
|
+
elsif value.respond_to? :to_hash
|
368
|
+
value.to_hash
|
369
|
+
else
|
370
|
+
value
|
371
|
+
end
|
372
|
+
end
|
373
|
+
end
|
374
|
+
end
|