-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge in SST/mobile-testing-ios-sdk from feature/meg to master * commit 'f6c9291cef711f03d12d19dac64d2227da01de72': (3 commits) Mutual exclusive group fixes ...
- Loading branch information
Showing
24 changed files
with
1,298 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// CampaignGroupMapper.h | ||
// VWO | ||
// | ||
// Created by Harsh Raghav on 30/11/22. | ||
// Copyright © 2022 vwo. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface CampaignGroupMapper : NSObject | ||
|
||
+ (NSDictionary *)getCampaignGroups: (NSDictionary *)jsonObject; | ||
+ (NSDictionary *)createAndGetGroups: (NSDictionary *)jsonObject; | ||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
// | ||
// CampaignGroupMapper.m | ||
// VWO | ||
// | ||
// Created by Harsh Raghav on 30/11/22. | ||
// Copyright © 2022 vwo. All rights reserved. | ||
// | ||
|
||
#import "CampaignGroupMapper.h" | ||
#import "VWOLogger.h" | ||
#import "VWOCampaign.h" | ||
#import "Group.h" | ||
|
||
@implementation CampaignGroupMapper | ||
|
||
static NSString * const KEY_CAMPAIGN_GROUPS = @"campaignGroups"; | ||
static NSString * const KEY_GROUPS = @"groups"; | ||
static NSString * const KEY_NAME = @"name"; | ||
static NSString * const KEY_CAMPAIGNS = @"campaigns"; | ||
|
||
float m = 1.0; | ||
|
||
//months, | ||
|
||
+ (NSDictionary *)getCampaignGroups: (NSDictionary *)jsonObject{ | ||
|
||
NSDictionary* jsonCampaignGroups = nil; | ||
@try { | ||
jsonCampaignGroups = jsonObject[KEY_CAMPAIGN_GROUPS]; | ||
} | ||
@catch (NSException *exception) { | ||
VWOLogDebug(@"MutuallyExclusive %@", exception); | ||
|
||
} | ||
return jsonCampaignGroups; | ||
} | ||
|
||
|
||
+ (NSDictionary *)createAndGetGroups: (NSDictionary *)jsonObject{ | ||
NSMutableDictionary<NSString*, Group*> *groups = [NSMutableDictionary new]; | ||
@try{ | ||
NSDictionary *jsonGroups = [self getGroups:jsonObject]; | ||
|
||
if(jsonGroups == nil) return groups; | ||
|
||
NSArray<NSString*> *itrJsonGroups = [jsonGroups allKeys]; | ||
int index=0; | ||
while (index < itrJsonGroups.count) { | ||
NSString *key = itrJsonGroups[index]; | ||
|
||
NSDictionary *objGroup = jsonGroups[key]; | ||
NSArray *arrCampaigns = objGroup[KEY_CAMPAIGNS]; | ||
|
||
NSString *groupName = objGroup[KEY_NAME]; | ||
|
||
Group *group = [[Group alloc]init]; | ||
group.name = groupName; | ||
group.Id = key.intValue; | ||
|
||
for (int i = 0; i < arrCampaigns.count; i++) { | ||
[group addCampaign:arrCampaigns[i]]; | ||
} | ||
VWOLogDebug(@"MutuallyExclusive Added Group Id %d", group.Id); | ||
VWOLogDebug(@"MutuallyExclusive Added Group Campaign %@", group.getCampaigns); | ||
|
||
[groups setObject:group forKey:groupName]; | ||
index++; | ||
} | ||
} | ||
|
||
@catch (NSException *exception) { | ||
VWOLogDebug(@"MutuallyExclusive error while adding groups %@", exception); | ||
} | ||
return groups; | ||
} | ||
|
||
+ (NSDictionary *)getGroups: (NSDictionary *)jsonObject{ | ||
NSDictionary *jsonGroups = nil; | ||
|
||
@try { | ||
VWOCampaign *groupDict = [jsonObject objectForKey:KEY_GROUPS] ; | ||
jsonGroups = groupDict.group.groups; | ||
} | ||
@catch (NSException *exception) { | ||
VWOLogDebug(@"MutuallyExclusive %@", exception); | ||
} | ||
return jsonGroups; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// CampaignUniquenessTracker.h | ||
// VWO | ||
// | ||
// Created by Harsh Raghav on 30/11/22. | ||
// Copyright © 2022 vwo. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface CampaignUniquenessTracker : NSObject { | ||
|
||
} | ||
|
||
- (BOOL)groupContainsCampaign:(NSString *) campaign; | ||
- (NSString *)getNameOfGroupFor:(NSString *) campaign; | ||
- (void)addCampaignAsRegistered:(NSString *) campaign group:(NSString *) group; | ||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// | ||
// CampaignUniquenessTracker.m | ||
// VWO | ||
// | ||
// Created by Harsh Raghav on 30/11/22. | ||
// Copyright © 2022 vwo. All rights reserved. | ||
// | ||
|
||
#import "CampaignUniquenessTracker.h" | ||
|
||
@implementation CampaignUniquenessTracker | ||
|
||
-(id) init | ||
{ | ||
self = [super init]; | ||
if(self) | ||
{ | ||
//do something | ||
} | ||
return self; | ||
} | ||
|
||
static NSMutableDictionary<NSString *, NSString *> * CAMPAIGNS; | ||
|
||
- (BOOL)groupContainsCampaign:(NSString *) campaign{ | ||
|
||
if (CAMPAIGNS == nil) { | ||
CAMPAIGNS = [NSMutableDictionary new]; | ||
} | ||
return (CAMPAIGNS[campaign] != nil); | ||
} | ||
|
||
- (NSString *)getNameOfGroupFor:(NSString *) campaign{ | ||
if (CAMPAIGNS == nil) { | ||
CAMPAIGNS = [NSMutableDictionary new]; | ||
} | ||
return CAMPAIGNS[campaign]; | ||
} | ||
- (void)addCampaignAsRegistered:(NSString *) campaign group:(NSString *) group | ||
{ | ||
if (CAMPAIGNS == nil) { | ||
CAMPAIGNS = [NSMutableDictionary new]; | ||
} | ||
[CAMPAIGNS setObject:campaign forKey:group]; | ||
} | ||
|
||
@end |
Oops, something went wrong.