Showing
2 changed files
with
57 additions
and
17 deletions
... | @@ -33,6 +33,8 @@ import SwiftEventBus | ... | @@ -33,6 +33,8 @@ import SwiftEventBus |
33 | 33 | ||
34 | public var couponset: swiftApi.CouponSetItemModel? | 34 | public var couponset: swiftApi.CouponSetItemModel? |
35 | public var campaign: swiftApi.CampaignItemModel? | 35 | public var campaign: swiftApi.CampaignItemModel? |
36 | + | ||
37 | + let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList() | ||
36 | 38 | ||
37 | let spinner = SpinnerViewController() | 39 | let spinner = SpinnerViewController() |
38 | 40 | ||
... | @@ -214,7 +216,8 @@ import SwiftEventBus | ... | @@ -214,7 +216,8 @@ import SwiftEventBus |
214 | redeemButton.isEnabled = false | 216 | redeemButton.isEnabled = false |
215 | 217 | ||
216 | if (ccms == nil) { | 218 | if (ccms == nil) { |
217 | - swiftApi().redeemCouponSetAsync(uuid: uuid, communication_uuid: communication_uuid, redeemCouponSetCallback, failureCallback: {errorCode in | 219 | + // swiftApi().redeemCouponSetAsync(uuid: uuid, communication_uuid: communication_uuid, redeemCouponSetCallback, failureCallback: {errorCode in |
220 | + swiftApi().redeemCouponSetAsyncInternal(uuid: uuid, communication_uuid: communication_uuid, redeemCouponSetCallback, failureCallback: {errorCode in | ||
218 | self.hideSpinner() | 221 | self.hideSpinner() |
219 | self.redeemButton.isEnabled = true | 222 | self.redeemButton.isEnabled = true |
220 | 223 | ||
... | @@ -229,7 +232,8 @@ import SwiftEventBus | ... | @@ -229,7 +232,8 @@ import SwiftEventBus |
229 | }) | 232 | }) |
230 | } else { | 233 | } else { |
231 | // TODO: MAybe change user_msisdn: profile?._msisdn ?? "" | 234 | // TODO: MAybe change user_msisdn: profile?._msisdn ?? "" |
232 | - swiftApi().redeemCouponSetAsync(uuid: uuid, communication_uuid: communication_uuid, user_msisdn: profile?._msisdn ?? "", businessService: (ccms?._businessService ?? ""), offerName: (ccms?._offerName ?? ""), productType: (ccms?._productType ?? ""), provDuration: (ccms?._provDuration ?? ""), noOfRecurrance: (ccms?._noOfRecurrance ?? ""), price: (ccms?._price ?? ""), discount: (ccms?._discount ?? ""), voiceCategory: (ccms?._voiceCategory ?? ""), dataCategory: (ccms?._dataCategory ?? ""), minsValue: (ccms?._minsValue ?? ""), dataValue: (ccms?._dataValue ?? ""), provStepValueMins: (ccms?._provStepValueMins ?? ""), OfferAudienceLevel: (ccms?._offerAudienceLevel ?? ""), UACIOfferTrackingCode: (ccms?._uaciOfferTrackingCode ?? ""), OFFERCODE1: (ccms?._offerCode1 ?? ""), SCORE: (ccms?._score ?? ""), ZONE: (ccms?._zone ?? ""), WAVE: (ccms?._wave ?? ""), VALIDITY: (ccms?._validity ?? ""), TREATMENT_CODE: (ccms?._treatmentCode ?? ""), ccms_session_id: (ccms?._sessionId ?? ""), redeemCouponSetCallback, failureCallback: {errorCode in | 235 | + // swiftApi().redeemCouponSetAsync(uuid: uuid, communication_uuid: communication_uuid, user_msisdn: profile?._msisdn ?? "", businessService: (ccms?._businessService ?? ""), offerName: (ccms?._offerName ?? ""), productType: (ccms?._productType ?? ""), provDuration: (ccms?._provDuration ?? ""), noOfRecurrance: (ccms?._noOfRecurrance ?? ""), price: (ccms?._price ?? ""), discount: (ccms?._discount ?? ""), voiceCategory: (ccms?._voiceCategory ?? ""), dataCategory: (ccms?._dataCategory ?? ""), minsValue: (ccms?._minsValue ?? ""), dataValue: (ccms?._dataValue ?? ""), provStepValueMins: (ccms?._provStepValueMins ?? ""), OfferAudienceLevel: (ccms?._offerAudienceLevel ?? ""), UACIOfferTrackingCode: (ccms?._uaciOfferTrackingCode ?? ""), OFFERCODE1: (ccms?._offerCode1 ?? ""), SCORE: (ccms?._score ?? ""), ZONE: (ccms?._zone ?? ""), WAVE: (ccms?._wave ?? ""), VALIDITY: (ccms?._validity ?? ""), TREATMENT_CODE: (ccms?._treatmentCode ?? ""), ccms_session_id: (ccms?._sessionId ?? ""), redeemCouponSetCallback, failureCallback: {errorCode in |
236 | + swiftApi().redeemCouponSetAsyncInternal(uuid: uuid, communication_uuid: communication_uuid, user_msisdn: profile?._msisdn ?? "", businessService: (ccms?._businessService ?? ""), offerName: (ccms?._offerName ?? ""), productType: (ccms?._productType ?? ""), provDuration: (ccms?._provDuration ?? ""), noOfRecurrance: (ccms?._noOfRecurrance ?? ""), price: (ccms?._price ?? ""), discount: (ccms?._discount ?? ""), voiceCategory: (ccms?._voiceCategory ?? ""), dataCategory: (ccms?._dataCategory ?? ""), minsValue: (ccms?._minsValue ?? ""), dataValue: (ccms?._dataValue ?? ""), provStepValueMins: (ccms?._provStepValueMins ?? ""), OfferAudienceLevel: (ccms?._offerAudienceLevel ?? ""), UACIOfferTrackingCode: (ccms?._uaciOfferTrackingCode ?? ""), OFFERCODE1: (ccms?._offerCode1 ?? ""), SCORE: (ccms?._score ?? ""), ZONE: (ccms?._zone ?? ""), WAVE: (ccms?._wave ?? ""), VALIDITY: (ccms?._validity ?? ""), TREATMENT_CODE: (ccms?._treatmentCode ?? ""), ccms_session_id: (ccms?._sessionId ?? ""), redeemCouponSetCallback, failureCallback: {errorCode in | ||
233 | self.hideSpinner() | 237 | self.hideSpinner() |
234 | self.redeemButton.isEnabled = true | 238 | self.redeemButton.isEnabled = true |
235 | 239 | ||
... | @@ -245,7 +249,8 @@ import SwiftEventBus | ... | @@ -245,7 +249,8 @@ import SwiftEventBus |
245 | } | 249 | } |
246 | } | 250 | } |
247 | 251 | ||
248 | - func redeemCouponSetCallback (_ response: swiftApi.GenericResponseModel?) -> Void { | 252 | + // func redeemCouponSetCallback (_ response: swiftApi.GenericResponseModel?) -> Void { |
253 | + func redeemCouponSetCallback (_ response: swiftApi.RedeemCouponSetResponseModel?) -> Void { | ||
249 | hideSpinner() | 254 | hideSpinner() |
250 | self.redeemButton.isEnabled = true | 255 | self.redeemButton.isEnabled = true |
251 | 256 | ||
... | @@ -267,27 +272,62 @@ import SwiftEventBus | ... | @@ -267,27 +272,62 @@ import SwiftEventBus |
267 | 272 | ||
268 | self.showSuccessDialog("Επιτυχής ενεργοποίηση","Το κουπόνι σου έχει ενεργοποιηθεί και βρίσκεται στην ενότητα My Rewards.") | 273 | self.showSuccessDialog("Επιτυχής ενεργοποίηση","Το κουπόνι σου έχει ενεργοποιηθεί και βρίσκεται στην ενότητα My Rewards.") |
269 | 274 | ||
270 | - swiftApi().getCouponsAsync(getCouponsCallback, failureCallback: {errorCode in }) | 275 | + /* OLD Addition start */ |
271 | - swiftApi().getCampaignsAsyncNew(language: "en", filters: [String : Any](), getCampaignsCallback, failureCallback: {errorCode in }) | 276 | +// swiftApi().getCouponsAsync(getCouponsCallback, failureCallback: {errorCode in }) |
277 | +// swiftApi().getCampaignsAsyncNew(language: "en", filters: [String : Any](), getCampaignsCallback, failureCallback: {errorCode in }) | ||
278 | +// | ||
279 | +// func getCouponsCallback (_ couponsData: Array<swiftApi.CouponItemModel>?) -> Void { | ||
280 | +// if (couponsData != nil) { | ||
281 | +// | ||
282 | +// DispatchQueue.main.async { | ||
283 | +// SwiftEventBus.post("coupons_fetched") | ||
284 | +// } | ||
285 | +// } else { | ||
286 | +// } | ||
287 | +// } | ||
288 | +// | ||
289 | +// func getCampaignsCallback (_ campaignsData: Array<swiftApi.CampaignItemModel>?) -> Void { | ||
290 | +// if (campaignsData != nil) { | ||
291 | +// DispatchQueue.main.async { | ||
292 | +// SwiftEventBus.post("campaigns_retrieved") | ||
293 | +// } | ||
294 | +// } else { | ||
295 | +// } | ||
296 | +// } | ||
297 | + /* OLD Addition end */ | ||
272 | 298 | ||
273 | - func getCouponsCallback (_ couponsData: Array<swiftApi.CouponItemModel>?) -> Void { | 299 | + /* New Addition start */ |
274 | - if (couponsData != nil) { | 300 | + if let newCoupon = response?.getCoupon { |
301 | + newCoupon.status = 1 | ||
302 | + | ||
303 | + if let couponsetData = self.couponset { | ||
304 | + newCoupon.setCouponSetData(couponsetData) | ||
275 | 305 | ||
276 | - DispatchQueue.main.async { | 306 | + for merchant in self.merchantList { |
277 | - SwiftEventBus.post("coupons_fetched") | 307 | + if (merchant._uuid == couponsetData.merchant_uuid) { |
308 | + newCoupon.merchant_details = merchant | ||
309 | + break; | ||
310 | + } | ||
278 | } | 311 | } |
279 | - } else { | ||
280 | } | 312 | } |
281 | - } | 313 | + |
282 | - | 314 | + swiftApi().addCouponItem(newCoupon: newCoupon) |
283 | - func getCampaignsCallback (_ campaignsData: Array<swiftApi.CampaignItemModel>?) -> Void { | 315 | + SwiftEventBus.post("coupons_fetched") |
284 | - if (campaignsData != nil) { | 316 | + |
285 | - DispatchQueue.main.async { | 317 | + if let tempCampaign = self.campaign { |
286 | - SwiftEventBus.post("campaigns_retrieved") | 318 | + swiftApi().removeCampaignItem(campaignArg: tempCampaign) |
319 | + swiftApi().getCampaignsAsyncNewInternal(getCampaignsCallback, failureCallback: {errorCode in}) | ||
320 | + } | ||
321 | + | ||
322 | + func getCampaignsCallback (_ campaignsData: Array<swiftApi.CampaignItemModel>?) -> Void { | ||
323 | + if (campaignsData != nil) { | ||
324 | + DispatchQueue.main.async { | ||
325 | + SwiftEventBus.post("campaigns_retrieved") | ||
326 | + } | ||
287 | } | 327 | } |
288 | - } else { | ||
289 | } | 328 | } |
290 | } | 329 | } |
330 | + /* New Addition end */ | ||
291 | 331 | ||
292 | } else if (response?.getStatus == 3) { | 332 | } else if (response?.getStatus == 3) { |
293 | let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel() | 333 | let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel() | ... | ... |
This diff is collapsed. Click to expand it.
-
Please register or login to post a comment