Manos Chorianopoulos

add getMarketPassDetailsAsync request

......@@ -92,6 +92,7 @@
- (void)verifyTicketAsync:(NSString*)guid :(NSString*)ticket :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)getProfileAsync:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)consumerIntegrationAsync:(NSNumber*)nonTelco :(NSNumber*)acceptedConsent :(NSArray*)msisdnList :(NSString*)guid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)getMarketPassDetailsAsync:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)redeemCouponSetAsync:(NSString*)uuid :(NSString*)communication_uuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (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;
- (void)getPacingDetailsAsync:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
......
......@@ -1594,6 +1594,19 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify";
}];
}
- (void)getMarketPassDetailsAsync:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
{
[[Warply sharedService] getMarketPassDetailsWithSuccessBlock:^(NSDictionary *response) {
if (success) {
success(response);
}
} failureBlock:^(NSError *error) {
if (failure) {
failure(error);
}
}];
}
- (void)consumerIntegrationAsync:(NSNumber*)nonTelco :(NSNumber*)acceptedConsent :(NSArray*)msisdnList :(NSString*)guid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
{
[[Warply sharedService] consumerIntegrationWithSuccessBlock:nonTelco :acceptedConsent :msisdnList :guid :^(NSDictionary *response) {
......
......@@ -347,6 +347,8 @@ WL_VERSION_INTERFACE()
- (void)getProfileWithSuccessBlock :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)getMarketPassDetailsWithSuccessBlock:(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;
......
......@@ -1915,6 +1915,73 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
}];
}
- (void)getMarketPassDetailsWithSuccessBlock:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
{
/*
{
"consumer_data": {
"method":"supermarket_profile",
"action": "integration"
}
}
*/
NSMutableDictionary* consumerDataDictionary = [[NSMutableDictionary alloc] init];
[consumerDataDictionary setValue:@"supermarket_profile" forKey:@"method"];
[consumerDataDictionary setValue:@"integration" forKey:@"action"];
NSMutableDictionary* dataDictionary = [[NSMutableDictionary alloc] init];
[dataDictionary setValue:consumerDataDictionary forKey:@"consumer_data"];
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dataDictionary 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)"]) {
// NSString* errorDomain = [error domain];
// NSError *errorToken = [NSError errorWithDomain:errorDomain code:401 userInfo:dict];
//
// if (failure) {
// failure(errorToken);
// }
[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 );
}];
} else {
NSLog(@"Error at getMarketPassDetails %@", error );
failure(error);
}
}
}];
}
//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
{
......
......@@ -9384,4 +9384,228 @@ public class swiftApi {
}
}
/*
{
logo = "https://warply.s3.amazonaws.com/applications/f83dfde1145e4c2da69793abb2f579af/content/80717ec9eecf4b19adbf47bd2edd12e7/preview/masoutis.png";
name = "Masoutis ";
uuid = 80717ec9eecf4b19adbf47bd2edd12e7;
}
*/
public class SupermarketModel {
private var logo: String?
private var name: String?
private var uuid: String?
public init() {
self.logo = ""
self.name = ""
self.uuid = ""
}
public init(dictionary: [String: Any]) {
self.logo = dictionary["logo"] as? String? ?? ""
self.name = dictionary["name"] as? String? ?? ""
self.uuid = dictionary["uuid"] as? String? ?? ""
}
public var _logo: String {
get { // getter
return self.logo ?? ""
}
set(newValue) { //setter
self.logo = newValue
}
}
public var _name: String {
get { // getter
return self.name ?? ""
}
set(newValue) { //setter
self.name = newValue
}
}
public var _uuid: String {
get { // getter
return self.uuid ?? ""
}
set(newValue) { //setter
self.uuid = newValue
}
}
}
/*
{
barcode = 0070000008337;
"new_offers" = 3;
supermarkets =
(
{
logo = "https://warply.s3.amazonaws.com/applications/f83dfde1145e4c2da69793abb2f579af/content/80717ec9eecf4b19adbf47bd2edd12e7/preview/masoutis.png";
name = "Masoutis ";
uuid = 80717ec9eecf4b19adbf47bd2edd12e7;
},
{
logo = "https://warply.s3.amazonaws.com/applications/f83dfde1145e4c2da69793abb2f579af/content/45d284ff3f824c80af1390d33f699bbd/preview/ab.png";
name = "\U0391\U0392 Supermarket ";
uuid = 45d284ff3f824c80af1390d33f699bbd;
}
);
"total_available_discount" = "25.75";
}
*/
public class MarketPassDetailsModel {
private var barcode: String?
private var new_offers: Int?
private var total_available_discount: Float?
private var supermarkets: Array<SupermarketModel>?
public init() {
self.barcode = ""
self.new_offers = 0
self.total_available_discount = 0.0
self.supermarkets = []
}
public init(dictionary: [String: Any]) {
self.barcode = dictionary["barcode"] as? String? ?? ""
self.new_offers = dictionary["new_offers"] as? Int? ?? 0
// self.total_available_discount = dictionary["total_available_discount"] as? Float? ?? 0.0
if let float_discount = dictionary["total_available_discount"] as? Float {
self.total_available_discount = float_discount
}
else if let double_discount = dictionary["total_available_discount"] as? Double {
self.total_available_discount = Float(double_discount)
}
else if let string_discount = dictionary["total_available_discount"] as? String {
self.total_available_discount = Float(string_discount) ?? 0.0
}
else {
self.total_available_discount = 0.0
}
if let supermarketsData = dictionary["supermarkets"] as? [[String : Any]?] {
var supermarketsArray:Array<SupermarketModel> = []
for item in supermarketsData {
if let itemDictionary = item {
let tempCoupon = SupermarketModel(dictionary: itemDictionary)
supermarketsArray.append(tempCoupon)
}
}
self.supermarkets = supermarketsArray
} else {
self.supermarkets = []
}
}
public var _barcode: String {
get { // getter
return self.barcode ?? ""
}
set(newValue) { //setter
self.barcode = newValue
}
}
public var _new_offers: Int {
get { // getter
return self.new_offers ?? 0
}
set(newValue) { //setter
self.new_offers = newValue
}
}
public var _total_available_discount: Float {
get { // getter
return self.total_available_discount ?? 0.0
}
set(newValue) { //setter
self.total_available_discount = newValue
}
}
public var _supermarkets: Array<SupermarketModel> {
get { // getter
return self.supermarkets ?? []
}
set(newValue) { //setter
self.supermarkets = newValue
}
}
}
public func getMarketPassDetailsAsync(_ successCallback: @escaping (_ responseData: MarketPassDetailsModel?) -> Void, failureCallback: @escaping (_ errorCode: Int) -> Void) -> Void {
let instanceOfMyApi = MyApi()
instanceOfMyApi.getMarketPassDetailsAsync(requestCallback, failureBlock: requestFailureCallback)
func requestCallback(_ responseData: [AnyHashable: Any]?) -> Void {
if let responseDataDictionary = responseData as? [String: AnyObject] {
if (responseDataDictionary["status"] as? Int == 1) {
let dynatraceEvent = swiftApi.LoyaltySDKDynatraceEventModel()
dynatraceEvent._eventName = "custom_success_market_pass_details"
dynatraceEvent._parameters = nil
SwiftEventBus.post("dynatrace", sender: dynatraceEvent)
if let responseDataResult = responseDataDictionary["result"] as? [String : Any] {
let tempMarketPassDetails = MarketPassDetailsModel(dictionary: responseDataResult)
successCallback(tempMarketPassDetails)
} else {
successCallback(nil)
}
} else {
let dynatraceEvent = swiftApi.LoyaltySDKDynatraceEventModel()
dynatraceEvent._eventName = "custom_error_market_pass_details"
dynatraceEvent._parameters = nil
SwiftEventBus.post("dynatrace", sender: dynatraceEvent)
successCallback(nil)
}
} else {
let dynatraceEvent = swiftApi.LoyaltySDKDynatraceEventModel()
dynatraceEvent._eventName = "custom_error_market_pass_details"
dynatraceEvent._parameters = nil
SwiftEventBus.post("dynatrace", sender: dynatraceEvent)
successCallback(nil)
}
}
func requestFailureCallback(_ error: Error?) -> Void {
print("getMarketPassDetailsAsync error: ")
print(error)
print("====================")
let dynatraceEvent = swiftApi.LoyaltySDKDynatraceEventModel()
dynatraceEvent._eventName = "custom_error_market_pass_details"
dynatraceEvent._parameters = nil
SwiftEventBus.post("dynatrace", sender: dynatraceEvent)
// successCallback(nil)
if let error = error as? NSError {
// if (error.code == 401) {
// let sessionEvent = swiftApi.LoyaltySDKSessionExpiredEventModel()
// sessionEvent._sessionExpired = true
// SwiftEventBus.post("sdk_session_expired", sender: sessionEvent)
// }
failureCallback(error.code)
} else {
failureCallback(-1)
}
}
}
}
......