Showing
8 changed files
with
100 additions
and
20 deletions
... | @@ -125,22 +125,22 @@ extension AnalysisItemViewCell { | ... | @@ -125,22 +125,22 @@ extension AnalysisItemViewCell { |
125 | // COUPON: coupon, expiration, discount, status | 125 | // COUPON: coupon, expiration, discount, status |
126 | // MERCHANT: _img_preview,_admin_name | 126 | // MERCHANT: _img_preview,_admin_name |
127 | 127 | ||
128 | -// let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList() | 128 | + let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList() |
129 | // let couponSetData: swiftApi.CouponSetItemModel? = item.couponset_data | 129 | // let couponSetData: swiftApi.CouponSetItemModel? = item.couponset_data |
130 | -// | 130 | + |
131 | -// titleLabel.text = "" | 131 | + titleLabel.text = "" |
132 | -// | 132 | + |
133 | -// for merchant in merchantList { | 133 | + for merchant in merchantList { |
134 | -// if (merchant._uuid == couponSetData?.merchant_uuid) { | 134 | + if (merchant._uuid == item.merchant_uuid) { |
135 | -// // itemImage.load(link: merchant._img_preview, placeholder: UIImage(), cache: URLCache()) | 135 | + // itemImage.load(link: merchant._img_preview, placeholder: UIImage(), cache: URLCache()) |
136 | -// self.postImageURL = merchant._img_preview | 136 | + self.postImageURL = merchant._img_preview |
137 | -// titleLabel.text = merchant._admin_name | 137 | + titleLabel.text = merchant._admin_name |
138 | -// break; | 138 | + break; |
139 | -// } | 139 | + } |
140 | -// } | 140 | + } |
141 | - | 141 | + |
142 | - titleLabel.text = item.name | 142 | +// titleLabel.text = item.name |
143 | - self.postImageURL = item.image | 143 | +// self.postImageURL = item.image |
144 | 144 | ||
145 | dateLabel.text = item.redeemed ?? "" | 145 | dateLabel.text = item.redeemed ?? "" |
146 | 146 | ... | ... |
... | @@ -40,7 +40,7 @@ class MarketSharingHistoryViewController: AnalysisChildViewController { | ... | @@ -40,7 +40,7 @@ class MarketSharingHistoryViewController: AnalysisChildViewController { |
40 | 40 | ||
41 | showLoading() | 41 | showLoading() |
42 | 42 | ||
43 | - swiftApi().getSharingHistoryAsync(responseCallback, failureCallback: {errorCode in }) | 43 | + swiftApi().getSharingHistoryAsync(isMarketHistory: true, getSharingHistoryCallback: responseCallback, failureCallback: {errorCode in }) |
44 | } | 44 | } |
45 | 45 | ||
46 | private func showLoading() { | 46 | private func showLoading() { | ... | ... |
... | @@ -99,6 +99,7 @@ | ... | @@ -99,6 +99,7 @@ |
99 | - (void)getCampaignsAsyncNew:(NSString*)language :(NSDictionary*)filters :(void (^)(NSDictionary *response))success failureBlock:(void (^)(NSError *error))failure; | 99 | - (void)getCampaignsAsyncNew:(NSString*)language :(NSDictionary*)filters :(void (^)(NSDictionary *response))success failureBlock:(void (^)(NSError *error))failure; |
100 | - (void)getCampaignsPersonalizedAsync:(NSString*)language :(NSDictionary*)filters :(void (^)(NSDictionary *response))success failureBlock:(void (^)(NSError *error))failure; | 100 | - (void)getCampaignsPersonalizedAsync:(NSString*)language :(NSDictionary*)filters :(void (^)(NSDictionary *response))success failureBlock:(void (^)(NSError *error))failure; |
101 | - (void)getSharingHistoryAsync:(void (^)(NSDictionary *response))success failureBlock:(void (^)(NSError *error))failure; | 101 | - (void)getSharingHistoryAsync:(void (^)(NSDictionary *response))success failureBlock:(void (^)(NSError *error))failure; |
102 | +- (void)getMarketSharingHistoryAsync:(void (^)(NSDictionary *response))success failureBlock:(void (^)(NSError *error))failure; | ||
102 | - (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; | 103 | - (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; |
103 | // - (void)didReceiveNotification:(NSDictionary *)userInfo whileAppWasInState:(WLApplicationState)state; | 104 | // - (void)didReceiveNotification:(NSDictionary *)userInfo whileAppWasInState:(WLApplicationState)state; |
104 | - (void)didReceiveNotification:(NSDictionary *)payload; | 105 | - (void)didReceiveNotification:(NSDictionary *)payload; | ... | ... |
... | @@ -1690,6 +1690,19 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify"; | ... | @@ -1690,6 +1690,19 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify"; |
1690 | }]; | 1690 | }]; |
1691 | } | 1691 | } |
1692 | 1692 | ||
1693 | +- (void)getMarketSharingHistoryAsync:(void (^)(NSDictionary *response))success failureBlock:(void (^)(NSError *error))failure | ||
1694 | +{ | ||
1695 | + [[Warply sharedService] getMarketSharingHistoryWithSuccessBlock:^(NSDictionary *response) { | ||
1696 | + if (success) { | ||
1697 | + success(response); | ||
1698 | + } | ||
1699 | + } failureBlock:^(NSError *error) { | ||
1700 | + if (failure) { | ||
1701 | + failure(error); | ||
1702 | + } | ||
1703 | + }]; | ||
1704 | +} | ||
1705 | + | ||
1693 | - (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 { | 1706 | - (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 { |
1694 | 1707 | ||
1695 | [[Warply sharedService] retrieveMultilingualMerchantsWithCategoriesWithSuccessBlock:categories andDefaultShown:defaultShown andCenter:center andTags:tags andUuid:uuid andDistance:distance parent_uuids:parent_uuids :^(NSDictionary *response) { | 1708 | [[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 { | ... | @@ -40,7 +40,7 @@ class SharingHistoryViewController: AnalysisChildViewController { |
40 | 40 | ||
41 | showLoading() | 41 | showLoading() |
42 | 42 | ||
43 | - swiftApi().getSharingHistoryAsync(responseCallback, failureCallback: {errorCode in }) | 43 | + swiftApi().getSharingHistoryAsync(isMarketHistory: false, getSharingHistoryCallback: responseCallback, failureCallback: {errorCode in }) |
44 | } | 44 | } |
45 | 45 | ||
46 | private func showLoading() { | 46 | private func showLoading() { | ... | ... |
... | @@ -377,6 +377,8 @@ WL_VERSION_INTERFACE() | ... | @@ -377,6 +377,8 @@ WL_VERSION_INTERFACE() |
377 | 377 | ||
378 | - (void)getSharingHistoryWithSuccessBlock:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | 378 | - (void)getSharingHistoryWithSuccessBlock:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; |
379 | 379 | ||
380 | +- (void)getMarketSharingHistoryWithSuccessBlock:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | ||
381 | + | ||
380 | - (void)verifyTicketWithSuccessBlock:(NSString*)guid :(NSString*)ticket :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | 382 | - (void)verifyTicketWithSuccessBlock:(NSString*)guid :(NSString*)ticket :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; |
381 | 383 | ||
382 | - (void)getCosmoteUserWithSuccessBlock:(NSString*)guid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | 384 | - (void)getCosmoteUserWithSuccessBlock:(NSString*)guid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | ... | ... |
... | @@ -2720,7 +2720,58 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -2720,7 +2720,58 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
2720 | 2720 | ||
2721 | - (void)getSharingHistoryWithSuccessBlock:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure | 2721 | - (void)getSharingHistoryWithSuccessBlock:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure |
2722 | { | 2722 | { |
2723 | - NSDictionary *postDictionary = @{@"coupon": @{@"action": @"sharing_history"}}; | 2723 | + NSDictionary *postDictionary = @{@"coupon": @{@"action": @"sharing_history", @"exclude": @[ @{ @"field": @"couponset_type", @"value": @[@"supermarket"] } ]}}; |
2724 | + NSData *jsonData = [NSJSONSerialization dataWithJSONObject:postDictionary options:0 error:NULL]; | ||
2725 | + [self sendContext8:jsonData successBlock:^(NSDictionary *contextResponse) { | ||
2726 | + if (success) { | ||
2727 | + success(contextResponse); | ||
2728 | + } | ||
2729 | + NSLog(@"**************** WARPLY Response *****************" ); | ||
2730 | + NSLog(@"%@", contextResponse ); | ||
2731 | + } failureBlock:^(NSError *error) { | ||
2732 | + if (failure) { | ||
2733 | + NSDictionary* dict = [NSDictionary alloc]; | ||
2734 | + dict = [error userInfo]; | ||
2735 | + NSString* errorCode = [dict objectForKey:@"NSLocalizedDescription"]; | ||
2736 | + if ([errorCode isEqual:@"Request failed: unauthorized (401)"]) { | ||
2737 | + | ||
2738 | +// NSString* errorDomain = [error domain]; | ||
2739 | +// NSError *errorToken = [NSError errorWithDomain:errorDomain code:401 userInfo:dict]; | ||
2740 | +// | ||
2741 | +// if (failure) { | ||
2742 | +// failure(errorToken); | ||
2743 | +// } | ||
2744 | + | ||
2745 | + [self refreshToken:^(NSDictionary *response) { | ||
2746 | + [self sendContext8:jsonData successBlock:^(NSDictionary *contextResponse) { | ||
2747 | + if (success) { | ||
2748 | + success(contextResponse); | ||
2749 | + } | ||
2750 | + NSLog(@"**************** WARPLY Response *****************" ); | ||
2751 | + NSLog(@"%@", contextResponse ); | ||
2752 | + } failureBlock:^(NSError *error) { | ||
2753 | + if (failure) { | ||
2754 | + failure(error); | ||
2755 | + } | ||
2756 | + }]; | ||
2757 | + } failureBlock:^(NSError *error) { | ||
2758 | + if (failure) { | ||
2759 | + // [_db executeUpdate:@"DROP TABLE requestVariables"]; | ||
2760 | + failure(error); | ||
2761 | + } | ||
2762 | + NSLog(@"Error at token %@", error ); | ||
2763 | + }]; | ||
2764 | + } else { | ||
2765 | + NSLog(@"Error at get Sharing History %@", error ); | ||
2766 | + failure(error); | ||
2767 | + } | ||
2768 | + } | ||
2769 | + }]; | ||
2770 | +} | ||
2771 | + | ||
2772 | +- (void)getMarketSharingHistoryWithSuccessBlock:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure | ||
2773 | +{ | ||
2774 | + NSDictionary *postDictionary = @{@"coupon": @{@"action": @"sharing_history", @"couponset_types": @[@"supermarket"]}}; | ||
2724 | NSData *jsonData = [NSJSONSerialization dataWithJSONObject:postDictionary options:0 error:NULL]; | 2775 | NSData *jsonData = [NSJSONSerialization dataWithJSONObject:postDictionary options:0 error:NULL]; |
2725 | [self sendContext8:jsonData successBlock:^(NSDictionary *contextResponse) { | 2776 | [self sendContext8:jsonData successBlock:^(NSDictionary *contextResponse) { |
2726 | if (success) { | 2777 | if (success) { |
... | @@ -3251,6 +3302,7 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -3251,6 +3302,7 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
3251 | if (uuids && [uuids count] > 0) { | 3302 | if (uuids && [uuids count] > 0) { |
3252 | [data setValue:uuids forKey:@"uuids"]; | 3303 | [data setValue:uuids forKey:@"uuids"]; |
3253 | } | 3304 | } |
3305 | + [data setValue:@[ @{ @"field": @"couponset_type", @"value": @[@"supermarket"] } ] forKey:@"exclude"]; | ||
3254 | NSMutableDictionary* dataCoupons = [[NSMutableDictionary alloc] init]; | 3306 | NSMutableDictionary* dataCoupons = [[NSMutableDictionary alloc] init]; |
3255 | [dataCoupons setValue:data forKey:@"coupon"]; | 3307 | [dataCoupons setValue:data forKey:@"coupon"]; |
3256 | NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dataCoupons options:0 error:NULL]; | 3308 | NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dataCoupons options:0 error:NULL]; | ... | ... |
... | @@ -607,6 +607,11 @@ public class swiftApi { | ... | @@ -607,6 +607,11 @@ public class swiftApi { |
607 | public let redeemed: String? | 607 | public let redeemed: String? |
608 | public var couponset_data: CouponSetItemModel? | 608 | public var couponset_data: CouponSetItemModel? |
609 | 609 | ||
610 | + // Market Coupon | ||
611 | + public let inner_text: String? | ||
612 | + public let merchant_uuid: String? | ||
613 | + | ||
614 | + | ||
610 | public init(dictionary: [String: Any]) { | 615 | public init(dictionary: [String: Any]) { |
611 | self.couponset_uuid = dictionary["couponset_uuid"] as? String? ?? "" | 616 | self.couponset_uuid = dictionary["couponset_uuid"] as? String? ?? "" |
612 | self.name = dictionary["name"] as? String? ?? "" | 617 | self.name = dictionary["name"] as? String? ?? "" |
... | @@ -618,6 +623,10 @@ public class swiftApi { | ... | @@ -618,6 +623,10 @@ public class swiftApi { |
618 | self.barcode = dictionary["barcode"] as? String? ?? "" | 623 | self.barcode = dictionary["barcode"] as? String? ?? "" |
619 | self.status = dictionary["status"] as? Int? ?? nil | 624 | self.status = dictionary["status"] as? Int? ?? nil |
620 | 625 | ||
626 | + // Market Coupon | ||
627 | + self.inner_text = dictionary["inner_text"] as? String? ?? "" | ||
628 | + self.merchant_uuid = dictionary["merchant_uuid"] as? String? ?? "" | ||
629 | + | ||
621 | if let couponSetData = dictionary["couponset_data"] as? [String: Any]? ?? ["":""] { | 630 | if let couponSetData = dictionary["couponset_data"] as? [String: Any]? ?? ["":""] { |
622 | 631 | ||
623 | let tempCouponset = CouponSetItemModel(dictionary: couponSetData) | 632 | let tempCouponset = CouponSetItemModel(dictionary: couponSetData) |
... | @@ -5536,10 +5545,13 @@ public class swiftApi { | ... | @@ -5536,10 +5545,13 @@ public class swiftApi { |
5536 | } | 5545 | } |
5537 | 5546 | ||
5538 | 5547 | ||
5539 | - public func getSharingHistoryAsync(_ getSharingHistoryCallback: @escaping (_ sharingHistoryData: Array<SharingCouponModel>?) -> Void, failureCallback: @escaping (_ errorCode: Int) -> Void) -> Void { | 5548 | + public func getSharingHistoryAsync(isMarketHistory: Bool, getSharingHistoryCallback: @escaping (_ sharingHistoryData: Array<SharingCouponModel>?) -> Void, failureCallback: @escaping (_ errorCode: Int) -> Void) -> Void { |
5540 | let instanceOfMyApi = MyApi() | 5549 | let instanceOfMyApi = MyApi() |
5550 | + if (isMarketHistory == true) { | ||
5551 | + instanceOfMyApi.getMarketSharingHistoryAsync(requestCallback, failureBlock: requestFailureCallback) | ||
5552 | + } else { | ||
5541 | instanceOfMyApi.getSharingHistoryAsync(requestCallback, failureBlock: requestFailureCallback) | 5553 | instanceOfMyApi.getSharingHistoryAsync(requestCallback, failureBlock: requestFailureCallback) |
5542 | - | 5554 | + } |
5543 | 5555 | ||
5544 | func requestCallback(_ sharingHistoryData: [AnyHashable: Any]?) -> Void { | 5556 | func requestCallback(_ sharingHistoryData: [AnyHashable: Any]?) -> Void { |
5545 | var historyArray:Array<SharingCouponModel> = [] | 5557 | var historyArray:Array<SharingCouponModel> = [] | ... | ... |
-
Please register or login to post a comment