Showing
5 changed files
with
94 additions
and
0 deletions
| ... | @@ -85,6 +85,7 @@ | ... | @@ -85,6 +85,7 @@ |
| 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 | - (void)getPacingDetailsAsync:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; |
| 87 | - (void)cosmoteSharingAsync:(NSString*)sharingId :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | 87 | - (void)cosmoteSharingAsync:(NSString*)sharingId :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; |
| 88 | +- (void)cosmoteRetrieveSharingAsync:(NSString*)sharingId :(NSNumber*)accept :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | ||
| 88 | 89 | ||
| 89 | @end | 90 | @end |
| 90 | #endif /* MyApi_h */ | 91 | #endif /* MyApi_h */ | ... | ... |
| ... | @@ -1405,4 +1405,17 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify"; | ... | @@ -1405,4 +1405,17 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify"; |
| 1405 | }]; | 1405 | }]; |
| 1406 | } | 1406 | } |
| 1407 | 1407 | ||
| 1408 | +- (void)cosmoteRetrieveSharingAsync:(NSString*)sharingId :(NSNumber*)accept :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure | ||
| 1409 | +{ | ||
| 1410 | + [[Warply sharedService] cosmoteRetrieveSharingWithSuccessBlock:sharingId :accept :^(NSDictionary *response) { | ||
| 1411 | + if (success) { | ||
| 1412 | + success(response); | ||
| 1413 | + } | ||
| 1414 | + } failureBlock:^(NSError *error) { | ||
| 1415 | + if (failure) { | ||
| 1416 | + failure(error); | ||
| 1417 | + } | ||
| 1418 | + }]; | ||
| 1419 | +} | ||
| 1420 | + | ||
| 1408 | @end | 1421 | @end | ... | ... |
| ... | @@ -376,6 +376,8 @@ WL_VERSION_INTERFACE() | ... | @@ -376,6 +376,8 @@ WL_VERSION_INTERFACE() |
| 376 | 376 | ||
| 377 | - (void) cosmoteSharingWithSuccessBlock:(NSString*) sharingId :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | 377 | - (void) cosmoteSharingWithSuccessBlock:(NSString*) sharingId :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; |
| 378 | 378 | ||
| 379 | +- (void) cosmoteRetrieveSharingWithSuccessBlock:(NSString*) sharingId :(NSNumber*)accept :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | ||
| 380 | + | ||
| 379 | - (void) validateCouponWithSuccessBlock:(NSString*) coupon :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | 381 | - (void) validateCouponWithSuccessBlock:(NSString*) coupon :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; |
| 380 | 382 | ||
| 381 | - (void)loginCosmoteWithSuccessBlock:(NSString*)guid andAppUuid:(NSString*)appUuid andTicket:(NSString*)ticket :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | 383 | - (void)loginCosmoteWithSuccessBlock:(NSString*)guid andAppUuid:(NSString*)appUuid andTicket:(NSString*)ticket :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | ... | ... |
| ... | @@ -1958,6 +1958,47 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -1958,6 +1958,47 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
| 1958 | }]; | 1958 | }]; |
| 1959 | } | 1959 | } |
| 1960 | 1960 | ||
| 1961 | +- (void) cosmoteRetrieveSharingWithSuccessBlock:(NSString*) sharingId :(NSNumber*)accept :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure | ||
| 1962 | +{ | ||
| 1963 | + NSDictionary *postDictionary = @{@"wallet": @{@"action": @"sharing_response", @"sharing_id": sharingId, @"accept": accept}}; | ||
| 1964 | + NSData *jsonData = [NSJSONSerialization dataWithJSONObject:postDictionary options:0 error:NULL]; | ||
| 1965 | + [self sendContext8:jsonData successBlock:^(NSDictionary *contextResponse) { | ||
| 1966 | + if (success) { | ||
| 1967 | + success(contextResponse); | ||
| 1968 | + } | ||
| 1969 | + NSLog(@"**************** WARPLY Response *****************" ); | ||
| 1970 | + NSLog(@"%@", contextResponse ); | ||
| 1971 | + } failureBlock:^(NSError *error) { | ||
| 1972 | + if (failure) { | ||
| 1973 | + NSDictionary* dict = [NSDictionary alloc]; | ||
| 1974 | + dict = [error userInfo]; | ||
| 1975 | + NSString* errorCode = [dict objectForKey:@"NSLocalizedDescription"]; | ||
| 1976 | + if ([errorCode isEqual:@"Request failed: unauthorized (401)"]) { | ||
| 1977 | + [self refreshToken:^(NSDictionary *response) { | ||
| 1978 | + [self sendContext8:jsonData successBlock:^(NSDictionary *contextResponse) { | ||
| 1979 | + if (success) { | ||
| 1980 | + success(contextResponse); | ||
| 1981 | + } | ||
| 1982 | + NSLog(@"**************** WARPLY Response *****************" ); | ||
| 1983 | + NSLog(@"%@", contextResponse ); | ||
| 1984 | + } failureBlock:^(NSError *error) { | ||
| 1985 | + if (failure) { | ||
| 1986 | + failure(error); | ||
| 1987 | + } | ||
| 1988 | + }]; | ||
| 1989 | + } failureBlock:^(NSError *error) { | ||
| 1990 | + if (failure) { | ||
| 1991 | + [_db executeUpdate:@"DROP TABLE requestVariables"]; | ||
| 1992 | + failure(error); | ||
| 1993 | + } | ||
| 1994 | + NSLog(@"Error at token %@", error ); | ||
| 1995 | + }]; | ||
| 1996 | + } | ||
| 1997 | + NSLog(@"Error at cosmote retrieve sharing %@", error ); | ||
| 1998 | + } | ||
| 1999 | + }]; | ||
| 2000 | +} | ||
| 2001 | + | ||
| 1961 | - (void) validateCouponWithSuccessBlock:(NSString*) coupon :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure | 2002 | - (void) validateCouponWithSuccessBlock:(NSString*) coupon :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure |
| 1962 | { | 2003 | { |
| 1963 | NSDictionary *postDictionary = @{@"coupon": @{@"action": @"validate", @"coupon": coupon}}; | 2004 | NSDictionary *postDictionary = @{@"coupon": @{@"action": @"validate", @"coupon": coupon}}; | ... | ... |
| ... | @@ -2600,4 +2600,41 @@ public class swiftApi { | ... | @@ -2600,4 +2600,41 @@ public class swiftApi { |
| 2600 | } | 2600 | } |
| 2601 | } | 2601 | } |
| 2602 | 2602 | ||
| 2603 | + | ||
| 2604 | + public func cosmoteRetrieveSharingAsync(sharingId: String, accept: Bool, _ cosmoteSharingCallback: @escaping (_ responseData: GenericResponseModel?) -> Void) -> Void { | ||
| 2605 | + | ||
| 2606 | + let instanceOfMyApi = MyApi() | ||
| 2607 | + instanceOfMyApi.cosmoteRetrieveSharingAsync(sharingId, accept as NSNumber, requestCallback, failureBlock: requestFailureCallback) | ||
| 2608 | + | ||
| 2609 | + func requestCallback(_ responseData: [AnyHashable: Any]?) -> Void { | ||
| 2610 | + | ||
| 2611 | + if let responseDataDictionary = responseData as? [String: AnyObject] { | ||
| 2612 | + if (responseDataDictionary["status"] as? Int == 1) { | ||
| 2613 | + if let responseDataDictionary = responseData as? [String: Any] { | ||
| 2614 | + | ||
| 2615 | + let tempResponse = GenericResponseModel(dictionary: responseDataDictionary) | ||
| 2616 | + cosmoteSharingCallback(tempResponse); | ||
| 2617 | + | ||
| 2618 | + } else { | ||
| 2619 | + cosmoteSharingCallback(nil) | ||
| 2620 | + } | ||
| 2621 | + | ||
| 2622 | + } else { | ||
| 2623 | + cosmoteSharingCallback(nil) | ||
| 2624 | + } | ||
| 2625 | + | ||
| 2626 | + } else { | ||
| 2627 | + cosmoteSharingCallback(nil) | ||
| 2628 | + } | ||
| 2629 | + | ||
| 2630 | + } | ||
| 2631 | + | ||
| 2632 | + func requestFailureCallback(_ error: Error?) -> Void { | ||
| 2633 | + print("cosmoteRetrieveSharing error: ") | ||
| 2634 | + print(error) | ||
| 2635 | + print("====================") | ||
| 2636 | + cosmoteSharingCallback(nil) | ||
| 2637 | + } | ||
| 2638 | + } | ||
| 2639 | + | ||
| 2603 | } | 2640 | } | ... | ... |
-
Please register or login to post a comment