ultracart_api 4.1.40 → 4.1.42

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,419 @@
1
+ =begin
2
+ #UltraCart Rest API V2
3
+
4
+ #UltraCart REST API Version 2
5
+
6
+ The version of the OpenAPI document: 2.0.0
7
+ Contact: support@ultracart.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.0.1-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module UltracartClient
17
+ class ConversationPbxAvailablePhoneNumber
18
+ # Address requirements
19
+ attr_accessor :address_requirements
20
+
21
+ # ISO country code
22
+ attr_accessor :country
23
+
24
+ # Friendly formatted phone number
25
+ attr_accessor :friendly_name
26
+
27
+ # City/Locality
28
+ attr_accessor :locality
29
+
30
+ # MMS capability
31
+ attr_accessor :mms
32
+
33
+ # Monthly cost for this phone number
34
+ attr_accessor :monthly_cost
35
+
36
+ # Phone number in E.164 format
37
+ attr_accessor :phone_number
38
+
39
+ # State/Province/Region
40
+ attr_accessor :region
41
+
42
+ # SMS capability
43
+ attr_accessor :sms
44
+
45
+ # Voice capability
46
+ attr_accessor :voice
47
+
48
+ class EnumAttributeValidator
49
+ attr_reader :datatype
50
+ attr_reader :allowable_values
51
+
52
+ def initialize(datatype, allowable_values)
53
+ @allowable_values = allowable_values.map do |value|
54
+ case datatype.to_s
55
+ when /Integer/i
56
+ value.to_i
57
+ when /Float/i
58
+ value.to_f
59
+ else
60
+ value
61
+ end
62
+ end
63
+ end
64
+
65
+ def valid?(value)
66
+ !value || allowable_values.include?(value)
67
+ end
68
+ end
69
+
70
+ # Attribute mapping from ruby-style variable name to JSON key.
71
+ def self.attribute_map
72
+ {
73
+ :'address_requirements' => :'address_requirements',
74
+ :'country' => :'country',
75
+ :'friendly_name' => :'friendly_name',
76
+ :'locality' => :'locality',
77
+ :'mms' => :'mms',
78
+ :'monthly_cost' => :'monthly_cost',
79
+ :'phone_number' => :'phone_number',
80
+ :'region' => :'region',
81
+ :'sms' => :'sms',
82
+ :'voice' => :'voice'
83
+ }
84
+ end
85
+
86
+ # Returns all the JSON keys this model knows about
87
+ def self.acceptable_attributes
88
+ attribute_map.values
89
+ end
90
+
91
+ # Attribute type mapping.
92
+ def self.openapi_types
93
+ {
94
+ :'address_requirements' => :'String',
95
+ :'country' => :'String',
96
+ :'friendly_name' => :'String',
97
+ :'locality' => :'String',
98
+ :'mms' => :'Boolean',
99
+ :'monthly_cost' => :'Float',
100
+ :'phone_number' => :'String',
101
+ :'region' => :'String',
102
+ :'sms' => :'Boolean',
103
+ :'voice' => :'Boolean'
104
+ }
105
+ end
106
+
107
+ # List of attributes with nullable: true
108
+ def self.openapi_nullable
109
+ Set.new([
110
+ ])
111
+ end
112
+
113
+ # Initializes the object
114
+ # @param [Hash] attributes Model attributes in the form of hash
115
+ def initialize(attributes = {})
116
+ if (!attributes.is_a?(Hash))
117
+ fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::ConversationPbxAvailablePhoneNumber` initialize method"
118
+ end
119
+
120
+ # check to see if the attribute exists and convert string to symbol for hash key
121
+ attributes = attributes.each_with_object({}) { |(k, v), h|
122
+ if (!self.class.attribute_map.key?(k.to_sym))
123
+ fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::ConversationPbxAvailablePhoneNumber`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
124
+ end
125
+ h[k.to_sym] = v
126
+ }
127
+
128
+ if attributes.key?(:'address_requirements')
129
+ self.address_requirements = attributes[:'address_requirements']
130
+ end
131
+
132
+ if attributes.key?(:'country')
133
+ self.country = attributes[:'country']
134
+ end
135
+
136
+ if attributes.key?(:'friendly_name')
137
+ self.friendly_name = attributes[:'friendly_name']
138
+ end
139
+
140
+ if attributes.key?(:'locality')
141
+ self.locality = attributes[:'locality']
142
+ end
143
+
144
+ if attributes.key?(:'mms')
145
+ self.mms = attributes[:'mms']
146
+ end
147
+
148
+ if attributes.key?(:'monthly_cost')
149
+ self.monthly_cost = attributes[:'monthly_cost']
150
+ end
151
+
152
+ if attributes.key?(:'phone_number')
153
+ self.phone_number = attributes[:'phone_number']
154
+ end
155
+
156
+ if attributes.key?(:'region')
157
+ self.region = attributes[:'region']
158
+ end
159
+
160
+ if attributes.key?(:'sms')
161
+ self.sms = attributes[:'sms']
162
+ end
163
+
164
+ if attributes.key?(:'voice')
165
+ self.voice = attributes[:'voice']
166
+ end
167
+ end
168
+
169
+ # Show invalid properties with the reasons. Usually used together with valid?
170
+ # @return Array for valid properties with the reasons
171
+ def list_invalid_properties
172
+ invalid_properties = Array.new
173
+ if !@country.nil? && @country.to_s.length > 2
174
+ invalid_properties.push('invalid value for "country", the character length must be smaller than or equal to 2.')
175
+ end
176
+
177
+ if !@friendly_name.nil? && @friendly_name.to_s.length > 50
178
+ invalid_properties.push('invalid value for "friendly_name", the character length must be smaller than or equal to 50.')
179
+ end
180
+
181
+ if !@locality.nil? && @locality.to_s.length > 100
182
+ invalid_properties.push('invalid value for "locality", the character length must be smaller than or equal to 100.')
183
+ end
184
+
185
+ if !@phone_number.nil? && @phone_number.to_s.length > 50
186
+ invalid_properties.push('invalid value for "phone_number", the character length must be smaller than or equal to 50.')
187
+ end
188
+
189
+ if !@region.nil? && @region.to_s.length > 50
190
+ invalid_properties.push('invalid value for "region", the character length must be smaller than or equal to 50.')
191
+ end
192
+
193
+ invalid_properties
194
+ end
195
+
196
+ # Check to see if the all the properties in the model are valid
197
+ # @return true if the model is valid
198
+ def valid?
199
+ address_requirements_validator = EnumAttributeValidator.new('String', ["none", "any", "local", "foreign"])
200
+ return false unless address_requirements_validator.valid?(@address_requirements)
201
+ return false if !@country.nil? && @country.to_s.length > 2
202
+ return false if !@friendly_name.nil? && @friendly_name.to_s.length > 50
203
+ return false if !@locality.nil? && @locality.to_s.length > 100
204
+ return false if !@phone_number.nil? && @phone_number.to_s.length > 50
205
+ return false if !@region.nil? && @region.to_s.length > 50
206
+ true
207
+ end
208
+
209
+ # Custom attribute writer method checking allowed values (enum).
210
+ # @param [Object] address_requirements Object to be assigned
211
+ def address_requirements=(address_requirements)
212
+ validator = EnumAttributeValidator.new('String', ["none", "any", "local", "foreign"])
213
+ unless validator.valid?(address_requirements)
214
+ fail ArgumentError, "invalid value for \"address_requirements\", must be one of #{validator.allowable_values}."
215
+ end
216
+ @address_requirements = address_requirements
217
+ end
218
+
219
+ # Custom attribute writer method with validation
220
+ # @param [Object] country Value to be assigned
221
+ def country=(country)
222
+ if !country.nil? && country.to_s.length > 2
223
+ fail ArgumentError, 'invalid value for "country", the character length must be smaller than or equal to 2.'
224
+ end
225
+
226
+ @country = country
227
+ end
228
+
229
+ # Custom attribute writer method with validation
230
+ # @param [Object] friendly_name Value to be assigned
231
+ def friendly_name=(friendly_name)
232
+ if !friendly_name.nil? && friendly_name.to_s.length > 50
233
+ fail ArgumentError, 'invalid value for "friendly_name", the character length must be smaller than or equal to 50.'
234
+ end
235
+
236
+ @friendly_name = friendly_name
237
+ end
238
+
239
+ # Custom attribute writer method with validation
240
+ # @param [Object] locality Value to be assigned
241
+ def locality=(locality)
242
+ if !locality.nil? && locality.to_s.length > 100
243
+ fail ArgumentError, 'invalid value for "locality", the character length must be smaller than or equal to 100.'
244
+ end
245
+
246
+ @locality = locality
247
+ end
248
+
249
+ # Custom attribute writer method with validation
250
+ # @param [Object] phone_number Value to be assigned
251
+ def phone_number=(phone_number)
252
+ if !phone_number.nil? && phone_number.to_s.length > 50
253
+ fail ArgumentError, 'invalid value for "phone_number", the character length must be smaller than or equal to 50.'
254
+ end
255
+
256
+ @phone_number = phone_number
257
+ end
258
+
259
+ # Custom attribute writer method with validation
260
+ # @param [Object] region Value to be assigned
261
+ def region=(region)
262
+ if !region.nil? && region.to_s.length > 50
263
+ fail ArgumentError, 'invalid value for "region", the character length must be smaller than or equal to 50.'
264
+ end
265
+
266
+ @region = region
267
+ end
268
+
269
+ # Checks equality by comparing each attribute.
270
+ # @param [Object] Object to be compared
271
+ def ==(o)
272
+ return true if self.equal?(o)
273
+ self.class == o.class &&
274
+ address_requirements == o.address_requirements &&
275
+ country == o.country &&
276
+ friendly_name == o.friendly_name &&
277
+ locality == o.locality &&
278
+ mms == o.mms &&
279
+ monthly_cost == o.monthly_cost &&
280
+ phone_number == o.phone_number &&
281
+ region == o.region &&
282
+ sms == o.sms &&
283
+ voice == o.voice
284
+ end
285
+
286
+ # @see the `==` method
287
+ # @param [Object] Object to be compared
288
+ def eql?(o)
289
+ self == o
290
+ end
291
+
292
+ # Calculates hash code according to all attributes.
293
+ # @return [Integer] Hash code
294
+ def hash
295
+ [address_requirements, country, friendly_name, locality, mms, monthly_cost, phone_number, region, sms, voice].hash
296
+ end
297
+
298
+ # Builds the object from hash
299
+ # @param [Hash] attributes Model attributes in the form of hash
300
+ # @return [Object] Returns the model itself
301
+ def self.build_from_hash(attributes)
302
+ new.build_from_hash(attributes)
303
+ end
304
+
305
+ # Builds the object from hash
306
+ # @param [Hash] attributes Model attributes in the form of hash
307
+ # @return [Object] Returns the model itself
308
+ def build_from_hash(attributes)
309
+ return nil unless attributes.is_a?(Hash)
310
+ attributes = attributes.transform_keys(&:to_sym)
311
+ self.class.openapi_types.each_pair do |key, type|
312
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
313
+ self.send("#{key}=", nil)
314
+ elsif type =~ /\AArray<(.*)>/i
315
+ # check to ensure the input is an array given that the attribute
316
+ # is documented as an array but the input is not
317
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
318
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
319
+ end
320
+ elsif !attributes[self.class.attribute_map[key]].nil?
321
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
322
+ end
323
+ end
324
+
325
+ self
326
+ end
327
+
328
+ # Deserializes the data based on type
329
+ # @param string type Data type
330
+ # @param string value Value to be deserialized
331
+ # @return [Object] Deserialized data
332
+ def _deserialize(type, value)
333
+ case type.to_sym
334
+ when :Time
335
+ Time.parse(value)
336
+ when :Date
337
+ Date.parse(value)
338
+ when :String
339
+ value.to_s
340
+ when :Integer
341
+ value.to_i
342
+ when :Float
343
+ value.to_f
344
+ when :Boolean
345
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
346
+ true
347
+ else
348
+ false
349
+ end
350
+ when :Object
351
+ # generic object (usually a Hash), return directly
352
+ value
353
+ when /\AArray<(?<inner_type>.+)>\z/
354
+ inner_type = Regexp.last_match[:inner_type]
355
+ value.map { |v| _deserialize(inner_type, v) }
356
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
357
+ k_type = Regexp.last_match[:k_type]
358
+ v_type = Regexp.last_match[:v_type]
359
+ {}.tap do |hash|
360
+ value.each do |k, v|
361
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
362
+ end
363
+ end
364
+ else # model
365
+ # models (e.g. Pet) or oneOf
366
+ klass = UltracartClient.const_get(type)
367
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
368
+ end
369
+ end
370
+
371
+ # Returns the string representation of the object
372
+ # @return [String] String presentation of the object
373
+ def to_s
374
+ to_hash.to_s
375
+ end
376
+
377
+ # to_body is an alias to to_hash (backward compatibility)
378
+ # @return [Hash] Returns the object in the form of hash
379
+ def to_body
380
+ to_hash
381
+ end
382
+
383
+ # Returns the object in the form of hash
384
+ # @return [Hash] Returns the object in the form of hash
385
+ def to_hash
386
+ hash = {}
387
+ self.class.attribute_map.each_pair do |attr, param|
388
+ value = self.send(attr)
389
+ if value.nil?
390
+ is_nullable = self.class.openapi_nullable.include?(attr)
391
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
392
+ end
393
+
394
+ hash[param] = _to_hash(value)
395
+ end
396
+ hash
397
+ end
398
+
399
+ # Outputs non-array value in the form of hash
400
+ # For object, use to_hash. Otherwise, just return the value
401
+ # @param [Object] value Any valid value
402
+ # @return [Hash] Returns the value in the form of hash
403
+ def _to_hash(value)
404
+ if value.is_a?(Array)
405
+ value.compact.map { |v| _to_hash(v) }
406
+ elsif value.is_a?(Hash)
407
+ {}.tap do |hash|
408
+ value.each { |k, v| hash[k] = _to_hash(v) }
409
+ end
410
+ elsif value.respond_to? :to_hash
411
+ value.to_hash
412
+ else
413
+ value
414
+ end
415
+ end
416
+
417
+ end
418
+
419
+ end
@@ -0,0 +1,258 @@
1
+ =begin
2
+ #UltraCart Rest API V2
3
+
4
+ #UltraCart REST API Version 2
5
+
6
+ The version of the OpenAPI document: 2.0.0
7
+ Contact: support@ultracart.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 6.0.1-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module UltracartClient
17
+ class ConversationPbxAvailablePhoneNumbersResponse
18
+ attr_accessor :available_phone_numbers
19
+
20
+ attr_accessor :error
21
+
22
+ attr_accessor :metadata
23
+
24
+ # Indicates if API call was successful
25
+ attr_accessor :success
26
+
27
+ attr_accessor :warning
28
+
29
+ # Attribute mapping from ruby-style variable name to JSON key.
30
+ def self.attribute_map
31
+ {
32
+ :'available_phone_numbers' => :'available_phone_numbers',
33
+ :'error' => :'error',
34
+ :'metadata' => :'metadata',
35
+ :'success' => :'success',
36
+ :'warning' => :'warning'
37
+ }
38
+ end
39
+
40
+ # Returns all the JSON keys this model knows about
41
+ def self.acceptable_attributes
42
+ attribute_map.values
43
+ end
44
+
45
+ # Attribute type mapping.
46
+ def self.openapi_types
47
+ {
48
+ :'available_phone_numbers' => :'Array<ConversationPbxAvailablePhoneNumber>',
49
+ :'error' => :'Error',
50
+ :'metadata' => :'ResponseMetadata',
51
+ :'success' => :'Boolean',
52
+ :'warning' => :'Warning'
53
+ }
54
+ end
55
+
56
+ # List of attributes with nullable: true
57
+ def self.openapi_nullable
58
+ Set.new([
59
+ ])
60
+ end
61
+
62
+ # Initializes the object
63
+ # @param [Hash] attributes Model attributes in the form of hash
64
+ def initialize(attributes = {})
65
+ if (!attributes.is_a?(Hash))
66
+ fail ArgumentError, "The input argument (attributes) must be a hash in `UltracartClient::ConversationPbxAvailablePhoneNumbersResponse` initialize method"
67
+ end
68
+
69
+ # check to see if the attribute exists and convert string to symbol for hash key
70
+ attributes = attributes.each_with_object({}) { |(k, v), h|
71
+ if (!self.class.attribute_map.key?(k.to_sym))
72
+ fail ArgumentError, "`#{k}` is not a valid attribute in `UltracartClient::ConversationPbxAvailablePhoneNumbersResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
73
+ end
74
+ h[k.to_sym] = v
75
+ }
76
+
77
+ if attributes.key?(:'available_phone_numbers')
78
+ if (value = attributes[:'available_phone_numbers']).is_a?(Array)
79
+ self.available_phone_numbers = value
80
+ end
81
+ end
82
+
83
+ if attributes.key?(:'error')
84
+ self.error = attributes[:'error']
85
+ end
86
+
87
+ if attributes.key?(:'metadata')
88
+ self.metadata = attributes[:'metadata']
89
+ end
90
+
91
+ if attributes.key?(:'success')
92
+ self.success = attributes[:'success']
93
+ end
94
+
95
+ if attributes.key?(:'warning')
96
+ self.warning = attributes[:'warning']
97
+ end
98
+ end
99
+
100
+ # Show invalid properties with the reasons. Usually used together with valid?
101
+ # @return Array for valid properties with the reasons
102
+ def list_invalid_properties
103
+ invalid_properties = Array.new
104
+ invalid_properties
105
+ end
106
+
107
+ # Check to see if the all the properties in the model are valid
108
+ # @return true if the model is valid
109
+ def valid?
110
+ true
111
+ end
112
+
113
+ # Checks equality by comparing each attribute.
114
+ # @param [Object] Object to be compared
115
+ def ==(o)
116
+ return true if self.equal?(o)
117
+ self.class == o.class &&
118
+ available_phone_numbers == o.available_phone_numbers &&
119
+ error == o.error &&
120
+ metadata == o.metadata &&
121
+ success == o.success &&
122
+ warning == o.warning
123
+ end
124
+
125
+ # @see the `==` method
126
+ # @param [Object] Object to be compared
127
+ def eql?(o)
128
+ self == o
129
+ end
130
+
131
+ # Calculates hash code according to all attributes.
132
+ # @return [Integer] Hash code
133
+ def hash
134
+ [available_phone_numbers, error, metadata, success, warning].hash
135
+ end
136
+
137
+ # Builds the object from hash
138
+ # @param [Hash] attributes Model attributes in the form of hash
139
+ # @return [Object] Returns the model itself
140
+ def self.build_from_hash(attributes)
141
+ new.build_from_hash(attributes)
142
+ end
143
+
144
+ # Builds the object from hash
145
+ # @param [Hash] attributes Model attributes in the form of hash
146
+ # @return [Object] Returns the model itself
147
+ def build_from_hash(attributes)
148
+ return nil unless attributes.is_a?(Hash)
149
+ attributes = attributes.transform_keys(&:to_sym)
150
+ self.class.openapi_types.each_pair do |key, type|
151
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
152
+ self.send("#{key}=", nil)
153
+ elsif type =~ /\AArray<(.*)>/i
154
+ # check to ensure the input is an array given that the attribute
155
+ # is documented as an array but the input is not
156
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
157
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
158
+ end
159
+ elsif !attributes[self.class.attribute_map[key]].nil?
160
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
161
+ end
162
+ end
163
+
164
+ self
165
+ end
166
+
167
+ # Deserializes the data based on type
168
+ # @param string type Data type
169
+ # @param string value Value to be deserialized
170
+ # @return [Object] Deserialized data
171
+ def _deserialize(type, value)
172
+ case type.to_sym
173
+ when :Time
174
+ Time.parse(value)
175
+ when :Date
176
+ Date.parse(value)
177
+ when :String
178
+ value.to_s
179
+ when :Integer
180
+ value.to_i
181
+ when :Float
182
+ value.to_f
183
+ when :Boolean
184
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
185
+ true
186
+ else
187
+ false
188
+ end
189
+ when :Object
190
+ # generic object (usually a Hash), return directly
191
+ value
192
+ when /\AArray<(?<inner_type>.+)>\z/
193
+ inner_type = Regexp.last_match[:inner_type]
194
+ value.map { |v| _deserialize(inner_type, v) }
195
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
196
+ k_type = Regexp.last_match[:k_type]
197
+ v_type = Regexp.last_match[:v_type]
198
+ {}.tap do |hash|
199
+ value.each do |k, v|
200
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
201
+ end
202
+ end
203
+ else # model
204
+ # models (e.g. Pet) or oneOf
205
+ klass = UltracartClient.const_get(type)
206
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
207
+ end
208
+ end
209
+
210
+ # Returns the string representation of the object
211
+ # @return [String] String presentation of the object
212
+ def to_s
213
+ to_hash.to_s
214
+ end
215
+
216
+ # to_body is an alias to to_hash (backward compatibility)
217
+ # @return [Hash] Returns the object in the form of hash
218
+ def to_body
219
+ to_hash
220
+ end
221
+
222
+ # Returns the object in the form of hash
223
+ # @return [Hash] Returns the object in the form of hash
224
+ def to_hash
225
+ hash = {}
226
+ self.class.attribute_map.each_pair do |attr, param|
227
+ value = self.send(attr)
228
+ if value.nil?
229
+ is_nullable = self.class.openapi_nullable.include?(attr)
230
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
231
+ end
232
+
233
+ hash[param] = _to_hash(value)
234
+ end
235
+ hash
236
+ end
237
+
238
+ # Outputs non-array value in the form of hash
239
+ # For object, use to_hash. Otherwise, just return the value
240
+ # @param [Object] value Any valid value
241
+ # @return [Hash] Returns the value in the form of hash
242
+ def _to_hash(value)
243
+ if value.is_a?(Array)
244
+ value.compact.map { |v| _to_hash(v) }
245
+ elsif value.is_a?(Hash)
246
+ {}.tap do |hash|
247
+ value.each { |k, v| hash[k] = _to_hash(v) }
248
+ end
249
+ elsif value.respond_to? :to_hash
250
+ value.to_hash
251
+ else
252
+ value
253
+ end
254
+ end
255
+
256
+ end
257
+
258
+ end