Vasilis

added method for tokens info

......@@ -282,6 +282,14 @@ WL_VERSION_INTERFACE()
@discussion This method gets the inbox with campaigns from Warply service. The
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.
*/
- (NSString*)getAccessToken;
- (NSString*)getRefreshToken;
- (NSString*)getClientId;
- (NSString*)getClientSecret;
- (BOOL)getInboxWithSuccessBlock:(void (^)(NSArray *list))success failureBlock:(void (^)(NSError *error))failure;
- (BOOL)getInbox2WithSuccessBlock:(void (^)(NSArray *list))success failureBlock:(void (^)(NSError *error))failure;
......
......@@ -453,6 +453,54 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
return [self isRegistrationValid];
}
- (NSString*)getAccessToken {
NSString *accessToken = [NSString alloc];
if ([_db tableExists:@"requestVariables"] == YES) {
FMResultSet *accessTokenSet = [_db executeQuery:@"SELECT access_token FROM requestVariables WHERE id = 1;"];
while ([accessTokenSet next]) {
accessToken = [[accessTokenSet resultDictionary][@"access_token"] stringValue];
}
return accessToken;
}
return @"";
};
- (NSString*)getRefreshToken {
NSString *refreshToken = [NSString alloc];
if ([_db tableExists:@"requestVariables"] == YES) {
FMResultSet *refreshTokenSet = [_db executeQuery:@"SELECT refresh_token FROM requestVariables WHERE id = 1;"];
while ([refreshTokenSet next]) {
refreshToken = [[refreshTokenSet resultDictionary][@"refresh_token"] stringValue];
}
return refreshToken;
}
return @"";
}
- (NSString*)getClientId {
NSString *clientId = [NSString alloc];
if ([_db tableExists:@"requestVariables"] == YES) {
FMResultSet *clientIdSet = [_db executeQuery:@"SELECT access_token FROM requestVariables WHERE id = 1;"];
while ([clientIdSet next]) {
clientId = [[clientIdSet resultDictionary][@"client_id"] stringValue];
}
return clientId;
}
return @"";
}
- (NSString*)getClientSecret {
NSString *clientSecret = [NSString alloc];
if ([_db tableExists:@"requestVariables"] == YES) {
FMResultSet *clientSecretSet = [_db executeQuery:@"SELECT client_secret FROM requestVariables WHERE id = 1;"];
while ([clientSecretSet next]) {
clientSecret = [[clientSecretSet resultDictionary][@"client_secret"] stringValue];
}
return clientSecret;
}
return @"";
}
- (void)getProductsWithSuccessBlock:(NSString*)filter :(void(^)(NSMutableArray *params)) success failureBlock:(void(^)(NSError *error))failure
{
if (filter == nil) {
......
......@@ -11,6 +11,7 @@ import SwiftUI
import Combine
import Foundation
import UIKit
import WebKit
extension CampaignWebview {
......
......@@ -8,10 +8,12 @@
#ifndef MyApi_h
#define MyApi_h
#import <UIKit/UIKit.h>
@class Coupons;
@class Warply;
@interface MyApi : NSObject
@property (nonatomic, weak) Warply *warply;
+ (void)init:(NSDictionary *)launchOptions uuid:(NSString*)uuid merchantId:(NSString*)merchantId lang:(NSString*)lang;
- (void) setToStage;
- (void) setLang:(NSString*) lang;
......@@ -21,6 +23,7 @@
- (UIViewController *) openWallet:(UIView*) parentView;
- (UIViewController *) openMoreForYou:(UIView*) parentView;
- (UIViewController *) openCampaign:(UIView*) parentView campaign:(NSString*) campaign;
- (NSDictionary *) provideInfoForCampaign;
- (void) applicationDidEnterBackground:(UIApplication *)application;
- (void) applicationWillEnterForeground:(UIApplication *)application;
- (void) applicationDidBecomeActive:(UIApplication *)application;
......
......@@ -8,6 +8,7 @@
#import <Foundation/Foundation.h>
#import "MyApi.h"
#import "Warply.h"
#import "WLUtils.h"
#import <WarplySDKFrameworkIOS/WarplySDKFrameworkIOS-Swift.h>
......@@ -80,6 +81,19 @@ NSString *LANG;
return campaignViewController;
}
- (NSDictionary *) provideInfoForCampaign {
NSMutableDictionary* info = [[NSMutableDictionary alloc] init];
info[@"web_id"] = [Warply sharedService].webId;
info[@"app_uuid"] = [WLKeychain getStringForKey:@"NBAPPUuid"];
info[@"api_key"] = self.warply.apiKey;
Warply* warplyInstance = [[Warply alloc] init];
info[@"access_token"] = [warplyInstance getAccessToken];
info[@"refresh_token"] = [warplyInstance getRefreshToken];
info[@"client_id"] = [warplyInstance getClientId];
info[@"client_secret"] = [warplyInstance getClientSecret];
return info;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
- (void)applicationDidEnterBackground:(UIApplication *)application
{
......