Showing
5 changed files
with
307 additions
and
0 deletions
... | @@ -92,6 +92,7 @@ | ... | @@ -92,6 +92,7 @@ |
92 | - (void)verifyTicketAsync:(NSString*)guid :(NSString*)ticket :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | 92 | - (void)verifyTicketAsync:(NSString*)guid :(NSString*)ticket :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; |
93 | - (void)getProfileAsync:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | 93 | - (void)getProfileAsync:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; |
94 | - (void)consumerIntegrationAsync:(NSNumber*)nonTelco :(NSNumber*)acceptedConsent :(NSArray*)msisdnList :(NSString*)guid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | 94 | - (void)consumerIntegrationAsync:(NSNumber*)nonTelco :(NSNumber*)acceptedConsent :(NSArray*)msisdnList :(NSString*)guid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; |
95 | +- (void)getMarketPassDetailsAsync:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | ||
95 | - (void)redeemCouponSetAsync:(NSString*)uuid :(NSString*)communication_uuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | 96 | - (void)redeemCouponSetAsync:(NSString*)uuid :(NSString*)communication_uuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; |
96 | - (void)redeemCouponSetAsync:(NSString*)uuid :(NSString*)communication_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 :(NSString*)OfferAudienceLevel :(NSString*)UACIOfferTrackingCode :(NSString*)OFFERCODE1 :(NSString*)SCORE :(NSString*)ZONE :(NSString*)WAVE :(NSString*)VALIDITY :(NSString*)TREATMENT_CODE :(NSString*)ccms_session_id :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | 97 | - (void)redeemCouponSetAsync:(NSString*)uuid :(NSString*)communication_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 :(NSString*)OfferAudienceLevel :(NSString*)UACIOfferTrackingCode :(NSString*)OFFERCODE1 :(NSString*)SCORE :(NSString*)ZONE :(NSString*)WAVE :(NSString*)VALIDITY :(NSString*)TREATMENT_CODE :(NSString*)ccms_session_id :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; |
97 | - (void)getPacingDetailsAsync:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | 98 | - (void)getPacingDetailsAsync:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | ... | ... |
... | @@ -1594,6 +1594,19 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify"; | ... | @@ -1594,6 +1594,19 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify"; |
1594 | }]; | 1594 | }]; |
1595 | } | 1595 | } |
1596 | 1596 | ||
1597 | +- (void)getMarketPassDetailsAsync:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure | ||
1598 | +{ | ||
1599 | + [[Warply sharedService] getMarketPassDetailsWithSuccessBlock:^(NSDictionary *response) { | ||
1600 | + if (success) { | ||
1601 | + success(response); | ||
1602 | + } | ||
1603 | + } failureBlock:^(NSError *error) { | ||
1604 | + if (failure) { | ||
1605 | + failure(error); | ||
1606 | + } | ||
1607 | + }]; | ||
1608 | +} | ||
1609 | + | ||
1597 | - (void)consumerIntegrationAsync:(NSNumber*)nonTelco :(NSNumber*)acceptedConsent :(NSArray*)msisdnList :(NSString*)guid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure | 1610 | - (void)consumerIntegrationAsync:(NSNumber*)nonTelco :(NSNumber*)acceptedConsent :(NSArray*)msisdnList :(NSString*)guid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure |
1598 | { | 1611 | { |
1599 | [[Warply sharedService] consumerIntegrationWithSuccessBlock:nonTelco :acceptedConsent :msisdnList :guid :^(NSDictionary *response) { | 1612 | [[Warply sharedService] consumerIntegrationWithSuccessBlock:nonTelco :acceptedConsent :msisdnList :guid :^(NSDictionary *response) { | ... | ... |
... | @@ -347,6 +347,8 @@ WL_VERSION_INTERFACE() | ... | @@ -347,6 +347,8 @@ WL_VERSION_INTERFACE() |
347 | 347 | ||
348 | - (void)getProfileWithSuccessBlock :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | 348 | - (void)getProfileWithSuccessBlock :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; |
349 | 349 | ||
350 | +- (void)getMarketPassDetailsWithSuccessBlock:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | ||
351 | + | ||
350 | - (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; | 352 | - (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; |
351 | 353 | ||
352 | 354 | ... | ... |
... | @@ -1915,6 +1915,73 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -1915,6 +1915,73 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
1915 | }]; | 1915 | }]; |
1916 | } | 1916 | } |
1917 | 1917 | ||
1918 | +- (void)getMarketPassDetailsWithSuccessBlock:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure | ||
1919 | +{ | ||
1920 | + /* | ||
1921 | + { | ||
1922 | + "consumer_data": { | ||
1923 | + "method":"supermarket_profile", | ||
1924 | + "action": "integration" | ||
1925 | + } | ||
1926 | + } | ||
1927 | + */ | ||
1928 | + | ||
1929 | + NSMutableDictionary* consumerDataDictionary = [[NSMutableDictionary alloc] init]; | ||
1930 | + [consumerDataDictionary setValue:@"supermarket_profile" forKey:@"method"]; | ||
1931 | + [consumerDataDictionary setValue:@"integration" forKey:@"action"]; | ||
1932 | + | ||
1933 | + NSMutableDictionary* dataDictionary = [[NSMutableDictionary alloc] init]; | ||
1934 | + [dataDictionary setValue:consumerDataDictionary forKey:@"consumer_data"]; | ||
1935 | + | ||
1936 | + NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dataDictionary options:0 error:NULL]; | ||
1937 | + | ||
1938 | + [self sendContext8:jsonData successBlock:^(NSDictionary *contextResponse) { | ||
1939 | + if (success) { | ||
1940 | + success(contextResponse); | ||
1941 | + } | ||
1942 | + NSLog(@"**************** WARPLY Response *****************" ); | ||
1943 | + NSLog(@"%@", contextResponse ); | ||
1944 | + } failureBlock:^(NSError *error) { | ||
1945 | + if (failure) { | ||
1946 | + NSDictionary* dict = [NSDictionary alloc]; | ||
1947 | + dict = [error userInfo]; | ||
1948 | + NSString* errorCode = [dict objectForKey:@"NSLocalizedDescription"]; | ||
1949 | + if ([errorCode isEqual:@"Request failed: unauthorized (401)"]) { | ||
1950 | + | ||
1951 | +// NSString* errorDomain = [error domain]; | ||
1952 | +// NSError *errorToken = [NSError errorWithDomain:errorDomain code:401 userInfo:dict]; | ||
1953 | +// | ||
1954 | +// if (failure) { | ||
1955 | +// failure(errorToken); | ||
1956 | +// } | ||
1957 | + | ||
1958 | + [self refreshToken:^(NSDictionary *response) { | ||
1959 | + [self sendContext8:jsonData successBlock:^(NSDictionary *contextResponse) { | ||
1960 | + if (success) { | ||
1961 | + success(contextResponse); | ||
1962 | + } | ||
1963 | + NSLog(@"**************** WARPLY Response *****************" ); | ||
1964 | + NSLog(@"%@", contextResponse ); | ||
1965 | + } failureBlock:^(NSError *error) { | ||
1966 | + if (failure) { | ||
1967 | + failure(error); | ||
1968 | + } | ||
1969 | + }]; | ||
1970 | + } failureBlock:^(NSError *error) { | ||
1971 | + if (failure) { | ||
1972 | + // [_db executeUpdate:@"DROP TABLE requestVariables"]; | ||
1973 | + failure(error); | ||
1974 | + } | ||
1975 | + NSLog(@"Error at token %@", error ); | ||
1976 | + }]; | ||
1977 | + } else { | ||
1978 | + NSLog(@"Error at getMarketPassDetails %@", error ); | ||
1979 | + failure(error); | ||
1980 | + } | ||
1981 | + } | ||
1982 | + }]; | ||
1983 | +} | ||
1984 | + | ||
1918 | //all parameters here : https://docs.google.com/spreadsheets/d/1kGtjZjO70EdygZxcRbwPBc5niNWEVl2bpl8RtCy5Bak/edit#gid=51763182 | 1985 | //all parameters here : https://docs.google.com/spreadsheets/d/1kGtjZjO70EdygZxcRbwPBc5niNWEVl2bpl8RtCy5Bak/edit#gid=51763182 |
1919 | - (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 | 1986 | - (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 |
1920 | { | 1987 | { | ... | ... |
... | @@ -9384,4 +9384,228 @@ public class swiftApi { | ... | @@ -9384,4 +9384,228 @@ public class swiftApi { |
9384 | } | 9384 | } |
9385 | } | 9385 | } |
9386 | 9386 | ||
9387 | + | ||
9388 | + /* | ||
9389 | + { | ||
9390 | + logo = "https://warply.s3.amazonaws.com/applications/f83dfde1145e4c2da69793abb2f579af/content/80717ec9eecf4b19adbf47bd2edd12e7/preview/masoutis.png"; | ||
9391 | + name = "Masoutis "; | ||
9392 | + uuid = 80717ec9eecf4b19adbf47bd2edd12e7; | ||
9393 | + } | ||
9394 | + */ | ||
9395 | + public class SupermarketModel { | ||
9396 | + private var logo: String? | ||
9397 | + private var name: String? | ||
9398 | + private var uuid: String? | ||
9399 | + | ||
9400 | + public init() { | ||
9401 | + self.logo = "" | ||
9402 | + self.name = "" | ||
9403 | + self.uuid = "" | ||
9404 | + } | ||
9405 | + | ||
9406 | + public init(dictionary: [String: Any]) { | ||
9407 | + self.logo = dictionary["logo"] as? String? ?? "" | ||
9408 | + self.name = dictionary["name"] as? String? ?? "" | ||
9409 | + self.uuid = dictionary["uuid"] as? String? ?? "" | ||
9410 | + } | ||
9411 | + | ||
9412 | + public var _logo: String { | ||
9413 | + get { // getter | ||
9414 | + return self.logo ?? "" | ||
9415 | + } | ||
9416 | + set(newValue) { //setter | ||
9417 | + self.logo = newValue | ||
9418 | + } | ||
9419 | + } | ||
9420 | + | ||
9421 | + public var _name: String { | ||
9422 | + get { // getter | ||
9423 | + return self.name ?? "" | ||
9424 | + } | ||
9425 | + set(newValue) { //setter | ||
9426 | + self.name = newValue | ||
9427 | + } | ||
9428 | + } | ||
9429 | + | ||
9430 | + public var _uuid: String { | ||
9431 | + get { // getter | ||
9432 | + return self.uuid ?? "" | ||
9433 | + } | ||
9434 | + set(newValue) { //setter | ||
9435 | + self.uuid = newValue | ||
9436 | + } | ||
9437 | + } | ||
9438 | + | ||
9439 | + } | ||
9440 | + | ||
9441 | + | ||
9442 | + /* | ||
9443 | + { | ||
9444 | + barcode = 0070000008337; | ||
9445 | + "new_offers" = 3; | ||
9446 | + supermarkets = | ||
9447 | + ( | ||
9448 | + { | ||
9449 | + logo = "https://warply.s3.amazonaws.com/applications/f83dfde1145e4c2da69793abb2f579af/content/80717ec9eecf4b19adbf47bd2edd12e7/preview/masoutis.png"; | ||
9450 | + name = "Masoutis "; | ||
9451 | + uuid = 80717ec9eecf4b19adbf47bd2edd12e7; | ||
9452 | + }, | ||
9453 | + { | ||
9454 | + logo = "https://warply.s3.amazonaws.com/applications/f83dfde1145e4c2da69793abb2f579af/content/45d284ff3f824c80af1390d33f699bbd/preview/ab.png"; | ||
9455 | + name = "\U0391\U0392 Supermarket "; | ||
9456 | + uuid = 45d284ff3f824c80af1390d33f699bbd; | ||
9457 | + } | ||
9458 | + ); | ||
9459 | + "total_available_discount" = "25.75"; | ||
9460 | + } | ||
9461 | + */ | ||
9462 | + public class MarketPassDetailsModel { | ||
9463 | + private var barcode: String? | ||
9464 | + private var new_offers: Int? | ||
9465 | + private var total_available_discount: Float? | ||
9466 | + private var supermarkets: Array<SupermarketModel>? | ||
9467 | + | ||
9468 | + public init() { | ||
9469 | + self.barcode = "" | ||
9470 | + self.new_offers = 0 | ||
9471 | + self.total_available_discount = 0.0 | ||
9472 | + self.supermarkets = [] | ||
9473 | + } | ||
9474 | + | ||
9475 | + public init(dictionary: [String: Any]) { | ||
9476 | + self.barcode = dictionary["barcode"] as? String? ?? "" | ||
9477 | + self.new_offers = dictionary["new_offers"] as? Int? ?? 0 | ||
9478 | + // self.total_available_discount = dictionary["total_available_discount"] as? Float? ?? 0.0 | ||
9479 | + | ||
9480 | + if let float_discount = dictionary["total_available_discount"] as? Float { | ||
9481 | + self.total_available_discount = float_discount | ||
9482 | + } | ||
9483 | + else if let double_discount = dictionary["total_available_discount"] as? Double { | ||
9484 | + self.total_available_discount = Float(double_discount) | ||
9485 | + } | ||
9486 | + else if let string_discount = dictionary["total_available_discount"] as? String { | ||
9487 | + self.total_available_discount = Float(string_discount) ?? 0.0 | ||
9488 | + } | ||
9489 | + else { | ||
9490 | + self.total_available_discount = 0.0 | ||
9491 | + } | ||
9492 | + | ||
9493 | + if let supermarketsData = dictionary["supermarkets"] as? [[String : Any]?] { | ||
9494 | + var supermarketsArray:Array<SupermarketModel> = [] | ||
9495 | + for item in supermarketsData { | ||
9496 | + if let itemDictionary = item { | ||
9497 | + let tempCoupon = SupermarketModel(dictionary: itemDictionary) | ||
9498 | + supermarketsArray.append(tempCoupon) | ||
9499 | + } | ||
9500 | + } | ||
9501 | + self.supermarkets = supermarketsArray | ||
9502 | + } else { | ||
9503 | + self.supermarkets = [] | ||
9504 | + } | ||
9505 | + } | ||
9506 | + | ||
9507 | + public var _barcode: String { | ||
9508 | + get { // getter | ||
9509 | + return self.barcode ?? "" | ||
9510 | + } | ||
9511 | + set(newValue) { //setter | ||
9512 | + self.barcode = newValue | ||
9513 | + } | ||
9514 | + } | ||
9515 | + | ||
9516 | + public var _new_offers: Int { | ||
9517 | + get { // getter | ||
9518 | + return self.new_offers ?? 0 | ||
9519 | + } | ||
9520 | + set(newValue) { //setter | ||
9521 | + self.new_offers = newValue | ||
9522 | + } | ||
9523 | + } | ||
9524 | + | ||
9525 | + public var _total_available_discount: Float { | ||
9526 | + get { // getter | ||
9527 | + return self.total_available_discount ?? 0.0 | ||
9528 | + } | ||
9529 | + set(newValue) { //setter | ||
9530 | + self.total_available_discount = newValue | ||
9531 | + } | ||
9532 | + } | ||
9533 | + | ||
9534 | + public var _supermarkets: Array<SupermarketModel> { | ||
9535 | + get { // getter | ||
9536 | + return self.supermarkets ?? [] | ||
9537 | + } | ||
9538 | + set(newValue) { //setter | ||
9539 | + self.supermarkets = newValue | ||
9540 | + } | ||
9541 | + } | ||
9542 | + } | ||
9543 | + | ||
9544 | + public func getMarketPassDetailsAsync(_ successCallback: @escaping (_ responseData: MarketPassDetailsModel?) -> Void, failureCallback: @escaping (_ errorCode: Int) -> Void) -> Void { | ||
9545 | + | ||
9546 | + let instanceOfMyApi = MyApi() | ||
9547 | + instanceOfMyApi.getMarketPassDetailsAsync(requestCallback, failureBlock: requestFailureCallback) | ||
9548 | + | ||
9549 | + func requestCallback(_ responseData: [AnyHashable: Any]?) -> Void { | ||
9550 | + if let responseDataDictionary = responseData as? [String: AnyObject] { | ||
9551 | + | ||
9552 | + if (responseDataDictionary["status"] as? Int == 1) { | ||
9553 | + let dynatraceEvent = swiftApi.LoyaltySDKDynatraceEventModel() | ||
9554 | + dynatraceEvent._eventName = "custom_success_market_pass_details" | ||
9555 | + dynatraceEvent._parameters = nil | ||
9556 | + SwiftEventBus.post("dynatrace", sender: dynatraceEvent) | ||
9557 | + | ||
9558 | + if let responseDataResult = responseDataDictionary["result"] as? [String : Any] { | ||
9559 | + let tempMarketPassDetails = MarketPassDetailsModel(dictionary: responseDataResult) | ||
9560 | + successCallback(tempMarketPassDetails) | ||
9561 | + | ||
9562 | + } else { | ||
9563 | + successCallback(nil) | ||
9564 | + } | ||
9565 | + | ||
9566 | + } else { | ||
9567 | + let dynatraceEvent = swiftApi.LoyaltySDKDynatraceEventModel() | ||
9568 | + dynatraceEvent._eventName = "custom_error_market_pass_details" | ||
9569 | + dynatraceEvent._parameters = nil | ||
9570 | + SwiftEventBus.post("dynatrace", sender: dynatraceEvent) | ||
9571 | + | ||
9572 | + successCallback(nil) | ||
9573 | + } | ||
9574 | + | ||
9575 | + } else { | ||
9576 | + let dynatraceEvent = swiftApi.LoyaltySDKDynatraceEventModel() | ||
9577 | + dynatraceEvent._eventName = "custom_error_market_pass_details" | ||
9578 | + dynatraceEvent._parameters = nil | ||
9579 | + SwiftEventBus.post("dynatrace", sender: dynatraceEvent) | ||
9580 | + | ||
9581 | + successCallback(nil) | ||
9582 | + } | ||
9583 | + | ||
9584 | + } | ||
9585 | + | ||
9586 | + func requestFailureCallback(_ error: Error?) -> Void { | ||
9587 | + print("getMarketPassDetailsAsync error: ") | ||
9588 | + print(error) | ||
9589 | + print("====================") | ||
9590 | + | ||
9591 | + let dynatraceEvent = swiftApi.LoyaltySDKDynatraceEventModel() | ||
9592 | + dynatraceEvent._eventName = "custom_error_market_pass_details" | ||
9593 | + dynatraceEvent._parameters = nil | ||
9594 | + SwiftEventBus.post("dynatrace", sender: dynatraceEvent) | ||
9595 | + | ||
9596 | + // successCallback(nil) | ||
9597 | + if let error = error as? NSError { | ||
9598 | +// if (error.code == 401) { | ||
9599 | +// let sessionEvent = swiftApi.LoyaltySDKSessionExpiredEventModel() | ||
9600 | +// sessionEvent._sessionExpired = true | ||
9601 | +// SwiftEventBus.post("sdk_session_expired", sender: sessionEvent) | ||
9602 | +// } | ||
9603 | + | ||
9604 | + failureCallback(error.code) | ||
9605 | + } else { | ||
9606 | + failureCallback(-1) | ||
9607 | + } | ||
9608 | + } | ||
9609 | + } | ||
9610 | + | ||
9387 | } | 9611 | } | ... | ... |
-
Please register or login to post a comment