Manos Chorianopoulos

redeemCouponSet optimizations

......@@ -33,6 +33,8 @@ import SwiftEventBus
public var couponset: swiftApi.CouponSetItemModel?
public var campaign: swiftApi.CampaignItemModel?
let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList()
let spinner = SpinnerViewController()
......@@ -214,7 +216,8 @@ import SwiftEventBus
redeemButton.isEnabled = false
if (ccms == nil) {
swiftApi().redeemCouponSetAsync(uuid: uuid, communication_uuid: communication_uuid, redeemCouponSetCallback, failureCallback: {errorCode in
// swiftApi().redeemCouponSetAsync(uuid: uuid, communication_uuid: communication_uuid, redeemCouponSetCallback, failureCallback: {errorCode in
swiftApi().redeemCouponSetAsyncInternal(uuid: uuid, communication_uuid: communication_uuid, redeemCouponSetCallback, failureCallback: {errorCode in
self.hideSpinner()
self.redeemButton.isEnabled = true
......@@ -229,7 +232,8 @@ import SwiftEventBus
})
} else {
// TODO: MAybe change user_msisdn: profile?._msisdn ?? ""
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
// 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
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
self.hideSpinner()
self.redeemButton.isEnabled = true
......@@ -245,7 +249,8 @@ import SwiftEventBus
}
}
func redeemCouponSetCallback (_ response: swiftApi.GenericResponseModel?) -> Void {
// func redeemCouponSetCallback (_ response: swiftApi.GenericResponseModel?) -> Void {
func redeemCouponSetCallback (_ response: swiftApi.RedeemCouponSetResponseModel?) -> Void {
hideSpinner()
self.redeemButton.isEnabled = true
......@@ -267,27 +272,62 @@ import SwiftEventBus
self.showSuccessDialog("Επιτυχής ενεργοποίηση","Το κουπόνι σου έχει ενεργοποιηθεί και βρίσκεται στην ενότητα My Rewards.")
swiftApi().getCouponsAsync(getCouponsCallback, failureCallback: {errorCode in })
swiftApi().getCampaignsAsyncNew(language: "en", filters: [String : Any](), getCampaignsCallback, failureCallback: {errorCode in })
/* OLD Addition start */
// swiftApi().getCouponsAsync(getCouponsCallback, failureCallback: {errorCode in })
// swiftApi().getCampaignsAsyncNew(language: "en", filters: [String : Any](), getCampaignsCallback, failureCallback: {errorCode in })
//
// func getCouponsCallback (_ couponsData: Array<swiftApi.CouponItemModel>?) -> Void {
// if (couponsData != nil) {
//
// DispatchQueue.main.async {
// SwiftEventBus.post("coupons_fetched")
// }
// } else {
// }
// }
//
// func getCampaignsCallback (_ campaignsData: Array<swiftApi.CampaignItemModel>?) -> Void {
// if (campaignsData != nil) {
// DispatchQueue.main.async {
// SwiftEventBus.post("campaigns_retrieved")
// }
// } else {
// }
// }
/* OLD Addition end */
func getCouponsCallback (_ couponsData: Array<swiftApi.CouponItemModel>?) -> Void {
if (couponsData != nil) {
/* New Addition start */
if let newCoupon = response?.getCoupon {
newCoupon.status = 1
if let couponsetData = self.couponset {
newCoupon.setCouponSetData(couponsetData)
DispatchQueue.main.async {
SwiftEventBus.post("coupons_fetched")
for merchant in self.merchantList {
if (merchant._uuid == couponsetData.merchant_uuid) {
newCoupon.merchant_details = merchant
break;
}
}
} else {
}
}
func getCampaignsCallback (_ campaignsData: Array<swiftApi.CampaignItemModel>?) -> Void {
if (campaignsData != nil) {
DispatchQueue.main.async {
SwiftEventBus.post("campaigns_retrieved")
swiftApi().addCouponItem(newCoupon: newCoupon)
SwiftEventBus.post("coupons_fetched")
if let tempCampaign = self.campaign {
swiftApi().removeCampaignItem(campaignArg: tempCampaign)
swiftApi().getCampaignsAsyncNewInternal(getCampaignsCallback, failureCallback: {errorCode in})
}
func getCampaignsCallback (_ campaignsData: Array<swiftApi.CampaignItemModel>?) -> Void {
if (campaignsData != nil) {
DispatchQueue.main.async {
SwiftEventBus.post("campaigns_retrieved")
}
}
} else {
}
}
/* New Addition end */
} else if (response?.getStatus == 3) {
let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
......