Panagiotis Triantafyllou

minor fixes and additions

...@@ -2,7 +2,7 @@ apply plugin: 'com.android.library' ...@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
2 2
3 ext { 3 ext {
4 PUBLISH_GROUP_ID = 'ly.warp' 4 PUBLISH_GROUP_ID = 'ly.warp'
5 - PUBLISH_VERSION = '4.5.4-cosbeta31i' 5 + PUBLISH_VERSION = '4.5.4-cosbeta32'
6 PUBLISH_ARTIFACT_ID = 'warply-android-sdk' 6 PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
7 } 7 }
8 8
......
...@@ -29,7 +29,9 @@ import ly.warp.sdk.io.models.CampaignList; ...@@ -29,7 +29,9 @@ import ly.warp.sdk.io.models.CampaignList;
29 import ly.warp.sdk.io.models.Consumer; 29 import ly.warp.sdk.io.models.Consumer;
30 import ly.warp.sdk.io.models.CouponList; 30 import ly.warp.sdk.io.models.CouponList;
31 import ly.warp.sdk.io.models.CouponsetsList; 31 import ly.warp.sdk.io.models.CouponsetsList;
32 +import ly.warp.sdk.io.models.NewCampaignList;
32 import ly.warp.sdk.io.request.WarplyConsumerRequest; 33 import ly.warp.sdk.io.request.WarplyConsumerRequest;
34 +import ly.warp.sdk.io.request.WarplyGetCampaignsRequest;
33 import ly.warp.sdk.io.request.WarplyGetCouponsetsRequest; 35 import ly.warp.sdk.io.request.WarplyGetCouponsetsRequest;
34 import ly.warp.sdk.io.request.WarplyInboxRequest; 36 import ly.warp.sdk.io.request.WarplyInboxRequest;
35 import ly.warp.sdk.io.request.WarplyUserCouponsRequest; 37 import ly.warp.sdk.io.request.WarplyUserCouponsRequest;
...@@ -69,6 +71,7 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation ...@@ -69,6 +71,7 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation
69 if (!Thread.currentThread().isInterrupted()) { 71 if (!Thread.currentThread().isInterrupted()) {
70 // WarplyManager.getConsumer(new WarplyConsumerRequest(), mConsumerReceiver); 72 // WarplyManager.getConsumer(new WarplyConsumerRequest(), mConsumerReceiver);
71 Warply.getInbox(new WarplyInboxRequest().setUseCache(false), mInboxReceiver); 73 Warply.getInbox(new WarplyInboxRequest().setUseCache(false), mInboxReceiver);
74 +// WarplyManager.getCampaigns(new WarplyGetCampaignsRequest().setLanguage("el"), mCampaignsCallback);
72 } 75 }
73 }).start(); 76 }).start();
74 } 77 }
...@@ -204,6 +207,18 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation ...@@ -204,6 +207,18 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation
204 } 207 }
205 }; 208 };
206 209
210 + private CallbackReceiver<NewCampaignList> mCampaignsCallback = new CallbackReceiver<NewCampaignList>() {
211 + @Override
212 + public void onSuccess(NewCampaignList result) {
213 + WarplyManager.getUserCouponsWithCouponsets(new WarplyUserCouponsRequest(), mUserCouponsReceiver);
214 + }
215 +
216 + @Override
217 + public void onFailure(int errorCode) {
218 + Thread.currentThread().interrupt();
219 + }
220 + };
221 +
207 222
208 private final CallbackReceiver<CouponList> mUserCouponsReceiver = new CallbackReceiver<CouponList>() { 223 private final CallbackReceiver<CouponList> mUserCouponsReceiver = new CallbackReceiver<CouponList>() {
209 @Override 224 @Override
......
...@@ -182,6 +182,7 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene ...@@ -182,6 +182,7 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene
182 if (extraFields.has("ccms_offer") && extraFields.optString("ccms_offer").equals("true")) { 182 if (extraFields.has("ccms_offer") && extraFields.optString("ccms_offer").equals("true")) {
183 for (LoyaltyContextualOfferModel ccms : WarplyManagerHelper.getCCMSLoyaltyCampaigns()) { 183 for (LoyaltyContextualOfferModel ccms : WarplyManagerHelper.getCCMSLoyaltyCampaigns()) {
184 if (ccms.getLoyaltyCampaignId().equals(dataItem.getCampaign().getSessionUUID())) { 184 if (ccms.getLoyaltyCampaignId().equals(dataItem.getCampaign().getSessionUUID())) {
185 + WarpUtils.log("CCMS_CLICK " + ccms.toString());
185 startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCcmsUrl(dataItem.getCampaign(), ccms))); 186 startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCcmsUrl(dataItem.getCampaign(), ccms)));
186 break; 187 break;
187 } 188 }
......
...@@ -73,30 +73,30 @@ public class Campaign implements Parcelable, Serializable { ...@@ -73,30 +73,30 @@ public class Campaign implements Parcelable, Serializable {
73 73
74 /* Member variables of the Campaign object */ 74 /* Member variables of the Campaign object */
75 75
76 - private final int action; 76 + private int action;
77 - private final double delivered; 77 + private double delivered;
78 private double expires; 78 private double expires;
79 - private final String message; 79 + private String message;
80 private String offerCategory; 80 private String offerCategory;
81 - private final String offerMessage; 81 + private String offerMessage;
82 - private final String sessionUUID; 82 + private String sessionUUID;
83 - private final double starts; 83 + private double starts;
84 - private final String subtitle; 84 + private String subtitle;
85 - private final String title; 85 + private String title;
86 - private final int sorting; 86 + private int sorting;
87 - private final int opened; 87 + private int opened;
88 private boolean isNew; 88 private boolean isNew;
89 - private final String logoUrl; 89 + private String logoUrl;
90 - private final String extraFields; 90 + private String extraFields;
91 - private final String type; 91 + private String type;
92 - private final boolean expired; 92 + private boolean expired;
93 private boolean show; 93 private boolean show;
94 private String deliveryMethod; 94 private String deliveryMethod;
95 private String displayType; 95 private String displayType;
96 private String indexUrl; 96 private String indexUrl;
97 private String busId; 97 private String busId;
98 private ArrayList<CampaignAction> actions = new ArrayList<>(); 98 private ArrayList<CampaignAction> actions = new ArrayList<>();
99 - private final String campaignTypeSettings; 99 + private String campaignTypeSettings;
100 100
101 /** 101 /**
102 * Basic constructor used to create an object from a String, representing a 102 * Basic constructor used to create an object from a String, representing a
...@@ -109,6 +109,33 @@ public class Campaign implements Parcelable, Serializable { ...@@ -109,6 +109,33 @@ public class Campaign implements Parcelable, Serializable {
109 this(new JSONObject(json)); 109 this(new JSONObject(json));
110 } 110 }
111 111
112 + public Campaign() {
113 + this.action = 0;
114 + this.delivered = 0.0d;
115 + this.expires = 0.0d;
116 + this.message = "";
117 + this.offerCategory = "";
118 + this.offerMessage = "";
119 + this.sessionUUID = "";
120 + this.starts = 0.0d;
121 + this.subtitle = "";
122 + this.title = "";
123 + this.sorting = 0;
124 + this.opened = 0;
125 + this.isNew = true;
126 + this.logoUrl = "";
127 + this.extraFields = "";
128 + this.type = "";
129 + this.expired = false;
130 + this.show = true;
131 + this.deliveryMethod = "";
132 + this.displayType = "";
133 + this.indexUrl = "";
134 + this.busId = "";
135 + this.actions = new ArrayList<>();
136 + this.campaignTypeSettings = "";
137 + }
138 +
112 /** 139 /**
113 * Constructor used to create an Object from a given JSON Object 140 * Constructor used to create an Object from a given JSON Object
114 * 141 *
...@@ -475,6 +502,94 @@ public class Campaign implements Parcelable, Serializable { ...@@ -475,6 +502,94 @@ public class Campaign implements Parcelable, Serializable {
475 return campaignTypeSettings; 502 return campaignTypeSettings;
476 } 503 }
477 504
505 + public void setExpires(double expires) {
506 + this.expires = expires;
507 + }
508 +
509 + public void setOfferCategory(String offerCategory) {
510 + this.offerCategory = offerCategory;
511 + }
512 +
513 + public void setShow(boolean show) {
514 + this.show = show;
515 + }
516 +
517 + public void setDeliveryMethod(String deliveryMethod) {
518 + this.deliveryMethod = deliveryMethod;
519 + }
520 +
521 + public void setDisplayType(String displayType) {
522 + this.displayType = displayType;
523 + }
524 +
525 + public void setIndexUrl(String indexUrl) {
526 + this.indexUrl = indexUrl;
527 + }
528 +
529 + public void setActions(ArrayList<CampaignAction> actions) {
530 + this.actions = actions;
531 + }
532 +
533 + public void setAction(int action) {
534 + this.action = action;
535 + }
536 +
537 + public void setDelivered(double delivered) {
538 + this.delivered = delivered;
539 + }
540 +
541 + public void setMessage(String message) {
542 + this.message = message;
543 + }
544 +
545 + public void setOfferMessage(String offerMessage) {
546 + this.offerMessage = offerMessage;
547 + }
548 +
549 + public void setSessionUUID(String sessionUUID) {
550 + this.sessionUUID = sessionUUID;
551 + }
552 +
553 + public void setStarts(double starts) {
554 + this.starts = starts;
555 + }
556 +
557 + public void setSubtitle(String subtitle) {
558 + this.subtitle = subtitle;
559 + }
560 +
561 + public void setTitle(String title) {
562 + this.title = title;
563 + }
564 +
565 + public void setSorting(int sorting) {
566 + this.sorting = sorting;
567 + }
568 +
569 + public void setOpened(int opened) {
570 + this.opened = opened;
571 + }
572 +
573 + public void setLogoUrl(String logoUrl) {
574 + this.logoUrl = logoUrl;
575 + }
576 +
577 + public void setExtraFields(String extraFields) {
578 + this.extraFields = extraFields;
579 + }
580 +
581 + public void setType(String type) {
582 + this.type = type;
583 + }
584 +
585 + public void setExpired(boolean expired) {
586 + this.expired = expired;
587 + }
588 +
589 + public void setCampaignTypeSettings(String campaignTypeSettings) {
590 + this.campaignTypeSettings = campaignTypeSettings;
591 + }
592 +
478 @Override 593 @Override
479 public int describeContents() { 594 public int describeContents() {
480 return 0; 595 return 0;
......
...@@ -69,12 +69,12 @@ public class NewCampaign implements Parcelable, Serializable { ...@@ -69,12 +69,12 @@ public class NewCampaign implements Parcelable, Serializable {
69 69
70 /* Member variables of the Campaign object */ 70 /* Member variables of the Campaign object */
71 private final String campaignType; 71 private final String campaignType;
72 - private final String settings; 72 + private JSONObject settings = new JSONObject();
73 private final String audience; 73 private final String audience;
74 private final String deliveryMethod; 74 private final String deliveryMethod;
75 private final String displayType; 75 private final String displayType;
76 - private final String extraFields; 76 + private JSONObject extraFields = new JSONObject();
77 - private final String workflowSettings; 77 + private JSONObject workflowSettings = new JSONObject();
78 private final String category; 78 private final String category;
79 private final int sorting; 79 private final int sorting;
80 private final String indexUrl; 80 private final String indexUrl;
...@@ -115,13 +115,13 @@ public class NewCampaign implements Parcelable, Serializable { ...@@ -115,13 +115,13 @@ public class NewCampaign implements Parcelable, Serializable {
115 this.category = json.optString(CATEGORY); 115 this.category = json.optString(CATEGORY);
116 this.title = json.optString(TITLE); 116 this.title = json.optString(TITLE);
117 this.sorting = json.optInt(SORTING); 117 this.sorting = json.optInt(SORTING);
118 - this.extraFields = json.optString(EXTRA_FIELDS); 118 + this.extraFields = json.optJSONObject(EXTRA_FIELDS);
119 this.campaignType = json.optString(CAMPAIGN_TYPE); 119 this.campaignType = json.optString(CAMPAIGN_TYPE);
120 this.deliveryMethod = json.optString(DELIVERY_METHOD); 120 this.deliveryMethod = json.optString(DELIVERY_METHOD);
121 this.displayType = json.optString(DISPLAY_TYPE); 121 this.displayType = json.optString(DISPLAY_TYPE);
122 - this.settings = json.optString(SETTINGS); 122 + this.settings = json.optJSONObject(SETTINGS);
123 this.audience = json.optString(AUDIENCE); 123 this.audience = json.optString(AUDIENCE);
124 - this.workflowSettings = json.optString(WORKFLOW_SETTINGS); 124 + this.workflowSettings = json.optJSONObject(WORKFLOW_SETTINGS);
125 this.description = json.optString(DESCRIPTION); 125 this.description = json.optString(DESCRIPTION);
126 this.startDate = json.optString(START_DATE); 126 this.startDate = json.optString(START_DATE);
127 this.endDate = json.optString(END_DATE); 127 this.endDate = json.optString(END_DATE);
...@@ -140,12 +140,12 @@ public class NewCampaign implements Parcelable, Serializable { ...@@ -140,12 +140,12 @@ public class NewCampaign implements Parcelable, Serializable {
140 this.sorting = source.readInt(); 140 this.sorting = source.readInt();
141 this.isNew = source.readByte() != 0; 141 this.isNew = source.readByte() != 0;
142 this.logoUrl = source.readString(); 142 this.logoUrl = source.readString();
143 - this.extraFields = source.readString(); 143 +// this.extraFields = source.readString();
144 this.deliveryMethod = source.readString(); 144 this.deliveryMethod = source.readString();
145 this.displayType = source.readString(); 145 this.displayType = source.readString();
146 - this.settings = source.readString(); 146 +// this.settings = source.readString();
147 this.audience = source.readString(); 147 this.audience = source.readString();
148 - this.workflowSettings = source.readString(); 148 +// this.workflowSettings = source.readString();
149 this.description = source.readString(); 149 this.description = source.readString();
150 this.startDate = source.readString(); 150 this.startDate = source.readString();
151 this.endDate = source.readString(); 151 this.endDate = source.readString();
...@@ -164,12 +164,12 @@ public class NewCampaign implements Parcelable, Serializable { ...@@ -164,12 +164,12 @@ public class NewCampaign implements Parcelable, Serializable {
164 dest.writeInt(this.sorting); 164 dest.writeInt(this.sorting);
165 dest.writeInt(this.isNew ? 1 : 0); 165 dest.writeInt(this.isNew ? 1 : 0);
166 dest.writeString(this.logoUrl); 166 dest.writeString(this.logoUrl);
167 - dest.writeString(extraFields); 167 +// dest.writeString(extraFields);
168 dest.writeString(deliveryMethod); 168 dest.writeString(deliveryMethod);
169 dest.writeString(displayType); 169 dest.writeString(displayType);
170 - dest.writeString(this.settings); 170 +// dest.writeString(this.settings);
171 dest.writeString(this.audience); 171 dest.writeString(this.audience);
172 - dest.writeString(this.workflowSettings); 172 +// dest.writeString(this.workflowSettings);
173 dest.writeString(this.description); 173 dest.writeString(this.description);
174 dest.writeString(this.startDate); 174 dest.writeString(this.startDate);
175 dest.writeString(this.endDate); 175 dest.writeString(this.endDate);
...@@ -295,10 +295,6 @@ public class NewCampaign implements Parcelable, Serializable { ...@@ -295,10 +295,6 @@ public class NewCampaign implements Parcelable, Serializable {
295 return indexUrl; 295 return indexUrl;
296 } 296 }
297 297
298 - public String getExtraFields() {
299 - return extraFields;
300 - }
301 -
302 public String getDeliveryMethod() { 298 public String getDeliveryMethod() {
303 return deliveryMethod; 299 return deliveryMethod;
304 } 300 }
...@@ -311,18 +307,10 @@ public class NewCampaign implements Parcelable, Serializable { ...@@ -311,18 +307,10 @@ public class NewCampaign implements Parcelable, Serializable {
311 return campaignType; 307 return campaignType;
312 } 308 }
313 309
314 - public String getSettings() {
315 - return settings;
316 - }
317 -
318 public String getAudience() { 310 public String getAudience() {
319 return audience; 311 return audience;
320 } 312 }
321 313
322 - public String getWorkflowSettings() {
323 - return workflowSettings;
324 - }
325 -
326 public String getCategory() { 314 public String getCategory() {
327 return category; 315 return category;
328 } 316 }
...@@ -355,6 +343,18 @@ public class NewCampaign implements Parcelable, Serializable { ...@@ -355,6 +343,18 @@ public class NewCampaign implements Parcelable, Serializable {
355 return isNew; 343 return isNew;
356 } 344 }
357 345
346 + public JSONObject getSettings() {
347 + return settings;
348 + }
349 +
350 + public JSONObject getExtraFields() {
351 + return extraFields;
352 + }
353 +
354 + public JSONObject getWorkflowSettings() {
355 + return workflowSettings;
356 + }
357 +
358 @Override 358 @Override
359 public int describeContents() { 359 public int describeContents() {
360 return 0; 360 return 0;
......
...@@ -28,6 +28,8 @@ package ly.warp.sdk.utils.managers; ...@@ -28,6 +28,8 @@ package ly.warp.sdk.utils.managers;
28 import org.json.JSONException; 28 import org.json.JSONException;
29 import org.json.JSONObject; 29 import org.json.JSONObject;
30 30
31 +import java.util.ArrayList;
32 +
31 import ly.warp.sdk.Warply; 33 import ly.warp.sdk.Warply;
32 import ly.warp.sdk.activities.BaseFragmentActivity; 34 import ly.warp.sdk.activities.BaseFragmentActivity;
33 import ly.warp.sdk.db.WarplyDBHelper; 35 import ly.warp.sdk.db.WarplyDBHelper;
...@@ -48,6 +50,8 @@ import ly.warp.sdk.io.callbacks.TagsCategoriesHook; ...@@ -48,6 +50,8 @@ import ly.warp.sdk.io.callbacks.TagsCategoriesHook;
48 import ly.warp.sdk.io.callbacks.TagsHook; 50 import ly.warp.sdk.io.callbacks.TagsHook;
49 import ly.warp.sdk.io.callbacks.TransactionsHook; 51 import ly.warp.sdk.io.callbacks.TransactionsHook;
50 import ly.warp.sdk.io.models.AddressList; 52 import ly.warp.sdk.io.models.AddressList;
53 +import ly.warp.sdk.io.models.Campaign;
54 +import ly.warp.sdk.io.models.CampaignList;
51 import ly.warp.sdk.io.models.Card; 55 import ly.warp.sdk.io.models.Card;
52 import ly.warp.sdk.io.models.CardList; 56 import ly.warp.sdk.io.models.CardList;
53 import ly.warp.sdk.io.models.Consumer; 57 import ly.warp.sdk.io.models.Consumer;
...@@ -58,6 +62,7 @@ import ly.warp.sdk.io.models.Couponset; ...@@ -58,6 +62,7 @@ import ly.warp.sdk.io.models.Couponset;
58 import ly.warp.sdk.io.models.CouponsetsList; 62 import ly.warp.sdk.io.models.CouponsetsList;
59 import ly.warp.sdk.io.models.MerchantCategoriesList; 63 import ly.warp.sdk.io.models.MerchantCategoriesList;
60 import ly.warp.sdk.io.models.MerchantList; 64 import ly.warp.sdk.io.models.MerchantList;
65 +import ly.warp.sdk.io.models.NewCampaign;
61 import ly.warp.sdk.io.models.NewCampaignList; 66 import ly.warp.sdk.io.models.NewCampaignList;
62 import ly.warp.sdk.io.models.PacingDetails; 67 import ly.warp.sdk.io.models.PacingDetails;
63 import ly.warp.sdk.io.models.PointsList; 68 import ly.warp.sdk.io.models.PointsList;
...@@ -118,6 +123,7 @@ import ly.warp.sdk.utils.constants.WarpConstants; ...@@ -118,6 +123,7 @@ import ly.warp.sdk.utils.constants.WarpConstants;
118 */ 123 */
119 124
120 public class WarplyManager { 125 public class WarplyManager {
126 + private static NewCampaignList mNewCampaignList = new NewCampaignList();
121 127
122 public static void getProducts(WarplyProductsRequest request, final CallbackReceiver<ProductList> receiver) { 128 public static void getProducts(WarplyProductsRequest request, final CallbackReceiver<ProductList> receiver) {
123 // String productCategory = ""; 129 // String productCategory = "";
...@@ -1318,38 +1324,97 @@ public class WarplyManager { ...@@ -1318,38 +1324,97 @@ public class WarplyManager {
1318 }); 1324 });
1319 } 1325 }
1320 1326
1321 - public static void getCampaigns(WarplyGetCampaignsRequest request, boolean auth, final CallbackReceiver<NewCampaignList> receiver) { 1327 + public static void getCampaigns(WarplyGetCampaignsRequest request, final CallbackReceiver<NewCampaignList> receiver) {
1328 + WarpUtils.log("************* WARPLY Get Campaigns Request ********************");
1329 + WarpUtils.log("[WARP Trace] WARPLY Get Campaigns Request is active");
1330 + WarpUtils.log("**************************************************");
1331 +
1332 + Warply.postReceiveMicroappData(WarpConstants.MICROAPP_NEW_CAMPAIGNS, false, "campaigns", request.toJson(), new NewCampaignsHook(new CallbackReceiver<NewCampaignList>() {
1333 + @Override
1334 + public void onSuccess(NewCampaignList result) {
1335 +// receiver.onSuccess(result);
1336 + mNewCampaignList.clear();
1337 + mNewCampaignList.addAll(result);
1338 + getCampaignsPersonalized(request, new CallbackReceiver<NewCampaignList>() {
1339 + @Override
1340 + public void onSuccess(NewCampaignList resultPersonalized) {
1341 + receiver.onSuccess(resultPersonalized);
1342 + }
1343 +
1344 + @Override
1345 + public void onFailure(int errorCode) {
1346 + receiver.onFailure(errorCode);
1347 + }
1348 + });
1349 + }
1350 +
1351 + @Override
1352 + public void onFailure(int errorCode) {
1353 + receiver.onFailure(errorCode);
1354 + }
1355 + },
1356 + request.getSignature()));
1357 + }
1358 +
1359 + public static void getCampaignsPersonalized(WarplyGetCampaignsRequest request, final CallbackReceiver<NewCampaignList> receiver) {
1322 WarpUtils.log("************* WARPLY Get Campaigns Request ********************"); 1360 WarpUtils.log("************* WARPLY Get Campaigns Request ********************");
1323 WarpUtils.log("[WARP Trace] WARPLY Get Campaigns Request is active"); 1361 WarpUtils.log("[WARP Trace] WARPLY Get Campaigns Request is active");
1324 WarpUtils.log("**************************************************"); 1362 WarpUtils.log("**************************************************");
1325 1363
1326 - Warply.postReceiveMicroappData(WarpConstants.MICROAPP_NEW_CAMPAIGNS, auth, "campaigns", request.toJson(), new NewCampaignsHook(new CallbackReceiver<NewCampaignList>() { 1364 + Warply.postReceiveMicroappData(WarpConstants.MICROAPP_NEW_CAMPAIGNS, true, "campaignsPersonalized", request.toJson(), new NewCampaignsHook(new CallbackReceiver<NewCampaignList>() {
1327 @Override 1365 @Override
1328 public void onSuccess(NewCampaignList result) { 1366 public void onSuccess(NewCampaignList result) {
1367 + mNewCampaignList.addAll(result);
1368 + CampaignList tempCampaigns = new CampaignList();
1369 + for (NewCampaign newCamp : mNewCampaignList) {
1370 + Campaign camp = new Campaign();
1371 + camp.setIndexUrl(newCamp.getIndexUrl());
1372 + camp.setLogoUrl(newCamp.getLogoUrl());
1373 + camp.setMessage(newCamp.getMessage());
1374 + camp.setOfferCategory(newCamp.getCommunicationCategory());
1375 + camp.setSessionUUID(newCamp.getCommunicationUUID());
1376 + camp.setTitle(newCamp.getTitle());
1377 + camp.setSubtitle(newCamp.getSubtitle());
1378 + camp.setSorting(newCamp.getSorting());
1379 + camp.setNew(newCamp.getIsNew());
1380 + camp.setType(newCamp.getCampaignType());
1381 + try {
1382 + camp.setExtraFields(newCamp.getExtraFields().toString());
1383 + } catch (NullPointerException e) {
1384 + camp.setExtraFields("");
1385 + e.printStackTrace();
1386 + }
1387 +
1388 + try {
1389 + camp.setCampaignTypeSettings(newCamp.getSettings().toString());
1390 + } catch (NullPointerException e) {
1391 + camp.setCampaignTypeSettings("");
1392 + e.printStackTrace();
1393 + }
1394 + tempCampaigns.add(camp);
1395 + }
1396 + WarplyManagerHelper.setCampaignList(tempCampaigns);
1329 receiver.onSuccess(result); 1397 receiver.onSuccess(result);
1330 } 1398 }
1331 1399
1332 @Override 1400 @Override
1333 public void onFailure(int errorCode) { 1401 public void onFailure(int errorCode) {
1334 - if (auth) { 1402 + if (errorCode == 401) {
1335 - if (errorCode == 401) { 1403 + refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() {
1336 - refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() { 1404 + @Override
1337 - @Override 1405 + public void onSuccess(JSONObject result) {
1338 - public void onSuccess(JSONObject result) { 1406 + int status = result.optInt("status", 2);
1339 - int status = result.optInt("status", 2); 1407 + if (status == 1)
1340 - if (status == 1) 1408 + getCampaignsPersonalized(request, receiver);
1341 - getCampaigns(request, auth, receiver); 1409 + else
1342 - else 1410 + receiver.onFailure(status);
1343 - receiver.onFailure(status); 1411 + }
1344 - }
1345 1412
1346 - @Override 1413 + @Override
1347 - public void onFailure(int errorCode) { 1414 + public void onFailure(int errorCode) {
1348 - receiver.onFailure(errorCode); 1415 + receiver.onFailure(errorCode);
1349 - } 1416 + }
1350 - }); 1417 + });
1351 - } else
1352 - receiver.onFailure(errorCode);
1353 } else 1418 } else
1354 receiver.onFailure(errorCode); 1419 receiver.onFailure(errorCode);
1355 } 1420 }
...@@ -1554,7 +1619,7 @@ public class WarplyManager { ...@@ -1554,7 +1619,7 @@ public class WarplyManager {
1554 WarpUtils.log("[WARP Trace] WARPLY User Coupons Request is active"); 1619 WarpUtils.log("[WARP Trace] WARPLY User Coupons Request is active");
1555 WarpUtils.log("**************************************************"); 1620 WarpUtils.log("**************************************************");
1556 1621
1557 - WarplyManager.getCouponsets(new WarplyGetCouponsetsRequest() 1622 + getCouponsets(new WarplyGetCouponsetsRequest()
1558 .setLanguage(WarplyProperty.getLanguage(Warply.getWarplyContext())), new CallbackReceiver<CouponsetsList>() { 1623 .setLanguage(WarplyProperty.getLanguage(Warply.getWarplyContext())), new CallbackReceiver<CouponsetsList>() {
1559 @Override 1624 @Override
1560 public void onSuccess(CouponsetsList result) { 1625 public void onSuccess(CouponsetsList result) {
......
...@@ -383,19 +383,6 @@ public class WarpView extends WebView { ...@@ -383,19 +383,6 @@ public class WarpView extends WebView {
383 questionnaireEvent.setName(parts[1]); 383 questionnaireEvent.setName(parts[1]);
384 EventBus.getDefault().post(new WarplyEventBusManager(questionnaireEvent)); 384 EventBus.getDefault().post(new WarplyEventBusManager(questionnaireEvent));
385 } else if (parts[1].equals("userAnswered")) { 385 } else if (parts[1].equals("userAnswered")) {
386 - QuestionnaireEventModel questionnaireEvent = new QuestionnaireEventModel();
387 - try {
388 - questionnaireEvent.setName(parts[1]);
389 - questionnaireEvent.setParameter(parts[2]);
390 - WarpUtils.setUserTag(Warply.getWarplyContext(), parts[2]);
391 - EventBus.getDefault().post(new WarplyEventBusManager(questionnaireEvent));
392 - } catch (IndexOutOfBoundsException e) {
393 - questionnaireEvent.setName(parts[1]);
394 - questionnaireEvent.setParameter("");
395 - WarpUtils.setUserTag(Warply.getWarplyContext(), "");
396 - EventBus.getDefault().post(new WarplyEventBusManager(questionnaireEvent));
397 - }
398 - } else if (parts[1].equals("addUserTag")) {
399 // QuestionnaireEventModel questionnaireEvent = new QuestionnaireEventModel(); 386 // QuestionnaireEventModel questionnaireEvent = new QuestionnaireEventModel();
400 try { 387 try {
401 // questionnaireEvent.setName(parts[1]); 388 // questionnaireEvent.setName(parts[1]);
...@@ -408,6 +395,19 @@ public class WarpView extends WebView { ...@@ -408,6 +395,19 @@ public class WarpView extends WebView {
408 WarpUtils.setUserTag(Warply.getWarplyContext(), ""); 395 WarpUtils.setUserTag(Warply.getWarplyContext(), "");
409 // EventBus.getDefault().post(new WarplyEventBusManager(questionnaireEvent)); 396 // EventBus.getDefault().post(new WarplyEventBusManager(questionnaireEvent));
410 } 397 }
398 + } else if (parts[1].equals("addUserTag")) {
399 + QuestionnaireEventModel questionnaireEvent = new QuestionnaireEventModel();
400 + try {
401 + questionnaireEvent.setName(parts[1]);
402 + questionnaireEvent.setParameter(parts[2]);
403 + WarpUtils.setUserTag(Warply.getWarplyContext(), parts[2]);
404 + EventBus.getDefault().post(new WarplyEventBusManager(questionnaireEvent));
405 + } catch (IndexOutOfBoundsException e) {
406 + questionnaireEvent.setName(parts[1]);
407 + questionnaireEvent.setParameter("");
408 + WarpUtils.setUserTag(Warply.getWarplyContext(), "");
409 + EventBus.getDefault().post(new WarplyEventBusManager(questionnaireEvent));
410 + }
411 } else if (parts[1].equals("couponRetrieved")) { 411 } else if (parts[1].equals("couponRetrieved")) {
412 EventBus.getDefault().post(new WarplyEventBusManager(new CouponEventModel())); 412 EventBus.getDefault().post(new WarplyEventBusManager(new CouponEventModel()));
413 } else if (parts[1].equals("couponShared")) { 413 } else if (parts[1].equals("couponShared")) {
......