ultracart_api 3.11.39 → 3.11.41

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