Showing
5 changed files
with
181 additions
and
0 deletions
... | @@ -353,6 +353,13 @@ WL_VERSION_INTERFACE() | ... | @@ -353,6 +353,13 @@ WL_VERSION_INTERFACE() |
353 | - (void)resetPasswordWithPasswordWithSuccessBlock:(NSString*)password andConfCode:(NSString*)confCode andOtpUuid:(NSString*)otpUuid andConfToken:(NSString*)confToken :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | 353 | - (void)resetPasswordWithPasswordWithSuccessBlock:(NSString*)password andConfCode:(NSString*)confCode andOtpUuid:(NSString*)otpUuid andConfToken:(NSString*)confToken :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; |
354 | 354 | ||
355 | - (void)retrieveMultilingualMerchantsWithCategoriesWithSuccessBlock:(NSArray*)categories andDefaultShown:(NSNumber*)defaultShown andCenter:(NSNumber*)center andTags:(NSArray*)tags andUuid:(NSString*)uuid andDistance:(NSNumber*)distance :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | 355 | - (void)retrieveMultilingualMerchantsWithCategoriesWithSuccessBlock:(NSArray*)categories andDefaultShown:(NSNumber*)defaultShown andCenter:(NSNumber*)center andTags:(NSArray*)tags andUuid:(NSString*)uuid andDistance:(NSNumber*)distance :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; |
356 | + | ||
357 | +- (void) getCouponSetsWithSuccessBlock:(NSNumber*) active andVisible:(NSNumber*) visible andUuids:(NSArray*) uuids :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | ||
358 | + | ||
359 | +- (void) redeemCouponSetsWithSuccessBlock:(NSString*) uuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | ||
360 | + | ||
361 | +- (void) validateCoupoWithSuccessBlock:(NSString*) coupon :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | ||
362 | + | ||
356 | /*! | 363 | /*! |
357 | @abstract Get the full page add accordint to the display_type of a campaign. | 364 | @abstract Get the full page add accordint to the display_type of a campaign. |
358 | @attributeblock successBlock This block is called when getInbox is sucessful and allOffers is empty or nil and returns an array with the available WLInboxItem items. Otherwise, the allOffers array is filtered. | 365 | @attributeblock successBlock This block is called when getInbox is sucessful and allOffers is empty or nil and returns an array with the available WLInboxItem items. Otherwise, the allOffers array is filtered. | ... | ... |
... | @@ -1546,6 +1546,96 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -1546,6 +1546,96 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
1546 | }]; | 1546 | }]; |
1547 | } | 1547 | } |
1548 | 1548 | ||
1549 | +- (void) getCouponSetsWithSuccessBlock:(NSNumber*) active andVisible:(NSNumber*) visible andUuids:(NSArray*) uuids :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure | ||
1550 | +{ | ||
1551 | + NSDictionary *postDictionary = @{@"coupon": @{@"action": @"retrieve_multilingual", @"active": active, @"visible": visible, @"language": LANG, @"uuids": uuids}}; | ||
1552 | + NSData *jsonData = [NSJSONSerialization dataWithJSONObject:postDictionary options:0 error:NULL]; | ||
1553 | + [self sendContext:jsonData successBlock:^(NSDictionary *contextResponse) { | ||
1554 | + if (success) { | ||
1555 | + success(contextResponse); | ||
1556 | + } | ||
1557 | + } failureBlock:^(NSError *error) { | ||
1558 | + if (failure) { | ||
1559 | + failure(error); | ||
1560 | + } | ||
1561 | + NSLog(@"Error at get coupon sets %@", error ); | ||
1562 | + }]; | ||
1563 | +} | ||
1564 | + | ||
1565 | +- (void) redeemCouponSetsWithSuccessBlock:(NSString*) uuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure | ||
1566 | +{ | ||
1567 | + NSDictionary *postDictionary = @{@"coupon": @{@"action": @"retrieve_coupon", @"coupon_set": uuid}}; | ||
1568 | + NSData *jsonData = [NSJSONSerialization dataWithJSONObject:postDictionary options:0 error:NULL]; | ||
1569 | + [self sendContext8:jsonData successBlock:^(NSDictionary *contextResponse) { | ||
1570 | + if (success) { | ||
1571 | + success(contextResponse); | ||
1572 | + } | ||
1573 | + } failureBlock:^(NSError *error) { | ||
1574 | + if (failure) { | ||
1575 | + NSDictionary* dict = [NSDictionary alloc]; | ||
1576 | + dict = [error userInfo]; | ||
1577 | + NSString* errorCode = [dict objectForKey:@"NSLocalizedDescription"]; | ||
1578 | + if ([errorCode isEqual:@"Request failed: unauthorized (401)"]) { | ||
1579 | + [self refreshToken:^(NSDictionary *response) { | ||
1580 | + [self sendContext8:jsonData successBlock:^(NSDictionary *contextResponse) { | ||
1581 | + if (success) { | ||
1582 | + success(contextResponse); | ||
1583 | + } | ||
1584 | + } failureBlock:^(NSError *error) { | ||
1585 | + if (failure) { | ||
1586 | + failure(error); | ||
1587 | + } | ||
1588 | + }]; | ||
1589 | + } failureBlock:^(NSError *error) { | ||
1590 | + if (failure) { | ||
1591 | + [_db executeUpdate:@"DROP TABLE requestVariables"]; | ||
1592 | + failure(error); | ||
1593 | + } | ||
1594 | + NSLog(@"Error at token %@", error ); | ||
1595 | + }]; | ||
1596 | + } | ||
1597 | + NSLog(@"Error at get coupon sets %@", error ); | ||
1598 | + } | ||
1599 | + }]; | ||
1600 | +} | ||
1601 | + | ||
1602 | +- (void) validateCoupoWithSuccessBlock:(NSString*) coupon :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure | ||
1603 | +{ | ||
1604 | + NSDictionary *postDictionary = @{@"coupon": @{@"action": @"validate", @"coupon": coupon}}; | ||
1605 | + NSData *jsonData = [NSJSONSerialization dataWithJSONObject:postDictionary options:0 error:NULL]; | ||
1606 | + [self sendContext8:jsonData successBlock:^(NSDictionary *contextResponse) { | ||
1607 | + if (success) { | ||
1608 | + success(contextResponse); | ||
1609 | + } | ||
1610 | + } failureBlock:^(NSError *error) { | ||
1611 | + if (failure) { | ||
1612 | + NSDictionary* dict = [NSDictionary alloc]; | ||
1613 | + dict = [error userInfo]; | ||
1614 | + NSString* errorCode = [dict objectForKey:@"NSLocalizedDescription"]; | ||
1615 | + if ([errorCode isEqual:@"Request failed: unauthorized (401)"]) { | ||
1616 | + [self refreshToken:^(NSDictionary *response) { | ||
1617 | + [self sendContext8:jsonData successBlock:^(NSDictionary *contextResponse) { | ||
1618 | + if (success) { | ||
1619 | + success(contextResponse); | ||
1620 | + } | ||
1621 | + } failureBlock:^(NSError *error) { | ||
1622 | + if (failure) { | ||
1623 | + failure(error); | ||
1624 | + } | ||
1625 | + }]; | ||
1626 | + } failureBlock:^(NSError *error) { | ||
1627 | + if (failure) { | ||
1628 | + [_db executeUpdate:@"DROP TABLE requestVariables"]; | ||
1629 | + failure(error); | ||
1630 | + } | ||
1631 | + NSLog(@"Error at token %@", error ); | ||
1632 | + }]; | ||
1633 | + } | ||
1634 | + NSLog(@"Error at get coupon sets %@", error ); | ||
1635 | + } | ||
1636 | + }]; | ||
1637 | +} | ||
1638 | + | ||
1549 | /////////////////////////////////////////////////////////////////////////////// | 1639 | /////////////////////////////////////////////////////////////////////////////// |
1550 | - (BOOL)showFullPageAdIfExists:(void (^)(NSArray *list))success failureBlock:(void (^)(NSError *error))failure | 1640 | - (BOOL)showFullPageAdIfExists:(void (^)(NSArray *list))success failureBlock:(void (^)(NSError *error))failure |
1551 | { | 1641 | { | ... | ... |
No preview for this file type
... | @@ -55,6 +55,9 @@ | ... | @@ -55,6 +55,9 @@ |
55 | - (NSDictionary*)resetPasswordWithPassword:(NSString*)password andConfCode:(NSString*)confCode andOtpUuid:(NSString*)otpUuid andConfToken:(NSString*)confToken; | 55 | - (NSDictionary*)resetPasswordWithPassword:(NSString*)password andConfCode:(NSString*)confCode andOtpUuid:(NSString*)otpUuid andConfToken:(NSString*)confToken; |
56 | - (NSDictionary*)requestOtpWithMsisdn:(NSString*)msisdn andScope:(NSString*)scope; | 56 | - (NSDictionary*)requestOtpWithMsisdn:(NSString*)msisdn andScope:(NSString*)scope; |
57 | - (NSDictionary*)retrieveMultilingualMerchantsWithCategories:(NSArray*)categories andDefaultShown:(NSNumber*)defaultShown andCenter:(NSNumber*)center andTags:(NSArray*)tags andUuid:(NSString*)uuid andDistance:(NSNumber*)distance; | 57 | - (NSDictionary*)retrieveMultilingualMerchantsWithCategories:(NSArray*)categories andDefaultShown:(NSNumber*)defaultShown andCenter:(NSNumber*)center andTags:(NSArray*)tags andUuid:(NSString*)uuid andDistance:(NSNumber*)distance; |
58 | +- (NSDictionary*)getCouponSetsWithActive:(NSNumber*)active andVisible:(NSNumber*)visible andUuids:(NSArray*)uuids; | ||
59 | +- (NSDictionary*)redeemCouponWithCoupon:(NSString*)coupon; | ||
60 | +- (NSDictionary*)validateCouponWithCoupon:(NSString*)coupon; | ||
58 | 61 | ||
59 | @end | 62 | @end |
60 | #endif /* MyApi_h */ | 63 | #endif /* MyApi_h */ | ... | ... |
... | @@ -1029,4 +1029,85 @@ NSString *LANG; | ... | @@ -1029,4 +1029,85 @@ NSString *LANG; |
1029 | } | 1029 | } |
1030 | return resp; | 1030 | return resp; |
1031 | } | 1031 | } |
1032 | + | ||
1033 | +- (NSDictionary*)getCouponSetsWithActive:(NSNumber*)active andVisible:(NSNumber*)visible andUuids:(NSArray*)uuids { | ||
1034 | + __block NSDictionary *resp = [NSDictionary alloc]; | ||
1035 | + __block BOOL isRunLoopNested = NO; | ||
1036 | + __block BOOL isOperationCompleted = NO; | ||
1037 | + [[Warply sharedService] getCouponSetsWithSuccessBlock:active andVisible:visible andUuids:uuids :^(NSDictionary *response) { | ||
1038 | + resp = response; | ||
1039 | + isOperationCompleted = YES; | ||
1040 | + if (isRunLoopNested) { | ||
1041 | + CFRunLoopStop(CFRunLoopGetCurrent()); // CFRunLoopRun() returns | ||
1042 | + } | ||
1043 | + } failureBlock:^(NSError *error) { | ||
1044 | + NSLog(@"%@", error); | ||
1045 | + resp = nil; | ||
1046 | + isOperationCompleted = YES; | ||
1047 | + if (isRunLoopNested) { | ||
1048 | + CFRunLoopStop(CFRunLoopGetCurrent()); // CFRunLoopRun() returns | ||
1049 | + } | ||
1050 | + }]; | ||
1051 | + if ( ! isOperationCompleted) { | ||
1052 | + isRunLoopNested = YES; | ||
1053 | + NSLog(@"Waiting..."); | ||
1054 | + CFRunLoopRun(); // Magic! | ||
1055 | + isRunLoopNested = NO; | ||
1056 | + } | ||
1057 | + return resp; | ||
1058 | +} | ||
1059 | + | ||
1060 | +- (NSDictionary*)redeemCouponWithCoupon:(NSString*)coupon { | ||
1061 | + __block NSDictionary *resp = [NSDictionary alloc]; | ||
1062 | + __block BOOL isRunLoopNested = NO; | ||
1063 | + __block BOOL isOperationCompleted = NO; | ||
1064 | + [[Warply sharedService] redeemCouponSetsWithSuccessBlock:coupon :^(NSDictionary *response) { | ||
1065 | + resp = response; | ||
1066 | + isOperationCompleted = YES; | ||
1067 | + if (isRunLoopNested) { | ||
1068 | + CFRunLoopStop(CFRunLoopGetCurrent()); // CFRunLoopRun() returns | ||
1069 | + } | ||
1070 | + } failureBlock:^(NSError *error) { | ||
1071 | + NSLog(@"%@", error); | ||
1072 | + resp = nil; | ||
1073 | + isOperationCompleted = YES; | ||
1074 | + if (isRunLoopNested) { | ||
1075 | + CFRunLoopStop(CFRunLoopGetCurrent()); // CFRunLoopRun() returns | ||
1076 | + } | ||
1077 | + }]; | ||
1078 | + if ( ! isOperationCompleted) { | ||
1079 | + isRunLoopNested = YES; | ||
1080 | + NSLog(@"Waiting..."); | ||
1081 | + CFRunLoopRun(); // Magic! | ||
1082 | + isRunLoopNested = NO; | ||
1083 | + } | ||
1084 | + return resp; | ||
1085 | +} | ||
1086 | + | ||
1087 | +- (NSDictionary*)validateCouponWithCoupon:(NSString*)coupon { | ||
1088 | + __block NSDictionary *resp = [NSDictionary alloc]; | ||
1089 | + __block BOOL isRunLoopNested = NO; | ||
1090 | + __block BOOL isOperationCompleted = NO; | ||
1091 | + [[Warply sharedService] validateCoupoWithSuccessBlock:coupon :^(NSDictionary *response) { | ||
1092 | + resp = response; | ||
1093 | + isOperationCompleted = YES; | ||
1094 | + if (isRunLoopNested) { | ||
1095 | + CFRunLoopStop(CFRunLoopGetCurrent()); // CFRunLoopRun() returns | ||
1096 | + } | ||
1097 | + } failureBlock:^(NSError *error) { | ||
1098 | + NSLog(@"%@", error); | ||
1099 | + resp = nil; | ||
1100 | + isOperationCompleted = YES; | ||
1101 | + if (isRunLoopNested) { | ||
1102 | + CFRunLoopStop(CFRunLoopGetCurrent()); // CFRunLoopRun() returns | ||
1103 | + } | ||
1104 | + }]; | ||
1105 | + if ( ! isOperationCompleted) { | ||
1106 | + isRunLoopNested = YES; | ||
1107 | + NSLog(@"Waiting..."); | ||
1108 | + CFRunLoopRun(); // Magic! | ||
1109 | + isRunLoopNested = NO; | ||
1110 | + } | ||
1111 | + return resp; | ||
1112 | +} | ||
1032 | @end | 1113 | @end | ... | ... |
-
Please register or login to post a comment