Manos Chorianopoulos

add postEventAsync request

......@@ -89,6 +89,7 @@
- (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;
- (void)postEventAsync:(NSString*)Session_ID :(NSString*)OfferAudienceLevel :(NSString*)msisdn :(NSString*)UACIOfferTrackingCode :(NSString*)OFFERCODE1 :(NSString*)SCORE :(NSString*)ZONE :(NSString*)WAVE :(NSString*)VALIDITY :(NSString*)TREATMENT_CODE :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
@end
#endif /* MyApi_h */
......
......@@ -1457,4 +1457,15 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify";
}];
}
- (void)postEventAsync:(NSString*)Session_ID :(NSString*)OfferAudienceLevel :(NSString*)msisdn :(NSString*)UACIOfferTrackingCode :(NSString*)OFFERCODE1 :(NSString*)SCORE :(NSString*)ZONE :(NSString*)WAVE :(NSString*)VALIDITY :(NSString*)TREATMENT_CODE :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
{
[[Warply sharedService] postEventWithSuccessBlock:Session_ID :OfferAudienceLevel :msisdn :UACIOfferTrackingCode :OFFERCODE1 :SCORE :ZONE :WAVE :VALIDITY :TREATMENT_CODE :^(NSDictionary *response) {
if (success) {
success(response);
}
} failureBlock:^(NSError *error) {
failure(error);
}];
}
@end
......
......@@ -329,6 +329,9 @@ WL_VERSION_INTERFACE()
- (void)getProfileWithSuccessBlock :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)postEventWithSuccessBlock :(NSString*)Session_ID :(NSString*)OfferAudienceLevel :(NSString*)msisdn :(NSString*)UACIOfferTrackingCode :(NSString*)OFFERCODE1 :(NSString*)SCORE :(NSString*)ZONE :(NSString*)WAVE :(NSString*)VALIDITY :(NSString*)TREATMENT_CODE :(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
......
......@@ -961,6 +961,67 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
}];
}
//all parameters here : https://docs.google.com/spreadsheets/d/1kGtjZjO70EdygZxcRbwPBc5niNWEVl2bpl8RtCy5Bak/edit#gid=51763182
- (void)postEventWithSuccessBlock:(NSString*)Session_ID :(NSString*)OfferAudienceLevel :(NSString*)msisdn :(NSString*)UACIOfferTrackingCode :(NSString*)OFFERCODE1 :(NSString*)SCORE :(NSString*)ZONE :(NSString*)WAVE :(NSString*)VALIDITY :(NSString*)TREATMENT_CODE :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
{
NSDictionary *postDictionary = @{@"consumer_data":@{@"method": @"postEvent", @"action": @"integration", @"data": @{@"InteractiveChannel": @"COSMOTE_OMNI", @"InteractionPoint": @"COSMOTE_APP_GIFTS4U", @"Session_ID": Session_ID, @"OfferAudienceLevel": OfferAudienceLevel, @"MSISDN": msisdn, @"GUID": @"", @"parameters": @[
@{@"Name": @"UACIOfferTrackingCode", @"Value": UACIOfferTrackingCode, @"Type": @"string"},
@{@"Name": @"UACICustomLoggerTableName", @"Value": @"VW_WHITELIST", @"Type": @"string"},
@{@"Name": @"MSISDN", @"Value": msisdn, @"Type": @"string"},
@{@"Name": @"OFFERCODE1", @"Value": OFFERCODE1, @"Type": @"string"},
@{@"Name": @"SCORE", @"Value": SCORE, @"Type": @"string"},
@{@"Name": @"PREDICATE", @"Value": @"0", @"Type": @"string"},
@{@"Name": @"ZONE", @"Value": ZONE, @"Type": @"string"},
@{@"Name": @"APPLICATIONNAME", @"Value": @"COSMOTE_APP_GIFTS4U", @"Type": @"string"},
@{@"Name": @"Session_ID", @"Value": Session_ID, @"Type": @"string"},
@{@"Name": @"CAMPAIGN_CODE", @"Value": @"MCC_00006", @"Type": @"string"},
@{@"Name": @"CAMPAIGN_TYPE", @"Value": @"Inbound", @"Type": @"string"},
@{@"Name": @"UACIResponseTypeCode", @"Value": @"CON", @"Type": @"string"},
@{@"Name": @"CHANNEL", @"Value": @"ONE_APP", @"Type": @"string"},
@{@"Name": @"WAVE", @"Value": WAVE, @"Type": @"string"},
@{@"Name": @"RESPONSECHANNEL", @"Value": @"ONE_APP", @"Type": @"string"},
@{@"Name": @"VALIDITY", @"Value": VALIDITY, @"Type": @"numeric"},
@{@"Name": @"TREATMENT_CODE", @"Value": TREATMENT_CODE, @"Type": @"string"},
@{@"Name": @"EventName", @"Value": @"INTEREST_P", @"Type": @"string"}
]}}};
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 post Event %@", error );
}
}];
}
- (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
......
......@@ -3190,4 +3190,32 @@ public class swiftApi {
}
}
public func postEventAsync(Session_ID: String, OfferAudienceLevel: String, msisdn: String, UACIOfferTrackingCode: String, OFFERCODE1: String, SCORE: String, ZONE: String, WAVE: String, VALIDITY: String, TREATMENT_CODE: String, _ postEventCallback: @escaping (_ responseData: GenericResponseModel?) -> Void) -> Void {
let instanceOfMyApi = MyApi()
instanceOfMyApi.postEventAsync(Session_ID, OfferAudienceLevel, msisdn, UACIOfferTrackingCode, OFFERCODE1, SCORE, ZONE, WAVE, VALIDITY, TREATMENT_CODE, requestCallback, failureBlock: requestFailureCallback)
func requestCallback(_ responseData: [AnyHashable: Any]?) -> Void {
if let responseDataDictionary = responseData as? [String: Any] {
let tempResponse = GenericResponseModel(dictionary: responseDataDictionary)
postEventCallback(tempResponse);
} else {
postEventCallback(nil)
}
}
func requestFailureCallback(_ error: Error?) -> Void {
print("postEvent error: ")
print(error)
print("====================")
postEventCallback(nil)
}
}
}
......