Skip to content

Commit 1ccc4e9

Browse files
authored
refactor: breaking up Leanplum.h / Leanplum.m (#145)
* refactor: breaking up leanplum.m * fix name * refactor LPActionArg * refactor LPVar * refactor LeanplumCompatibility * lpvar changes * rename Leanplum-Internal back to LeanplumInternal to avoid breaking other modules * missed a few files * refactor lpinternalstate
1 parent 972f221 commit 1ccc4e9

12 files changed

+1533
-1431
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//
2+
// LPActionArg.h
3+
// Leanplum-iOS-SDK-source
4+
//
5+
// Created by Mayank Sanganeria on 4/24/18.
6+
//
7+
8+
#import "LeanplumInternal.h"
9+
10+
@interface LPActionArg ()
11+
12+
@property (readonly, strong) NSString *private_Name;
13+
@property (readonly, strong) id private_DefaultValue;
14+
@property (readonly, strong) NSString *private_Kind;
15+
16+
@end

Leanplum-SDK/Classes/LPActionArg.m

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
//
2+
// LPActionArg.m
3+
// Leanplum-iOS-SDK-source
4+
//
5+
// Created by Mayank Sanganeria on 4/24/18.
6+
//
7+
8+
#import "LeanplumInternal.h"
9+
#import "Utils.h"
10+
#import "LPVarCache.h"
11+
12+
@implementation LPActionArg : NSObject
13+
14+
@synthesize private_Name=_name;
15+
@synthesize private_Kind=_kind;
16+
@synthesize private_DefaultValue=_defaultValue;
17+
18+
+ (LPActionArg *)argNamed:(NSString *)name with:(NSObject *)defaultValue kind:(NSString *)kind
19+
{
20+
if ([Utils isNullOrEmpty:name]) {
21+
[Leanplum throwError:@"[LPVar argNamed:with:kind:] Empty name parameter provided."];
22+
return nil;
23+
}
24+
LPActionArg *arg = [LPActionArg new];
25+
LP_TRY
26+
arg->_name = name;
27+
arg->_kind = kind;
28+
arg->_defaultValue = defaultValue;
29+
if ([kind isEqualToString:LP_KIND_FILE]) {
30+
[LPVarCache registerFile:(NSString *) defaultValue
31+
withDefaultValue:(NSString *) defaultValue];
32+
}
33+
LP_END_TRY
34+
return arg;
35+
}
36+
37+
+ (LPActionArg *)argNamed:(NSString *)name withNumber:(NSNumber *)defaultValue
38+
{
39+
return [self argNamed:name with:defaultValue kind:LP_KIND_FLOAT];
40+
}
41+
42+
+ (LPActionArg *)argNamed:(NSString *)name withString:(NSString *)defaultValue
43+
{
44+
return [self argNamed:name with:defaultValue kind:LP_KIND_STRING];
45+
}
46+
47+
+ (LPActionArg *)argNamed:(NSString *)name withBool:(BOOL)defaultValue
48+
{
49+
return [self argNamed:name with:@(defaultValue) kind:LP_KIND_BOOLEAN];
50+
}
51+
52+
+ (LPActionArg *)argNamed:(NSString *)name withFile:(NSString *)defaultValue
53+
{
54+
if (defaultValue == nil) {
55+
defaultValue = @"";
56+
}
57+
return [self argNamed:name with:defaultValue kind:LP_KIND_FILE];
58+
}
59+
60+
+ (LPActionArg *)argNamed:(NSString *)name withDict:(NSDictionary *)defaultValue
61+
{
62+
return [self argNamed:name with:defaultValue kind:LP_KIND_DICTIONARY];
63+
}
64+
65+
+ (LPActionArg *)argNamed:(NSString *)name withArray:(NSArray *)defaultValue
66+
{
67+
return [self argNamed:name with:defaultValue kind:LP_KIND_ARRAY];
68+
}
69+
70+
+ (LPActionArg *)argNamed:(NSString *)name withAction:(NSString *)defaultValue
71+
{
72+
if (defaultValue == nil) {
73+
defaultValue = @"";
74+
}
75+
return [self argNamed:name with:defaultValue kind:LP_KIND_ACTION];
76+
}
77+
78+
+ (LPActionArg *)argNamed:(NSString *)name withColor:(UIColor *)defaultValue
79+
{
80+
return [self argNamed:name with:@(leanplum_colorToInt(defaultValue)) kind:LP_KIND_COLOR];
81+
}
82+
83+
- (NSString *)name
84+
{
85+
return _name;
86+
}
87+
88+
- (id)defaultValue
89+
{
90+
return _defaultValue;
91+
}
92+
93+
- (NSString *)kind
94+
{
95+
return _kind;
96+
}
97+
98+
@end
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
//
2+
// LPActionContext.h
3+
// Leanplum-iOS-SDK-source
4+
//
5+
// Created by Mayank Sanganeria on 4/24/18.
6+
//
7+
8+
#import "LeanplumInternal.h"
9+
10+
@class LPContextualValues;
11+
12+
@interface LPActionContext ()
13+
14+
+ (LPActionContext *)actionContextWithName:(NSString *)name
15+
args:(NSDictionary *)args
16+
messageId:(NSString *)messageId;
17+
18+
+ (LPActionContext *)actionContextWithName:(NSString *)name
19+
args:(NSDictionary *)args
20+
messageId:(NSString *)messageId
21+
originalMessageId:(NSString *)originalMessageId
22+
priority:(NSNumber *)priority;
23+
24+
@property (readonly, strong) NSString *private_Name;
25+
@property (readonly, strong) NSString *private_MessageId;
26+
@property (readonly, strong) NSString *private_OriginalMessageId;
27+
@property (readonly, strong) NSNumber *private_Priority;
28+
@property (readonly, strong) NSDictionary *private_Args;
29+
@property (readonly, strong) LPActionContext *private_ParentContext;
30+
@property (readonly) int private_ContentVersion;
31+
@property (readonly, strong) NSString *private_Key;
32+
@property (readonly) BOOL private_PreventRealtimeUpdating;
33+
@property (readonly) BOOL private_IsRooted;
34+
@property (readonly) BOOL private_IsPreview;
35+
@property (nonatomic, strong) LPContextualValues *contextualValues;
36+
37+
- (NSString *)messageId;
38+
- (NSString *)originalMessageId;
39+
- (NSNumber *)priority;
40+
- (void)maybeDownloadFiles;
41+
- (id)objectNamed:(NSString *)name;
42+
- (void)preventRealtimeUpdating;
43+
- (void)setIsRooted:(BOOL)value;
44+
- (void)setIsPreview:(BOOL)preview;
45+
- (NSDictionary *)args;
46+
+ (void)sortByPriority:(NSMutableArray *)actionContexts;
47+
48+
@end

0 commit comments

Comments
 (0)