Manos Chorianopoulos

added updateRefreshToken

......@@ -348,6 +348,25 @@ var timer2: DispatchSourceTimer?
firebaseEvent.setParameter = ("name", name)
firebaseEvent.setParameter = ("seconds", seconds)
SwiftEventBus.post("firebase", sender: firebaseEvent)
} else if (eventArray[1] == "refreshToken") {
var access_token: String = ""
if (eventArray.count > 2) {
access_token = String(eventArray[2])
} else {
access_token = ""
}
var refresh_token: String = ""
if (eventArray.count > 3) {
refresh_token = String(eventArray[3])
} else {
refresh_token = ""
}
if (access_token != "" && refresh_token != "") {
swiftApi().updateRefreshToken(access_token: access_token, refresh_token: refresh_token)
}
}
}
......
......@@ -108,6 +108,7 @@
- (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;
- (void)getSingleCampaignAsync:(NSString*)sessionUuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void) sendEvent: (NSString *) eventName priority: (BOOL) priority;
- (void)updateRefreshTokenMA:(NSString*)access_token :(NSString*)refresh_token;
@end
#endif /* MyApi_h */
......
......@@ -1673,4 +1673,9 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify";
[[Warply sharedService] addEvent:simpleEvent priority:priority];
}
- (void)updateRefreshTokenMA:(NSString*)access_token :(NSString*)refresh_token
{
[[Warply sharedService] updateRefreshTokenW:access_token :refresh_token
}
@end
......
......@@ -327,6 +327,8 @@ WL_VERSION_INTERFACE()
- (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;
- (void)updateRefreshTokenW:(NSString*)access_token :(NSString*)refresh_token;
- (void)refreshToken:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)refreshToken2ndTry:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
......
......@@ -903,6 +903,13 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
}];
}
- (void)updateRefreshTokenW:(NSString*)access_token :(NSString*)refresh_token
{
if ([_db tableExists:@"requestVariables"] == YES) {
[_db executeUpdate:@"UPDATE requestVariables SET access_token = ?, refresh_token = ? WHERE id = 1", access_token, refresh_token];
}
}
- (void)refreshToken:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
{
FMResultSet *refreshTokenSet = [_db executeQuery:@"SELECT refresh_token FROM requestVariables WHERE id = 1;"];
......
......@@ -5960,4 +5960,10 @@ public class swiftApi {
}
public func updateRefreshToken(access_token: String, refresh_token: String) -> Void {
let instanceOfMyApi = MyApi()
instanceOfMyApi.updateRefreshTokenMA(access_token, refresh_token)
}
}
......