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