File tree Expand file tree Collapse file tree 4 files changed +71
-1
lines changed
Leanplum-SDK/Classes/Managers/Networking Expand file tree Collapse file tree 4 files changed +71
-1
lines changed Original file line number Diff line number Diff line change 1+ #import < Foundation/Foundation.h>
2+ #import " LPRequesting.h"
3+ #import " LPFeatureFlagManager.h"
4+
5+ @interface LPRequestFactory : NSObject
6+
7+ -(instancetype )initWithFeatureFlagManager : (LPFeatureFlagManager *)featureFlagManager ;
8+
9+ - (id <LPRequesting>)createGetForApiMethod : (NSString *)apiMethod params : (NSDictionary *)params ;
10+ - (id <LPRequesting>)createPostForApiMethod : (NSString *)apiMethod params : (NSDictionary *)params ;
11+
12+ @end
Original file line number Diff line number Diff line change 1+
2+ #import " LPRequestFactory.h"
3+ #import " LeanplumRequest.h"
4+
5+ @interface LPRequestFactory ()
6+
7+ @property (nonatomic , strong ) LPFeatureFlagManager *featureFlagManager;
8+
9+ @end
10+
11+ @implementation LPRequestFactory
12+
13+ -(instancetype )initWithFeatureFlagManager : (LPFeatureFlagManager *)featureFlagManager
14+ {
15+ self = [super init ];
16+ if (self) {
17+ _featureFlagManager = featureFlagManager;
18+ }
19+ return self;
20+ }
21+
22+ - (id <LPRequesting>)createGetForApiMethod : (NSString *)apiMethod params : (NSDictionary *)params {
23+ return [[LeanplumRequest alloc ] initWithHttpMethod: @" GET" apiMethod: apiMethod params: params];
24+ }
25+
26+ - (id <LPRequesting>)createPostForApiMethod : (NSString *)apiMethod params : (NSDictionary *)params {
27+ return [[LeanplumRequest alloc ] initWithHttpMethod: @" POST" apiMethod: apiMethod params: params];
28+ }
29+
30+ @end
Original file line number Diff line number Diff line change 1+ //
2+ // LPRequesting.h
3+ // Pods
4+ //
5+ // Created by Mayank Sanganeria on 8/23/18.
6+ //
7+
8+ #ifndef LPRequesting_h
9+ #define LPRequesting_h
10+
11+ #import " LPNetworkProtocol.h"
12+ #import " LeanplumInternal.h"
13+
14+ @protocol LPRequesting
15+
16+ @property (nonatomic , strong ) NSString *apiMethod;
17+ @property (nonatomic , strong ) NSDictionary *params;
18+ @property (atomic ) BOOL sent;
19+ @property (nonatomic , copy ) LPNetworkResponseBlock responseBlock;
20+ @property (nonatomic , copy ) LPNetworkErrorBlock errorBlock;
21+
22+ - (void )onResponse : (LPNetworkResponseBlock)response ;
23+ - (void )onError : (LPNetworkErrorBlock)error ;
24+
25+ @end
26+
27+ #endif /* LPRequesting_h */
Original file line number Diff line number Diff line change 2525#import < Foundation/Foundation.h>
2626#import " Leanplum.h"
2727#import " LPNetworkFactory.h"
28+ #import " LPRequesting.h"
2829
29- @interface LeanplumRequest : NSObject {
30+ @interface LeanplumRequest : NSObject <LPRequesting> {
3031@private
3132 NSString *_httpMethod;
3233 NSString *_apiMethod;
You can’t perform that action at this time.
0 commit comments