Showing
5 changed files
with
107 additions
and
4 deletions
... | @@ -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-cosbeta41' | 5 | + PUBLISH_VERSION = '4.5.4-cosbeta42' |
6 | PUBLISH_ARTIFACT_ID = 'warply-android-sdk' | 6 | PUBLISH_ARTIFACT_ID = 'warply-android-sdk' |
7 | } | 7 | } |
8 | 8 | ... | ... |
... | @@ -152,6 +152,11 @@ | ... | @@ -152,6 +152,11 @@ |
152 | android:permission="android.permission.BIND_JOB_SERVICE" /> | 152 | android:permission="android.permission.BIND_JOB_SERVICE" /> |
153 | 153 | ||
154 | <service | 154 | <service |
155 | + android:name="ly.warp.sdk.services.EventQuestionnaireService" | ||
156 | + android:exported="false" | ||
157 | + android:permission="android.permission.BIND_JOB_SERVICE" /> | ||
158 | + | ||
159 | + <service | ||
155 | android:name="ly.warp.sdk.services.WarplyBeaconsRangingService" | 160 | android:name="ly.warp.sdk.services.WarplyBeaconsRangingService" |
156 | android:exported="false" /> | 161 | android:exported="false" /> |
157 | 162 | ... | ... |
... | @@ -33,8 +33,6 @@ import android.content.Intent; | ... | @@ -33,8 +33,6 @@ import android.content.Intent; |
33 | import android.graphics.Color; | 33 | import android.graphics.Color; |
34 | import android.os.Build; | 34 | import android.os.Build; |
35 | import android.os.Bundle; | 35 | import android.os.Bundle; |
36 | -import android.os.Handler; | ||
37 | -import android.os.Looper; | ||
38 | import android.text.TextUtils; | 36 | import android.text.TextUtils; |
39 | import android.view.KeyEvent; | 37 | import android.view.KeyEvent; |
40 | import android.view.View; | 38 | import android.view.View; |
... | @@ -56,11 +54,11 @@ import java.security.SecureRandom; | ... | @@ -56,11 +54,11 @@ import java.security.SecureRandom; |
56 | import java.util.concurrent.ThreadLocalRandom; | 54 | import java.util.concurrent.ThreadLocalRandom; |
57 | import java.util.concurrent.TimeUnit; | 55 | import java.util.concurrent.TimeUnit; |
58 | 56 | ||
59 | -import ly.warp.sdk.R; | ||
60 | import ly.warp.sdk.Warply; | 57 | import ly.warp.sdk.Warply; |
61 | import ly.warp.sdk.io.callbacks.CallbackReceiver; | 58 | import ly.warp.sdk.io.callbacks.CallbackReceiver; |
62 | import ly.warp.sdk.io.models.CouponList; | 59 | import ly.warp.sdk.io.models.CouponList; |
63 | import ly.warp.sdk.io.request.WarplyUserCouponsRequest; | 60 | import ly.warp.sdk.io.request.WarplyUserCouponsRequest; |
61 | +import ly.warp.sdk.services.EventQuestionnaireService; | ||
64 | import ly.warp.sdk.services.PushEventsClickedWorkerService; | 62 | import ly.warp.sdk.services.PushEventsClickedWorkerService; |
65 | import ly.warp.sdk.utils.WarpJSONParser; | 63 | import ly.warp.sdk.utils.WarpJSONParser; |
66 | import ly.warp.sdk.utils.WarpUtils; | 64 | import ly.warp.sdk.utils.WarpUtils; |
... | @@ -130,6 +128,8 @@ public class WarpViewActivity extends WarpBaseActivity { | ... | @@ -130,6 +128,8 @@ public class WarpViewActivity extends WarpBaseActivity { |
130 | public void onMessageEvent(WarplyEventBusManager event) { | 128 | public void onMessageEvent(WarplyEventBusManager event) { |
131 | // EventBus.getDefault().unregister(this); | 129 | // EventBus.getDefault().unregister(this); |
132 | if (event.getQuestionnaire() != null) { | 130 | if (event.getQuestionnaire() != null) { |
131 | + OneTimeWorkRequest mywork = new OneTimeWorkRequest.Builder(EventQuestionnaireService.class).build(); | ||
132 | + WorkManager.getInstance(WarpViewActivity.this).enqueue(mywork); | ||
133 | setResult(RESULT_OK, new Intent()); | 133 | setResult(RESULT_OK, new Intent()); |
134 | finish(); | 134 | finish(); |
135 | } | 135 | } | ... | ... |
1 | +package ly.warp.sdk.services; | ||
2 | + | ||
3 | +import android.content.Context; | ||
4 | + | ||
5 | +import androidx.annotation.NonNull; | ||
6 | +import androidx.work.Worker; | ||
7 | +import androidx.work.WorkerParameters; | ||
8 | + | ||
9 | +import ly.warp.sdk.io.callbacks.CallbackReceiver; | ||
10 | +import ly.warp.sdk.io.models.CampaignList; | ||
11 | +import ly.warp.sdk.io.models.Consumer; | ||
12 | +import ly.warp.sdk.io.request.WarplyConsumerRequest; | ||
13 | +import ly.warp.sdk.io.request.WarplyGetCampaignsRequest; | ||
14 | +import ly.warp.sdk.utils.WarpUtils; | ||
15 | +import ly.warp.sdk.utils.WarplyManagerHelper; | ||
16 | +import ly.warp.sdk.utils.managers.WarplyManager; | ||
17 | + | ||
18 | +/** | ||
19 | + * Created by Panagiotis Triantafyllou on 22/Ιουλ/2022. | ||
20 | + */ | ||
21 | +public class EventQuestionnaireService extends Worker { | ||
22 | + | ||
23 | + public EventQuestionnaireService(@NonNull Context context, @NonNull WorkerParameters workerParams) { | ||
24 | + super(context, workerParams); | ||
25 | + } | ||
26 | + | ||
27 | + @NonNull | ||
28 | + @Override | ||
29 | + public Result doWork() { | ||
30 | + WarplyManager.getConsumer(new WarplyConsumerRequest(), new CallbackReceiver<Consumer>() { | ||
31 | + @Override | ||
32 | + public void onSuccess(Consumer result) { | ||
33 | + WarplyManagerHelper.setConsumer(result); | ||
34 | + | ||
35 | + WarplyManager.getCampaigns(new WarplyGetCampaignsRequest().setLanguage("en"), new CallbackReceiver<CampaignList>() { | ||
36 | + @Override | ||
37 | + public void onSuccess(CampaignList result) { | ||
38 | + WarpUtils.log("SUCCESS_QUESTIONNAIRE_EVENT"); | ||
39 | + } | ||
40 | + | ||
41 | + @Override | ||
42 | + public void onFailure(int errorCode) { | ||
43 | + WarpUtils.log("ERROR_QUESTIONNAIRE_EVENT " + String.valueOf(errorCode)); | ||
44 | + } | ||
45 | + }); | ||
46 | + } | ||
47 | + | ||
48 | + @Override | ||
49 | + public void onFailure(int errorCode) { | ||
50 | + WarpUtils.log("ERROR_QUESTIONNAIRE_CONSUMER_EVENT " + String.valueOf(errorCode)); | ||
51 | + } | ||
52 | + }); | ||
53 | + | ||
54 | + return Result.success(); | ||
55 | + } | ||
56 | +} |
... | @@ -1374,6 +1374,35 @@ public class WarplyManager { | ... | @@ -1374,6 +1374,35 @@ public class WarplyManager { |
1374 | CampaignList campaignLoyaltyList = new CampaignList(); | 1374 | CampaignList campaignLoyaltyList = new CampaignList(); |
1375 | campaignLoyaltyList.clear(); | 1375 | campaignLoyaltyList.clear(); |
1376 | for (Campaign camp : mNewCampaignList) { | 1376 | for (Campaign camp : mNewCampaignList) { |
1377 | + if (camp.getOfferCategory().equals("questionnaire")) { | ||
1378 | + if (WarplyManagerHelper.getConsumer() != null) { | ||
1379 | + JSONObject profMetadata = WarpJSONParser.getJSONFromString(WarplyManagerHelper.getConsumer().getProfileMetadata()); | ||
1380 | + if (profMetadata != null) { | ||
1381 | + if (!profMetadata.has("answered")) { | ||
1382 | + try { | ||
1383 | + JSONObject extraFields = WarpJSONParser.getJSONFromString(camp.getExtraFields()); | ||
1384 | + if (extraFields != null) { | ||
1385 | + if (extraFields.length() == 0 || !(extraFields.has("ccms_offer") || extraFields.has("type"))) { | ||
1386 | + campaignLoyaltyList.add(camp); | ||
1387 | + } | ||
1388 | + } | ||
1389 | + } catch (Exception exception) { | ||
1390 | + campaignLoyaltyList.add(camp); | ||
1391 | + } | ||
1392 | + } | ||
1393 | + } else { | ||
1394 | + try { | ||
1395 | + JSONObject extraFields = WarpJSONParser.getJSONFromString(camp.getExtraFields()); | ||
1396 | + if (extraFields != null) { | ||
1397 | + if (extraFields.length() == 0 || !(extraFields.has("ccms_offer") || extraFields.has("type"))) { | ||
1398 | + campaignLoyaltyList.add(camp); | ||
1399 | + } | ||
1400 | + } | ||
1401 | + } catch (Exception exception) { | ||
1402 | + campaignLoyaltyList.add(camp); | ||
1403 | + } | ||
1404 | + } | ||
1405 | + } else { | ||
1377 | try { | 1406 | try { |
1378 | JSONObject extraFields = WarpJSONParser.getJSONFromString(camp.getExtraFields()); | 1407 | JSONObject extraFields = WarpJSONParser.getJSONFromString(camp.getExtraFields()); |
1379 | if (extraFields != null) { | 1408 | if (extraFields != null) { |
... | @@ -1385,6 +1414,19 @@ public class WarplyManager { | ... | @@ -1385,6 +1414,19 @@ public class WarplyManager { |
1385 | campaignLoyaltyList.add(camp); | 1414 | campaignLoyaltyList.add(camp); |
1386 | } | 1415 | } |
1387 | } | 1416 | } |
1417 | + } else { | ||
1418 | + try { | ||
1419 | + JSONObject extraFields = WarpJSONParser.getJSONFromString(camp.getExtraFields()); | ||
1420 | + if (extraFields != null) { | ||
1421 | + if (extraFields.length() == 0 || !(extraFields.has("ccms_offer") || extraFields.has("type"))) { | ||
1422 | + campaignLoyaltyList.add(camp); | ||
1423 | + } | ||
1424 | + } | ||
1425 | + } catch (Exception exception) { | ||
1426 | + campaignLoyaltyList.add(camp); | ||
1427 | + } | ||
1428 | + } | ||
1429 | + } | ||
1388 | WarplyManagerHelper.setCampaignList(mNewCampaignList); | 1430 | WarplyManagerHelper.setCampaignList(mNewCampaignList); |
1389 | 1431 | ||
1390 | // ArrayList<LoyaltyContextualOfferModel> list = new ArrayList<>(); | 1432 | // ArrayList<LoyaltyContextualOfferModel> list = new ArrayList<>(); | ... | ... |
-
Please register or login to post a comment