Showing
6 changed files
with
75 additions
and
1 deletions
... | @@ -282,6 +282,14 @@ WL_VERSION_INTERFACE() | ... | @@ -282,6 +282,14 @@ WL_VERSION_INTERFACE() |
282 | @discussion This method gets the inbox with campaigns from Warply service. The | 282 | @discussion This method gets the inbox with campaigns from Warply service. The |
283 | method returns an array with WLInboxItem objects (campaigns). The caller will probably want to use the return parameter and a timer to update the UI or do any other operation after a certain amount of time that the app remains unregistered and thus, cannot make the call. | 283 | method returns an array with WLInboxItem objects (campaigns). The caller will probably want to use the return parameter and a timer to update the UI or do any other operation after a certain amount of time that the app remains unregistered and thus, cannot make the call. |
284 | */ | 284 | */ |
285 | +- (NSString*)getAccessToken; | ||
286 | + | ||
287 | +- (NSString*)getRefreshToken; | ||
288 | + | ||
289 | +- (NSString*)getClientId; | ||
290 | + | ||
291 | +- (NSString*)getClientSecret; | ||
292 | + | ||
285 | - (BOOL)getInboxWithSuccessBlock:(void (^)(NSArray *list))success failureBlock:(void (^)(NSError *error))failure; | 293 | - (BOOL)getInboxWithSuccessBlock:(void (^)(NSArray *list))success failureBlock:(void (^)(NSError *error))failure; |
286 | 294 | ||
287 | - (BOOL)getInbox2WithSuccessBlock:(void (^)(NSArray *list))success failureBlock:(void (^)(NSError *error))failure; | 295 | - (BOOL)getInbox2WithSuccessBlock:(void (^)(NSArray *list))success failureBlock:(void (^)(NSError *error))failure; | ... | ... |
... | @@ -453,6 +453,54 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -453,6 +453,54 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
453 | return [self isRegistrationValid]; | 453 | return [self isRegistrationValid]; |
454 | } | 454 | } |
455 | 455 | ||
456 | +- (NSString*)getAccessToken { | ||
457 | + NSString *accessToken = [NSString alloc]; | ||
458 | + if ([_db tableExists:@"requestVariables"] == YES) { | ||
459 | + FMResultSet *accessTokenSet = [_db executeQuery:@"SELECT access_token FROM requestVariables WHERE id = 1;"]; | ||
460 | + while ([accessTokenSet next]) { | ||
461 | + accessToken = [[accessTokenSet resultDictionary][@"access_token"] stringValue]; | ||
462 | + } | ||
463 | + return accessToken; | ||
464 | + } | ||
465 | + return @""; | ||
466 | +}; | ||
467 | + | ||
468 | +- (NSString*)getRefreshToken { | ||
469 | + NSString *refreshToken = [NSString alloc]; | ||
470 | + if ([_db tableExists:@"requestVariables"] == YES) { | ||
471 | + FMResultSet *refreshTokenSet = [_db executeQuery:@"SELECT refresh_token FROM requestVariables WHERE id = 1;"]; | ||
472 | + while ([refreshTokenSet next]) { | ||
473 | + refreshToken = [[refreshTokenSet resultDictionary][@"refresh_token"] stringValue]; | ||
474 | + } | ||
475 | + return refreshToken; | ||
476 | + } | ||
477 | + return @""; | ||
478 | +} | ||
479 | + | ||
480 | +- (NSString*)getClientId { | ||
481 | + NSString *clientId = [NSString alloc]; | ||
482 | + if ([_db tableExists:@"requestVariables"] == YES) { | ||
483 | + FMResultSet *clientIdSet = [_db executeQuery:@"SELECT access_token FROM requestVariables WHERE id = 1;"]; | ||
484 | + while ([clientIdSet next]) { | ||
485 | + clientId = [[clientIdSet resultDictionary][@"client_id"] stringValue]; | ||
486 | + } | ||
487 | + return clientId; | ||
488 | + } | ||
489 | + return @""; | ||
490 | +} | ||
491 | + | ||
492 | +- (NSString*)getClientSecret { | ||
493 | + NSString *clientSecret = [NSString alloc]; | ||
494 | + if ([_db tableExists:@"requestVariables"] == YES) { | ||
495 | + FMResultSet *clientSecretSet = [_db executeQuery:@"SELECT client_secret FROM requestVariables WHERE id = 1;"]; | ||
496 | + while ([clientSecretSet next]) { | ||
497 | + clientSecret = [[clientSecretSet resultDictionary][@"client_secret"] stringValue]; | ||
498 | + } | ||
499 | + return clientSecret; | ||
500 | + } | ||
501 | + return @""; | ||
502 | +} | ||
503 | + | ||
456 | - (void)getProductsWithSuccessBlock:(NSString*)filter :(void(^)(NSMutableArray *params)) success failureBlock:(void(^)(NSError *error))failure | 504 | - (void)getProductsWithSuccessBlock:(NSString*)filter :(void(^)(NSMutableArray *params)) success failureBlock:(void(^)(NSError *error))failure |
457 | { | 505 | { |
458 | if (filter == nil) { | 506 | if (filter == nil) { | ... | ... |
No preview for this file type
... | @@ -8,10 +8,12 @@ | ... | @@ -8,10 +8,12 @@ |
8 | #ifndef MyApi_h | 8 | #ifndef MyApi_h |
9 | #define MyApi_h | 9 | #define MyApi_h |
10 | #import <UIKit/UIKit.h> | 10 | #import <UIKit/UIKit.h> |
11 | -@class Coupons; | 11 | +@class Warply; |
12 | 12 | ||
13 | @interface MyApi : NSObject | 13 | @interface MyApi : NSObject |
14 | 14 | ||
15 | +@property (nonatomic, weak) Warply *warply; | ||
16 | + | ||
15 | + (void)init:(NSDictionary *)launchOptions uuid:(NSString*)uuid merchantId:(NSString*)merchantId lang:(NSString*)lang; | 17 | + (void)init:(NSDictionary *)launchOptions uuid:(NSString*)uuid merchantId:(NSString*)merchantId lang:(NSString*)lang; |
16 | - (void) setToStage; | 18 | - (void) setToStage; |
17 | - (void) setLang:(NSString*) lang; | 19 | - (void) setLang:(NSString*) lang; |
... | @@ -21,6 +23,7 @@ | ... | @@ -21,6 +23,7 @@ |
21 | - (UIViewController *) openWallet:(UIView*) parentView; | 23 | - (UIViewController *) openWallet:(UIView*) parentView; |
22 | - (UIViewController *) openMoreForYou:(UIView*) parentView; | 24 | - (UIViewController *) openMoreForYou:(UIView*) parentView; |
23 | - (UIViewController *) openCampaign:(UIView*) parentView campaign:(NSString*) campaign; | 25 | - (UIViewController *) openCampaign:(UIView*) parentView campaign:(NSString*) campaign; |
26 | +- (NSDictionary *) provideInfoForCampaign; | ||
24 | - (void) applicationDidEnterBackground:(UIApplication *)application; | 27 | - (void) applicationDidEnterBackground:(UIApplication *)application; |
25 | - (void) applicationWillEnterForeground:(UIApplication *)application; | 28 | - (void) applicationWillEnterForeground:(UIApplication *)application; |
26 | - (void) applicationDidBecomeActive:(UIApplication *)application; | 29 | - (void) applicationDidBecomeActive:(UIApplication *)application; | ... | ... |
... | @@ -8,6 +8,7 @@ | ... | @@ -8,6 +8,7 @@ |
8 | #import <Foundation/Foundation.h> | 8 | #import <Foundation/Foundation.h> |
9 | #import "MyApi.h" | 9 | #import "MyApi.h" |
10 | #import "Warply.h" | 10 | #import "Warply.h" |
11 | +#import "WLUtils.h" | ||
11 | 12 | ||
12 | #import <WarplySDKFrameworkIOS/WarplySDKFrameworkIOS-Swift.h> | 13 | #import <WarplySDKFrameworkIOS/WarplySDKFrameworkIOS-Swift.h> |
13 | 14 | ||
... | @@ -80,6 +81,19 @@ NSString *LANG; | ... | @@ -80,6 +81,19 @@ NSString *LANG; |
80 | return campaignViewController; | 81 | return campaignViewController; |
81 | } | 82 | } |
82 | 83 | ||
84 | +- (NSDictionary *) provideInfoForCampaign { | ||
85 | + NSMutableDictionary* info = [[NSMutableDictionary alloc] init]; | ||
86 | + info[@"web_id"] = [Warply sharedService].webId; | ||
87 | + info[@"app_uuid"] = [WLKeychain getStringForKey:@"NBAPPUuid"]; | ||
88 | + info[@"api_key"] = self.warply.apiKey; | ||
89 | + Warply* warplyInstance = [[Warply alloc] init]; | ||
90 | + info[@"access_token"] = [warplyInstance getAccessToken]; | ||
91 | + info[@"refresh_token"] = [warplyInstance getRefreshToken]; | ||
92 | + info[@"client_id"] = [warplyInstance getClientId]; | ||
93 | + info[@"client_secret"] = [warplyInstance getClientSecret]; | ||
94 | + return info; | ||
95 | +} | ||
96 | + | ||
83 | /////////////////////////////////////////////////////////////////////////////////////////////////// | 97 | /////////////////////////////////////////////////////////////////////////////////////////////////// |
84 | - (void)applicationDidEnterBackground:(UIApplication *)application | 98 | - (void)applicationDidEnterBackground:(UIApplication *)application |
85 | { | 99 | { | ... | ... |
-
Please register or login to post a comment