dear-inventory-ruby 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,381 @@
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.2.3
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module DearInventoryRuby
16
+ class Contact
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
+ # Name of Contact
21
+ attr_accessor :name
22
+
23
+ # Phone
24
+ attr_accessor :phone
25
+
26
+ # Fax
27
+ attr_accessor :fax
28
+
29
+ # Email
30
+ attr_accessor :email
31
+
32
+ # Website
33
+ attr_accessor :website
34
+
35
+ # Comment
36
+ attr_accessor :comment
37
+
38
+ # Points that Contact is used as default. `false` as default.
39
+ attr_accessor :default
40
+
41
+ # Points that Contact is included in Email. `false` as default.
42
+ attr_accessor :include_in_email
43
+
44
+ # Attribute mapping from ruby-style variable name to JSON key.
45
+ def self.attribute_map
46
+ {
47
+ :'id' => :'ID',
48
+ :'name' => :'Name',
49
+ :'phone' => :'Phone',
50
+ :'fax' => :'Fax',
51
+ :'email' => :'Email',
52
+ :'website' => :'Website',
53
+ :'comment' => :'Comment',
54
+ :'default' => :'Default',
55
+ :'include_in_email' => :'IncludeInEmail'
56
+ }
57
+ end
58
+
59
+ # Attribute type mapping.
60
+ def self.openapi_types
61
+ {
62
+ :'id' => :'String',
63
+ :'name' => :'String',
64
+ :'phone' => :'String',
65
+ :'fax' => :'String',
66
+ :'email' => :'String',
67
+ :'website' => :'String',
68
+ :'comment' => :'String',
69
+ :'default' => :'Boolean',
70
+ :'include_in_email' => :'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::Contact` 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::Contact`. 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?(:'name')
100
+ self.name = attributes[:'name']
101
+ end
102
+
103
+ if attributes.key?(:'phone')
104
+ self.phone = attributes[:'phone']
105
+ end
106
+
107
+ if attributes.key?(:'fax')
108
+ self.fax = attributes[:'fax']
109
+ end
110
+
111
+ if attributes.key?(:'email')
112
+ self.email = attributes[:'email']
113
+ end
114
+
115
+ if attributes.key?(:'website')
116
+ self.website = attributes[:'website']
117
+ end
118
+
119
+ if attributes.key?(:'comment')
120
+ self.comment = attributes[:'comment']
121
+ end
122
+
123
+ if attributes.key?(:'default')
124
+ self.default = attributes[:'default']
125
+ else
126
+ self.default = false
127
+ end
128
+
129
+ if attributes.key?(:'include_in_email')
130
+ self.include_in_email = attributes[:'include_in_email']
131
+ else
132
+ self.include_in_email = false
133
+ end
134
+ end
135
+
136
+ # Show invalid properties with the reasons. Usually used together with valid?
137
+ # @return Array for valid properties with the reasons
138
+ def list_invalid_properties
139
+ invalid_properties = Array.new
140
+ if !@name.nil? && @name.to_s.length > 256
141
+ invalid_properties.push('invalid value for "name", the character length must be smaller than or equal to 256.')
142
+ end
143
+
144
+ if !@phone.nil? && @phone.to_s.length > 50
145
+ invalid_properties.push('invalid value for "phone", the character length must be smaller than or equal to 50.')
146
+ end
147
+
148
+ if !@fax.nil? && @fax.to_s.length > 50
149
+ invalid_properties.push('invalid value for "fax", the character length must be smaller than or equal to 50.')
150
+ end
151
+
152
+ if !@email.nil? && @email.to_s.length > 256
153
+ invalid_properties.push('invalid value for "email", the character length must be smaller than or equal to 256.')
154
+ end
155
+
156
+ if !@website.nil? && @website.to_s.length > 256
157
+ invalid_properties.push('invalid value for "website", the character length must be smaller than or equal to 256.')
158
+ end
159
+
160
+ if !@comment.nil? && @comment.to_s.length > 256
161
+ invalid_properties.push('invalid value for "comment", the character length must be smaller than or equal to 256.')
162
+ end
163
+
164
+ invalid_properties
165
+ end
166
+
167
+ # Check to see if the all the properties in the model are valid
168
+ # @return true if the model is valid
169
+ def valid?
170
+ return false if !@name.nil? && @name.to_s.length > 256
171
+ return false if !@phone.nil? && @phone.to_s.length > 50
172
+ return false if !@fax.nil? && @fax.to_s.length > 50
173
+ return false if !@email.nil? && @email.to_s.length > 256
174
+ return false if !@website.nil? && @website.to_s.length > 256
175
+ return false if !@comment.nil? && @comment.to_s.length > 256
176
+ true
177
+ end
178
+
179
+ # Custom attribute writer method with validation
180
+ # @param [Object] name Value to be assigned
181
+ def name=(name)
182
+ if !name.nil? && name.to_s.length > 256
183
+ fail ArgumentError, 'invalid value for "name", the character length must be smaller than or equal to 256.'
184
+ end
185
+
186
+ @name = name
187
+ end
188
+
189
+ # Custom attribute writer method with validation
190
+ # @param [Object] phone Value to be assigned
191
+ def phone=(phone)
192
+ if !phone.nil? && phone.to_s.length > 50
193
+ fail ArgumentError, 'invalid value for "phone", the character length must be smaller than or equal to 50.'
194
+ end
195
+
196
+ @phone = phone
197
+ end
198
+
199
+ # Custom attribute writer method with validation
200
+ # @param [Object] fax Value to be assigned
201
+ def fax=(fax)
202
+ if !fax.nil? && fax.to_s.length > 50
203
+ fail ArgumentError, 'invalid value for "fax", the character length must be smaller than or equal to 50.'
204
+ end
205
+
206
+ @fax = fax
207
+ end
208
+
209
+ # Custom attribute writer method with validation
210
+ # @param [Object] email Value to be assigned
211
+ def email=(email)
212
+ if !email.nil? && email.to_s.length > 256
213
+ fail ArgumentError, 'invalid value for "email", the character length must be smaller than or equal to 256.'
214
+ end
215
+
216
+ @email = email
217
+ end
218
+
219
+ # Custom attribute writer method with validation
220
+ # @param [Object] website Value to be assigned
221
+ def website=(website)
222
+ if !website.nil? && website.to_s.length > 256
223
+ fail ArgumentError, 'invalid value for "website", the character length must be smaller than or equal to 256.'
224
+ end
225
+
226
+ @website = website
227
+ end
228
+
229
+ # Custom attribute writer method with validation
230
+ # @param [Object] comment Value to be assigned
231
+ def comment=(comment)
232
+ if !comment.nil? && comment.to_s.length > 256
233
+ fail ArgumentError, 'invalid value for "comment", the character length must be smaller than or equal to 256.'
234
+ end
235
+
236
+ @comment = comment
237
+ end
238
+
239
+ # Checks equality by comparing each attribute.
240
+ # @param [Object] Object to be compared
241
+ def ==(o)
242
+ return true if self.equal?(o)
243
+ self.class == o.class &&
244
+ id == o.id &&
245
+ name == o.name &&
246
+ phone == o.phone &&
247
+ fax == o.fax &&
248
+ email == o.email &&
249
+ website == o.website &&
250
+ comment == o.comment &&
251
+ default == o.default &&
252
+ include_in_email == o.include_in_email
253
+ end
254
+
255
+ # @see the `==` method
256
+ # @param [Object] Object to be compared
257
+ def eql?(o)
258
+ self == o
259
+ end
260
+
261
+ # Calculates hash code according to all attributes.
262
+ # @return [Integer] Hash code
263
+ def hash
264
+ [id, name, phone, fax, email, website, comment, default, include_in_email].hash
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 self.build_from_hash(attributes)
271
+ new.build_from_hash(attributes)
272
+ end
273
+
274
+ # Builds the object from hash
275
+ # @param [Hash] attributes Model attributes in the form of hash
276
+ # @return [Object] Returns the model itself
277
+ def build_from_hash(attributes)
278
+ return nil unless attributes.is_a?(Hash)
279
+ self.class.openapi_types.each_pair do |key, type|
280
+ if type =~ /\AArray<(.*)>/i
281
+ # check to ensure the input is an array given that the attribute
282
+ # is documented as an array but the input is not
283
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
284
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
285
+ end
286
+ elsif !attributes[self.class.attribute_map[key]].nil?
287
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
288
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
289
+ end
290
+
291
+ self
292
+ end
293
+
294
+ # Deserializes the data based on type
295
+ # @param string type Data type
296
+ # @param string value Value to be deserialized
297
+ # @return [Object] Deserialized data
298
+ def _deserialize(type, value)
299
+ case type.to_sym
300
+ when :DateTime
301
+ DateTime.parse(value)
302
+ when :Date
303
+ Date.parse(value)
304
+ when :String
305
+ value.to_s
306
+ when :Integer
307
+ value.to_i
308
+ when :Float
309
+ value.to_f
310
+ when :Boolean
311
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
312
+ true
313
+ else
314
+ false
315
+ end
316
+ when :Object
317
+ # generic object (usually a Hash), return directly
318
+ value
319
+ when /\AArray<(?<inner_type>.+)>\z/
320
+ inner_type = Regexp.last_match[:inner_type]
321
+ value.map { |v| _deserialize(inner_type, v) }
322
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
323
+ k_type = Regexp.last_match[:k_type]
324
+ v_type = Regexp.last_match[:v_type]
325
+ {}.tap do |hash|
326
+ value.each do |k, v|
327
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
328
+ end
329
+ end
330
+ else # model
331
+ DearInventoryRuby.const_get(type).build_from_hash(value)
332
+ end
333
+ end
334
+
335
+ # Returns the string representation of the object
336
+ # @return [String] String presentation of the object
337
+ def to_s
338
+ to_hash.to_s
339
+ end
340
+
341
+ # to_body is an alias to to_hash (backward compatibility)
342
+ # @return [Hash] Returns the object in the form of hash
343
+ def to_body
344
+ to_hash
345
+ end
346
+
347
+ # Returns the object in the form of hash
348
+ # @return [Hash] Returns the object in the form of hash
349
+ def to_hash
350
+ hash = {}
351
+ self.class.attribute_map.each_pair do |attr, param|
352
+ value = self.send(attr)
353
+ if value.nil?
354
+ is_nullable = self.class.openapi_nullable.include?(attr)
355
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
356
+ end
357
+
358
+ hash[param] = _to_hash(value)
359
+ end
360
+ hash
361
+ end
362
+
363
+ # Outputs non-array value in the form of hash
364
+ # For object, use to_hash. Otherwise, just return the value
365
+ # @param [Object] value Any valid value
366
+ # @return [Hash] Returns the value in the form of hash
367
+ def _to_hash(value)
368
+ if value.is_a?(Array)
369
+ value.compact.map { |v| _to_hash(v) }
370
+ elsif value.is_a?(Hash)
371
+ {}.tap do |hash|
372
+ value.each { |k, v| hash[k] = _to_hash(v) }
373
+ end
374
+ elsif value.respond_to? :to_hash
375
+ value.to_hash
376
+ else
377
+ value
378
+ end
379
+ end
380
+ end
381
+ end
@@ -0,0 +1,196 @@
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.2.3
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module DearInventoryRuby
16
+ class CurrencyCode
17
+ AED = "AED".freeze
18
+ AFN = "AFN".freeze
19
+ ALL = "ALL".freeze
20
+ AMD = "AMD".freeze
21
+ ANG = "ANG".freeze
22
+ AOA = "AOA".freeze
23
+ ARS = "ARS".freeze
24
+ AUD = "AUD".freeze
25
+ AWG = "AWG".freeze
26
+ AZN = "AZN".freeze
27
+ BAM = "BAM".freeze
28
+ BBD = "BBD".freeze
29
+ BDT = "BDT".freeze
30
+ BGN = "BGN".freeze
31
+ BHD = "BHD".freeze
32
+ BIF = "BIF".freeze
33
+ BMD = "BMD".freeze
34
+ BND = "BND".freeze
35
+ BOB = "BOB".freeze
36
+ BRL = "BRL".freeze
37
+ BSD = "BSD".freeze
38
+ BTN = "BTN".freeze
39
+ BWP = "BWP".freeze
40
+ BYN = "BYN".freeze
41
+ BZD = "BZD".freeze
42
+ CAD = "CAD".freeze
43
+ CDF = "CDF".freeze
44
+ CHF = "CHF".freeze
45
+ CLP = "CLP".freeze
46
+ CNY = "CNY".freeze
47
+ COP = "COP".freeze
48
+ CRC = "CRC".freeze
49
+ CUC = "CUC".freeze
50
+ CUP = "CUP".freeze
51
+ CVE = "CVE".freeze
52
+ CZK = "CZK".freeze
53
+ DJF = "DJF".freeze
54
+ DKK = "DKK".freeze
55
+ DOP = "DOP".freeze
56
+ DZD = "DZD".freeze
57
+ EGP = "EGP".freeze
58
+ ERN = "ERN".freeze
59
+ ETB = "ETB".freeze
60
+ EUR = "EUR".freeze
61
+ FJD = "FJD".freeze
62
+ FKP = "FKP".freeze
63
+ GBP = "GBP".freeze
64
+ GEL = "GEL".freeze
65
+ GGP = "GGP".freeze
66
+ GHS = "GHS".freeze
67
+ GIP = "GIP".freeze
68
+ GMD = "GMD".freeze
69
+ GNF = "GNF".freeze
70
+ GTQ = "GTQ".freeze
71
+ GYD = "GYD".freeze
72
+ HKD = "HKD".freeze
73
+ HNL = "HNL".freeze
74
+ HRK = "HRK".freeze
75
+ HTG = "HTG".freeze
76
+ HUF = "HUF".freeze
77
+ IDR = "IDR".freeze
78
+ ILS = "ILS".freeze
79
+ IMP = "IMP".freeze
80
+ INR = "INR".freeze
81
+ IQD = "IQD".freeze
82
+ IRR = "IRR".freeze
83
+ ISK = "ISK".freeze
84
+ JEP = "JEP".freeze
85
+ JMD = "JMD".freeze
86
+ JOD = "JOD".freeze
87
+ JPY = "JPY".freeze
88
+ KES = "KES".freeze
89
+ KGS = "KGS".freeze
90
+ KHR = "KHR".freeze
91
+ KMF = "KMF".freeze
92
+ KPW = "KPW".freeze
93
+ KRW = "KRW".freeze
94
+ KWD = "KWD".freeze
95
+ KYD = "KYD".freeze
96
+ KZT = "KZT".freeze
97
+ LAK = "LAK".freeze
98
+ LBP = "LBP".freeze
99
+ LKR = "LKR".freeze
100
+ LRD = "LRD".freeze
101
+ LSL = "LSL".freeze
102
+ LYD = "LYD".freeze
103
+ MAD = "MAD".freeze
104
+ MDL = "MDL".freeze
105
+ MGA = "MGA".freeze
106
+ MKD = "MKD".freeze
107
+ MMK = "MMK".freeze
108
+ MNT = "MNT".freeze
109
+ MOP = "MOP".freeze
110
+ MRU = "MRU".freeze
111
+ MUR = "MUR".freeze
112
+ MVR = "MVR".freeze
113
+ MWK = "MWK".freeze
114
+ MXN = "MXN".freeze
115
+ MYR = "MYR".freeze
116
+ MZN = "MZN".freeze
117
+ NAD = "NAD".freeze
118
+ NGN = "NGN".freeze
119
+ NIO = "NIO".freeze
120
+ NOK = "NOK".freeze
121
+ NPR = "NPR".freeze
122
+ NZD = "NZD".freeze
123
+ OMR = "OMR".freeze
124
+ PAB = "PAB".freeze
125
+ PEN = "PEN".freeze
126
+ PGK = "PGK".freeze
127
+ PHP = "PHP".freeze
128
+ PKR = "PKR".freeze
129
+ PLN = "PLN".freeze
130
+ PYG = "PYG".freeze
131
+ QAR = "QAR".freeze
132
+ RON = "RON".freeze
133
+ RSD = "RSD".freeze
134
+ RUB = "RUB".freeze
135
+ RWF = "RWF".freeze
136
+ SAR = "SAR".freeze
137
+ SBD = "SBD".freeze
138
+ SCR = "SCR".freeze
139
+ SDG = "SDG".freeze
140
+ SEK = "SEK".freeze
141
+ SGD = "SGD".freeze
142
+ SHP = "SHP".freeze
143
+ SLL = "SLL".freeze
144
+ SOS = "SOS".freeze
145
+ SPL = "SPL".freeze
146
+ SRD = "SRD".freeze
147
+ STN = "STN".freeze
148
+ SVC = "SVC".freeze
149
+ SYP = "SYP".freeze
150
+ SZL = "SZL".freeze
151
+ THB = "THB".freeze
152
+ TJS = "TJS".freeze
153
+ TMT = "TMT".freeze
154
+ TND = "TND".freeze
155
+ TOP = "TOP".freeze
156
+ TRY = "TRY".freeze
157
+ TTD = "TTD".freeze
158
+ TVD = "TVD".freeze
159
+ TWD = "TWD".freeze
160
+ TZS = "TZS".freeze
161
+ UAH = "UAH".freeze
162
+ UGX = "UGX".freeze
163
+ USD = "USD".freeze
164
+ UYU = "UYU".freeze
165
+ UZS = "UZS".freeze
166
+ VEF = "VEF".freeze
167
+ VND = "VND".freeze
168
+ VUV = "VUV".freeze
169
+ WST = "WST".freeze
170
+ XAF = "XAF".freeze
171
+ XCD = "XCD".freeze
172
+ XDR = "XDR".freeze
173
+ XOF = "XOF".freeze
174
+ XPF = "XPF".freeze
175
+ YER = "YER".freeze
176
+ ZAR = "ZAR".freeze
177
+ ZMW = "ZMW".freeze
178
+ ZWD = "ZWD".freeze
179
+
180
+ # Builds the enum from string
181
+ # @param [String] The enum value in the form of the string
182
+ # @return [String] The enum value
183
+ def self.build_from_hash(value)
184
+ new.build_from_hash(value)
185
+ end
186
+
187
+ # Builds the enum from string
188
+ # @param [String] The enum value in the form of the string
189
+ # @return [String] The enum value
190
+ def build_from_hash(value)
191
+ constantValues = CurrencyCode.constants.select { |c| CurrencyCode::const_get(c) == value }
192
+ raise "Invalid ENUM value #{value} for class #CurrencyCode" if constantValues.empty?
193
+ value
194
+ end
195
+ end
196
+ end