Manos Chorianopoulos

add set getMerchantList, refactor getCoupons

...@@ -23,6 +23,7 @@ public struct GlobalVariables { ...@@ -23,6 +23,7 @@ public struct GlobalVariables {
23 static var dealsSum: Float = 0.0 23 static var dealsSum: Float = 0.0
24 static var seasonalList: Array<swiftApi.LoyaltyGiftsForYouPackage> = [] 24 static var seasonalList: Array<swiftApi.LoyaltyGiftsForYouPackage> = []
25 static var savedSteps: Int = 0 25 static var savedSteps: Int = 0
26 + static var merchantList: Array<swiftApi.MerchantModel> = []
26 } 27 }
27 28
28 var timer: DispatchSourceTimer? 29 var timer: DispatchSourceTimer?
...@@ -500,7 +501,17 @@ public class swiftApi { ...@@ -500,7 +501,17 @@ public class swiftApi {
500 var couponSetsArray:Array<CouponSetItemModel> = [] 501 var couponSetsArray:Array<CouponSetItemModel> = []
501 let instanceOfMyApi = MyApi() 502 let instanceOfMyApi = MyApi()
502 503
504 + swiftApi().getMultilingualMerchantsAsync([], false, 0.0, [], "", 0, [], getMerchantsCallback)
505 +
506 + func getMerchantsCallback (_ merchantsData: Array<swiftApi.MerchantModel>?) -> Void {
507 + if (merchantsData != nil) {
508 + DispatchQueue.main.async {
509 + swiftApi().setMerchantList(merchantsData ?? [])
503 instanceOfMyApi.getCouponsWithSuccessBlock(couponsCallback, failureBlock: (couponsFailureCallback)) 510 instanceOfMyApi.getCouponsWithSuccessBlock(couponsCallback, failureBlock: (couponsFailureCallback))
511 + }
512 + } else {
513 + }
514 + }
504 515
505 func couponsCallback(_ couponsData: [AnyHashable : Any]?) -> Void { 516 func couponsCallback(_ couponsData: [AnyHashable : Any]?) -> Void {
506 coupons = couponsData ?? ["":""] 517 coupons = couponsData ?? ["":""]
...@@ -4633,4 +4644,14 @@ public class swiftApi { ...@@ -4633,4 +4644,14 @@ public class swiftApi {
4633 } 4644 }
4634 4645
4635 4646
4647 + public func setMerchantList(_ merchants: Array<MerchantModel>) {
4648 + GlobalVariables.merchantList = merchants
4649 + }
4650 +
4651 +
4652 + public func getMerchantList() -> Array<MerchantModel> {
4653 + return GlobalVariables.merchantList
4654 + }
4655 +
4656 +
4636 } 4657 }
......