Showing
5 changed files
with
85 additions
and
0 deletions
... | @@ -88,6 +88,7 @@ | ... | @@ -88,6 +88,7 @@ |
88 | - (void)cosmoteRetrieveSharingAsync:(NSString*)sharingId :(NSNumber*)accept :(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; |
89 | - (void)getCosmoteUserAsync:(NSString*)guid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | 89 | - (void)getCosmoteUserAsync:(NSString*)guid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; |
90 | - (void)cosmoteCouponSharingAsync:(NSString*) coupon :(NSString*)sender :(NSString*)receiver :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | 90 | - (void)cosmoteCouponSharingAsync:(NSString*) coupon :(NSString*)sender :(NSString*)receiver :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; |
91 | +- (void)submitOrderAsync:(NSString*) campaign_session_uuid :(NSString*)user_msisdn :(NSString*)businessService :(NSString*)offerName :(NSString*)productType :(NSString*)provDuration :(NSString*)noOfRecurrance :(NSString*)price :(NSString*)discount :(NSString*)voiceCategory :(NSString*)dataCategory :(NSString*)minsValue :(NSString*)dataValue :(NSString*)provStepValueMins :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | ||
91 | 92 | ||
92 | @end | 93 | @end |
93 | #endif /* MyApi_h */ | 94 | #endif /* MyApi_h */ | ... | ... |
... | @@ -1444,4 +1444,17 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify"; | ... | @@ -1444,4 +1444,17 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify"; |
1444 | }]; | 1444 | }]; |
1445 | } | 1445 | } |
1446 | 1446 | ||
1447 | +- (void)submitOrderAsync:(NSString*) campaign_session_uuid :(NSString*)user_msisdn :(NSString*)businessService :(NSString*)offerName :(NSString*)productType :(NSString*)provDuration :(NSString*)noOfRecurrance :(NSString*)price :(NSString*)discount :(NSString*)voiceCategory :(NSString*)dataCategory :(NSString*)minsValue :(NSString*)dataValue :(NSString*)provStepValueMins :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure | ||
1448 | +{ | ||
1449 | + [[Warply sharedService] submitOrderWithSuccessBlock:campaign_session_uuid :user_msisdn :businessService :offerName :productType :provDuration :noOfRecurrance :price :discount :voiceCategory :dataCategory :minsValue :dataValue :provStepValueMins :^(NSDictionary *response) { | ||
1450 | + if (success) { | ||
1451 | + success(response); | ||
1452 | + } | ||
1453 | + } failureBlock:^(NSError *error) { | ||
1454 | + if (failure) { | ||
1455 | + failure(error); | ||
1456 | + } | ||
1457 | + }]; | ||
1458 | +} | ||
1459 | + | ||
1447 | @end | 1460 | @end | ... | ... |
... | @@ -384,6 +384,8 @@ WL_VERSION_INTERFACE() | ... | @@ -384,6 +384,8 @@ WL_VERSION_INTERFACE() |
384 | 384 | ||
385 | - (void) cosmoteRetrieveSharingWithSuccessBlock:(NSString*) sharingId :(NSNumber*)accept :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | 385 | - (void) cosmoteRetrieveSharingWithSuccessBlock:(NSString*) sharingId :(NSNumber*)accept :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; |
386 | 386 | ||
387 | +- (void) submitOrderWithSuccessBlock:(NSString*) campaign_session_uuid :(NSString*)user_msisdn :(NSString*)businessService :(NSString*)offerName :(NSString*)productType :(NSString*)provDuration :(NSString*)noOfRecurrance :(NSString*)price :(NSString*)discount :(NSString*)voiceCategory :(NSString*)dataCategory :(NSString*)minsValue :(NSString*)dataValue :(NSString*)provStepValueMins :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | ||
388 | + | ||
387 | - (void) validateCouponWithSuccessBlock:(NSString*) coupon :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | 389 | - (void) validateCouponWithSuccessBlock:(NSString*) coupon :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; |
388 | 390 | ||
389 | - (void)loginCosmoteWithSuccessBlock:(NSString*)guid andAppUuid:(NSString*)appUuid andTicket:(NSString*)ticket :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | 391 | - (void)loginCosmoteWithSuccessBlock:(NSString*)guid andAppUuid:(NSString*)appUuid andTicket:(NSString*)ticket :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | ... | ... |
... | @@ -2077,6 +2077,47 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -2077,6 +2077,47 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
2077 | }]; | 2077 | }]; |
2078 | } | 2078 | } |
2079 | 2079 | ||
2080 | +- (void) submitOrderWithSuccessBlock:(NSString*) campaign_session_uuid :(NSString*)user_msisdn :(NSString*)businessService :(NSString*)offerName :(NSString*)productType :(NSString*)provDuration :(NSString*)noOfRecurrance :(NSString*)price :(NSString*)discount :(NSString*)voiceCategory :(NSString*)dataCategory :(NSString*)minsValue :(NSString*)dataValue :(NSString*)provStepValueMins :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure | ||
2081 | +{ | ||
2082 | + NSDictionary *postDictionary = @{@"wallet": @{@"action": @"add_product", @"product_uuid": @"011d21908d984e3cbecbdfd2920a5d3b", @"communication_uuid": campaign_session_uuid, @"extra_data": @{@"user_msisdn": user_msisdn, @"businessService": businessService, @"offerName": offerName, @"productType": productType, @"provDuration": provDuration, @"noOfRecurrance": noOfRecurrance, @"price": price, @"discount": discount, @"voiceCategory": voiceCategory, @"dataCategory": dataCategory, @"minsValue": minsValue, @"dataValue": dataValue, @"provStepValueMins": provStepValueMins}}}; | ||
2083 | + NSData *jsonData = [NSJSONSerialization dataWithJSONObject:postDictionary options:0 error:NULL]; | ||
2084 | + [self sendContext8:jsonData successBlock:^(NSDictionary *contextResponse) { | ||
2085 | + if (success) { | ||
2086 | + success(contextResponse); | ||
2087 | + } | ||
2088 | + NSLog(@"**************** WARPLY Response *****************" ); | ||
2089 | + NSLog(@"%@", contextResponse ); | ||
2090 | + } failureBlock:^(NSError *error) { | ||
2091 | + if (failure) { | ||
2092 | + NSDictionary* dict = [NSDictionary alloc]; | ||
2093 | + dict = [error userInfo]; | ||
2094 | + NSString* errorCode = [dict objectForKey:@"NSLocalizedDescription"]; | ||
2095 | + if ([errorCode isEqual:@"Request failed: unauthorized (401)"]) { | ||
2096 | + [self refreshToken:^(NSDictionary *response) { | ||
2097 | + [self sendContext8:jsonData successBlock:^(NSDictionary *contextResponse) { | ||
2098 | + if (success) { | ||
2099 | + success(contextResponse); | ||
2100 | + } | ||
2101 | + NSLog(@"**************** WARPLY Response *****************" ); | ||
2102 | + NSLog(@"%@", contextResponse ); | ||
2103 | + } failureBlock:^(NSError *error) { | ||
2104 | + if (failure) { | ||
2105 | + failure(error); | ||
2106 | + } | ||
2107 | + }]; | ||
2108 | + } failureBlock:^(NSError *error) { | ||
2109 | + if (failure) { | ||
2110 | + [_db executeUpdate:@"DROP TABLE requestVariables"]; | ||
2111 | + failure(error); | ||
2112 | + } | ||
2113 | + NSLog(@"Error at token %@", error ); | ||
2114 | + }]; | ||
2115 | + } | ||
2116 | + NSLog(@"Error at submit Order %@", error ); | ||
2117 | + } | ||
2118 | + }]; | ||
2119 | +} | ||
2120 | + | ||
2080 | - (void) validateCouponWithSuccessBlock:(NSString*) coupon :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure | 2121 | - (void) validateCouponWithSuccessBlock:(NSString*) coupon :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure |
2081 | { | 2122 | { |
2082 | NSDictionary *postDictionary = @{@"coupon": @{@"action": @"validate", @"coupon": coupon}}; | 2123 | NSDictionary *postDictionary = @{@"coupon": @{@"action": @"validate", @"coupon": coupon}}; | ... | ... |
... | @@ -3127,4 +3127,32 @@ public class swiftApi { | ... | @@ -3127,4 +3127,32 @@ public class swiftApi { |
3127 | } | 3127 | } |
3128 | } | 3128 | } |
3129 | 3129 | ||
3130 | + | ||
3131 | + public func submitOrderAsync(campaign_session_uuid: String, user_msisdn: String, businessService: String, offerName: String, productType: String, provDuration: String, noOfRecurrance: String, price: String, discount: String, voiceCategory: String, dataCategory: String, minsValue: String, dataValue: String, provStepValueMins: String, _ submitOrderCallback: @escaping (_ responseData: GenericResponseModel?) -> Void) -> Void { | ||
3132 | + | ||
3133 | + let instanceOfMyApi = MyApi() | ||
3134 | + instanceOfMyApi.submitOrderAsync(campaign_session_uuid, user_msisdn, businessService, offerName, productType, provDuration, noOfRecurrance, price, discount, voiceCategory, dataCategory, minsValue, dataValue, provStepValueMins, requestCallback, failureBlock: requestFailureCallback) | ||
3135 | + | ||
3136 | + func requestCallback(_ responseData: [AnyHashable: Any]?) -> Void { | ||
3137 | + | ||
3138 | + if let responseDataDictionary = responseData as? [String: Any] { | ||
3139 | + | ||
3140 | + let tempResponse = GenericResponseModel(dictionary: responseDataDictionary) | ||
3141 | + | ||
3142 | + submitOrderCallback(tempResponse); | ||
3143 | + | ||
3144 | + } else { | ||
3145 | + submitOrderCallback(nil) | ||
3146 | + } | ||
3147 | + | ||
3148 | + } | ||
3149 | + | ||
3150 | + func requestFailureCallback(_ error: Error?) -> Void { | ||
3151 | + print("submitOrder error: ") | ||
3152 | + print(error) | ||
3153 | + print("====================") | ||
3154 | + submitOrderCallback(nil) | ||
3155 | + } | ||
3156 | + } | ||
3157 | + | ||
3130 | } | 3158 | } | ... | ... |
-
Please register or login to post a comment