Manos Chorianopoulos

add submitOrderAsync request

......@@ -88,6 +88,7 @@
- (void)cosmoteRetrieveSharingAsync:(NSString*)sharingId :(NSNumber*)accept :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)getCosmoteUserAsync:(NSString*)guid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)cosmoteCouponSharingAsync:(NSString*) coupon :(NSString*)sender :(NSString*)receiver :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (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;
@end
#endif /* MyApi_h */
......
......@@ -1444,4 +1444,17 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify";
}];
}
- (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
{
[[Warply sharedService] submitOrderWithSuccessBlock:campaign_session_uuid :user_msisdn :businessService :offerName :productType :provDuration :noOfRecurrance :price :discount :voiceCategory :dataCategory :minsValue :dataValue :provStepValueMins :^(NSDictionary *response) {
if (success) {
success(response);
}
} failureBlock:^(NSError *error) {
if (failure) {
failure(error);
}
}];
}
@end
......
......@@ -384,6 +384,8 @@ WL_VERSION_INTERFACE()
- (void) cosmoteRetrieveSharingWithSuccessBlock:(NSString*) sharingId :(NSNumber*)accept :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (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;
- (void) validateCouponWithSuccessBlock:(NSString*) coupon :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (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)
}];
}
- (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
{
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}}};
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 submit Order %@", error );
}
}];
}
- (void) validateCouponWithSuccessBlock:(NSString*) coupon :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
{
NSDictionary *postDictionary = @{@"coupon": @{@"action": @"validate", @"coupon": coupon}};
......
......@@ -3127,4 +3127,32 @@ public class swiftApi {
}
}
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 {
let instanceOfMyApi = MyApi()
instanceOfMyApi.submitOrderAsync(campaign_session_uuid, user_msisdn, businessService, offerName, productType, provDuration, noOfRecurrance, price, discount, voiceCategory, dataCategory, minsValue, dataValue, provStepValueMins, requestCallback, failureBlock: requestFailureCallback)
func requestCallback(_ responseData: [AnyHashable: Any]?) -> Void {
if let responseDataDictionary = responseData as? [String: Any] {
let tempResponse = GenericResponseModel(dictionary: responseDataDictionary)
submitOrderCallback(tempResponse);
} else {
submitOrderCallback(nil)
}
}
func requestFailureCallback(_ error: Error?) -> Void {
print("submitOrder error: ")
print(error)
print("====================")
submitOrderCallback(nil)
}
}
}
......