Dimitris Togias

add sharig history api call and view controller

...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
26 A07936792885EF9400064122 /* RESegmentedControl in Frameworks */ = {isa = PBXBuildFile; productRef = A07936782885EF9400064122 /* RESegmentedControl */; }; 26 A07936792885EF9400064122 /* RESegmentedControl in Frameworks */ = {isa = PBXBuildFile; productRef = A07936782885EF9400064122 /* RESegmentedControl */; };
27 A079367C2885F2F500064122 /* AnalysisHeaderViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A079367B2885F2F500064122 /* AnalysisHeaderViewCell.swift */; }; 27 A079367C2885F2F500064122 /* AnalysisHeaderViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A079367B2885F2F500064122 /* AnalysisHeaderViewCell.swift */; };
28 A079367E2885F60A00064122 /* AnalysisHeaderMessageViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A079367D2885F60A00064122 /* AnalysisHeaderMessageViewCell.swift */; }; 28 A079367E2885F60A00064122 /* AnalysisHeaderMessageViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A079367D2885F60A00064122 /* AnalysisHeaderMessageViewCell.swift */; };
29 + A09DBCAE2888BA8100DD50B0 /* SharingHistoryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A09DBCAD2888BA8100DD50B0 /* SharingHistoryViewController.swift */; };
29 E6A77853282933340045BBA8 /* SwiftWarplyFramework.docc in Sources */ = {isa = PBXBuildFile; fileRef = E6A77852282933340045BBA8 /* SwiftWarplyFramework.docc */; }; 30 E6A77853282933340045BBA8 /* SwiftWarplyFramework.docc in Sources */ = {isa = PBXBuildFile; fileRef = E6A77852282933340045BBA8 /* SwiftWarplyFramework.docc */; };
30 E6A77854282933340045BBA8 /* SwiftWarplyFramework.h in Headers */ = {isa = PBXBuildFile; fileRef = E6A77851282933340045BBA8 /* SwiftWarplyFramework.h */; settings = {ATTRIBUTES = (Public, ); }; }; 31 E6A77854282933340045BBA8 /* SwiftWarplyFramework.h in Headers */ = {isa = PBXBuildFile; fileRef = E6A77851282933340045BBA8 /* SwiftWarplyFramework.h */; settings = {ATTRIBUTES = (Public, ); }; };
31 E6A778DF282933E60045BBA8 /* WarplyReactMethods.m in Sources */ = {isa = PBXBuildFile; fileRef = E6A7785B282933E40045BBA8 /* WarplyReactMethods.m */; }; 32 E6A778DF282933E60045BBA8 /* WarplyReactMethods.m in Sources */ = {isa = PBXBuildFile; fileRef = E6A7785B282933E40045BBA8 /* WarplyReactMethods.m */; };
...@@ -170,6 +171,7 @@ ...@@ -170,6 +171,7 @@
170 A07936752885E9CC00064122 /* UIColorExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIColorExtensions.swift; sourceTree = "<group>"; }; 171 A07936752885E9CC00064122 /* UIColorExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIColorExtensions.swift; sourceTree = "<group>"; };
171 A079367B2885F2F500064122 /* AnalysisHeaderViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalysisHeaderViewCell.swift; sourceTree = "<group>"; }; 172 A079367B2885F2F500064122 /* AnalysisHeaderViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalysisHeaderViewCell.swift; sourceTree = "<group>"; };
172 A079367D2885F60A00064122 /* AnalysisHeaderMessageViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalysisHeaderMessageViewCell.swift; sourceTree = "<group>"; }; 173 A079367D2885F60A00064122 /* AnalysisHeaderMessageViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalysisHeaderMessageViewCell.swift; sourceTree = "<group>"; };
174 + A09DBCAD2888BA8100DD50B0 /* SharingHistoryViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SharingHistoryViewController.swift; sourceTree = "<group>"; };
173 A9B7BE01A4E812DE49866EF8 /* Pods-SwiftWarplyFramework.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftWarplyFramework.debug.xcconfig"; path = "Target Support Files/Pods-SwiftWarplyFramework/Pods-SwiftWarplyFramework.debug.xcconfig"; sourceTree = "<group>"; }; 175 A9B7BE01A4E812DE49866EF8 /* Pods-SwiftWarplyFramework.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftWarplyFramework.debug.xcconfig"; path = "Target Support Files/Pods-SwiftWarplyFramework/Pods-SwiftWarplyFramework.debug.xcconfig"; sourceTree = "<group>"; };
174 B9EB8A451EF0C5AD75094EEE /* Pods-SwiftWarplyFramework.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftWarplyFramework.release.xcconfig"; path = "Target Support Files/Pods-SwiftWarplyFramework/Pods-SwiftWarplyFramework.release.xcconfig"; sourceTree = "<group>"; }; 176 B9EB8A451EF0C5AD75094EEE /* Pods-SwiftWarplyFramework.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftWarplyFramework.release.xcconfig"; path = "Target Support Files/Pods-SwiftWarplyFramework/Pods-SwiftWarplyFramework.release.xcconfig"; sourceTree = "<group>"; };
175 C0D5F56DD4E5371A50AD2D87 /* Pods_SwiftWarplyFramework.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SwiftWarplyFramework.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 177 C0D5F56DD4E5371A50AD2D87 /* Pods_SwiftWarplyFramework.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SwiftWarplyFramework.framework; sourceTree = BUILT_PRODUCTS_DIR; };
...@@ -331,6 +333,7 @@ ...@@ -331,6 +333,7 @@
331 A079367A2885F2D100064122 /* cells */, 333 A079367A2885F2D100064122 /* cells */,
332 1EB5F4C9285370C90016F36E /* LoyaltyAnalysisViewController.swift */, 334 1EB5F4C9285370C90016F36E /* LoyaltyAnalysisViewController.swift */,
333 A079366D2885D07700064122 /* AnalysisChildViewController.swift */, 335 A079366D2885D07700064122 /* AnalysisChildViewController.swift */,
336 + A09DBCAD2888BA8100DD50B0 /* SharingHistoryViewController.swift */,
334 ); 337 );
335 name = analysis; 338 name = analysis;
336 sourceTree = "<group>"; 339 sourceTree = "<group>";
...@@ -837,6 +840,7 @@ ...@@ -837,6 +840,7 @@
837 E6A7794B282933E70045BBA8 /* FMDatabase.m in Sources */, 840 E6A7794B282933E70045BBA8 /* FMDatabase.m in Sources */,
838 E6A778EC282933E60045BBA8 /* WLNativeVideoTableViewCell.m in Sources */, 841 E6A778EC282933E60045BBA8 /* WLNativeVideoTableViewCell.m in Sources */,
839 E6A77954282933E70045BBA8 /* MyApi.m in Sources */, 842 E6A77954282933E70045BBA8 /* MyApi.m in Sources */,
843 + A09DBCAE2888BA8100DD50B0 /* SharingHistoryViewController.swift in Sources */,
840 E6A778F2282933E60045BBA8 /* WLNativeAdCollectionViewCell.m in Sources */, 844 E6A778F2282933E60045BBA8 /* WLNativeAdCollectionViewCell.m in Sources */,
841 E6A77904282933E60045BBA8 /* WLEvent.m in Sources */, 845 E6A77904282933E60045BBA8 /* WLEvent.m in Sources */,
842 E6A77927282933E70045BBA8 /* UIRefreshControl+AFNetworking.m in Sources */, 846 E6A77927282933E70045BBA8 /* UIRefreshControl+AFNetworking.m in Sources */,
......
...@@ -10,78 +10,4 @@ import UIKit ...@@ -10,78 +10,4 @@ import UIKit
10 class AnalysisChildViewController: UITableViewController { 10 class AnalysisChildViewController: UITableViewController {
11 11
12 public var index: Int = -1 12 public var index: Int = -1
13 - var items: Array<AnalysisItem> = Array()
14 -
15 - // TODO: remove this when configuring model
16 - let hasMessage = true
17 -
18 - // lifecycle
19 - override func viewDidLoad() {
20 -
21 - super.viewDidLoad()
22 -
23 - self.refreshControl = UIRefreshControl()
24 - self.refreshControl?.addTarget(self, action: #selector(handleRefresh(_:)), for: .valueChanged)
25 -
26 - loadData()
27 - }
28 -
29 - // mvp
30 - private func loadData() {
31 -
32 - self.items = Array()
33 - }
34 -
35 - private func showLoading() {
36 - }
37 -
38 - private func showError() {
39 - }
40 -
41 - private func showContent() {
42 - }
43 -
44 - // private
45 - @objc func handleRefresh(_ refreshControl: UIRefreshControl) {
46 -
47 - loadData()
48 - }
49 -
50 - // MARK: - Table view data source
51 - override func numberOfSections(in tableView: UITableView) -> Int {
52 - return 2
53 - }
54 -
55 - override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
56 - if (section == 0) {
57 - return 1;
58 - }
59 -
60 - return items.count
61 - }
62 -
63 - override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
64 - if (indexPath.section == 0) {
65 - return hasMessage ? 380.0 : 280
66 - }
67 -
68 - return 160.0
69 - }
70 -
71 - override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
72 -
73 - // header
74 - if (indexPath.section == 0) {
75 - if (hasMessage) {
76 - return tableView.dequeueReusableCell(withIdentifier: "AnalysisHeaderMessageViewCell", for: indexPath) as! AnalysisHeaderMessageViewCell
77 - }
78 -
79 - return tableView.dequeueReusableCell(withIdentifier: "AnalysisHeaderViewCell", for: indexPath) as! AnalysisHeaderViewCell
80 - }
81 -
82 - let cell = tableView.dequeueReusableCell(withIdentifier: "AnalysisItemViewCell", for: indexPath) as! AnalysisItemViewCell
83 - cell.configureCell(item: items[indexPath.row])
84 -
85 - return cell
86 - }
87 } 13 }
......
...@@ -34,17 +34,17 @@ class AnalysisItemViewCell: UITableViewCell { ...@@ -34,17 +34,17 @@ class AnalysisItemViewCell: UITableViewCell {
34 } 34 }
35 35
36 extension AnalysisItemViewCell { 36 extension AnalysisItemViewCell {
37 - func configureCell(item: AnalysisItem) { 37 + func configureCell(item: swiftApi.SharingCouponModel) {
38 38
39 // TODO: this is not optimal. we need a static date formatter. we cannot instantiate a new object each time we render a new item. 39 // TODO: this is not optimal. we need a static date formatter. we cannot instantiate a new object each time we render a new item.
40 let dateFormatter = DateFormatter() 40 let dateFormatter = DateFormatter()
41 dateFormatter.dateFormat = "dd-MM-yyyy" 41 dateFormatter.dateFormat = "dd-MM-yyyy"
42 42
43 - dateLabel.text = dateFormatter.string(from: item.date) 43 +// dateLabel.text = dateFormatter.string(from: item.date)
44 //itemImage.image = 44 //itemImage.image =
45 - titleLabel.text = item.title 45 +// titleLabel.text = item.name
46 - priceLabel.text = String(format: "%.2f€", item.price) 46 +// priceLabel.text = String(format: "%.2f€", item.discount)
47 - subtitleLabel.text = item.subtitle 47 +// subtitleLabel.text = item.subtitle
48 48
49 } 49 }
50 } 50 }
......
...@@ -29,7 +29,7 @@ import RESegmentedControl ...@@ -29,7 +29,7 @@ import RESegmentedControl
29 return titles.map({ SegmentModel(title: $0) }) 29 return titles.map({ SegmentModel(title: $0) })
30 } 30 }
31 31
32 - let preset = BootstapPreset(backgroundColor: .white, selectedBackgroundColor: .white, border) 32 + let preset = BootstapPreset(backgroundColor: .white, selectedBackgroundColor: .white)
33 tabView.configure(segmentItems: segmentItems, preset: preset) 33 tabView.configure(segmentItems: segmentItems, preset: preset)
34 34
35 // pages 35 // pages
...@@ -46,6 +46,13 @@ import RESegmentedControl ...@@ -46,6 +46,13 @@ import RESegmentedControl
46 //////////////////////////////////////////////////////////////////////////////// 46 ////////////////////////////////////////////////////////////////////////////////
47 private func viewControllerAt(_ index:Int) -> AnalysisChildViewController? 47 private func viewControllerAt(_ index:Int) -> AnalysisChildViewController?
48 { 48 {
49 + if (index == 1) {
50 + let analysisVC = SharingHistoryViewController()
51 + analysisVC.index = index;
52 +
53 + return analysisVC;
54 + }
55 +
49 let analysisVC = AnalysisChildViewController() 56 let analysisVC = AnalysisChildViewController()
50 analysisVC.index = index; 57 analysisVC.index = index;
51 58
......
...@@ -63,6 +63,7 @@ ...@@ -63,6 +63,7 @@
63 - (NSDictionary*) getCoupons; 63 - (NSDictionary*) getCoupons;
64 - (NSDictionary*) getTransactionHistory; 64 - (NSDictionary*) getTransactionHistory;
65 - (NSDictionary*) getPointsHistory; 65 - (NSDictionary*) getPointsHistory;
66 +- (NSDictionary*) getSharingHistory;
66 - (NSDictionary*)addAddress:(NSString*)friendlyName andAddressName:(NSString*)addressName andAddressNumber:(NSString*)addressNumber andPostalCode:(NSString*)postalCode andFloorNumber:(NSNumber*)floorNumber andDoorbell:(NSString*)doorbel andRegion:(NSString*)region andLatitude:(NSString*)latitude andLongitude:(NSString*)longitude andNotes:(NSString*)notes; 67 - (NSDictionary*)addAddress:(NSString*)friendlyName andAddressName:(NSString*)addressName andAddressNumber:(NSString*)addressNumber andPostalCode:(NSString*)postalCode andFloorNumber:(NSNumber*)floorNumber andDoorbell:(NSString*)doorbel andRegion:(NSString*)region andLatitude:(NSString*)latitude andLongitude:(NSString*)longitude andNotes:(NSString*)notes;
67 - (NSDictionary*)getAddress; 68 - (NSDictionary*)getAddress;
68 - (NSDictionary*)editAddress:(NSString*)friendlyName andAddressName:(NSString*)addressName andAddressNumber:(NSString*)addressNumber andPostalCode:(NSString*)postalCode andFloorNumber:(NSNumber*)floorNumber andDoorbell:(NSString*)doorbel andRegion:(NSString*)region andLatitude:(NSString*)latitude andLongitude:(NSString*)longitude andNotes:(NSString*)notes andUuid:(NSString*)uuid; 69 - (NSDictionary*)editAddress:(NSString*)friendlyName andAddressName:(NSString*)addressName andAddressNumber:(NSString*)addressNumber andPostalCode:(NSString*)postalCode andFloorNumber:(NSNumber*)floorNumber andDoorbell:(NSString*)doorbel andRegion:(NSString*)region andLatitude:(NSString*)latitude andLongitude:(NSString*)longitude andNotes:(NSString*)notes andUuid:(NSString*)uuid;
......
...@@ -940,6 +940,35 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify"; ...@@ -940,6 +940,35 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify";
940 return resp; 940 return resp;
941 } 941 }
942 942
943 +- (NSDictionary*) getSharingHistory
944 +{
945 + __block NSDictionary *resp = [NSDictionary alloc];
946 + __block BOOL isRunLoopNested = NO;
947 + __block BOOL isOperationCompleted = NO;
948 + [[Warply sharedService] getSharingHistoryWithSuccessBlock:^(NSDictionary *response) {
949 + resp = response;
950 + isOperationCompleted = YES;
951 + if (isRunLoopNested) {
952 + CFRunLoopStop(CFRunLoopGetCurrent()); // CFRunLoopRun() returns
953 + }
954 + } failureBlock:^(NSError *error) {
955 + NSLog(@"%@", error);
956 + resp = nil;
957 + isOperationCompleted = YES;
958 + if (isRunLoopNested) {
959 + CFRunLoopStop(CFRunLoopGetCurrent()); // CFRunLoopRun() returns
960 + }
961 + }];
962 + if ( ! isOperationCompleted) {
963 + isRunLoopNested = YES;
964 + NSLog(@"Waiting...");
965 + CFRunLoopRun(); // Magic!
966 + isRunLoopNested = NO;
967 + }
968 + return resp;
969 +}
970 +
971 +
943 - (NSDictionary*)addAddress:(NSString*)friendlyName andAddressName:(NSString*)addressName andAddressNumber:(NSString*)addressNumber andPostalCode:(NSString*)postalCode andFloorNumber:(NSNumber*)floorNumber andDoorbell:(NSString*)doorbel andRegion:(NSString*)region andLatitude:(NSString*)latitude andLongitude:(NSString*)longitude andNotes:(NSString*)notes { 972 - (NSDictionary*)addAddress:(NSString*)friendlyName andAddressName:(NSString*)addressName andAddressNumber:(NSString*)addressNumber andPostalCode:(NSString*)postalCode andFloorNumber:(NSNumber*)floorNumber andDoorbell:(NSString*)doorbel andRegion:(NSString*)region andLatitude:(NSString*)latitude andLongitude:(NSString*)longitude andNotes:(NSString*)notes {
944 __block NSDictionary *resp = [NSDictionary alloc]; 973 __block NSDictionary *resp = [NSDictionary alloc];
945 __block BOOL isRunLoopNested = NO; 974 __block BOOL isRunLoopNested = NO;
......
1 +//
2 +// SharingHistoryViewController.swift
3 +// SwiftWarplyFramework
4 +//
5 +// Created by Manos Chorianopoulos on 18/7/22.
6 +//
7 +
8 +import UIKit
9 +
10 +class SharingHistoryViewController: AnalysisChildViewController {
11 +
12 + var loading: Bool = false
13 + var items: Array<swiftApi.SharingCouponModel> = Array()
14 +
15 + // TODO: remove this when configuring model
16 + let hasMessage = true
17 +
18 + // lifecycle
19 + override func viewDidLoad() {
20 +
21 + super.viewDidLoad()
22 +
23 + self.refreshControl = UIRefreshControl()
24 + self.refreshControl?.addTarget(self, action: #selector(handleRefresh(_:)), for: .valueChanged)
25 +
26 + handleRefresh(self.refreshControl!)
27 + }
28 +
29 + // mvp
30 + @objc func load() {
31 +
32 + if (loading) {
33 + return;
34 + }
35 +
36 + showLoading()
37 + // TODO: Implement API call
38 + }
39 +
40 + private func showLoading() {
41 +
42 + loading = true
43 + if (self.refreshControl!.isRefreshing) {
44 + return;
45 + }
46 +
47 + self.refreshControl!.beginRefreshing()
48 + }
49 +
50 + private func showError() {
51 + }
52 +
53 + private func showContent() {
54 +
55 + loading = true
56 + self.refreshControl!.endRefreshing()
57 + }
58 +
59 + // private
60 + func responseCallback (_ data: Array<swiftApi.SharingCouponModel>?) -> Void {
61 +
62 + self.items = data!
63 + showContent()
64 + DispatchQueue.main.async {
65 + self.tableView.reloadData()
66 + }
67 + }
68 +
69 + @objc func handleRefresh(_ refreshControl: UIRefreshControl) {
70 +
71 + self.perform(_: #selector(load), with: nil, afterDelay: 0.5)
72 + }
73 +
74 + // MARK: - Table view data source
75 + override func numberOfSections(in tableView: UITableView) -> Int {
76 + return 2
77 + }
78 +
79 + override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
80 + if (section == 0) {
81 + return 1;
82 + }
83 +
84 + return items.count
85 + }
86 +
87 + override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
88 + if (indexPath.section == 0) {
89 + return hasMessage ? 380.0 : 280
90 + }
91 +
92 + return 160.0
93 + }
94 +
95 + override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
96 +
97 + // header
98 + if (indexPath.section == 0) {
99 + if (hasMessage) {
100 + return tableView.dequeueReusableCell(withIdentifier: "AnalysisHeaderMessageViewCell", for: indexPath) as! AnalysisHeaderMessageViewCell
101 + }
102 +
103 + return tableView.dequeueReusableCell(withIdentifier: "AnalysisHeaderViewCell", for: indexPath) as! AnalysisHeaderViewCell
104 + }
105 +
106 + let cell = tableView.dequeueReusableCell(withIdentifier: "AnalysisItemViewCell", for: indexPath) as! AnalysisItemViewCell
107 + cell.configureCell(item: items[indexPath.row])
108 +
109 + return cell
110 + }
111 +}
...@@ -352,6 +352,8 @@ WL_VERSION_INTERFACE() ...@@ -352,6 +352,8 @@ WL_VERSION_INTERFACE()
352 352
353 - (void)getPointsHistoryWithSuccessBlock:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; 353 - (void)getPointsHistoryWithSuccessBlock:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
354 354
355 +- (void)getSharingHistoryWithSuccessBlock:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
356 +
355 - (void)verifyTicketWithSuccessBlock:(NSString*)guid :(NSString*)ticket :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; 357 - (void)verifyTicketWithSuccessBlock:(NSString*)guid :(NSString*)ticket :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
356 358
357 - (void)getCosmoteUserWithSuccessBlock:(NSString*)guid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; 359 - (void)getCosmoteUserWithSuccessBlock:(NSString*)guid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
......
...@@ -1518,6 +1518,43 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) ...@@ -1518,6 +1518,43 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
1518 }]; 1518 }];
1519 } 1519 }
1520 1520
1521 +- (void)getSharingHistoryWithSuccessBlock:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
1522 +{
1523 + NSDictionary *postDictionary = @{@"coupon": @{@"action": @"sharing_history"}};
1524 + NSData *jsonData = [NSJSONSerialization dataWithJSONObject:postDictionary options:0 error:NULL];
1525 + [self sendContext8:jsonData successBlock:^(NSDictionary *contextResponse) {
1526 + if (success) {
1527 + success(contextResponse);
1528 + }
1529 + } failureBlock:^(NSError *error) {
1530 + if (failure) {
1531 + NSDictionary* dict = [NSDictionary alloc];
1532 + dict = [error userInfo];
1533 + NSString* errorCode = [dict objectForKey:@"NSLocalizedDescription"];
1534 + if ([errorCode isEqual:@"Request failed: unauthorized (401)"]) {
1535 + [self refreshToken:^(NSDictionary *response) {
1536 + [self sendContext8:jsonData successBlock:^(NSDictionary *contextResponse) {
1537 + if (success) {
1538 + success(contextResponse);
1539 + }
1540 + } failureBlock:^(NSError *error) {
1541 + if (failure) {
1542 + failure(error);
1543 + }
1544 + }];
1545 + } failureBlock:^(NSError *error) {
1546 + if (failure) {
1547 + [_db executeUpdate:@"DROP TABLE requestVariables"];
1548 + failure(error);
1549 + }
1550 + NSLog(@"Error at token %@", error );
1551 + }];
1552 + }
1553 + NSLog(@"Error at get points history %@", error );
1554 + }
1555 + }];
1556 +}
1557 +
1521 - (void)addAddressWithSuccessBlock:(NSString*)friendlyName :(NSString*)addressName :(NSString*)addressNumber :(NSString*)postalCode :(NSNumber*)floorNumber :(NSString*)doorbel :(NSString*)region :(NSString*)latitude :(NSString*)longitude :(NSString*)notes :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure 1558 - (void)addAddressWithSuccessBlock:(NSString*)friendlyName :(NSString*)addressName :(NSString*)addressNumber :(NSString*)postalCode :(NSNumber*)floorNumber :(NSString*)doorbel :(NSString*)region :(NSString*)latitude :(NSString*)longitude :(NSString*)notes :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
1522 { 1559 {
1523 NSDictionary *postDictionary = @{@"consumer_data" : @{@"action": @"handle_addresses_new", @"process": @"add", @"data": @{@"friendly_name": friendlyName,@"address_name": addressName, @"address_number": addressNumber, @"postal_code": postalCode, @"floor_number": floorNumber, @"doorbel": doorbel, @"region": region, @"latitude": latitude, @"longitude": longitude, @"notes": notes}}}; 1560 NSDictionary *postDictionary = @{@"consumer_data" : @{@"action": @"handle_addresses_new", @"process": @"add", @"data": @{@"friendly_name": friendlyName,@"address_name": addressName, @"address_number": addressNumber, @"postal_code": postalCode, @"floor_number": floorNumber, @"doorbel": doorbel, @"region": region, @"latitude": latitude, @"longitude": longitude, @"notes": notes}}};
......
...@@ -155,7 +155,6 @@ public class swiftApi { ...@@ -155,7 +155,6 @@ public class swiftApi {
155 return GlobalVariables.dfyCoupons 155 return GlobalVariables.dfyCoupons
156 } 156 }
157 157
158 -
159 public class CouponSetItemModel: Codable { 158 public class CouponSetItemModel: Codable {
160 public let uuid: String? 159 public let uuid: String?
161 public let admin_name: String? 160 public let admin_name: String?
...@@ -455,6 +454,24 @@ public class swiftApi { ...@@ -455,6 +454,24 @@ public class swiftApi {
455 454
456 } 455 }
457 456
457 + public class SharingCouponModel: Codable {
458 + public let transactionMetadata: String?
459 + public let sharingType: String?
460 + public let discount: String?
461 + public let date: String?
462 + public let couponsetUuid: String?
463 + public let name: String?
464 +
465 + public init(dictionary: [String: Any]) {
466 + self.transactionMetadata = dictionary["transaction_metadata"] as? String? ?? ""
467 + self.sharingType = dictionary["sharing_type"] as? String? ?? ""
468 + self.discount = dictionary["discount"] as? String? ?? ""
469 + self.date = dictionary["date"] as? String? ?? ""
470 + self.couponsetUuid = dictionary["couponsetUuid"] as? String? ?? ""
471 + self.name = dictionary["name"] as? String? ?? ""
472 + }
473 + }
474 +
458 475
459 public func filterActiveCoupons(_ coupons: Array<CouponItemModel>) -> Array<CouponItemModel> { 476 public func filterActiveCoupons(_ coupons: Array<CouponItemModel>) -> Array<CouponItemModel> {
460 return coupons.filter({ 477 return coupons.filter({
......