Manos Chorianopoulos

market History fixes v2

......@@ -125,22 +125,22 @@ extension AnalysisItemViewCell {
// COUPON: coupon, expiration, discount, status
// MERCHANT: _img_preview,_admin_name
// let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList()
let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList()
// let couponSetData: swiftApi.CouponSetItemModel? = item.couponset_data
//
// titleLabel.text = ""
//
// for merchant in merchantList {
// if (merchant._uuid == couponSetData?.merchant_uuid) {
// // itemImage.load(link: merchant._img_preview, placeholder: UIImage(), cache: URLCache())
// self.postImageURL = merchant._img_preview
// titleLabel.text = merchant._admin_name
// break;
// }
// }
titleLabel.text = item.name
self.postImageURL = item.image
titleLabel.text = ""
for merchant in merchantList {
if (merchant._uuid == item.merchant_uuid) {
// itemImage.load(link: merchant._img_preview, placeholder: UIImage(), cache: URLCache())
self.postImageURL = merchant._img_preview
titleLabel.text = merchant._admin_name
break;
}
}
// titleLabel.text = item.name
// self.postImageURL = item.image
dateLabel.text = item.redeemed ?? ""
......
......@@ -40,7 +40,7 @@ class MarketSharingHistoryViewController: AnalysisChildViewController {
showLoading()
swiftApi().getSharingHistoryAsync(responseCallback, failureCallback: {errorCode in })
swiftApi().getSharingHistoryAsync(isMarketHistory: true, getSharingHistoryCallback: responseCallback, failureCallback: {errorCode in })
}
private func showLoading() {
......
......@@ -99,6 +99,7 @@
- (void)getCampaignsAsyncNew:(NSString*)language :(NSDictionary*)filters :(void (^)(NSDictionary *response))success failureBlock:(void (^)(NSError *error))failure;
- (void)getCampaignsPersonalizedAsync:(NSString*)language :(NSDictionary*)filters :(void (^)(NSDictionary *response))success failureBlock:(void (^)(NSError *error))failure;
- (void)getSharingHistoryAsync:(void (^)(NSDictionary *response))success failureBlock:(void (^)(NSError *error))failure;
- (void)getMarketSharingHistoryAsync:(void (^)(NSDictionary *response))success failureBlock:(void (^)(NSError *error))failure;
- (void)getMultilingualMerchantsAsync:(NSArray*)categories andDefaultShown:(NSNumber*)defaultShown andCenter:(NSNumber*)center andTags:(NSArray*)tags andUuid:(NSString*)uuid andDistance:(NSNumber*)distance parent_uuids:(NSArray*)parent_uuids :(void (^)(NSDictionary *response))success failureBlock:(void (^)(NSError *error))failure;
// - (void)didReceiveNotification:(NSDictionary *)userInfo whileAppWasInState:(WLApplicationState)state;
- (void)didReceiveNotification:(NSDictionary *)payload;
......
......@@ -1690,6 +1690,19 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify";
}];
}
- (void)getMarketSharingHistoryAsync:(void (^)(NSDictionary *response))success failureBlock:(void (^)(NSError *error))failure
{
[[Warply sharedService] getMarketSharingHistoryWithSuccessBlock:^(NSDictionary *response) {
if (success) {
success(response);
}
} failureBlock:^(NSError *error) {
if (failure) {
failure(error);
}
}];
}
- (void)getMultilingualMerchantsAsync:(NSArray*)categories andDefaultShown:(NSNumber*)defaultShown andCenter:(NSNumber*)center andTags:(NSArray*)tags andUuid:(NSString*)uuid andDistance:(NSNumber*)distance parent_uuids:(NSArray*)parent_uuids :(void (^)(NSDictionary *response))success failureBlock:(void (^)(NSError *error))failure {
[[Warply sharedService] retrieveMultilingualMerchantsWithCategoriesWithSuccessBlock:categories andDefaultShown:defaultShown andCenter:center andTags:tags andUuid:uuid andDistance:distance parent_uuids:parent_uuids :^(NSDictionary *response) {
......
......@@ -40,7 +40,7 @@ class SharingHistoryViewController: AnalysisChildViewController {
showLoading()
swiftApi().getSharingHistoryAsync(responseCallback, failureCallback: {errorCode in })
swiftApi().getSharingHistoryAsync(isMarketHistory: false, getSharingHistoryCallback: responseCallback, failureCallback: {errorCode in })
}
private func showLoading() {
......
......@@ -377,6 +377,8 @@ WL_VERSION_INTERFACE()
- (void)getSharingHistoryWithSuccessBlock:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)getMarketSharingHistoryWithSuccessBlock:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)verifyTicketWithSuccessBlock:(NSString*)guid :(NSString*)ticket :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)getCosmoteUserWithSuccessBlock:(NSString*)guid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
......
......@@ -2720,7 +2720,58 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
- (void)getSharingHistoryWithSuccessBlock:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
{
NSDictionary *postDictionary = @{@"coupon": @{@"action": @"sharing_history"}};
NSDictionary *postDictionary = @{@"coupon": @{@"action": @"sharing_history", @"exclude": @[ @{ @"field": @"couponset_type", @"value": @[@"supermarket"] } ]}};
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)"]) {
// 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 get Sharing History %@", error );
failure(error);
}
}
}];
}
- (void)getMarketSharingHistoryWithSuccessBlock:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
{
NSDictionary *postDictionary = @{@"coupon": @{@"action": @"sharing_history", @"couponset_types": @[@"supermarket"]}};
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:postDictionary options:0 error:NULL];
[self sendContext8:jsonData successBlock:^(NSDictionary *contextResponse) {
if (success) {
......@@ -3251,6 +3302,7 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
if (uuids && [uuids count] > 0) {
[data setValue:uuids forKey:@"uuids"];
}
[data setValue:@[ @{ @"field": @"couponset_type", @"value": @[@"supermarket"] } ] forKey:@"exclude"];
NSMutableDictionary* dataCoupons = [[NSMutableDictionary alloc] init];
[dataCoupons setValue:data forKey:@"coupon"];
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dataCoupons options:0 error:NULL];
......
......@@ -607,6 +607,11 @@ public class swiftApi {
public let redeemed: String?
public var couponset_data: CouponSetItemModel?
// Market Coupon
public let inner_text: String?
public let merchant_uuid: String?
public init(dictionary: [String: Any]) {
self.couponset_uuid = dictionary["couponset_uuid"] as? String? ?? ""
self.name = dictionary["name"] as? String? ?? ""
......@@ -618,6 +623,10 @@ public class swiftApi {
self.barcode = dictionary["barcode"] as? String? ?? ""
self.status = dictionary["status"] as? Int? ?? nil
// Market Coupon
self.inner_text = dictionary["inner_text"] as? String? ?? ""
self.merchant_uuid = dictionary["merchant_uuid"] as? String? ?? ""
if let couponSetData = dictionary["couponset_data"] as? [String: Any]? ?? ["":""] {
let tempCouponset = CouponSetItemModel(dictionary: couponSetData)
......@@ -5536,10 +5545,13 @@ public class swiftApi {
}
public func getSharingHistoryAsync(_ getSharingHistoryCallback: @escaping (_ sharingHistoryData: Array<SharingCouponModel>?) -> Void, failureCallback: @escaping (_ errorCode: Int) -> Void) -> Void {
public func getSharingHistoryAsync(isMarketHistory: Bool, getSharingHistoryCallback: @escaping (_ sharingHistoryData: Array<SharingCouponModel>?) -> Void, failureCallback: @escaping (_ errorCode: Int) -> Void) -> Void {
let instanceOfMyApi = MyApi()
if (isMarketHistory == true) {
instanceOfMyApi.getMarketSharingHistoryAsync(requestCallback, failureBlock: requestFailureCallback)
} else {
instanceOfMyApi.getSharingHistoryAsync(requestCallback, failureBlock: requestFailureCallback)
}
func requestCallback(_ sharingHistoryData: [AnyHashable: Any]?) -> Void {
var historyArray:Array<SharingCouponModel> = []
......