Manos Chorianopoulos

add getPacingDetailsAsync request

......@@ -83,6 +83,7 @@
- (void)getProfileAsync:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)consumerIntegrationAsync:(NSNumber*)nonTelco :(NSNumber*)acceptedConsent :(NSArray*)msisdnList :(NSString*)guid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)redeemCouponSetAsync:(NSString*)uuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)getPacingDetailsAsync:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
@end
#endif /* MyApi_h */
......
......@@ -1381,4 +1381,15 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify";
}];
}
- (void)getPacingDetailsAsync:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
{
[[Warply sharedService] getPacingDetailsWithSuccessBlock:^(NSDictionary *response) {
if (success) {
success(response);
}
} failureBlock:^(NSError *error) {
failure(error);
}];
}
@end
......
......@@ -327,6 +327,8 @@ WL_VERSION_INTERFACE()
- (void)getProfileWithSuccessBlock :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)getPacingDetailsWithSuccessBlock :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)editProfileWithSuccessBlock:(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;
......
......@@ -1062,6 +1062,47 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
}];
}
- (void)getPacingDetailsWithSuccessBlock:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
{
NSDictionary *postDictionary = @{@"consumer_data":@{@"action": @"integration", @"method": @"steps", @"operation": @"get"}};
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:postDictionary options:0 error:NULL];
[self sendContext8:jsonData successBlock:^(NSDictionary *contextResponse) {
if (success) {
success(contextResponse);
}
NSLog(@"**************** WARPLY Response *****************" );
NSLog(@"%@", contextResponse );
} failureBlock:^(NSError *error) {
if (failure) {
NSDictionary* dict = [NSDictionary alloc];
dict = [error userInfo];
NSString* errorCode = [dict objectForKey:@"NSLocalizedDescription"];
if ([errorCode isEqual:@"Request failed: unauthorized (401)"]) {
[self refreshToken:^(NSDictionary *response) {
[self sendContext8:jsonData successBlock:^(NSDictionary *contextResponse) {
if (success) {
success(contextResponse);
}
NSLog(@"**************** WARPLY Response *****************" );
NSLog(@"%@", contextResponse );
} failureBlock:^(NSError *error) {
if (failure) {
failure(error);
}
}];
} failureBlock:^(NSError *error) {
if (failure) {
[_db executeUpdate:@"DROP TABLE requestVariables"];
failure(error);
}
NSLog(@"Error at token %@", error );
}];
}
NSLog(@"Error at get pacing details %@", error );
}
}];
}
- (void)consumerIntegrationWithSuccessBlock:(NSNumber*)nonTelco :(NSNumber*)acceptedConsent :(NSArray*)msisdnList :(NSString*)guid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
{
NSMutableDictionary* data = [[NSMutableDictionary alloc] init];
......
......@@ -2377,4 +2377,33 @@ public class swiftApi {
}
public func getPacingDetailsAsync(_ getPacingDetailsCallback: @escaping (_ pacingData: PacingDetails?) -> Void) -> Void {
let instanceOfMyApi = MyApi()
instanceOfMyApi.getPacingDetailsAsync(pacingCallback, failureBlock: pacingFailureCallback)
func pacingCallback(_ pacingData: [AnyHashable: Any]?) -> Void {
if let pacingDataDictionary = pacingData as? [String : AnyObject] {
if (pacingDataDictionary["status"] as? Int == 1) {
let pacingDataResult = (pacingDataDictionary["result"] as? [String: Any] ?? [String: Any]())
let tempPacingDetails = PacingDetails(dictionary: pacingDataResult)
getPacingDetailsCallback(tempPacingDetails);
}
} else {
getPacingDetailsCallback(nil)
}
}
func pacingFailureCallback(_ error: Error?) -> Void {
print("getPacingDetails error: ")
getPacingDetailsCallback(nil)
}
}
}
......