Manos Chorianopoulos

add getPacingDetailsAsync request

...@@ -83,6 +83,7 @@ ...@@ -83,6 +83,7 @@
83 - (void)getProfileAsync:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; 83 - (void)getProfileAsync:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
84 - (void)consumerIntegrationAsync:(NSNumber*)nonTelco :(NSNumber*)acceptedConsent :(NSArray*)msisdnList :(NSString*)guid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; 84 - (void)consumerIntegrationAsync:(NSNumber*)nonTelco :(NSNumber*)acceptedConsent :(NSArray*)msisdnList :(NSString*)guid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
85 - (void)redeemCouponSetAsync:(NSString*)uuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; 85 - (void)redeemCouponSetAsync:(NSString*)uuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
86 +- (void)getPacingDetailsAsync:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
86 87
87 @end 88 @end
88 #endif /* MyApi_h */ 89 #endif /* MyApi_h */
......
...@@ -1381,4 +1381,15 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify"; ...@@ -1381,4 +1381,15 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify";
1381 }]; 1381 }];
1382 } 1382 }
1383 1383
1384 +- (void)getPacingDetailsAsync:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
1385 +{
1386 + [[Warply sharedService] getPacingDetailsWithSuccessBlock:^(NSDictionary *response) {
1387 + if (success) {
1388 + success(response);
1389 + }
1390 + } failureBlock:^(NSError *error) {
1391 + failure(error);
1392 + }];
1393 +}
1394 +
1384 @end 1395 @end
......
...@@ -327,6 +327,8 @@ WL_VERSION_INTERFACE() ...@@ -327,6 +327,8 @@ WL_VERSION_INTERFACE()
327 327
328 - (void)getProfileWithSuccessBlock :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; 328 - (void)getProfileWithSuccessBlock :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
329 329
330 +- (void)getPacingDetailsWithSuccessBlock :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
331 +
330 - (void)editProfileWithSuccessBlock:(NSString*)firstName andLastName:(NSString*)lastName andEmail:(NSString*)email andSalutation:(NSString*)salutation andMsisdn:(NSString*)msisdn 332 - (void)editProfileWithSuccessBlock:(NSString*)firstName andLastName:(NSString*)lastName andEmail:(NSString*)email andSalutation:(NSString*)salutation andMsisdn:(NSString*)msisdn
331 andNickname:(NSString*)nickname andGender:(NSString*)gender andBirthday:(NSString*)birthday andNameDay:(NSString*)nameday andTaxID:(NSString*)taxID andProfileMetadata:(NSDictionary*)profileMetadata optin:(NSNumber*) optin newsLetter:(NSNumber*)newsletter 333 andNickname:(NSString*)nickname andGender:(NSString*)gender andBirthday:(NSString*)birthday andNameDay:(NSString*)nameday andTaxID:(NSString*)taxID andProfileMetadata:(NSDictionary*)profileMetadata optin:(NSNumber*) optin newsLetter:(NSNumber*)newsletter
332 andSMS:(NSNumber*)sms andSegmentation:(NSNumber*)segmentation andSMSSegmentation:(NSNumber*)smsSegmentation :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; 334 andSMS:(NSNumber*)sms andSegmentation:(NSNumber*)segmentation andSMSSegmentation:(NSNumber*)smsSegmentation :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
......
...@@ -1062,6 +1062,47 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) ...@@ -1062,6 +1062,47 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
1062 }]; 1062 }];
1063 } 1063 }
1064 1064
1065 +- (void)getPacingDetailsWithSuccessBlock:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
1066 +{
1067 + NSDictionary *postDictionary = @{@"consumer_data":@{@"action": @"integration", @"method": @"steps", @"operation": @"get"}};
1068 + NSData *jsonData = [NSJSONSerialization dataWithJSONObject:postDictionary options:0 error:NULL];
1069 + [self sendContext8:jsonData successBlock:^(NSDictionary *contextResponse) {
1070 + if (success) {
1071 + success(contextResponse);
1072 + }
1073 + NSLog(@"**************** WARPLY Response *****************" );
1074 + NSLog(@"%@", contextResponse );
1075 + } failureBlock:^(NSError *error) {
1076 + if (failure) {
1077 + NSDictionary* dict = [NSDictionary alloc];
1078 + dict = [error userInfo];
1079 + NSString* errorCode = [dict objectForKey:@"NSLocalizedDescription"];
1080 + if ([errorCode isEqual:@"Request failed: unauthorized (401)"]) {
1081 + [self refreshToken:^(NSDictionary *response) {
1082 + [self sendContext8:jsonData successBlock:^(NSDictionary *contextResponse) {
1083 + if (success) {
1084 + success(contextResponse);
1085 + }
1086 + NSLog(@"**************** WARPLY Response *****************" );
1087 + NSLog(@"%@", contextResponse );
1088 + } failureBlock:^(NSError *error) {
1089 + if (failure) {
1090 + failure(error);
1091 + }
1092 + }];
1093 + } failureBlock:^(NSError *error) {
1094 + if (failure) {
1095 + [_db executeUpdate:@"DROP TABLE requestVariables"];
1096 + failure(error);
1097 + }
1098 + NSLog(@"Error at token %@", error );
1099 + }];
1100 + }
1101 + NSLog(@"Error at get pacing details %@", error );
1102 + }
1103 + }];
1104 +}
1105 +
1065 - (void)consumerIntegrationWithSuccessBlock:(NSNumber*)nonTelco :(NSNumber*)acceptedConsent :(NSArray*)msisdnList :(NSString*)guid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure 1106 - (void)consumerIntegrationWithSuccessBlock:(NSNumber*)nonTelco :(NSNumber*)acceptedConsent :(NSArray*)msisdnList :(NSString*)guid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
1066 { 1107 {
1067 NSMutableDictionary* data = [[NSMutableDictionary alloc] init]; 1108 NSMutableDictionary* data = [[NSMutableDictionary alloc] init];
......
...@@ -2377,4 +2377,33 @@ public class swiftApi { ...@@ -2377,4 +2377,33 @@ public class swiftApi {
2377 } 2377 }
2378 2378
2379 2379
2380 + public func getPacingDetailsAsync(_ getPacingDetailsCallback: @escaping (_ pacingData: PacingDetails?) -> Void) -> Void {
2381 +
2382 + let instanceOfMyApi = MyApi()
2383 + instanceOfMyApi.getPacingDetailsAsync(pacingCallback, failureBlock: pacingFailureCallback)
2384 +
2385 + func pacingCallback(_ pacingData: [AnyHashable: Any]?) -> Void {
2386 +
2387 + if let pacingDataDictionary = pacingData as? [String : AnyObject] {
2388 +
2389 + if (pacingDataDictionary["status"] as? Int == 1) {
2390 + let pacingDataResult = (pacingDataDictionary["result"] as? [String: Any] ?? [String: Any]())
2391 +
2392 + let tempPacingDetails = PacingDetails(dictionary: pacingDataResult)
2393 +
2394 + getPacingDetailsCallback(tempPacingDetails);
2395 + }
2396 +
2397 + } else {
2398 + getPacingDetailsCallback(nil)
2399 + }
2400 +
2401 + }
2402 +
2403 + func pacingFailureCallback(_ error: Error?) -> Void {
2404 + print("getPacingDetails error: ")
2405 + getPacingDetailsCallback(nil)
2406 + }
2407 + }
2408 +
2380 } 2409 }
......