Manos Chorianopoulos

add failureCallbacks, sdk_session_expired events

...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
7 <key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key> 7 <key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key>
8 <dict> 8 <dict>
9 <key>orderHint</key> 9 <key>orderHint</key>
10 - <integer>0</integer> 10 + <integer>1</integer>
11 </dict> 11 </dict>
12 </dict> 12 </dict>
13 </dict> 13 </dict>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
7 <key>SwiftWarplyFramework.xcscheme_^#shared#^_</key> 7 <key>SwiftWarplyFramework.xcscheme_^#shared#^_</key>
8 <dict> 8 <dict>
9 <key>orderHint</key> 9 <key>orderHint</key>
10 - <integer>1</integer> 10 + <integer>0</integer>
11 </dict> 11 </dict>
12 </dict> 12 </dict>
13 </dict> 13 </dict>
......
...@@ -44,7 +44,7 @@ var timer2: DispatchSourceTimer? ...@@ -44,7 +44,7 @@ var timer2: DispatchSourceTimer?
44 dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss" 44 dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
45 let dateString = dateFormatter.string(from: currentDateTime) 45 let dateString = dateFormatter.string(from: currentDateTime)
46 46
47 - swiftApi().setPacingDetailsAsync(persistedSteps, dateString, setPacingDetailsAsyncCallback) 47 + swiftApi().setPacingDetailsAsync(persistedSteps, dateString, setPacingDetailsAsyncCallback, failureCallback: {errorCode in })
48 } 48 }
49 49
50 func setPacingDetailsAsyncCallback (_ responseData: swiftApi.GenericResponseModel?) -> Void { 50 func setPacingDetailsAsyncCallback (_ responseData: swiftApi.GenericResponseModel?) -> Void {
...@@ -161,12 +161,12 @@ var timer2: DispatchSourceTimer? ...@@ -161,12 +161,12 @@ var timer2: DispatchSourceTimer?
161 } else if (eventArray[1] == "addUserTag") { 161 } else if (eventArray[1] == "addUserTag") {
162 // SwiftEventBus.post("questionnaire", sender: questionnaireEvent) 162 // SwiftEventBus.post("questionnaire", sender: questionnaireEvent)
163 163
164 - swiftApi().getProfileAsync(getProfileCallback) 164 + swiftApi().getProfileAsync(getProfileCallback, failureCallback: {errorCode in })
165 165
166 func getProfileCallback (_ profileData: swiftApi.ProfileModel?) -> Void { 166 func getProfileCallback (_ profileData: swiftApi.ProfileModel?) -> Void {
167 if (profileData != nil) { 167 if (profileData != nil) {
168 DispatchQueue.main.async { 168 DispatchQueue.main.async {
169 - swiftApi().getCampaignsAsyncNew(language: "en", filters: [String : Any](), getCampaignsCallback) 169 + swiftApi().getCampaignsAsyncNew(language: "en", filters: [String : Any](), getCampaignsCallback, failureCallback: {errorCode in })
170 170
171 func getCampaignsCallback (_ campaignsData: Array<swiftApi.CampaignItemModel>?) -> Void { 171 func getCampaignsCallback (_ campaignsData: Array<swiftApi.CampaignItemModel>?) -> Void {
172 if (campaignsData != nil) { 172 if (campaignsData != nil) {
...@@ -197,8 +197,8 @@ var timer2: DispatchSourceTimer? ...@@ -197,8 +197,8 @@ var timer2: DispatchSourceTimer?
197 let couponEvent = swiftApi.CouponEventModel() 197 let couponEvent = swiftApi.CouponEventModel()
198 SwiftEventBus.post("coupon_retrieved", sender: couponEvent) 198 SwiftEventBus.post("coupon_retrieved", sender: couponEvent)
199 199
200 - swiftApi().getCouponsAsync(getCouponsCallback) 200 + swiftApi().getCouponsAsync(getCouponsCallback, failureCallback: {errorCode in })
201 - swiftApi().getCampaignsAsyncNew(language: "en", filters: [String : Any](), getCampaignsCallback) 201 + swiftApi().getCampaignsAsyncNew(language: "en", filters: [String : Any](), getCampaignsCallback, failureCallback: {errorCode in })
202 202
203 func getCouponsCallback (_ couponsData: Array<swiftApi.CouponItemModel>?) -> Void { 203 func getCouponsCallback (_ couponsData: Array<swiftApi.CouponItemModel>?) -> Void {
204 if (couponsData != nil) { 204 if (couponsData != nil) {
......
...@@ -158,7 +158,7 @@ import SwiftEventBus ...@@ -158,7 +158,7 @@ import SwiftEventBus
158 158
159 // MARK: - API CALLS 159 // MARK: - API CALLS
160 func getProfileRequest() { 160 func getProfileRequest() {
161 - swiftApi().getProfileAsync(getProfileCallback) 161 + swiftApi().getProfileAsync(getProfileCallback, failureCallback: {errorCode in })
162 } 162 }
163 163
164 func getProfileCallback (_ profileData: swiftApi.ProfileModel?) -> Void { 164 func getProfileCallback (_ profileData: swiftApi.ProfileModel?) -> Void {
...@@ -173,7 +173,16 @@ import SwiftEventBus ...@@ -173,7 +173,16 @@ import SwiftEventBus
173 func submitOrderRequest() { 173 func submitOrderRequest() {
174 swiftApi().submitOrderAsync(campaign_session_uuid: "", user_msisdn: self.selectedNumber, 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 ?? ""), 174 swiftApi().submitOrderAsync(campaign_session_uuid: "", user_msisdn: self.selectedNumber, 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 ?? ""),
175 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 ?? ""), notificationMessage: (ccms?._notificationMessage ?? ""), 175 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 ?? ""), notificationMessage: (ccms?._notificationMessage ?? ""),
176 - submitOrderCallback) 176 + submitOrderCallback, failureCallback: {errorCode in
177 + let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
178 + firebaseEvent._eventName = "loyalty_offer_activated"
179 + firebaseEvent.setParameter = ("name", (self.ccms?._title ?? ""))
180 + firebaseEvent.setParameter = ("type", "gift")
181 + firebaseEvent.setParameter = ("successful", "false")
182 + SwiftEventBus.post("firebase", sender: firebaseEvent)
183 +
184 + self.showDialog("Αποτυχία","Κάτι πήγε στραβά")
185 + })
177 } 186 }
178 187
179 func submitOrderCallback (_ response: swiftApi.GenericResponseModel?) -> Void { 188 func submitOrderCallback (_ response: swiftApi.GenericResponseModel?) -> Void {
......
...@@ -181,10 +181,32 @@ import SwiftEventBus ...@@ -181,10 +181,32 @@ import SwiftEventBus
181 showSpinner() 181 showSpinner()
182 182
183 if (ccms == nil) { 183 if (ccms == nil) {
184 - swiftApi().redeemCouponSetAsync(uuid: uuid, communication_uuid: communication_uuid, redeemCouponSetCallback) 184 + swiftApi().redeemCouponSetAsync(uuid: uuid, communication_uuid: communication_uuid, redeemCouponSetCallback, failureCallback: {errorCode in
185 + self.hideSpinner()
186 +
187 + let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
188 + firebaseEvent._eventName = "loyalty_offer_activated"
189 + firebaseEvent.setParameter = ("name", (self.couponset?.name ?? ""))
190 + firebaseEvent.setParameter = ("type", "coupon")
191 + firebaseEvent.setParameter = ("successful", "false")
192 + SwiftEventBus.post("firebase", sender: firebaseEvent)
193 +
194 + self.showDialog("Αποτυχία","Κάτι πήγε στραβά")
195 + })
185 } else { 196 } else {
186 // TODO: MAybe change user_msisdn: profile?._msisdn ?? "" 197 // TODO: MAybe change user_msisdn: profile?._msisdn ?? ""
187 - 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) 198 + 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
199 + self.hideSpinner()
200 +
201 + let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
202 + firebaseEvent._eventName = "loyalty_offer_activated"
203 + firebaseEvent.setParameter = ("name", (self.couponset?.name ?? ""))
204 + firebaseEvent.setParameter = ("type", "coupon")
205 + firebaseEvent.setParameter = ("successful", "false")
206 + SwiftEventBus.post("firebase", sender: firebaseEvent)
207 +
208 + self.showDialog("Αποτυχία","Κάτι πήγε στραβά")
209 + })
188 } 210 }
189 } 211 }
190 212
...@@ -209,8 +231,8 @@ import SwiftEventBus ...@@ -209,8 +231,8 @@ import SwiftEventBus
209 231
210 self.showSuccessDialog("Επιτυχής ενεργοποίηση","Το κουπόνι σου έχει ενεργοποιηθεί στην ενότητα My Rewards.") 232 self.showSuccessDialog("Επιτυχής ενεργοποίηση","Το κουπόνι σου έχει ενεργοποιηθεί στην ενότητα My Rewards.")
211 233
212 - swiftApi().getCouponsAsync(getCouponsCallback) 234 + swiftApi().getCouponsAsync(getCouponsCallback, failureCallback: {errorCode in })
213 - swiftApi().getCampaignsAsyncNew(language: "en", filters: [String : Any](), getCampaignsCallback) 235 + swiftApi().getCampaignsAsyncNew(language: "en", filters: [String : Any](), getCampaignsCallback, failureCallback: {errorCode in })
214 236
215 func getCouponsCallback (_ couponsData: Array<swiftApi.CouponItemModel>?) -> Void { 237 func getCouponsCallback (_ couponsData: Array<swiftApi.CouponItemModel>?) -> Void {
216 if (couponsData != nil) { 238 if (couponsData != nil) {
......
...@@ -49,7 +49,9 @@ import SwiftEventBus ...@@ -49,7 +49,9 @@ import SwiftEventBus
49 49
50 // MARK: - API Functions 50 // MARK: - API Functions
51 func getCouponsRequest() { 51 func getCouponsRequest() {
52 - swiftApi().getCouponsAsync(getCouponsCallback) 52 + swiftApi().getCouponsAsync(getCouponsCallback, failureCallback: {errorCode in
53 + self.coupons = []
54 + })
53 } 55 }
54 56
55 func getCouponsCallback (_ couponsData: Array<swiftApi.CouponItemModel>?) -> Void { 57 func getCouponsCallback (_ couponsData: Array<swiftApi.CouponItemModel>?) -> Void {
......
...@@ -254,7 +254,9 @@ import SwiftEventBus ...@@ -254,7 +254,9 @@ import SwiftEventBus
254 254
255 // MARK: - API Calls 255 // MARK: - API Calls
256 func getProfileRequest() { 256 func getProfileRequest() {
257 - swiftApi().getProfileAsync(getProfileCallback) 257 + swiftApi().getProfileAsync(getProfileCallback, failureCallback: {errorCode in
258 + print("========= getProfileRequest ERROR =========")
259 + })
258 } 260 }
259 261
260 func getProfileCallback (_ profileData: swiftApi.ProfileModel?) -> Void { 262 func getProfileCallback (_ profileData: swiftApi.ProfileModel?) -> Void {
...@@ -270,7 +272,9 @@ import SwiftEventBus ...@@ -270,7 +272,9 @@ import SwiftEventBus
270 } 272 }
271 273
272 func cosmoteCouponSharingRequest() { 274 func cosmoteCouponSharingRequest() {
273 - swiftApi().cosmoteCouponSharingAsync(coupon: coupon?.coupon ?? "", sender: selectedNumber, receiver: numberTextField.text ?? "", couponSharingCallback) 275 + swiftApi().cosmoteCouponSharingAsync(coupon: coupon?.coupon ?? "", sender: selectedNumber, receiver: numberTextField.text ?? "", couponSharingCallback, failureCallback: {errorCode in
276 + self.showDialog("Αποτυχία","Κάτι πήγε στραβά")
277 + })
274 } 278 }
275 279
276 func couponSharingCallback (_ response: swiftApi.GenericResponseModel?) -> Void { 280 func couponSharingCallback (_ response: swiftApi.GenericResponseModel?) -> Void {
...@@ -278,7 +282,7 @@ import SwiftEventBus ...@@ -278,7 +282,7 @@ import SwiftEventBus
278 DispatchQueue.main.async { 282 DispatchQueue.main.async {
279 if (response?.getStatus == 1) { 283 if (response?.getStatus == 1) {
280 284
281 - swiftApi().getCouponsAsync(getCouponsCallback) 285 + swiftApi().getCouponsAsync(getCouponsCallback, failureCallback: {errorCode in })
282 286
283 func getCouponsCallback (_ couponsData: Array<swiftApi.CouponItemModel>?) -> Void { 287 func getCouponsCallback (_ couponsData: Array<swiftApi.CouponItemModel>?) -> Void {
284 if (couponsData != nil) { 288 if (couponsData != nil) {
......
...@@ -40,7 +40,7 @@ class SharingHistoryViewController: AnalysisChildViewController { ...@@ -40,7 +40,7 @@ class SharingHistoryViewController: AnalysisChildViewController {
40 40
41 showLoading() 41 showLoading()
42 42
43 - swiftApi().getSharingHistoryAsync(responseCallback) 43 + swiftApi().getSharingHistoryAsync(responseCallback, failureCallback: {errorCode in })
44 } 44 }
45 45
46 private func showLoading() { 46 private func showLoading() {
......
...@@ -212,7 +212,7 @@ import SwiftEventBus ...@@ -212,7 +212,7 @@ import SwiftEventBus
212 212
213 // MARK: - API CALLS 213 // MARK: - API CALLS
214 func getProfileRequest() { 214 func getProfileRequest() {
215 - swiftApi().getProfileAsync(getProfileCallback) 215 + swiftApi().getProfileAsync(getProfileCallback, failureCallback: {errorCode in })
216 } 216 }
217 217
218 func getProfileCallback (_ profileData: swiftApi.ProfileModel?) -> Void { 218 func getProfileCallback (_ profileData: swiftApi.ProfileModel?) -> Void {
...@@ -227,7 +227,16 @@ import SwiftEventBus ...@@ -227,7 +227,16 @@ import SwiftEventBus
227 func submitOrderRequest() { 227 func submitOrderRequest() {
228 swiftApi().submitOrderAsync(campaign_session_uuid: (campaign?.session_uuid ?? ""), user_msisdn: self.selectedNumber, 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 ?? ""), 228 swiftApi().submitOrderAsync(campaign_session_uuid: (campaign?.session_uuid ?? ""), user_msisdn: self.selectedNumber, 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 ?? ""),
229 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 ?? ""), notificationMessage: (ccms?._notificationMessage ?? ""), 229 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 ?? ""), notificationMessage: (ccms?._notificationMessage ?? ""),
230 - submitOrderCallback) 230 + submitOrderCallback, failureCallback: {errorCode in
231 + let firebaseEvent = swiftApi.LoyaltySDKFirebaseEventModel()
232 + firebaseEvent._eventName = "loyalty_offer_activated"
233 + firebaseEvent.setParameter = ("name", (self.ccms?._title ?? ""))
234 + firebaseEvent.setParameter = ("type", "gift")
235 + firebaseEvent.setParameter = ("successful", "false")
236 + SwiftEventBus.post("firebase", sender: firebaseEvent)
237 +
238 + self.showDialog("Αποτυχία","Κάτι πήγε στραβά")
239 + })
231 } 240 }
232 241
233 func submitOrderCallback (_ response: swiftApi.GenericResponseModel?) -> Void { 242 func submitOrderCallback (_ response: swiftApi.GenericResponseModel?) -> Void {
......