talon_one 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +7 -4
  3. data/docs/Application.md +1 -1
  4. data/docs/Campaign.md +2 -0
  5. data/docs/InlineResponse20025.md +2 -1
  6. data/docs/IntegrationState.md +1 -0
  7. data/docs/ManagementApi.md +11 -1
  8. data/docs/NewApplication.md +1 -1
  9. data/docs/NewSamlConnection.md +15 -0
  10. data/docs/SamlConnection.md +19 -0
  11. data/docs/UpdateApplication.md +14 -0
  12. data/docs/User.md +1 -0
  13. data/lib/talon_one.rb +3 -0
  14. data/lib/talon_one/api/management_api.rb +15 -0
  15. data/lib/talon_one/models/application.rb +53 -53
  16. data/lib/talon_one/models/campaign.rb +21 -1
  17. data/lib/talon_one/models/inline_response_200_25.rb +10 -6
  18. data/lib/talon_one/models/integration_state.rb +13 -4
  19. data/lib/talon_one/models/limit_config.rb +2 -2
  20. data/lib/talon_one/models/new_application.rb +48 -56
  21. data/lib/talon_one/models/new_saml_connection.rb +356 -0
  22. data/lib/talon_one/models/saml_connection.rb +420 -0
  23. data/lib/talon_one/models/update_application.rb +352 -0
  24. data/lib/talon_one/models/user.rb +14 -4
  25. data/lib/talon_one/version.rb +1 -1
  26. data/spec/api/management_api_spec.rb +5 -0
  27. data/spec/models/application_spec.rb +6 -6
  28. data/spec/models/campaign_spec.rb +12 -0
  29. data/spec/models/inline_response_200_25_spec.rb +6 -0
  30. data/spec/models/integration_state_spec.rb +6 -0
  31. data/spec/models/limit_config_spec.rb +1 -1
  32. data/spec/models/new_application_spec.rb +6 -6
  33. data/spec/models/new_saml_connection_spec.rb +83 -0
  34. data/spec/models/saml_connection_spec.rb +107 -0
  35. data/spec/models/update_application_spec.rb +81 -0
  36. data/spec/models/user_spec.rb +6 -0
  37. data/talon_one-1.2.0.gem +0 -0
  38. metadata +28 -16
@@ -0,0 +1,420 @@
1
+ =begin
2
+ #Talon.One API
3
+
4
+ #The Talon.One API is used to manage applications and campaigns, as well as to integrate with your application. The operations in the _Integration API_ section are used to integrate with our platform, while the other operations are used to manage applications and campaigns. ### Where is the API? The API is available at the same hostname as these docs. For example, if you are reading this page at `https://mycompany.talon.one/docs/api/`, the URL for the [updateCustomerProfile][] operation is `https://mycompany.talon.one/v1/customer_profiles/id` [updateCustomerProfile]: #operation--v1-customer_profiles--integrationId--put
5
+
6
+ OpenAPI spec version: 1.0.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.7
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module TalonOne
16
+ #
17
+ class SamlConnection
18
+ attr_accessor :id
19
+
20
+ # Unix timestamp indicating when the session was first created.
21
+ attr_accessor :created
22
+
23
+ # The ID of the account that owns this SAML Service.
24
+ attr_accessor :account_id
25
+
26
+ # The location where the SAML assertion is sent with a HTTP POST.
27
+ attr_accessor :assertion_consumer_service_url
28
+
29
+ # ID of the SAML service.
30
+ attr_accessor :name
31
+
32
+ # Determines if this SAML connection active.
33
+ attr_accessor :enabled
34
+
35
+ # Identity Provider Entity ID.
36
+ attr_accessor :issuer
37
+
38
+ # Single Sign-On URL.
39
+ attr_accessor :sign_on_url
40
+
41
+ # Single Sign-Out URL.
42
+ attr_accessor :sign_out_url
43
+
44
+ # Metadata URL.
45
+ attr_accessor :metadata_url
46
+
47
+ # X.509 Certificate.
48
+ attr_accessor :x509certificate
49
+
50
+ # The application-defined unique identifier that is the intended audience of the SAML assertion. This is most often the SP Entity ID of your application. When not specified, the ACS URL will be used.
51
+ attr_accessor :audience
52
+
53
+ # Attribute mapping from ruby-style variable name to JSON key.
54
+ def self.attribute_map
55
+ {
56
+ :'id' => :'id',
57
+ :'created' => :'created',
58
+ :'account_id' => :'accountId',
59
+ :'assertion_consumer_service_url' => :'assertionConsumerServiceURL',
60
+ :'name' => :'name',
61
+ :'enabled' => :'enabled',
62
+ :'issuer' => :'issuer',
63
+ :'sign_on_url' => :'signOnURL',
64
+ :'sign_out_url' => :'signOutURL',
65
+ :'metadata_url' => :'metadataURL',
66
+ :'x509certificate' => :'x509certificate',
67
+ :'audience' => :'audience'
68
+ }
69
+ end
70
+
71
+ # Attribute type mapping.
72
+ def self.swagger_types
73
+ {
74
+ :'id' => :'Integer',
75
+ :'created' => :'DateTime',
76
+ :'account_id' => :'Integer',
77
+ :'assertion_consumer_service_url' => :'String',
78
+ :'name' => :'String',
79
+ :'enabled' => :'BOOLEAN',
80
+ :'issuer' => :'String',
81
+ :'sign_on_url' => :'String',
82
+ :'sign_out_url' => :'String',
83
+ :'metadata_url' => :'String',
84
+ :'x509certificate' => :'String',
85
+ :'audience' => :'String'
86
+ }
87
+ end
88
+
89
+ # Initializes the object
90
+ # @param [Hash] attributes Model attributes in the form of hash
91
+ def initialize(attributes = {})
92
+ return unless attributes.is_a?(Hash)
93
+
94
+ # convert string to symbol for hash key
95
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
96
+
97
+ if attributes.has_key?(:'id')
98
+ self.id = attributes[:'id']
99
+ end
100
+
101
+ if attributes.has_key?(:'created')
102
+ self.created = attributes[:'created']
103
+ end
104
+
105
+ if attributes.has_key?(:'accountId')
106
+ self.account_id = attributes[:'accountId']
107
+ end
108
+
109
+ if attributes.has_key?(:'assertionConsumerServiceURL')
110
+ self.assertion_consumer_service_url = attributes[:'assertionConsumerServiceURL']
111
+ end
112
+
113
+ if attributes.has_key?(:'name')
114
+ self.name = attributes[:'name']
115
+ end
116
+
117
+ if attributes.has_key?(:'enabled')
118
+ self.enabled = attributes[:'enabled']
119
+ end
120
+
121
+ if attributes.has_key?(:'issuer')
122
+ self.issuer = attributes[:'issuer']
123
+ end
124
+
125
+ if attributes.has_key?(:'signOnURL')
126
+ self.sign_on_url = attributes[:'signOnURL']
127
+ end
128
+
129
+ if attributes.has_key?(:'signOutURL')
130
+ self.sign_out_url = attributes[:'signOutURL']
131
+ end
132
+
133
+ if attributes.has_key?(:'metadataURL')
134
+ self.metadata_url = attributes[:'metadataURL']
135
+ end
136
+
137
+ if attributes.has_key?(:'x509certificate')
138
+ self.x509certificate = attributes[:'x509certificate']
139
+ end
140
+
141
+ if attributes.has_key?(:'audience')
142
+ self.audience = attributes[:'audience']
143
+ end
144
+ end
145
+
146
+ # Show invalid properties with the reasons. Usually used together with valid?
147
+ # @return Array for valid properties with the reasons
148
+ def list_invalid_properties
149
+ invalid_properties = Array.new
150
+ if @id.nil?
151
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
152
+ end
153
+
154
+ if @created.nil?
155
+ invalid_properties.push('invalid value for "created", created cannot be nil.')
156
+ end
157
+
158
+ if @account_id.nil?
159
+ invalid_properties.push('invalid value for "account_id", account_id cannot be nil.')
160
+ end
161
+
162
+ if @assertion_consumer_service_url.nil?
163
+ invalid_properties.push('invalid value for "assertion_consumer_service_url", assertion_consumer_service_url cannot be nil.')
164
+ end
165
+
166
+ if @name.nil?
167
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
168
+ end
169
+
170
+ if @name.to_s.length < 1
171
+ invalid_properties.push('invalid value for "name", the character length must be great than or equal to 1.')
172
+ end
173
+
174
+ if @enabled.nil?
175
+ invalid_properties.push('invalid value for "enabled", enabled cannot be nil.')
176
+ end
177
+
178
+ if @issuer.nil?
179
+ invalid_properties.push('invalid value for "issuer", issuer cannot be nil.')
180
+ end
181
+
182
+ if @issuer.to_s.length < 1
183
+ invalid_properties.push('invalid value for "issuer", the character length must be great than or equal to 1.')
184
+ end
185
+
186
+ if @sign_on_url.nil?
187
+ invalid_properties.push('invalid value for "sign_on_url", sign_on_url cannot be nil.')
188
+ end
189
+
190
+ if @sign_on_url.to_s.length < 1
191
+ invalid_properties.push('invalid value for "sign_on_url", the character length must be great than or equal to 1.')
192
+ end
193
+
194
+ if @x509certificate.nil?
195
+ invalid_properties.push('invalid value for "x509certificate", x509certificate cannot be nil.')
196
+ end
197
+
198
+ if @x509certificate.to_s.length < 1
199
+ invalid_properties.push('invalid value for "x509certificate", the character length must be great than or equal to 1.')
200
+ end
201
+
202
+ if @audience.nil?
203
+ invalid_properties.push('invalid value for "audience", audience cannot be nil.')
204
+ end
205
+
206
+ invalid_properties
207
+ end
208
+
209
+ # Check to see if the all the properties in the model are valid
210
+ # @return true if the model is valid
211
+ def valid?
212
+ return false if @id.nil?
213
+ return false if @created.nil?
214
+ return false if @account_id.nil?
215
+ return false if @assertion_consumer_service_url.nil?
216
+ return false if @name.nil?
217
+ return false if @name.to_s.length < 1
218
+ return false if @enabled.nil?
219
+ return false if @issuer.nil?
220
+ return false if @issuer.to_s.length < 1
221
+ return false if @sign_on_url.nil?
222
+ return false if @sign_on_url.to_s.length < 1
223
+ return false if @x509certificate.nil?
224
+ return false if @x509certificate.to_s.length < 1
225
+ return false if @audience.nil?
226
+ true
227
+ end
228
+
229
+ # Custom attribute writer method with validation
230
+ # @param [Object] name Value to be assigned
231
+ def name=(name)
232
+ if name.nil?
233
+ fail ArgumentError, 'name cannot be nil'
234
+ end
235
+
236
+ if name.to_s.length < 1
237
+ fail ArgumentError, 'invalid value for "name", the character length must be great than or equal to 1.'
238
+ end
239
+
240
+ @name = name
241
+ end
242
+
243
+ # Custom attribute writer method with validation
244
+ # @param [Object] issuer Value to be assigned
245
+ def issuer=(issuer)
246
+ if issuer.nil?
247
+ fail ArgumentError, 'issuer cannot be nil'
248
+ end
249
+
250
+ if issuer.to_s.length < 1
251
+ fail ArgumentError, 'invalid value for "issuer", the character length must be great than or equal to 1.'
252
+ end
253
+
254
+ @issuer = issuer
255
+ end
256
+
257
+ # Custom attribute writer method with validation
258
+ # @param [Object] sign_on_url Value to be assigned
259
+ def sign_on_url=(sign_on_url)
260
+ if sign_on_url.nil?
261
+ fail ArgumentError, 'sign_on_url cannot be nil'
262
+ end
263
+
264
+ if sign_on_url.to_s.length < 1
265
+ fail ArgumentError, 'invalid value for "sign_on_url", the character length must be great than or equal to 1.'
266
+ end
267
+
268
+ @sign_on_url = sign_on_url
269
+ end
270
+
271
+ # Custom attribute writer method with validation
272
+ # @param [Object] x509certificate Value to be assigned
273
+ def x509certificate=(x509certificate)
274
+ if x509certificate.nil?
275
+ fail ArgumentError, 'x509certificate cannot be nil'
276
+ end
277
+
278
+ if x509certificate.to_s.length < 1
279
+ fail ArgumentError, 'invalid value for "x509certificate", the character length must be great than or equal to 1.'
280
+ end
281
+
282
+ @x509certificate = x509certificate
283
+ end
284
+
285
+ # Checks equality by comparing each attribute.
286
+ # @param [Object] Object to be compared
287
+ def ==(o)
288
+ return true if self.equal?(o)
289
+ self.class == o.class &&
290
+ id == o.id &&
291
+ created == o.created &&
292
+ account_id == o.account_id &&
293
+ assertion_consumer_service_url == o.assertion_consumer_service_url &&
294
+ name == o.name &&
295
+ enabled == o.enabled &&
296
+ issuer == o.issuer &&
297
+ sign_on_url == o.sign_on_url &&
298
+ sign_out_url == o.sign_out_url &&
299
+ metadata_url == o.metadata_url &&
300
+ x509certificate == o.x509certificate &&
301
+ audience == o.audience
302
+ end
303
+
304
+ # @see the `==` method
305
+ # @param [Object] Object to be compared
306
+ def eql?(o)
307
+ self == o
308
+ end
309
+
310
+ # Calculates hash code according to all attributes.
311
+ # @return [Fixnum] Hash code
312
+ def hash
313
+ [id, created, account_id, assertion_consumer_service_url, name, enabled, issuer, sign_on_url, sign_out_url, metadata_url, x509certificate, audience].hash
314
+ end
315
+
316
+ # Builds the object from hash
317
+ # @param [Hash] attributes Model attributes in the form of hash
318
+ # @return [Object] Returns the model itself
319
+ def build_from_hash(attributes)
320
+ return nil unless attributes.is_a?(Hash)
321
+ self.class.swagger_types.each_pair do |key, type|
322
+ if type =~ /\AArray<(.*)>/i
323
+ # check to ensure the input is an array given that the the attribute
324
+ # is documented as an array but the input is not
325
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
326
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
327
+ end
328
+ elsif !attributes[self.class.attribute_map[key]].nil?
329
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
330
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
331
+ end
332
+
333
+ self
334
+ end
335
+
336
+ # Deserializes the data based on type
337
+ # @param string type Data type
338
+ # @param string value Value to be deserialized
339
+ # @return [Object] Deserialized data
340
+ def _deserialize(type, value)
341
+ case type.to_sym
342
+ when :DateTime
343
+ DateTime.parse(value)
344
+ when :Date
345
+ Date.parse(value)
346
+ when :String
347
+ value.to_s
348
+ when :Integer
349
+ value.to_i
350
+ when :Float
351
+ value.to_f
352
+ when :BOOLEAN
353
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
354
+ true
355
+ else
356
+ false
357
+ end
358
+ when :Object
359
+ # generic object (usually a Hash), return directly
360
+ value
361
+ when /\AArray<(?<inner_type>.+)>\z/
362
+ inner_type = Regexp.last_match[:inner_type]
363
+ value.map { |v| _deserialize(inner_type, v) }
364
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
365
+ k_type = Regexp.last_match[:k_type]
366
+ v_type = Regexp.last_match[:v_type]
367
+ {}.tap do |hash|
368
+ value.each do |k, v|
369
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
370
+ end
371
+ end
372
+ else # model
373
+ temp_model = TalonOne.const_get(type).new
374
+ temp_model.build_from_hash(value)
375
+ end
376
+ end
377
+
378
+ # Returns the string representation of the object
379
+ # @return [String] String presentation of the object
380
+ def to_s
381
+ to_hash.to_s
382
+ end
383
+
384
+ # to_body is an alias to to_hash (backward compatibility)
385
+ # @return [Hash] Returns the object in the form of hash
386
+ def to_body
387
+ to_hash
388
+ end
389
+
390
+ # Returns the object in the form of hash
391
+ # @return [Hash] Returns the object in the form of hash
392
+ def to_hash
393
+ hash = {}
394
+ self.class.attribute_map.each_pair do |attr, param|
395
+ value = self.send(attr)
396
+ next if value.nil?
397
+ hash[param] = _to_hash(value)
398
+ end
399
+ hash
400
+ end
401
+
402
+ # Outputs non-array value in the form of hash
403
+ # For object, use to_hash. Otherwise, just return the value
404
+ # @param [Object] value Any valid value
405
+ # @return [Hash] Returns the value in the form of hash
406
+ def _to_hash(value)
407
+ if value.is_a?(Array)
408
+ value.compact.map { |v| _to_hash(v) }
409
+ elsif value.is_a?(Hash)
410
+ {}.tap do |hash|
411
+ value.each { |k, v| hash[k] = _to_hash(v) }
412
+ end
413
+ elsif value.respond_to? :to_hash
414
+ value.to_hash
415
+ else
416
+ value
417
+ end
418
+ end
419
+ end
420
+ end
@@ -0,0 +1,352 @@
1
+ =begin
2
+ #Talon.One API
3
+
4
+ #The Talon.One API is used to manage applications and campaigns, as well as to integrate with your application. The operations in the _Integration API_ section are used to integrate with our platform, while the other operations are used to manage applications and campaigns. ### Where is the API? The API is available at the same hostname as these docs. For example, if you are reading this page at `https://mycompany.talon.one/docs/api/`, the URL for the [updateCustomerProfile][] operation is `https://mycompany.talon.one/v1/customer_profiles/id` [updateCustomerProfile]: #operation--v1-customer_profiles--integrationId--put
5
+
6
+ OpenAPI spec version: 1.0.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.7
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module TalonOne
16
+ class UpdateApplication
17
+ # The name of this application.
18
+ attr_accessor :name
19
+
20
+ # A longer description of the application.
21
+ attr_accessor :description
22
+
23
+ # A string containing an IANA timezone descriptor.
24
+ attr_accessor :timezone
25
+
26
+ # A string describing a default currency for new customer sessions.
27
+ attr_accessor :currency
28
+
29
+ # A string indicating how should campaigns in this application deal with case sensitivity on coupon codes.
30
+ attr_accessor :case_sensitivity
31
+
32
+ # Arbitrary properties associated with this campaign
33
+ attr_accessor :attributes
34
+
35
+ # Default limits for campaigns created in this application
36
+ attr_accessor :limits
37
+
38
+ class EnumAttributeValidator
39
+ attr_reader :datatype
40
+ attr_reader :allowable_values
41
+
42
+ def initialize(datatype, allowable_values)
43
+ @allowable_values = allowable_values.map do |value|
44
+ case datatype.to_s
45
+ when /Integer/i
46
+ value.to_i
47
+ when /Float/i
48
+ value.to_f
49
+ else
50
+ value
51
+ end
52
+ end
53
+ end
54
+
55
+ def valid?(value)
56
+ !value || allowable_values.include?(value)
57
+ end
58
+ end
59
+
60
+ # Attribute mapping from ruby-style variable name to JSON key.
61
+ def self.attribute_map
62
+ {
63
+ :'name' => :'name',
64
+ :'description' => :'description',
65
+ :'timezone' => :'timezone',
66
+ :'currency' => :'currency',
67
+ :'case_sensitivity' => :'caseSensitivity',
68
+ :'attributes' => :'attributes',
69
+ :'limits' => :'limits'
70
+ }
71
+ end
72
+
73
+ # Attribute type mapping.
74
+ def self.swagger_types
75
+ {
76
+ :'name' => :'String',
77
+ :'description' => :'String',
78
+ :'timezone' => :'String',
79
+ :'currency' => :'String',
80
+ :'case_sensitivity' => :'String',
81
+ :'attributes' => :'Object',
82
+ :'limits' => :'Array<LimitConfig>'
83
+ }
84
+ end
85
+
86
+ # Initializes the object
87
+ # @param [Hash] attributes Model attributes in the form of hash
88
+ def initialize(attributes = {})
89
+ return unless attributes.is_a?(Hash)
90
+
91
+ # convert string to symbol for hash key
92
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
93
+
94
+ if attributes.has_key?(:'name')
95
+ self.name = attributes[:'name']
96
+ end
97
+
98
+ if attributes.has_key?(:'description')
99
+ self.description = attributes[:'description']
100
+ end
101
+
102
+ if attributes.has_key?(:'timezone')
103
+ self.timezone = attributes[:'timezone']
104
+ end
105
+
106
+ if attributes.has_key?(:'currency')
107
+ self.currency = attributes[:'currency']
108
+ end
109
+
110
+ if attributes.has_key?(:'caseSensitivity')
111
+ self.case_sensitivity = attributes[:'caseSensitivity']
112
+ end
113
+
114
+ if attributes.has_key?(:'attributes')
115
+ self.attributes = attributes[:'attributes']
116
+ end
117
+
118
+ if attributes.has_key?(:'limits')
119
+ if (value = attributes[:'limits']).is_a?(Array)
120
+ self.limits = value
121
+ end
122
+ end
123
+ end
124
+
125
+ # Show invalid properties with the reasons. Usually used together with valid?
126
+ # @return Array for valid properties with the reasons
127
+ def list_invalid_properties
128
+ invalid_properties = Array.new
129
+ if @name.nil?
130
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
131
+ end
132
+
133
+ if @name.to_s.length < 1
134
+ invalid_properties.push('invalid value for "name", the character length must be great than or equal to 1.')
135
+ end
136
+
137
+ if @timezone.nil?
138
+ invalid_properties.push('invalid value for "timezone", timezone cannot be nil.')
139
+ end
140
+
141
+ if @timezone.to_s.length < 1
142
+ invalid_properties.push('invalid value for "timezone", the character length must be great than or equal to 1.')
143
+ end
144
+
145
+ if @currency.nil?
146
+ invalid_properties.push('invalid value for "currency", currency cannot be nil.')
147
+ end
148
+
149
+ if @currency.to_s.length < 1
150
+ invalid_properties.push('invalid value for "currency", the character length must be great than or equal to 1.')
151
+ end
152
+
153
+ invalid_properties
154
+ end
155
+
156
+ # Check to see if the all the properties in the model are valid
157
+ # @return true if the model is valid
158
+ def valid?
159
+ return false if @name.nil?
160
+ return false if @name.to_s.length < 1
161
+ return false if @timezone.nil?
162
+ return false if @timezone.to_s.length < 1
163
+ return false if @currency.nil?
164
+ return false if @currency.to_s.length < 1
165
+ case_sensitivity_validator = EnumAttributeValidator.new('String', ['sensitive', 'insensitive-uppercase', 'insensitive-lowercase'])
166
+ return false unless case_sensitivity_validator.valid?(@case_sensitivity)
167
+ true
168
+ end
169
+
170
+ # Custom attribute writer method with validation
171
+ # @param [Object] name Value to be assigned
172
+ def name=(name)
173
+ if name.nil?
174
+ fail ArgumentError, 'name cannot be nil'
175
+ end
176
+
177
+ if name.to_s.length < 1
178
+ fail ArgumentError, 'invalid value for "name", the character length must be great than or equal to 1.'
179
+ end
180
+
181
+ @name = name
182
+ end
183
+
184
+ # Custom attribute writer method with validation
185
+ # @param [Object] timezone Value to be assigned
186
+ def timezone=(timezone)
187
+ if timezone.nil?
188
+ fail ArgumentError, 'timezone cannot be nil'
189
+ end
190
+
191
+ if timezone.to_s.length < 1
192
+ fail ArgumentError, 'invalid value for "timezone", the character length must be great than or equal to 1.'
193
+ end
194
+
195
+ @timezone = timezone
196
+ end
197
+
198
+ # Custom attribute writer method with validation
199
+ # @param [Object] currency Value to be assigned
200
+ def currency=(currency)
201
+ if currency.nil?
202
+ fail ArgumentError, 'currency cannot be nil'
203
+ end
204
+
205
+ if currency.to_s.length < 1
206
+ fail ArgumentError, 'invalid value for "currency", the character length must be great than or equal to 1.'
207
+ end
208
+
209
+ @currency = currency
210
+ end
211
+
212
+ # Custom attribute writer method checking allowed values (enum).
213
+ # @param [Object] case_sensitivity Object to be assigned
214
+ def case_sensitivity=(case_sensitivity)
215
+ validator = EnumAttributeValidator.new('String', ['sensitive', 'insensitive-uppercase', 'insensitive-lowercase'])
216
+ unless validator.valid?(case_sensitivity)
217
+ fail ArgumentError, 'invalid value for "case_sensitivity", must be one of #{validator.allowable_values}.'
218
+ end
219
+ @case_sensitivity = case_sensitivity
220
+ end
221
+
222
+ # Checks equality by comparing each attribute.
223
+ # @param [Object] Object to be compared
224
+ def ==(o)
225
+ return true if self.equal?(o)
226
+ self.class == o.class &&
227
+ name == o.name &&
228
+ description == o.description &&
229
+ timezone == o.timezone &&
230
+ currency == o.currency &&
231
+ case_sensitivity == o.case_sensitivity &&
232
+ attributes == o.attributes &&
233
+ limits == o.limits
234
+ end
235
+
236
+ # @see the `==` method
237
+ # @param [Object] Object to be compared
238
+ def eql?(o)
239
+ self == o
240
+ end
241
+
242
+ # Calculates hash code according to all attributes.
243
+ # @return [Fixnum] Hash code
244
+ def hash
245
+ [name, description, timezone, currency, case_sensitivity, attributes, limits].hash
246
+ end
247
+
248
+ # Builds the object from hash
249
+ # @param [Hash] attributes Model attributes in the form of hash
250
+ # @return [Object] Returns the model itself
251
+ def build_from_hash(attributes)
252
+ return nil unless attributes.is_a?(Hash)
253
+ self.class.swagger_types.each_pair do |key, type|
254
+ if type =~ /\AArray<(.*)>/i
255
+ # check to ensure the input is an array given that the the attribute
256
+ # is documented as an array but the input is not
257
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
258
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
259
+ end
260
+ elsif !attributes[self.class.attribute_map[key]].nil?
261
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
262
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
263
+ end
264
+
265
+ self
266
+ end
267
+
268
+ # Deserializes the data based on type
269
+ # @param string type Data type
270
+ # @param string value Value to be deserialized
271
+ # @return [Object] Deserialized data
272
+ def _deserialize(type, value)
273
+ case type.to_sym
274
+ when :DateTime
275
+ DateTime.parse(value)
276
+ when :Date
277
+ Date.parse(value)
278
+ when :String
279
+ value.to_s
280
+ when :Integer
281
+ value.to_i
282
+ when :Float
283
+ value.to_f
284
+ when :BOOLEAN
285
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
286
+ true
287
+ else
288
+ false
289
+ end
290
+ when :Object
291
+ # generic object (usually a Hash), return directly
292
+ value
293
+ when /\AArray<(?<inner_type>.+)>\z/
294
+ inner_type = Regexp.last_match[:inner_type]
295
+ value.map { |v| _deserialize(inner_type, v) }
296
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
297
+ k_type = Regexp.last_match[:k_type]
298
+ v_type = Regexp.last_match[:v_type]
299
+ {}.tap do |hash|
300
+ value.each do |k, v|
301
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
302
+ end
303
+ end
304
+ else # model
305
+ temp_model = TalonOne.const_get(type).new
306
+ temp_model.build_from_hash(value)
307
+ end
308
+ end
309
+
310
+ # Returns the string representation of the object
311
+ # @return [String] String presentation of the object
312
+ def to_s
313
+ to_hash.to_s
314
+ end
315
+
316
+ # to_body is an alias to to_hash (backward compatibility)
317
+ # @return [Hash] Returns the object in the form of hash
318
+ def to_body
319
+ to_hash
320
+ end
321
+
322
+ # Returns the object in the form of hash
323
+ # @return [Hash] Returns the object in the form of hash
324
+ def to_hash
325
+ hash = {}
326
+ self.class.attribute_map.each_pair do |attr, param|
327
+ value = self.send(attr)
328
+ next if value.nil?
329
+ hash[param] = _to_hash(value)
330
+ end
331
+ hash
332
+ end
333
+
334
+ # Outputs non-array value in the form of hash
335
+ # For object, use to_hash. Otherwise, just return the value
336
+ # @param [Object] value Any valid value
337
+ # @return [Hash] Returns the value in the form of hash
338
+ def _to_hash(value)
339
+ if value.is_a?(Array)
340
+ value.compact.map { |v| _to_hash(v) }
341
+ elsif value.is_a?(Hash)
342
+ {}.tap do |hash|
343
+ value.each { |k, v| hash[k] = _to_hash(v) }
344
+ end
345
+ elsif value.respond_to? :to_hash
346
+ value.to_hash
347
+ else
348
+ value
349
+ end
350
+ end
351
+ end
352
+ end