Manos Chorianopoulos

add set getMerchantList, refactor getCoupons

......@@ -23,6 +23,7 @@ public struct GlobalVariables {
static var dealsSum: Float = 0.0
static var seasonalList: Array<swiftApi.LoyaltyGiftsForYouPackage> = []
static var savedSteps: Int = 0
static var merchantList: Array<swiftApi.MerchantModel> = []
}
var timer: DispatchSourceTimer?
......@@ -500,7 +501,17 @@ public class swiftApi {
var couponSetsArray:Array<CouponSetItemModel> = []
let instanceOfMyApi = MyApi()
instanceOfMyApi.getCouponsWithSuccessBlock(couponsCallback, failureBlock: (couponsFailureCallback))
swiftApi().getMultilingualMerchantsAsync([], false, 0.0, [], "", 0, [], getMerchantsCallback)
func getMerchantsCallback (_ merchantsData: Array<swiftApi.MerchantModel>?) -> Void {
if (merchantsData != nil) {
DispatchQueue.main.async {
swiftApi().setMerchantList(merchantsData ?? [])
instanceOfMyApi.getCouponsWithSuccessBlock(couponsCallback, failureBlock: (couponsFailureCallback))
}
} else {
}
}
func couponsCallback(_ couponsData: [AnyHashable : Any]?) -> Void {
coupons = couponsData ?? ["":""]
......@@ -4632,5 +4643,15 @@ public class swiftApi {
// }
}
public func setMerchantList(_ merchants: Array<MerchantModel>) {
GlobalVariables.merchantList = merchants
}
public func getMerchantList() -> Array<MerchantModel> {
return GlobalVariables.merchantList
}
}
......