Toggle navigation
Toggle navigation
This project
Loading...
Sign in
open-source
/
warply_android_sdk_maven_plugin
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Panagiotis Triantafyllou
2024-02-29 13:24:47 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
2d6855ec022fe336c4e083e0d30150b21134c747
2d6855ec
1 parent
f37ddd9d
coupon availability per campaign
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
4 deletions
warply_android_sdk/src/main/java/ly/warp/sdk/utils/managers/WarplyManager.java
warply_android_sdk/src/main/java/ly/warp/sdk/utils/managers/WarplyManager.java
View file @
2d6855e
...
...
@@ -54,6 +54,7 @@ import org.json.JSONArray;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
java.io.Serializable
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
...
...
@@ -67,6 +68,9 @@ import java.util.concurrent.ExecutorService;
import
java.util.concurrent.Executors
;
import
ly.warp.sdk.Warply
;
import
ly.warp.sdk.activities.CouponsetInfoActivity
;
import
ly.warp.sdk.activities.GiftsForYouActivity
;
import
ly.warp.sdk.activities.WarpViewActivity
;
import
ly.warp.sdk.db.WarplyDBHelper
;
import
ly.warp.sdk.io.callbacks.AddressHook
;
import
ly.warp.sdk.io.callbacks.CallbackReceiver
;
...
...
@@ -96,6 +100,7 @@ import ly.warp.sdk.io.models.CouponList;
import
ly.warp.sdk.io.models.Couponset
;
import
ly.warp.sdk.io.models.CouponsetsList
;
import
ly.warp.sdk.io.models.LoyaltySDKDynatraceEventModel
;
import
ly.warp.sdk.io.models.LoyaltySDKFirebaseEventModel
;
import
ly.warp.sdk.io.models.Merchant
;
import
ly.warp.sdk.io.models.MerchantCategoriesList
;
import
ly.warp.sdk.io.models.MerchantList
;
...
...
@@ -1576,11 +1581,22 @@ public class WarplyManager {
if
(
newCampaignList
!=
null
&&
newCampaignList
.
size
()
>
0
)
{
Collections
.
sort
(
newCampaignList
,
(
obj1
,
obj2
)
->
Integer
.
compare
(
obj1
.
getSorting
(),
obj2
.
getSorting
()));
WarplyManagerHelper
.
setCampaignList
(
newCampaignList
);
campaignLoyaltyList
.
clear
();
ArrayList
<
Campaign
>
campaignCarouselList
=
new
ArrayList
<>();
campaignCarouselList
.
clear
();
for
(
Campaign
camp
:
newCampaignList
)
{
if
(
resultCampaignsAvailability
!=
null
&&
resultCampaignsAvailability
.
length
()
>
0
)
{
JSONObject
campaignSettings
=
WarpJSONParser
.
getJSONFromString
(
camp
.
getCampaignTypeSettings
());
if
(
campaignSettings
!=
null
)
{
if
(
campaignSettings
.
has
(
"couponset"
))
{
String
cpnUuid
=
campaignSettings
.
optString
(
"couponset"
);
if
(
resultCampaignsAvailability
.
has
(
cpnUuid
))
{
camp
.
setCouponAvailability
(
resultCampaignsAvailability
.
optInt
(
cpnUuid
));
}
}
}
}
JSONObject
campMetadata
=
WarpJSONParser
.
getJSONFromString
(
camp
.
getExtraFields
());
if
(
campMetadata
!=
null
)
{
if
(
campMetadata
.
has
(
"carousel"
))
{
...
...
@@ -1599,6 +1615,7 @@ public class WarplyManager {
campaignLoyaltyList
.
add
(
camp
);
}
}
WarplyManagerHelper
.
setCampaignList
(
newCampaignList
);
WarplyManagerHelper
.
setCarouselList
(
campaignCarouselList
);
Set
<
Campaign
>
set
=
new
LinkedHashSet
<>(
campaignLoyaltyList
);
...
...
@@ -1790,6 +1807,9 @@ public class WarplyManager {
if
(
extraFieldsResp
.
has
(
"Banner_img"
))
{
camp
.
setBannerImage
(
extraFieldsResp
.
optString
(
"Banner_img"
,
""
));
}
if
(
extraFieldsResp
.
has
(
"category_id"
))
{
camp
.
setCategoryId
(
extraFieldsResp
.
optString
(
"category_id"
,
""
));
}
}
}
else
{
camp
.
setBannerImage
(
""
);
...
...
@@ -1929,6 +1949,9 @@ public class WarplyManager {
if
(
extraFieldsResp
.
has
(
"Banner_img"
))
{
camp
.
setBannerImage
(
extraFieldsResp
.
optString
(
"Banner_img"
,
""
));
}
if
(
extraFieldsResp
.
has
(
"category_id"
))
{
camp
.
setCategoryId
(
extraFieldsResp
.
optString
(
"category_id"
,
""
));
}
}
}
else
{
camp
.
setBannerImage
(
""
);
...
...
@@ -2014,10 +2037,9 @@ public class WarplyManager {
Map
<
String
,
Object
>
jsonParams
=
new
ArrayMap
<>();
jsonParams
.
put
(
"action"
,
"availability"
);
Map
<
String
,
Object
>
jsonParamsFilters
=
new
ArrayMap
<>();
jsonParams
.
put
(
"uuids"
,
null
);
jsonParams
.
put
(
"availability_enabled"
,
true
);
jsonParams
Filters
.
put
(
"uuids"
,
null
);
jsonParams
Filters
.
put
(
"availability_enabled"
,
true
);
jsonParams
.
put
(
"filters"
,
jsonParamsFilters
);
jsonParams
.
put
(
"language"
,
WarplyProperty
.
getLanguage
(
Warply
.
getWarplyContext
()));
jsonParamsCampaignsAvailability
.
put
(
"coupon"
,
jsonParams
);
RequestBody
campaignsAvailabilityRequest
=
RequestBody
.
create
(
MediaType
.
get
(
"application/json; charset=utf-8"
),
(
new
JSONObject
(
jsonParamsCampaignsAvailability
)).
toString
());
...
...
Please
register
or
login
to post a comment