devcycle-ruby-server-sdk 1.2.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +6 -0
  3. data/devcycle-ruby-server-sdk.gemspec +9 -1
  4. data/lib/devcycle-ruby-server-sdk/api/devcycle_api.rb +128 -21
  5. data/lib/devcycle-ruby-server-sdk/api_client.rb +1 -1
  6. data/lib/devcycle-ruby-server-sdk/configuration.rb +5 -5
  7. data/lib/devcycle-ruby-server-sdk/localbucketing/bucketed_user_config.rb +21 -0
  8. data/lib/devcycle-ruby-server-sdk/localbucketing/bucketing-lib.release.wasm +0 -0
  9. data/lib/devcycle-ruby-server-sdk/localbucketing/config_manager.rb +97 -0
  10. data/lib/devcycle-ruby-server-sdk/localbucketing/dvc_options.rb +119 -0
  11. data/lib/devcycle-ruby-server-sdk/localbucketing/event_queue.rb +120 -0
  12. data/lib/devcycle-ruby-server-sdk/localbucketing/event_types.rb +8 -0
  13. data/lib/devcycle-ruby-server-sdk/localbucketing/events_payload.rb +23 -0
  14. data/lib/devcycle-ruby-server-sdk/localbucketing/local_bucketing.rb +257 -0
  15. data/lib/devcycle-ruby-server-sdk/localbucketing/platform_data.rb +29 -0
  16. data/lib/devcycle-ruby-server-sdk/models/event.rb +6 -6
  17. data/lib/devcycle-ruby-server-sdk/models/user_data.rb +78 -107
  18. data/lib/devcycle-ruby-server-sdk/models/variable.rb +0 -13
  19. data/lib/devcycle-ruby-server-sdk/version.rb +1 -1
  20. data/lib/devcycle-ruby-server-sdk.rb +9 -0
  21. data/spec/api/devcycle_api_spec.rb +26 -37
  22. metadata +77 -25
  23. data/Gemfile.lock +0 -70
  24. data/Rakefile +0 -10
  25. data/docs/DevcycleApi.md +0 -290
  26. data/docs/ErrorResponse.md +0 -20
  27. data/docs/Event.md +0 -26
  28. data/docs/Feature.md +0 -26
  29. data/docs/UserData.md +0 -48
  30. data/docs/Variable.md +0 -24
  31. data/examples/sinatra/Gemfile +0 -8
  32. data/examples/sinatra/Gemfile.lock +0 -51
  33. data/examples/sinatra/README.md +0 -14
  34. data/examples/sinatra/app.rb +0 -48
  35. data/git_push.sh +0 -57
@@ -0,0 +1,8 @@
1
+ module DevCycle
2
+ EventTypes = {
3
+ variable_evaluated: 'variableEvaluated',
4
+ agg_variable_evaluated: 'aggVariableEvaluated',
5
+ variable_defaulted: 'variableDefaulted',
6
+ agg_variable_defaulted: 'aggVariableDefaulted'
7
+ }.freeze
8
+ end
@@ -0,0 +1,23 @@
1
+ require 'sorbet-runtime'
2
+
3
+ module DevCycle
4
+ class EventsPayload
5
+ attr_reader :records
6
+ attr_reader :payloadId
7
+ attr_reader :eventCount
8
+
9
+ def initialize(records, payloadId, eventCount)
10
+ @records = records
11
+ @payloadId = payloadId
12
+ @eventCount = eventCount
13
+ end
14
+ end
15
+
16
+ class EventsRecord
17
+ def initialize(user, events)
18
+ @user = user
19
+ @events = events
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,257 @@
1
+ require 'wasmtime'
2
+ require 'date'
3
+ require 'bigdecimal'
4
+ require 'sorbet-runtime'
5
+
6
+ require_relative 'dvc_options'
7
+ require_relative 'platform_data'
8
+ require_relative 'events_payload'
9
+ require_relative 'config_manager'
10
+
11
+ module DevCycle
12
+ class LocalBucketing
13
+ extend T::Sig
14
+
15
+ attr_reader :options
16
+ attr_accessor :initialized
17
+
18
+ @@rand = Random.new(seed = Random.new_seed)
19
+ @@engine = Wasmtime::Engine.new
20
+
21
+ @@wasmmodule = Wasmtime::Module.from_file(@@engine, "#{__dir__}/bucketing-lib.release.wasm")
22
+ @@wasi_ctx = Wasmtime::WasiCtxBuilder.new
23
+ .inherit_stdout
24
+ .inherit_stderr
25
+ .set_argv(ARGV)
26
+ .set_env(ENV)
27
+ @@store = Wasmtime::Store.new(@@engine, wasi_ctx: @@wasi_ctx)
28
+ @@linker = Wasmtime::Linker.new(@@engine, wasi: true)
29
+
30
+ @@linker.func_new("env", "Date.now", [], [:f64]) do |_caller|
31
+ DateTime.now.strftime("%Q").to_i
32
+ end
33
+
34
+ inline_read_asc_string = lambda { |address|
35
+ raw_bytes = @@memory.read(address - 4, 4).bytes.reverse
36
+ message_len = 0
37
+ raw_bytes.each { |j|
38
+ message_len = (message_len << 8) + (j & 0xFF)
39
+ }
40
+ length = message_len
41
+ result = ""
42
+ i = 0
43
+ while i < length
44
+ result += @@memory.read(address + i, 1)
45
+ i += 2
46
+ end
47
+ result
48
+ }
49
+
50
+ @@stack_tracer = lambda {}
51
+
52
+ @@linker.func_new("env", "abort", [:i32, :i32, :i32, :i32], []) do |_caller, messagePtr, filenamePtr, lineNum, colNum|
53
+
54
+ exception_message = ""
55
+ exception_filename = ""
56
+
57
+ [messagePtr, filenamePtr].each { |m|
58
+ result = inline_read_asc_string.call(m)
59
+ if m == messagePtr
60
+ exception_message = result
61
+ else
62
+ if m == filenamePtr
63
+ exception_filename = result
64
+ end
65
+ end
66
+ }
67
+ @@stack_tracer.call("WASM Exception: #{exception_message} - #{exception_filename} #{lineNum}:#{colNum}")
68
+ end
69
+
70
+ @@linker.func_new("env", "console.log", [:i32], []) do |_caller, messagePtr|
71
+ @logger.info(inline_read_asc_string.call(messagePtr))
72
+ end
73
+
74
+ @@linker.func_new("env", "seed", [], [:f64]) do |_caller|
75
+ @@rand.rand(1.0) * DateTime.now.strftime("%Q").to_i
76
+
77
+ end
78
+
79
+ @@instance = @@linker.instantiate(@@store, @@wasmmodule)
80
+ @@memory = @@instance.export("memory").to_memory
81
+
82
+ sig { params(
83
+ sdkkey: String,
84
+ options: DVCOptions,
85
+ wait_for_init: T::Boolean
86
+ ).void }
87
+ def initialize(sdkkey, options, wait_for_init)
88
+ @initialized = false
89
+ @sdkkey = sdkkey
90
+ @options = options
91
+ @logger = options.logger
92
+
93
+ platform_data = PlatformData.new('server', VERSION, RUBY_VERSION, nil, 'Ruby', Socket.gethostname)
94
+ set_platform_data(platform_data)
95
+ @configmanager = ConfigManager.new(@sdkkey, self, wait_for_init)
96
+ end
97
+
98
+ def close
99
+ @configmanager.close
100
+ @configmanager = nil
101
+ end
102
+
103
+ sig { params(user: UserData).returns(BucketedUserConfig) }
104
+ def generate_bucketed_config(user)
105
+ sdkkey_addr = malloc_asc_string(@sdkkey)
106
+ user_addr = malloc_asc_string(user.to_json)
107
+ @@stack_tracer = lambda { |message| raise message }
108
+ config_addr = @@instance.invoke("generateBucketedConfigForUser", sdkkey_addr, user_addr)
109
+ bucketed_config_json = read_asc_string(config_addr)
110
+ bucketed_config_hash = Oj.load(bucketed_config_json)
111
+ BucketedUserConfig.new(bucketed_config_hash['project'],
112
+ bucketed_config_hash['environment'],
113
+ bucketed_config_hash['features'],
114
+ bucketed_config_hash['featureVariationMap'],
115
+ bucketed_config_hash['variableVariationMap'],
116
+ bucketed_config_hash['variables'],
117
+ bucketed_config_hash['knownVariableKeys'])
118
+ end
119
+
120
+ sig { returns(T::Array[EventsPayload]) }
121
+ def flush_event_queue
122
+ sdkkey_addr = malloc_asc_string(@sdkkey)
123
+ @@stack_tracer = lambda { |message| raise message }
124
+ payload_addr = @@instance.invoke("flushEventQueue", sdkkey_addr)
125
+ raw_json = read_asc_string(payload_addr)
126
+ raw_payloads = Oj.load(raw_json)
127
+
128
+ if raw_payloads == nil
129
+ return []
130
+ end
131
+ raw_payloads.map { |raw_payload| EventsPayload.new(raw_payload["records"], raw_payload["payloadId"], raw_payload["eventCount"]) }
132
+ end
133
+
134
+ sig { returns(Integer) }
135
+ def check_event_queue_size
136
+ sdkkey_addr = malloc_asc_string(@sdkkey)
137
+ @@stack_tracer = lambda { |message| raise message }
138
+ @@instance.invoke("eventQueueSize", sdkkey_addr)
139
+ end
140
+
141
+ sig { params(payload_id: String).returns(NilClass) }
142
+ def on_payload_success(payload_id)
143
+ sdkkey_addr = malloc_asc_string(@sdkkey)
144
+ payload_addr = malloc_asc_string(payload_id)
145
+ @@stack_tracer = lambda { |message| raise message }
146
+ @@instance.invoke("onPayloadSuccess", sdkkey_addr, payload_addr)
147
+ end
148
+
149
+ sig { params(user: UserData, event: Event).returns(NilClass) }
150
+ def queue_event(user, event)
151
+ sdkkey_addr = malloc_asc_string(@sdkkey)
152
+ user_addr = malloc_asc_string(Oj.dump(user))
153
+ event_addr = malloc_asc_string(Oj.dump(event))
154
+ @@stack_tracer = lambda { |message| raise message }
155
+ @@instance.invoke("queueEvent", sdkkey_addr, user_addr, event_addr)
156
+ end
157
+
158
+ sig { params(event: Event, bucketeduser: T.nilable(BucketedUserConfig)).returns(NilClass) }
159
+ def queue_aggregate_event(event, bucketeduser)
160
+ sdkkey_addr = malloc_asc_string(@sdkkey)
161
+ variable_variation_map =
162
+ if !bucketeduser.nil?
163
+ bucketeduser.variable_variation_map
164
+ else
165
+ {}
166
+ end
167
+ varmap_addr = malloc_asc_string(Oj.dump(variable_variation_map))
168
+ event_addr = malloc_asc_string(Oj.dump(event))
169
+ @@stack_tracer = lambda { |message| raise message }
170
+ @@instance.invoke("queueAggregateEvent", sdkkey_addr, event_addr, varmap_addr)
171
+ end
172
+
173
+ sig { params(payload_id: String, retryable: Object).returns(NilClass) }
174
+ def on_payload_failure(payload_id, retryable)
175
+ sdkkey_addr = malloc_asc_string(@sdkkey)
176
+ payload_addr = malloc_asc_string(payload_id)
177
+ @@stack_tracer = lambda { |message| raise message }
178
+ @@instance.invoke("onPayloadFailure", sdkkey_addr, payload_addr, retryable ? 1 : 0)
179
+ end
180
+
181
+ sig { params(sdkkey: String, config: String).returns(NilClass) }
182
+ def store_config(sdkkey, config)
183
+ sdkkey_addr = malloc_asc_string(sdkkey)
184
+ config_addr = malloc_asc_string(config)
185
+ @@stack_tracer = lambda { |message| raise message }
186
+ @@instance.invoke("setConfigData", sdkkey_addr, config_addr)
187
+ end
188
+
189
+ sig { params(options: EventQueueOptions).returns(NilClass) }
190
+ def init_event_queue(options)
191
+ options_json = Oj.dump(options)
192
+ sdkkey_addr = malloc_asc_string(@sdkkey)
193
+ options_addr = malloc_asc_string(options_json)
194
+ @@stack_tracer = lambda { |message| raise message }
195
+ @@instance.invoke("initEventQueue", sdkkey_addr, options_addr)
196
+ end
197
+
198
+ sig { params(customdata: Hash).returns(NilClass) }
199
+ def set_client_custom_data(customdata)
200
+ customdata_json = Oj.dump(customdata)
201
+ customdata_addr = malloc_asc_string(customdata_json)
202
+ @@stack_tracer = lambda { |message| raise message }
203
+ @@instance.invoke("setClientCustomData", customdata_addr)
204
+ end
205
+
206
+ private
207
+
208
+ sig { params(platformdata: PlatformData).returns(NilClass) }
209
+ def set_platform_data(platformdata)
210
+ platformdata_json = Oj.dump(platformdata)
211
+ platformdata_addr = malloc_asc_string(platformdata_json)
212
+ @@stack_tracer = lambda { |message| raise message }
213
+ @@instance.invoke("setPlatformData", platformdata_addr)
214
+ end
215
+
216
+ # @param [String] string utf8 string to allocate
217
+ # @return [Integer] address to WASM String
218
+ sig { params(string: String).returns(Integer) }
219
+ def malloc_asc_string(string)
220
+ wasm_object_id = 1
221
+ @@stack_tracer = lambda { |message| raise message }
222
+ wasm_new = @@instance.export("__new").to_func
223
+ utf8_bytes = string.encode("iso-8859-1").force_encoding("utf-8").bytes
224
+ byte_len = utf8_bytes.length
225
+
226
+ start_addr = wasm_new.call(byte_len * 2, wasm_object_id)
227
+ i = 0
228
+ while i < byte_len
229
+ @@stack_tracer = lambda { |message| raise message }
230
+ @@memory.write(start_addr + (i * 2), [utf8_bytes[i]].pack('U'))
231
+ i += 1
232
+ end
233
+ start_addr
234
+ end
235
+
236
+ # @param [Integer] address start address of string.
237
+ # @return [String] resulting string
238
+ sig { params(address: Integer).returns(String) }
239
+ def read_asc_string(address)
240
+ @@stack_tracer = lambda { |message| raise message }
241
+ raw_bytes = @@memory.read(address - 4, 4).bytes.reverse
242
+ len = 0
243
+ raw_bytes.each { |j|
244
+ len = (len << 8) + (j & 0xFF)
245
+ }
246
+ result = ""
247
+ i = 0
248
+ while i < len
249
+ @@stack_tracer = lambda { |message| raise message }
250
+ result += @@memory.read(address + i, 1)
251
+ i += 2
252
+ end
253
+ result
254
+ end
255
+ end
256
+ end
257
+
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'socket'
4
+ require 'json'
5
+
6
+ module DevCycle
7
+ class PlatformData
8
+ attr_accessor :deviceModel, :platformVersion, :sdkVersion, :sdkType, :platform, :hostname
9
+
10
+ def initialize(sdk_type = nil, sdk_version = nil, platform_version = nil, device_model = nil, platform = nil, hostname = nil)
11
+ @sdkType = sdk_type
12
+ @sdkVersion = sdk_version
13
+ @platformVersion = platform_version
14
+ @deviceModel = device_model
15
+ @platform = platform
16
+ @hostname = hostname
17
+ end
18
+
19
+ def default
20
+ @sdkType = 'server'
21
+ @sdkVersion = VERSION
22
+ @platformVersion = RUBY_VERSION
23
+ @deviceModel = nil
24
+ @platform = 'Ruby'
25
+ @hostname = Socket.gethostname
26
+ self
27
+ end
28
+ end
29
+ end
@@ -28,7 +28,7 @@ module DevCycle
28
28
  attr_accessor :value
29
29
 
30
30
  # Extra JSON metadata for event. Contextual to event type
31
- attr_accessor :meta_data
31
+ attr_accessor :metaData
32
32
 
33
33
  # Attribute mapping from ruby-style variable name to JSON key.
34
34
  def self.attribute_map
@@ -37,7 +37,7 @@ module DevCycle
37
37
  :'target' => :'target',
38
38
  :'date' => :'date',
39
39
  :'value' => :'value',
40
- :'meta_data' => :'metaData'
40
+ :'metaData' => :'metaData'
41
41
  }
42
42
  end
43
43
 
@@ -53,7 +53,7 @@ module DevCycle
53
53
  :'target' => :'String',
54
54
  :'date' => :'Float',
55
55
  :'value' => :'Float',
56
- :'meta_data' => :'Object'
56
+ :'metaData' => :'Object'
57
57
  }
58
58
  end
59
59
 
@@ -94,8 +94,8 @@ module DevCycle
94
94
  self.value = attributes[:'value']
95
95
  end
96
96
 
97
- if attributes.key?(:'meta_data')
98
- self.meta_data = attributes[:'meta_data']
97
+ if attributes.key?(:'metaData')
98
+ self.metaData = attributes[:'metaData']
99
99
  end
100
100
  end
101
101
 
@@ -138,7 +138,7 @@ module DevCycle
138
138
  # Calculates hash code according to all attributes.
139
139
  # @return [Integer] Hash code
140
140
  def hash
141
- [type, target, date, value, meta_data].hash
141
+ [type, target, date, value, metaData].hash
142
142
  end
143
143
 
144
144
  # Builds the object from hash
@@ -12,9 +12,14 @@ OpenAPI Generator version: 5.3.0
12
12
 
13
13
  require 'date'
14
14
  require 'time'
15
+ require 'oj'
15
16
 
16
17
  module DevCycle
17
18
  class UserData
19
+
20
+ def to_json
21
+ Oj.dump(self)
22
+ end
18
23
  # Unique id to identify the user
19
24
  attr_accessor :user_id
20
25
 
@@ -31,37 +36,39 @@ module DevCycle
31
36
  attr_accessor :country
32
37
 
33
38
  # App Version of the running application
34
- attr_accessor :app_version
39
+ attr_accessor :appVersion
35
40
 
36
41
  # App Build number of the running application
37
- attr_accessor :app_build
42
+ attr_accessor :appBuild
38
43
 
39
44
  # User's custom data to target the user with, data will be logged to DevCycle for use in dashboard.
40
- attr_accessor :custom_data
45
+ attr_accessor :customData
41
46
 
42
47
  # 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
48
+ attr_accessor :privateCustomData
49
+
50
+ # User's device model
51
+ attr_accessor :deviceModel
52
+
53
+ # read-only instance variables
44
54
 
45
55
  # Date the user was created, Unix epoch timestamp format
46
- attr_accessor :created_date
56
+ attr_reader :createdDate
47
57
 
48
58
  # Date the user was created, Unix epoch timestamp format
49
- attr_accessor :last_seen_date
59
+ attr_reader :lastSeenDate
50
60
 
51
61
  # Platform the Client SDK is running on
52
- attr_accessor :platform
62
+ attr_reader :platform
53
63
 
54
64
  # 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
65
+ attr_reader :platformVersion
59
66
 
60
67
  # DevCycle SDK type
61
- attr_accessor :sdk_type
68
+ attr_reader :sdkType
62
69
 
63
70
  # DevCycle SDK Version
64
- attr_accessor :sdk_version
71
+ attr_reader :sdkVersion
65
72
 
66
73
  class EnumAttributeValidator
67
74
  attr_reader :datatype
@@ -93,17 +100,17 @@ module DevCycle
93
100
  :'name' => :'name',
94
101
  :'language' => :'language',
95
102
  :'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',
103
+ :'appVersion' => :'appVersion',
104
+ :'appBuild' => :'appBuild',
105
+ :'customData' => :'customData',
106
+ :'privateCustomData' => :'privateCustomData',
107
+ :'createdDate' => :'createdDate',
108
+ :'lastSeenDate' => :'lastSeenDate',
102
109
  :'platform' => :'platform',
103
- :'platform_version' => :'platformVersion',
104
- :'device_model' => :'deviceModel',
105
- :'sdk_type' => :'sdkType',
106
- :'sdk_version' => :'sdkVersion'
110
+ :'platformVersion' => :'platformVersion',
111
+ :'deviceModel' => :'deviceModel',
112
+ :'sdkType' => :'sdkType',
113
+ :'sdkVersion' => :'sdkVersion'
107
114
  }
108
115
  end
109
116
 
@@ -120,24 +127,23 @@ module DevCycle
120
127
  :'name' => :'String',
121
128
  :'language' => :'String',
122
129
  :'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',
130
+ :'appVersion' => :'String',
131
+ :'appBuild' => :'String',
132
+ :'customData' => :'Object',
133
+ :'privateCustomData' => :'Object',
134
+ :'createdDate' => :'Float',
135
+ :'lastSeenDate' => :'Float',
129
136
  :'platform' => :'String',
130
- :'platform_version' => :'String',
131
- :'device_model' => :'String',
132
- :'sdk_type' => :'String',
133
- :'sdk_version' => :'String'
137
+ :'platformVersion' => :'String',
138
+ :'deviceModel' => :'String',
139
+ :'sdkType' => :'String',
140
+ :'sdkVersion' => :'String'
134
141
  }
135
142
  end
136
143
 
137
144
  # List of attributes with nullable: true
138
145
  def self.openapi_nullable
139
- Set.new([
140
- ])
146
+ Set.new([])
141
147
  end
142
148
 
143
149
  # Initializes the object
@@ -155,8 +161,6 @@ module DevCycle
155
161
  h[k.to_sym] = v
156
162
  }
157
163
 
158
- self.set_default_platform_info()
159
-
160
164
  if attributes.key?(:'user_id')
161
165
  self.user_id = attributes[:'user_id']
162
166
  end
@@ -177,56 +181,34 @@ module DevCycle
177
181
  self.country = attributes[:'country']
178
182
  end
179
183
 
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']
184
+ if attributes.key?(:'appVersion')
185
+ self.appVersion = attributes[:'appVersion']
194
186
  end
195
187
 
196
- if attributes.key?(:'created_date')
197
- self.created_date = attributes[:'created_date']
188
+ if attributes.key?(:'appBuild')
189
+ self.appBuild = attributes[:'appBuild']
198
190
  end
199
191
 
200
- if attributes.key?(:'last_seen_date')
201
- self.last_seen_date = attributes[:'last_seen_date']
192
+ if attributes.key?(:'customData')
193
+ self.customData = attributes[:'customData']
202
194
  end
203
195
 
204
- if attributes.key?(:'platform')
205
- self.platform = attributes[:'platform']
196
+ if attributes.key?(:'privateCustomData')
197
+ self.privateCustomData = attributes[:'privateCustomData']
206
198
  end
207
199
 
208
- if attributes.key?(:'platform_version')
209
- self.platform_version = attributes[:'platform_version']
200
+ if attributes.key?(:'deviceModel')
201
+ self.deviceModel = attributes[:'deviceModel']
210
202
  end
211
203
 
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
204
+ # set read-only instance variables
205
+ default_platform_data = PlatformData.new.default
206
+ @sdkType = default_platform_data.sdkType
207
+ @sdkVersion = default_platform_data.sdkVersion
208
+ @platform = default_platform_data.platform
209
+ @platformVersion = default_platform_data.platformVersion
210
+ @createdDate = Time.now.utc.iso8601
211
+ @lastSeenDate = Time.now.utc.iso8601
230
212
  end
231
213
 
232
214
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -279,37 +261,27 @@ module DevCycle
279
261
  @country = country
280
262
  end
281
263
 
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
264
  # Checks equality by comparing each attribute.
293
265
  # @param [Object] Object to be compared
294
266
  def ==(o)
295
267
  return true if self.equal?(o)
296
268
  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
269
+ user_id == o.user_id &&
270
+ email == o.email &&
271
+ name == o.name &&
272
+ language == o.language &&
273
+ country == o.country &&
274
+ appVersion == o.appVersion &&
275
+ appBuild == o.appBuild &&
276
+ customData == o.customData &&
277
+ privateCustomData == o.privateCustomData &&
278
+ createdDate == o.createdDate &&
279
+ lastSeenDate == o.lastSeenDate &&
280
+ platform == o.platform &&
281
+ platformVersion == o.platformVersion &&
282
+ deviceModel == o.deviceModel &&
283
+ sdkType == o.sdkType &&
284
+ sdkVersion == o.sdkVersion
313
285
  end
314
286
 
315
287
  # @see the `==` method
@@ -321,7 +293,7 @@ module DevCycle
321
293
  # Calculates hash code according to all attributes.
322
294
  # @return [Integer] Hash code
323
295
  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
296
+ [user_id, email, name, language, country, appVersion, appBuild, customData, privateCustomData, createdDate, lastSeenDate, platform, platformVersion, deviceModel, sdkType, sdkVersion].hash
325
297
  end
326
298
 
327
299
  # Builds the object from hash
@@ -389,7 +361,8 @@ module DevCycle
389
361
  hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
390
362
  end
391
363
  end
392
- else # model
364
+ else
365
+ # model
393
366
  # models (e.g. Pet) or oneOf
394
367
  klass = DevCycle.const_get(type)
395
368
  klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
@@ -441,7 +414,5 @@ module DevCycle
441
414
  value
442
415
  end
443
416
  end
444
-
445
417
  end
446
-
447
418
  end