wingify-fme-ruby-sdk 1.50.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.
- checksums.yaml +7 -0
- data/lib/resources/debug_messages.json +21 -0
- data/lib/resources/error_messages.json +63 -0
- data/lib/resources/info_messages.json +43 -0
- data/lib/resources/warn_messages.json +1 -0
- data/lib/vwo.rb +40 -0
- data/lib/wingify/api/get_flag.rb +244 -0
- data/lib/wingify/api/set_attribute.rb +57 -0
- data/lib/wingify/api/track_event.rb +80 -0
- data/lib/wingify/constants/constants.rb +106 -0
- data/lib/wingify/decorators/storage_decorator.rb +82 -0
- data/lib/wingify/enums/api_enum.rb +23 -0
- data/lib/wingify/enums/campaign_type_enum.rb +19 -0
- data/lib/wingify/enums/debug_category_enum.rb +20 -0
- data/lib/wingify/enums/decision_types_enum.rb +18 -0
- data/lib/wingify/enums/event_enum.rb +22 -0
- data/lib/wingify/enums/headers_enum.rb +20 -0
- data/lib/wingify/enums/hooks_enum.rb +17 -0
- data/lib/wingify/enums/http_method_enum.rb +18 -0
- data/lib/wingify/enums/log_level_enum.rb +21 -0
- data/lib/wingify/enums/log_level_to_number.rb +27 -0
- data/lib/wingify/enums/status_enum.rb +19 -0
- data/lib/wingify/enums/storage_enum.rb +22 -0
- data/lib/wingify/enums/url_enum.rb +22 -0
- data/lib/wingify/models/campaign/campaign_model.rb +192 -0
- data/lib/wingify/models/campaign/feature_model.rb +111 -0
- data/lib/wingify/models/campaign/impact_campaign_model.rb +38 -0
- data/lib/wingify/models/campaign/metric_model.rb +44 -0
- data/lib/wingify/models/campaign/rule_model.rb +56 -0
- data/lib/wingify/models/campaign/variable_model.rb +51 -0
- data/lib/wingify/models/campaign/variation_model.rb +137 -0
- data/lib/wingify/models/gateway_service_model.rb +39 -0
- data/lib/wingify/models/schemas/settings_schema_validation.rb +104 -0
- data/lib/wingify/models/settings/settings_model.rb +101 -0
- data/lib/wingify/models/storage/storage_data_model.rb +44 -0
- data/lib/wingify/models/user/context_model.rb +154 -0
- data/lib/wingify/models/user/context_vwo_model.rb +38 -0
- data/lib/wingify/models/user/get_flag_response.rb +50 -0
- data/lib/wingify/models/vwo_options_model.rb +129 -0
- data/lib/wingify/packages/decision_maker/decision_maker.rb +60 -0
- data/lib/wingify/packages/logger/core/log_manager.rb +92 -0
- data/lib/wingify/packages/logger/core/transport_manager.rb +76 -0
- data/lib/wingify/packages/logger/log_message_builder.rb +70 -0
- data/lib/wingify/packages/logger/logger.rb +38 -0
- data/lib/wingify/packages/logger/transports/console_transport.rb +49 -0
- data/lib/wingify/packages/network_layer/client/network_client.rb +276 -0
- data/lib/wingify/packages/network_layer/handlers/request_handler.rb +37 -0
- data/lib/wingify/packages/network_layer/manager/network_manager.rb +145 -0
- data/lib/wingify/packages/network_layer/models/global_request_model.rb +105 -0
- data/lib/wingify/packages/network_layer/models/request_model.rb +179 -0
- data/lib/wingify/packages/network_layer/models/response_model.rb +62 -0
- data/lib/wingify/packages/segmentation_evaluator/core/segmentation_manager.rb +77 -0
- data/lib/wingify/packages/segmentation_evaluator/enums/segment_operand_regex_enum.rb +29 -0
- data/lib/wingify/packages/segmentation_evaluator/enums/segment_operand_value_enum.rb +26 -0
- data/lib/wingify/packages/segmentation_evaluator/enums/segment_operator_value_enum.rb +33 -0
- data/lib/wingify/packages/segmentation_evaluator/evaluators/segment_evaluator.rb +218 -0
- data/lib/wingify/packages/segmentation_evaluator/evaluators/segment_operand_evaluator.rb +415 -0
- data/lib/wingify/packages/segmentation_evaluator/utils/segment_util.rb +44 -0
- data/lib/wingify/packages/storage/connector.rb +26 -0
- data/lib/wingify/packages/storage/storage.rb +47 -0
- data/lib/wingify/services/batch_event_queue.rb +179 -0
- data/lib/wingify/services/campaign_decision_service.rb +161 -0
- data/lib/wingify/services/hooks_service.rb +51 -0
- data/lib/wingify/services/logger_service.rb +114 -0
- data/lib/wingify/services/settings_service.rb +178 -0
- data/lib/wingify/services/storage_service.rb +66 -0
- data/lib/wingify/utils/batch_event_dispatcher_util.rb +178 -0
- data/lib/wingify/utils/brand_context.rb +33 -0
- data/lib/wingify/utils/brand_util.rb +53 -0
- data/lib/wingify/utils/campaign_util.rb +284 -0
- data/lib/wingify/utils/data_type_util.rb +105 -0
- data/lib/wingify/utils/debugger_service_util.rb +40 -0
- data/lib/wingify/utils/decision_util.rb +259 -0
- data/lib/wingify/utils/event_util.rb +55 -0
- data/lib/wingify/utils/function_util.rb +141 -0
- data/lib/wingify/utils/gateway_service_util.rb +101 -0
- data/lib/wingify/utils/impression_util.rb +66 -0
- data/lib/wingify/utils/log_message_util.rb +42 -0
- data/lib/wingify/utils/meg_util.rb +357 -0
- data/lib/wingify/utils/network_util.rb +503 -0
- data/lib/wingify/utils/rule_evaluation_util.rb +57 -0
- data/lib/wingify/utils/settings_util.rb +38 -0
- data/lib/wingify/utils/usage_stats_util.rb +119 -0
- data/lib/wingify/utils/uuid_util.rb +96 -0
- data/lib/wingify/wingify_builder.rb +261 -0
- data/lib/wingify/wingify_client.rb +227 -0
- data/lib/wingify.rb +117 -0
- metadata +327 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# Copyright 2024-2026 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_model'
|
|
16
|
+
require_relative 'impact_campaign_model'
|
|
17
|
+
require_relative 'metric_model'
|
|
18
|
+
require_relative 'rule_model'
|
|
19
|
+
|
|
20
|
+
class FeatureModel
|
|
21
|
+
attr_reader :id, :key, :name, :type, :rules, :impact_campaign, :rules_linked_campaign, :metrics, :is_gateway_service_required
|
|
22
|
+
|
|
23
|
+
def initialize
|
|
24
|
+
@id = nil
|
|
25
|
+
@key = ''
|
|
26
|
+
@name = ''
|
|
27
|
+
@type = ''
|
|
28
|
+
@rules = []
|
|
29
|
+
@impact_campaign = nil
|
|
30
|
+
@rules_linked_campaign = []
|
|
31
|
+
@metrics = []
|
|
32
|
+
@is_gateway_service_required = false
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# Creates a model instance from a hash (dictionary)
|
|
36
|
+
def model_from_dictionary(feature)
|
|
37
|
+
@id = feature["id"]
|
|
38
|
+
@key = feature["key"]
|
|
39
|
+
@name = feature["name"]
|
|
40
|
+
@type = feature["type"]
|
|
41
|
+
@is_gateway_service_required = feature["is_gateway_service_required"] if feature.key?("is_gateway_service_required")
|
|
42
|
+
|
|
43
|
+
if feature["impactCampaign"]
|
|
44
|
+
@impact_campaign = ImpactCampaignModel.new.model_from_dictionary(feature["impactCampaign"])
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
@metrics = process_metrics(feature["metrics"])
|
|
48
|
+
@rules = process_rules(feature["rules"])
|
|
49
|
+
@rules_linked_campaign = feature["rules_linked_campaign"].is_a?(Array) ? feature["rules_linked_campaign"] : []
|
|
50
|
+
|
|
51
|
+
self
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Setter method for rules_linked_campaign
|
|
55
|
+
def set_rules_linked_campaign(rules_linked_campaign)
|
|
56
|
+
@rules_linked_campaign = rules_linked_campaign
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# Setter method for is_gateway_service_required
|
|
60
|
+
def set_is_gateway_service_required(is_gateway_service_required)
|
|
61
|
+
@is_gateway_service_required = is_gateway_service_required
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def get_id
|
|
65
|
+
@id
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def get_key
|
|
69
|
+
@key
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def get_name
|
|
73
|
+
@name
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def get_type
|
|
77
|
+
@type
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def get_rules
|
|
81
|
+
@rules
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def get_impact_campaign
|
|
85
|
+
@impact_campaign
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def get_rules_linked_campaign
|
|
89
|
+
@rules_linked_campaign
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def get_metrics
|
|
93
|
+
@metrics
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def get_is_gateway_service_required
|
|
97
|
+
@is_gateway_service_required
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# Process rules list
|
|
101
|
+
def process_rules(rule_list)
|
|
102
|
+
return [] unless rule_list.is_a?(Array)
|
|
103
|
+
rule_list.map { |rule| RuleModel.new.model_from_dictionary(rule) }
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# Process metrics list
|
|
107
|
+
def process_metrics(metric_list)
|
|
108
|
+
return [] unless metric_list.is_a?(Array)
|
|
109
|
+
metric_list.map { |metric| MetricModel.new.model_from_dictionary(metric) }
|
|
110
|
+
end
|
|
111
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Copyright 2024-2026 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 ImpactCampaignModel
|
|
16
|
+
attr_reader :campaign_id, :type
|
|
17
|
+
|
|
18
|
+
def initialize
|
|
19
|
+
@campaign_id = nil
|
|
20
|
+
@type = ''
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Creates a model instance from a hash (dictionary)
|
|
24
|
+
def model_from_dictionary(impact_campaign)
|
|
25
|
+
@type = impact_campaign["type"]
|
|
26
|
+
@campaign_id = impact_campaign["campaignId"]
|
|
27
|
+
self
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def get_campaign_id
|
|
31
|
+
@campaign_id
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def get_type
|
|
35
|
+
@type
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Copyright 2024-2026 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 MetricModel
|
|
16
|
+
attr_reader :id, :identifier, :type
|
|
17
|
+
|
|
18
|
+
def initialize
|
|
19
|
+
@id = nil
|
|
20
|
+
@identifier = ''
|
|
21
|
+
@type = ''
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Creates a model instance from a hash (dictionary)
|
|
25
|
+
def model_from_dictionary(metric)
|
|
26
|
+
@identifier = metric["identifier"]
|
|
27
|
+
@id = metric["id"]
|
|
28
|
+
@type = metric["type"]
|
|
29
|
+
self
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def get_id
|
|
33
|
+
@id
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def get_identifier
|
|
37
|
+
@identifier
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def get_type
|
|
41
|
+
@type
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Copyright 2024-2026 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 RuleModel
|
|
16
|
+
attr_reader :status, :variation_id, :campaign_id, :type, :rule_key
|
|
17
|
+
|
|
18
|
+
def initialize
|
|
19
|
+
@status = false
|
|
20
|
+
@variation_id = nil
|
|
21
|
+
@campaign_id = nil
|
|
22
|
+
@type = ''
|
|
23
|
+
@rule_key = ''
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Creates a model instance from a hash (dictionary)
|
|
27
|
+
def model_from_dictionary(rule)
|
|
28
|
+
@type = rule["type"]
|
|
29
|
+
@status = rule["status"]
|
|
30
|
+
@variation_id = rule["variationId"]
|
|
31
|
+
@campaign_id = rule["campaignId"]
|
|
32
|
+
@rule_key = rule["ruleKey"]
|
|
33
|
+
self
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def get_type
|
|
37
|
+
@type
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def get_status
|
|
41
|
+
@status
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def get_variation_id
|
|
45
|
+
@variation_id
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def get_campaign_id
|
|
49
|
+
@campaign_id
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def get_rule_key
|
|
53
|
+
@rule_key
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Copyright 2024-2026 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 VariableModel
|
|
16
|
+
attr_accessor :value, :type, :key
|
|
17
|
+
attr_reader :id
|
|
18
|
+
|
|
19
|
+
def initialize
|
|
20
|
+
@value = nil
|
|
21
|
+
@type = ''
|
|
22
|
+
@key = ''
|
|
23
|
+
@id = nil
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Creates a model instance from a hash (dictionary)
|
|
27
|
+
def model_from_dictionary(variable)
|
|
28
|
+
@value = variable["value"]
|
|
29
|
+
@type = variable["type"]
|
|
30
|
+
@key = variable["key"]
|
|
31
|
+
@id = variable["id"]
|
|
32
|
+
self
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def get_value
|
|
36
|
+
@value
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def get_type
|
|
40
|
+
@type
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def get_key
|
|
44
|
+
@key
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def get_id
|
|
48
|
+
@id
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# Copyright 2024-2026 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 2024-2026 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,104 @@
|
|
|
1
|
+
# Copyright 2024-2026 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(:usageStatsAccountId).maybe(:integer)
|
|
88
|
+
optional(:features).array(:hash)
|
|
89
|
+
required(:campaigns).array(:hash)
|
|
90
|
+
optional(:groups).maybe(:hash)
|
|
91
|
+
optional(:campaignGroups).maybe(:hash)
|
|
92
|
+
optional(:collectionPrefix).maybe(:string)
|
|
93
|
+
optional(:sdkMetaInfo).maybe(:hash)
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# Validate the settings model
|
|
98
|
+
def is_settings_valid(settings)
|
|
99
|
+
return false if settings.nil?
|
|
100
|
+
|
|
101
|
+
result = @settings_schema.call(settings)
|
|
102
|
+
result.errors.empty?
|
|
103
|
+
end
|
|
104
|
+
end
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# Copyright 2024-2026 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
|
+
require_relative '../../constants/constants'
|
|
18
|
+
|
|
19
|
+
class SettingsModel
|
|
20
|
+
attr_reader :sdk_key, :account_id, :usage_stats_account_id, :version, :collection_prefix,
|
|
21
|
+
:features, :campaigns, :campaign_groups, :groups, :poll_interval, :is_web_connectivity_enabled
|
|
22
|
+
|
|
23
|
+
def initialize(settings)
|
|
24
|
+
@sdk_key = settings["sdkKey"]
|
|
25
|
+
@account_id = settings["accountId"]
|
|
26
|
+
@usage_stats_account_id = settings["usageStatsAccountId"]
|
|
27
|
+
@version = settings["version"]
|
|
28
|
+
@collection_prefix = settings["collectionPrefix"]
|
|
29
|
+
@poll_interval = settings["pollInterval"] || Constants::POLLING_INTERVAL
|
|
30
|
+
@features = []
|
|
31
|
+
@campaigns = []
|
|
32
|
+
@campaign_groups = settings["campaignGroups"] || {}
|
|
33
|
+
@groups = settings["groups"] || {}
|
|
34
|
+
@is_web_connectivity_enabled = settings.fetch("isWebConnectivityEnabled", true)
|
|
35
|
+
|
|
36
|
+
process_features(settings)
|
|
37
|
+
process_campaigns(settings)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def get_campaigns
|
|
41
|
+
@campaigns
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def get_features
|
|
45
|
+
@features
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def get_campaign_groups
|
|
49
|
+
@campaign_groups
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def get_groups
|
|
53
|
+
@groups
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def get_sdk_key
|
|
57
|
+
@sdk_key
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def get_account_id
|
|
61
|
+
@account_id
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def get_usage_stats_account_id
|
|
65
|
+
@usage_stats_account_id
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def get_version
|
|
69
|
+
@version
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def get_collection_prefix
|
|
73
|
+
@collection_prefix
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def get_poll_interval
|
|
77
|
+
@poll_interval
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def process_features(settings)
|
|
81
|
+
feature_list = settings["features"]
|
|
82
|
+
return unless feature_list.is_a?(Array)
|
|
83
|
+
|
|
84
|
+
feature_list.each do |feature|
|
|
85
|
+
@features << FeatureModel.new.model_from_dictionary(feature)
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def process_campaigns(settings)
|
|
90
|
+
campaign_list = settings["campaigns"]
|
|
91
|
+
return unless campaign_list.is_a?(Array)
|
|
92
|
+
|
|
93
|
+
campaign_list.each do |campaign|
|
|
94
|
+
@campaigns << CampaignModel.new.model_from_dictionary(campaign)
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def get_is_web_connectivity_enabled
|
|
99
|
+
@is_web_connectivity_enabled
|
|
100
|
+
end
|
|
101
|
+
end
|