vwo-fme-ruby-sdk 1.0.0 → 1.1.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.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/lib/vwo/api/get_flag.rb +236 -0
  3. data/lib/vwo/api/set_attribute.rb +57 -0
  4. data/lib/vwo/api/track_event.rb +77 -0
  5. data/lib/vwo/constants/constants.rb +54 -0
  6. data/lib/vwo/decorators/storage_decorator.rb +86 -0
  7. data/lib/vwo/{utils/logger_helper.rb → enums/api_enum.rb} +5 -10
  8. data/lib/vwo/enums/campaign_type_enum.rb +19 -0
  9. data/lib/vwo/enums/decision_types_enum.rb +18 -0
  10. data/lib/vwo/enums/event_enum.rb +19 -0
  11. data/lib/vwo/enums/headers_enum.rb +20 -0
  12. data/lib/vwo/enums/hooks_enum.rb +17 -0
  13. data/lib/vwo/enums/http_method_enum.rb +18 -0
  14. data/lib/vwo/enums/log_level_enum.rb +21 -0
  15. data/lib/vwo/enums/status_enum.rb +19 -0
  16. data/lib/vwo/enums/storage_enum.rb +22 -0
  17. data/lib/vwo/enums/url_enum.rb +21 -0
  18. data/lib/vwo/models/campaign/campaign_model.rb +192 -0
  19. data/lib/vwo/models/campaign/feature_model.rb +111 -0
  20. data/lib/vwo/models/campaign/impact_campaign_model.rb +38 -0
  21. data/lib/vwo/models/campaign/metric_model.rb +44 -0
  22. data/lib/vwo/models/campaign/rule_model.rb +56 -0
  23. data/lib/vwo/models/campaign/variable_model.rb +51 -0
  24. data/lib/vwo/models/campaign/variation_model.rb +137 -0
  25. data/lib/vwo/models/gateway_service_model.rb +39 -0
  26. data/lib/vwo/models/schemas/settings_schema_validation.rb +102 -0
  27. data/lib/vwo/models/settings/settings_model.rb +85 -0
  28. data/lib/vwo/models/storage/storage_data_model.rb +44 -0
  29. data/lib/vwo/models/user/context_model.rb +100 -0
  30. data/lib/vwo/models/user/context_vwo_model.rb +38 -0
  31. data/lib/vwo/{utils/feature_flag_response.rb → models/user/get_flag_response.rb} +14 -14
  32. data/lib/vwo/models/vwo_options_model.rb +107 -0
  33. data/lib/vwo/packages/decision_maker/decision_maker.rb +60 -0
  34. data/lib/vwo/packages/logger/core/log_manager.rb +90 -0
  35. data/lib/vwo/packages/logger/core/transport_manager.rb +87 -0
  36. data/lib/vwo/packages/logger/log_message_builder.rb +70 -0
  37. data/lib/vwo/packages/logger/logger.rb +38 -0
  38. data/lib/vwo/packages/logger/transports/console_transport.rb +49 -0
  39. data/lib/vwo/packages/network_layer/client/network_client.rb +107 -0
  40. data/lib/vwo/packages/network_layer/handlers/request_handler.rb +37 -0
  41. data/lib/vwo/packages/network_layer/manager/network_manager.rb +78 -0
  42. data/lib/vwo/packages/network_layer/models/global_request_model.rb +105 -0
  43. data/lib/vwo/packages/network_layer/models/request_model.rb +145 -0
  44. data/lib/vwo/packages/network_layer/models/response_model.rb +45 -0
  45. data/lib/vwo/packages/segmentation_evaluator/core/segmentation_manager.rb +76 -0
  46. data/lib/vwo/packages/segmentation_evaluator/enums/segment_operand_regex_enum.rb +29 -0
  47. data/lib/vwo/packages/segmentation_evaluator/enums/segment_operand_value_enum.rb +26 -0
  48. data/lib/vwo/packages/segmentation_evaluator/enums/segment_operator_value_enum.rb +30 -0
  49. data/lib/vwo/packages/segmentation_evaluator/evaluators/segment_evaluator.rb +210 -0
  50. data/lib/vwo/packages/segmentation_evaluator/evaluators/segment_operand_evaluator.rb +198 -0
  51. data/lib/vwo/packages/segmentation_evaluator/utils/segment_util.rb +44 -0
  52. data/lib/vwo/{constants.rb → packages/storage/connector.rb} +12 -10
  53. data/lib/vwo/packages/storage/storage.rb +45 -0
  54. data/lib/vwo/services/campaign_decision_service.rb +153 -0
  55. data/lib/vwo/services/hooks_service.rb +51 -0
  56. data/lib/vwo/services/logger_service.rb +83 -0
  57. data/lib/vwo/services/settings_service.rb +120 -0
  58. data/lib/vwo/services/storage_service.rb +65 -0
  59. data/lib/vwo/utils/campaign_util.rb +249 -0
  60. data/lib/vwo/utils/data_type_util.rb +105 -0
  61. data/lib/vwo/utils/decision_util.rb +253 -0
  62. data/lib/vwo/utils/function_util.rb +123 -0
  63. data/lib/vwo/utils/gateway_service_util.rb +101 -0
  64. data/lib/vwo/utils/impression_util.rb +49 -0
  65. data/lib/vwo/utils/log_message_util.rb +42 -0
  66. data/lib/vwo/utils/meg_util.rb +350 -0
  67. data/lib/vwo/utils/network_util.rb +235 -0
  68. data/lib/vwo/utils/rule_evaluation_util.rb +57 -0
  69. data/lib/vwo/utils/settings_util.rb +38 -0
  70. data/lib/vwo/utils/url_util.rb +46 -0
  71. data/lib/vwo/utils/uuid_util.rb +55 -0
  72. data/lib/vwo/vwo_builder.rb +156 -11
  73. data/lib/vwo/vwo_client.rb +163 -113
  74. data/lib/vwo.rb +49 -31
  75. metadata +187 -9
  76. data/lib/vwo/utils/request.rb +0 -89
@@ -0,0 +1,137 @@
1
+ # Copyright 2025 Wingify Software Pvt. Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require_relative 'variable_model'
16
+
17
+ class VariationModel
18
+ attr_accessor :id, :key, :rule_key, :weight, :segments, :start_range_variation,
19
+ :end_range_variation, :variables, :variations, :type, :salt
20
+
21
+ def initialize
22
+ @id = nil
23
+ @key = ''
24
+ @rule_key = ''
25
+ @weight = 0
26
+ @start_range_variation = 0
27
+ @end_range_variation = 0
28
+ @variables = []
29
+ @variations = []
30
+ @segments = {}
31
+ @type = ''
32
+ @salt = ''
33
+ end
34
+
35
+ # Creates a model instance from a hash (dictionary)
36
+ def model_from_dictionary(variation)
37
+ if variation.is_a?(Hash)
38
+ @id = variation["id"]
39
+ @key = variation["key"] || variation["name"]
40
+ @weight = variation["weight"]
41
+ @rule_key = variation["ruleKey"]
42
+ @salt = variation["salt"]
43
+ @type = variation["type"]
44
+ @start_range_variation = variation["start_range_variation"]
45
+ @end_range_variation = variation["end_range_variation"]
46
+ @segments = variation["segments"] if variation["segments"]
47
+
48
+ @variables = process_variables(variation["variables"])
49
+ @variations = process_variations(variation["variations"])
50
+ elsif variation.is_a?(VariationModel)
51
+ @id = variation.id
52
+ @key = variation.key
53
+ @weight = variation.weight
54
+ @rule_key = variation.rule_key
55
+ @salt = variation.salt
56
+ @type = variation.type
57
+ @start_range_variation = variation.start_range_variation
58
+ @end_range_variation = variation.end_range_variation
59
+ @segments = variation.segments
60
+ @variables = variation.variables
61
+ @variations = variation.variations
62
+ else
63
+ @id = variation.id
64
+ @key = variation.key
65
+ @rule_key = variation.rule_key
66
+ @salt = variation.salt
67
+ @type = variation.type
68
+ @segments = variation.segments
69
+ @variations = variation.variations
70
+ end
71
+ self
72
+ end
73
+
74
+ # Process variables list
75
+ def process_variables(variable_list)
76
+ return [] unless variable_list.is_a?(Array)
77
+ variable_list.map { |variable| VariableModel.new.model_from_dictionary(variable) }
78
+ end
79
+
80
+ # Process variations list
81
+ def process_variations(variation_list)
82
+ return [] unless variation_list.is_a?(Array)
83
+ variation_list.map { |variation| VariationModel.new.model_from_dictionary(variation) }
84
+ end
85
+
86
+ def get_id
87
+ @id
88
+ end
89
+
90
+ def get_key
91
+ @key
92
+ end
93
+
94
+ def get_rule_key
95
+ @rule_key
96
+ end
97
+
98
+ def get_weight
99
+ @weight
100
+ end
101
+
102
+ def get_start_range_variation
103
+ @start_range_variation
104
+ end
105
+
106
+ def set_start_range(start_range_variation)
107
+ @start_range_variation = start_range_variation
108
+ end
109
+
110
+ def get_end_range_variation
111
+ @end_range_variation
112
+ end
113
+
114
+ def set_end_range(end_range_variation)
115
+ @end_range_variation = end_range_variation
116
+ end
117
+
118
+ def get_variables
119
+ @variables
120
+ end
121
+
122
+ def get_variations
123
+ @variations
124
+ end
125
+
126
+ def get_segments
127
+ @segments
128
+ end
129
+
130
+ def get_type
131
+ @type
132
+ end
133
+
134
+ def get_salt
135
+ @salt
136
+ end
137
+ end
@@ -0,0 +1,39 @@
1
+ # Copyright 2025 Wingify Software Pvt. Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ class GatewayServiceModel
16
+ attr_accessor :url, :port
17
+
18
+ def initialize(url = '', port = nil)
19
+ @url = url
20
+ @port = port
21
+ end
22
+
23
+ # Creates a model instance from a hash (dictionary)
24
+ def model_from_dictionary(gateway_service_model)
25
+ @url = gateway_service_model[:url]
26
+ @port = gateway_service_model[:port]
27
+ self
28
+ end
29
+
30
+ def get_url
31
+ @url
32
+ end
33
+
34
+ def get_port
35
+ @port
36
+ end
37
+
38
+ end
39
+
@@ -0,0 +1,102 @@
1
+ # Copyright 2025 Wingify Software Pvt. Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'dry-schema'
16
+
17
+ class SettingsSchema
18
+ def initialize
19
+ initialize_schemas
20
+ end
21
+
22
+ def initialize_schemas
23
+ @campaign_metric_schema = Dry::Schema.Params do
24
+ required(:id).filled(:integer)
25
+ required(:type).filled(:string)
26
+ required(:identifier).filled(:string)
27
+ optional(:mca).maybe(:integer)
28
+ optional(:hasProps).maybe(:bool)
29
+ optional(:revenueProp).maybe(:string)
30
+ end
31
+
32
+ @variable_object_schema = Dry::Schema.Params do
33
+ required(:id).filled(:integer)
34
+ required(:type).filled(:string)
35
+ required(:key).filled(:string)
36
+ required(:value).filled(:string) # Ensuring consistent type
37
+ end
38
+
39
+ @campaign_variation_schema = Dry::Schema.Params do
40
+ required(:id).filled(:integer)
41
+ required(:name).filled(:string)
42
+ required(:weight).filled(:integer)
43
+ optional(:segments).maybe(:hash)
44
+ optional(:variables).array(:hash) # Ensuring it takes an array of hashes
45
+ optional(:startRangeVariation).maybe(:integer)
46
+ optional(:endRangeVariation).maybe(:integer)
47
+ optional(:salt).maybe(:string)
48
+ end
49
+
50
+ @campaign_object_schema = Dry::Schema.Params do
51
+ required(:id).filled(:integer)
52
+ required(:type).filled(:string)
53
+ required(:key).filled(:string)
54
+ optional(:percentTraffic).maybe(:integer)
55
+ required(:status).filled(:string)
56
+ required(:variations).array(:hash) # Referencing schema using array of hashes
57
+ required(:segments).filled(:hash)
58
+ optional(:isForcedVariationEnabled).maybe(:bool)
59
+ optional(:isAlwaysCheckSegment).maybe(:bool)
60
+ required(:name).filled(:string)
61
+ optional(:salt).maybe(:string)
62
+ end
63
+
64
+ @rule_schema = Dry::Schema.Params do
65
+ required(:type).filled(:string)
66
+ required(:ruleKey).filled(:string)
67
+ required(:campaignId).filled(:integer)
68
+ optional(:variationId).maybe(:integer)
69
+ end
70
+
71
+ @feature_schema = Dry::Schema.Params do
72
+ required(:id).filled(:integer)
73
+ required(:key).filled(:string)
74
+ required(:status).filled(:string)
75
+ required(:name).filled(:string)
76
+ required(:type).filled(:string)
77
+ required(:metrics).array(:hash)
78
+ optional(:impactCampaign).maybe(:hash)
79
+ optional(:rules).array(:hash)
80
+ optional(:variables).array(:hash)
81
+ end
82
+
83
+ @settings_schema = Dry::Schema.Params do
84
+ optional(:sdkKey).maybe(:string)
85
+ required(:version).filled(:integer)
86
+ required(:accountId).filled(:integer)
87
+ optional(:features).array(:hash)
88
+ required(:campaigns).array(:hash)
89
+ optional(:groups).maybe(:hash)
90
+ optional(:campaignGroups).maybe(:hash)
91
+ optional(:collectionPrefix).maybe(:string)
92
+ end
93
+ end
94
+
95
+ # Validate the settings model
96
+ def is_settings_valid(settings)
97
+ return false if settings.nil?
98
+
99
+ result = @settings_schema.call(settings)
100
+ result.errors.empty?
101
+ end
102
+ end
@@ -0,0 +1,85 @@
1
+ # Copyright 2025 Wingify Software Pvt. Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require_relative '../campaign/campaign_model'
16
+ require_relative '../campaign/feature_model'
17
+
18
+ class SettingsModel
19
+ attr_reader :sdk_key, :account_id, :version, :collection_prefix,
20
+ :features, :campaigns, :campaign_groups, :groups
21
+
22
+ def initialize(settings)
23
+ @sdk_key = settings["sdkKey"]
24
+ @account_id = settings["accountId"]
25
+ @version = settings["version"]
26
+ @collection_prefix = settings["collectionPrefix"]
27
+ @features = []
28
+ @campaigns = []
29
+ @campaign_groups = settings["campaignGroups"] || {}
30
+ @groups = settings["groups"] || {}
31
+
32
+ process_features(settings)
33
+ process_campaigns(settings)
34
+ end
35
+
36
+ def get_campaigns
37
+ @campaigns
38
+ end
39
+
40
+ def get_features
41
+ @features
42
+ end
43
+
44
+ def get_campaign_groups
45
+ @campaign_groups
46
+ end
47
+
48
+ def get_groups
49
+ @groups
50
+ end
51
+
52
+ def get_sdk_key
53
+ @sdk_key
54
+ end
55
+
56
+ def get_account_id
57
+ @account_id
58
+ end
59
+
60
+ def get_version
61
+ @version
62
+ end
63
+
64
+ def get_collection_prefix
65
+ @collection_prefix
66
+ end
67
+
68
+ def process_features(settings)
69
+ feature_list = settings["features"]
70
+ return unless feature_list.is_a?(Array)
71
+
72
+ feature_list.each do |feature|
73
+ @features << FeatureModel.new.model_from_dictionary(feature)
74
+ end
75
+ end
76
+
77
+ def process_campaigns(settings)
78
+ campaign_list = settings["campaigns"]
79
+ return unless campaign_list.is_a?(Array)
80
+
81
+ campaign_list.each do |campaign|
82
+ @campaigns << CampaignModel.new.model_from_dictionary(campaign)
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,44 @@
1
+ # Copyright 2025 Wingify Software Pvt. Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require_relative '../user/context_model'
16
+
17
+ class StorageDataModel
18
+ attr_accessor :feature_key, :context, :rollout_id, :rollout_key, :rollout_variation_id,
19
+ :experiment_id, :experiment_key, :experiment_variation_id
20
+
21
+ def initialize
22
+ @feature_key = ''
23
+ @context = nil
24
+ @rollout_id = nil
25
+ @rollout_key = ''
26
+ @rollout_variation_id = nil
27
+ @experiment_id = nil
28
+ @experiment_key = ''
29
+ @experiment_variation_id = nil
30
+ end
31
+
32
+ # Creates a model instance from a hash (dictionary)
33
+ def model_from_dictionary(storage_data)
34
+ @feature_key = storage_data[:feature_key]
35
+ @context = storage_data[:context]
36
+ @rollout_id = storage_data[:rollout_id]
37
+ @rollout_key = storage_data[:rollout_key]
38
+ @rollout_variation_id = storage_data[:rollout_variation_id]
39
+ @experiment_id = storage_data[:experiment_id]
40
+ @experiment_key = storage_data[:experiment_key]
41
+ @experiment_variation_id = storage_data[:experiment_variation_id]
42
+ self
43
+ end
44
+ end
@@ -0,0 +1,100 @@
1
+ # Copyright 2025 Wingify Software Pvt. Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require_relative './context_vwo_model'
16
+
17
+ class ContextModel
18
+ attr_accessor :id, :user_agent, :ip_address, :custom_variables, :variation_targeting_variables, :vwo
19
+
20
+ def initialize(id = nil, user_agent = nil, ip_address = nil, custom_variables = {}, variation_targeting_variables = {}, vwo = nil)
21
+ @id = id
22
+ @user_agent = user_agent
23
+ @ip_address = ip_address
24
+ @custom_variables = custom_variables || {}
25
+ @variation_targeting_variables = variation_targeting_variables || {}
26
+ @vwo = vwo
27
+ end
28
+
29
+ # Creates a model instance from a hash (dictionary)
30
+ def model_from_dictionary(context)
31
+ if context.key?(:customVariables) && !context[:customVariables].is_a?(Hash)
32
+ raise TypeError, 'Invalid context, customVariables should be a hash'
33
+ end
34
+
35
+ if context.key?(:userAgent) && !context[:userAgent].is_a?(String)
36
+ raise TypeError, 'Invalid context, userAgent should be a string'
37
+ end
38
+
39
+ if context.key?(:ipAddress) && !context[:ipAddress].is_a?(String)
40
+ raise TypeError, 'Invalid context, ipAddress should be a string'
41
+ end
42
+
43
+ @id = context[:id]
44
+ @user_agent = context[:userAgent]
45
+ @ip_address = context[:ipAddress]
46
+ @custom_variables = context[:customVariables] if context.key?(:customVariables)
47
+ @variation_targeting_variables = context[:variationTargetingVariables] if context.key?(:variationTargetingVariables)
48
+ @vwo = ContextVWOModel.new.model_from_dictionary(context[:_vwo]) if context.key?(:_vwo)
49
+
50
+ self
51
+ end
52
+
53
+ def get_id
54
+ @id
55
+ end
56
+
57
+ def set_id(id)
58
+ @id = id
59
+ end
60
+
61
+ def get_user_agent
62
+ @user_agent
63
+ end
64
+
65
+ def set_user_agent(user_agent)
66
+ @user_agent = user_agent
67
+ end
68
+
69
+ def get_ip_address
70
+ @ip_address
71
+ end
72
+
73
+ def set_ip_address(ip_address)
74
+ @ip_address = ip_address
75
+ end
76
+
77
+ def get_custom_variables
78
+ @custom_variables
79
+ end
80
+
81
+ def set_custom_variables(custom_variables)
82
+ @custom_variables = custom_variables
83
+ end
84
+
85
+ def get_variation_targeting_variables
86
+ @variation_targeting_variables
87
+ end
88
+
89
+ def set_variation_targeting_variables(variation_targeting_variables)
90
+ @variation_targeting_variables = variation_targeting_variables
91
+ end
92
+
93
+ def get_vwo
94
+ @vwo
95
+ end
96
+
97
+ def set_vwo(vwo)
98
+ @vwo = vwo
99
+ end
100
+ end
@@ -0,0 +1,38 @@
1
+ # Copyright 2025 Wingify Software Pvt. Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ class ContextVWOModel
16
+ attr_accessor :location, :user_agent
17
+
18
+ def initialize(location = {}, user_agent = {})
19
+ @location = location
20
+ @user_agent = user_agent
21
+ end
22
+
23
+ # Creates a model instance from a hash (dictionary)
24
+ def model_from_dictionary(context)
25
+ @location = context["location"] if context.key?("location")
26
+ @user_agent = context["userAgent"] if context.key?("userAgent")
27
+ self
28
+ end
29
+
30
+ def get_location
31
+ @location
32
+ end
33
+
34
+ def get_ua_info
35
+ @user_agent
36
+ end
37
+ end
38
+
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Wingify Software Pvt. Ltd.
1
+ # Copyright 2025 Wingify Software Pvt. Ltd.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -12,27 +12,27 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- module VWO
16
- class FeatureFlagResponse
15
+ class GetFlagResponse
16
+ attr_reader :is_enabled, :get_variables, :get_variable
17
+
17
18
  def initialize(is_enabled, variables = [])
18
19
  @is_enabled = is_enabled
19
20
  @variables = variables
20
21
  end
21
-
22
- # Method to check if the flag is enabled
22
+
23
+ # Define method for is_enabled
23
24
  def is_enabled
24
25
  @is_enabled
25
26
  end
26
-
27
- # Method to get all variables
27
+
28
+ # Define method for get_variables
28
29
  def get_variables
29
30
  @variables
30
31
  end
31
-
32
- # Method to get a specific variable by key, with a fallback default value
33
- def get_variable(key, default_value)
34
- variable = @variables.find { |var| var['key'] == key }
35
- variable ? variable['value'] : default_value
32
+
33
+ # Define method for get_variable
34
+ def get_variable(key, default_value = nil)
35
+ variable = @variables.find { |var| var.key == key }
36
+ variable ? variable.value : default_value
36
37
  end
37
- end
38
- end
38
+ end
@@ -0,0 +1,107 @@
1
+ # Copyright 2025 Wingify Software Pvt. Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ class VWOOptionsModel
16
+ attr_accessor :account_id, :sdk_key, :is_development_mode, :storage, :gateway_service,
17
+ :poll_interval, :logger, :segmentation, :integrations, :network,
18
+ :should_wait_for_tracking_calls, :settings, :vwo_builder
19
+
20
+ def initialize(options = {})
21
+ @account_id = options[:account_id]
22
+ @sdk_key = options[:sdk_key]
23
+ @is_development_mode = options[:is_development_mode]
24
+ @storage = options[:storage]
25
+ @gateway_service = options[:gateway_service]
26
+ @poll_interval = options[:poll_interval]
27
+ @logger = options[:logger]
28
+ @segmentation = options[:segmentation]
29
+ @integrations = options[:integrations]
30
+ @network = options[:network]
31
+ @should_wait_for_tracking_calls = options[:should_wait_for_tracking_calls]
32
+ @settings = options[:settings]
33
+ @vwo_builder = options[:vwo_builder]
34
+ end
35
+
36
+ # Creates a model instance from a hash (dictionary)
37
+ def model_from_dictionary(options)
38
+ @account_id = options[:account_id]
39
+ @sdk_key = options[:sdk_key]
40
+ @vwo_builder = options[:vwo_builder]
41
+
42
+ @should_wait_for_tracking_calls = options[:should_wait_for_tracking_calls] if options.key?(:should_wait_for_tracking_calls)
43
+ @is_development_mode = options[:is_development_mode] if options.key?(:is_development_mode)
44
+ @storage = options[:storage] if options.key?(:storage)
45
+ @gateway_service = options[:gateway_service] if options.key?(:gateway_service)
46
+ @poll_interval = options[:poll_interval] if options.key?(:poll_interval)
47
+ @logger = options[:logger] if options.key?(:logger)
48
+ @segmentation = options[:segmentation] if options.key?(:segmentation)
49
+ @integrations = options[:integrations] if options.key?(:integrations)
50
+ @network = options[:network] if options.key?(:network)
51
+ @settings = options[:settings] if options.key?(:settings)
52
+
53
+ self
54
+ end
55
+
56
+ def get_account_id
57
+ @account_id
58
+ end
59
+
60
+ def get_sdk_key
61
+ @sdk_key
62
+ end
63
+
64
+ def get_is_development_mode
65
+ @is_development_mode
66
+ end
67
+
68
+ def get_storage
69
+ @storage
70
+ end
71
+
72
+ def get_gateway_service
73
+ @gateway_service
74
+ end
75
+
76
+ def get_poll_interval
77
+ @poll_interval
78
+ end
79
+
80
+ def get_logger
81
+ @logger
82
+ end
83
+
84
+ def get_segmentation
85
+ @segmentation
86
+ end
87
+
88
+ def get_integrations
89
+ @integrations
90
+ end
91
+
92
+ def get_network
93
+ @network
94
+ end
95
+
96
+ def get_should_wait_for_tracking_calls
97
+ @should_wait_for_tracking_calls
98
+ end
99
+
100
+ def get_settings
101
+ @settings
102
+ end
103
+
104
+ def get_vwo_builder
105
+ @vwo_builder
106
+ end
107
+ end