Manos Chorianopoulos

added updateRefreshToken

...@@ -348,6 +348,25 @@ var timer2: DispatchSourceTimer? ...@@ -348,6 +348,25 @@ var timer2: DispatchSourceTimer?
348 firebaseEvent.setParameter = ("name", name) 348 firebaseEvent.setParameter = ("name", name)
349 firebaseEvent.setParameter = ("seconds", seconds) 349 firebaseEvent.setParameter = ("seconds", seconds)
350 SwiftEventBus.post("firebase", sender: firebaseEvent) 350 SwiftEventBus.post("firebase", sender: firebaseEvent)
351 +
352 + } else if (eventArray[1] == "refreshToken") {
353 + var access_token: String = ""
354 + if (eventArray.count > 2) {
355 + access_token = String(eventArray[2])
356 + } else {
357 + access_token = ""
358 + }
359 +
360 + var refresh_token: String = ""
361 + if (eventArray.count > 3) {
362 + refresh_token = String(eventArray[3])
363 + } else {
364 + refresh_token = ""
365 + }
366 +
367 + if (access_token != "" && refresh_token != "") {
368 + swiftApi().updateRefreshToken(access_token: access_token, refresh_token: refresh_token)
369 + }
351 } 370 }
352 371
353 } 372 }
......
...@@ -108,6 +108,7 @@ ...@@ -108,6 +108,7 @@
108 - (void)editProfileAsync:(NSString*)firstname andLastname:(NSString*)lastname andEmail:(NSString *)email andSalutation:(NSString *)salutation andMsisdn:(NSString *)msisdn andNickname:(NSString *)nickname andGender:(NSString *)gender andBirthday:(NSString *)birthday andNameDay:(NSString *)nameday andTaxID:(NSString *)taxid andProfileMetadata:(NSDictionary *)profileMetadata optin:(NSNumber *)optin newsLetter:(NSNumber *)newsletter andSMS:(NSNumber *)sms andSegmentation:(NSNumber *)segmentation andSMSSegmentation:(NSNumber *)smsSegmentation :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; 108 - (void)editProfileAsync:(NSString*)firstname andLastname:(NSString*)lastname andEmail:(NSString *)email andSalutation:(NSString *)salutation andMsisdn:(NSString *)msisdn andNickname:(NSString *)nickname andGender:(NSString *)gender andBirthday:(NSString *)birthday andNameDay:(NSString *)nameday andTaxID:(NSString *)taxid andProfileMetadata:(NSDictionary *)profileMetadata optin:(NSNumber *)optin newsLetter:(NSNumber *)newsletter andSMS:(NSNumber *)sms andSegmentation:(NSNumber *)segmentation andSMSSegmentation:(NSNumber *)smsSegmentation :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
109 - (void)getSingleCampaignAsync:(NSString*)sessionUuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; 109 - (void)getSingleCampaignAsync:(NSString*)sessionUuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
110 - (void) sendEvent: (NSString *) eventName priority: (BOOL) priority; 110 - (void) sendEvent: (NSString *) eventName priority: (BOOL) priority;
111 +- (void)updateRefreshTokenMA:(NSString*)access_token :(NSString*)refresh_token;
111 112
112 @end 113 @end
113 #endif /* MyApi_h */ 114 #endif /* MyApi_h */
......
...@@ -1673,4 +1673,9 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify"; ...@@ -1673,4 +1673,9 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify";
1673 [[Warply sharedService] addEvent:simpleEvent priority:priority]; 1673 [[Warply sharedService] addEvent:simpleEvent priority:priority];
1674 } 1674 }
1675 1675
1676 +- (void)updateRefreshTokenMA:(NSString*)access_token :(NSString*)refresh_token
1677 +{
1678 + [[Warply sharedService] updateRefreshTokenW:access_token :refresh_token
1679 +}
1680 +
1676 @end 1681 @end
......
...@@ -327,6 +327,8 @@ WL_VERSION_INTERFACE() ...@@ -327,6 +327,8 @@ WL_VERSION_INTERFACE()
327 327
328 - (void)registerWithSuccessBlock:(NSString*)id andPassword:(NSString*)password andName:(NSString*)name andEmail:(NSString*)email andSegmentation:(NSNumber*)segmentation andNewsletter:(NSNumber*)newsletter :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; 328 - (void)registerWithSuccessBlock:(NSString*)id andPassword:(NSString*)password andName:(NSString*)name andEmail:(NSString*)email andSegmentation:(NSNumber*)segmentation andNewsletter:(NSNumber*)newsletter :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
329 329
330 +- (void)updateRefreshTokenW:(NSString*)access_token :(NSString*)refresh_token;
331 +
330 - (void)refreshToken:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; 332 - (void)refreshToken:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
331 333
332 - (void)refreshToken2ndTry:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; 334 - (void)refreshToken2ndTry:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
......
...@@ -903,6 +903,13 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) ...@@ -903,6 +903,13 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
903 }]; 903 }];
904 } 904 }
905 905
906 +- (void)updateRefreshTokenW:(NSString*)access_token :(NSString*)refresh_token
907 +{
908 + if ([_db tableExists:@"requestVariables"] == YES) {
909 + [_db executeUpdate:@"UPDATE requestVariables SET access_token = ?, refresh_token = ? WHERE id = 1", access_token, refresh_token];
910 + }
911 +}
912 +
906 - (void)refreshToken:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure 913 - (void)refreshToken:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
907 { 914 {
908 FMResultSet *refreshTokenSet = [_db executeQuery:@"SELECT refresh_token FROM requestVariables WHERE id = 1;"]; 915 FMResultSet *refreshTokenSet = [_db executeQuery:@"SELECT refresh_token FROM requestVariables WHERE id = 1;"];
......
...@@ -5960,4 +5960,10 @@ public class swiftApi { ...@@ -5960,4 +5960,10 @@ public class swiftApi {
5960 } 5960 }
5961 5961
5962 5962
5963 + public func updateRefreshToken(access_token: String, refresh_token: String) -> Void {
5964 + let instanceOfMyApi = MyApi()
5965 + instanceOfMyApi.updateRefreshTokenMA(access_token, refresh_token)
5966 + }
5967 +
5968 +
5963 } 5969 }
......