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
2026-03-23 17:04:59 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
02bc8863c7423be642eaae696c1639b5957c98c5
02bc8863
1 parent
48c54980
changed sorting categories in couponsets
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
16 deletions
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/Couponset.java
warply_android_sdk/src/main/java/ly/warp/sdk/utils/managers/WarplyManager.java
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/Couponset.java
View file @
02bc886
...
...
@@ -143,7 +143,7 @@ public class Couponset implements Parcelable, Serializable {
private
String
endDate
;
private
JSONObject
hideCondition
;
private
JSONObject
showAsBanner
;
private
String
segment
;
private
JSONObject
segment
;
private
String
offerCategory
;
private
JSONObject
tagging
;
private
JSONArray
regions
;
...
...
@@ -325,7 +325,7 @@ public class Couponset implements Parcelable, Serializable {
this
.
endDate
=
optNullableString
(
json
,
END_DATE
);
this
.
hideCondition
=
json
.
optJSONObject
(
HIDE_CONDITION
);
this
.
showAsBanner
=
json
.
optJSONObject
(
SHOW_AS_BANNER
);
this
.
segment
=
optNullableString
(
json
,
SEGMENT
);
this
.
segment
=
json
.
optJSONObject
(
SEGMENT
);
this
.
offerCategory
=
optNullableString
(
json
,
OFFER_CATEGORY
);
this
.
tagging
=
json
.
optJSONObject
(
TAGGING
);
this
.
regions
=
json
.
optJSONArray
(
REGIONS
);
...
...
@@ -376,7 +376,7 @@ public class Couponset implements Parcelable, Serializable {
this
.
endDate
=
optNullableString
(
json
,
END_DATE
);
this
.
hideCondition
=
json
.
optJSONObject
(
HIDE_CONDITION
);
this
.
showAsBanner
=
json
.
optJSONObject
(
SHOW_AS_BANNER
);
this
.
segment
=
optNullableString
(
json
,
SEGMENT
);
this
.
segment
=
json
.
optJSONObject
(
SEGMENT
);
this
.
offerCategory
=
optNullableString
(
json
,
OFFER_CATEGORY
);
this
.
tagging
=
json
.
optJSONObject
(
TAGGING
);
this
.
regions
=
json
.
optJSONArray
(
REGIONS
);
...
...
@@ -469,7 +469,12 @@ public class Couponset implements Parcelable, Serializable {
}
catch
(
JSONException
e
)
{
this
.
showAsBanner
=
null
;
}
this
.
segment
=
source
.
readString
();
try
{
String
segmentStr
=
source
.
readString
();
this
.
segment
=
segmentStr
!=
null
?
new
JSONObject
(
segmentStr
)
:
null
;
}
catch
(
JSONException
e
)
{
this
.
segment
=
null
;
}
this
.
offerCategory
=
source
.
readString
();
try
{
String
taggingStr
=
source
.
readString
();
...
...
@@ -541,7 +546,7 @@ public class Couponset implements Parcelable, Serializable {
dest
.
writeString
(
this
.
endDate
);
dest
.
writeString
(
this
.
hideCondition
!=
null
?
this
.
hideCondition
.
toString
()
:
null
);
dest
.
writeString
(
this
.
showAsBanner
!=
null
?
this
.
showAsBanner
.
toString
()
:
null
);
dest
.
writeString
(
this
.
segment
);
dest
.
writeString
(
this
.
segment
!=
null
?
this
.
segment
.
toString
()
:
null
);
dest
.
writeString
(
this
.
offerCategory
);
dest
.
writeString
(
this
.
tagging
!=
null
?
this
.
tagging
.
toString
()
:
null
);
dest
.
writeString
(
this
.
regions
!=
null
?
this
.
regions
.
toString
()
:
null
);
...
...
@@ -603,7 +608,7 @@ public class Couponset implements Parcelable, Serializable {
jObj
.
put
(
END_DATE
,
this
.
endDate
!=
null
?
this
.
endDate
:
JSONObject
.
NULL
);
jObj
.
put
(
HIDE_CONDITION
,
this
.
hideCondition
!=
null
?
this
.
hideCondition
:
JSONObject
.
NULL
);
jObj
.
put
(
SHOW_AS_BANNER
,
this
.
showAsBanner
!=
null
?
this
.
showAsBanner
:
JSONObject
.
NULL
);
jObj
.
put
(
SEGMENT
,
this
.
segment
!=
null
?
this
.
segment
:
JSONObject
.
NULL
);
jObj
.
put
(
SEGMENT
,
this
.
segment
!=
null
?
this
.
segment
:
JSONObject
.
NULL
);
// segment is JSONObject
jObj
.
put
(
OFFER_CATEGORY
,
this
.
offerCategory
!=
null
?
this
.
offerCategory
:
JSONObject
.
NULL
);
jObj
.
put
(
TAGGING
,
this
.
tagging
!=
null
?
this
.
tagging
:
JSONObject
.
NULL
);
jObj
.
put
(
REGIONS
,
this
.
regions
!=
null
?
this
.
regions
:
JSONObject
.
NULL
);
...
...
@@ -852,10 +857,14 @@ public class Couponset implements Parcelable, Serializable {
return
showAsBanner
;
}
public
String
getSegment
()
{
public
JSONObject
getSegment
()
{
return
segment
;
}
public
String
getSegmentValue
()
{
return
segment
!=
null
?
segment
.
optString
(
"value"
,
null
)
:
null
;
}
public
String
getOfferCategory
()
{
return
offerCategory
;
}
...
...
@@ -1068,7 +1077,7 @@ public class Couponset implements Parcelable, Serializable {
this
.
showAsBanner
=
showAsBanner
;
}
public
void
setSegment
(
String
segment
)
{
public
void
setSegment
(
JSONObject
segment
)
{
this
.
segment
=
segment
;
}
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/utils/managers/WarplyManager.java
View file @
02bc886
...
...
@@ -429,18 +429,40 @@ public class WarplyManager {
}
}
// Get user segments once
ArrayList
<
String
>
userSegments
=
new
ArrayList
<>();
User
user
=
WarplyManagerHelper
.
getUser
();
if
(
user
!=
null
&&
user
.
getUserSegmentsList
()
!=
null
)
{
userSegments
=
user
.
getUserSegmentsList
();
}
boolean
userHasGreenPass
=
userSegments
.
contains
(
"GreenPass"
);
// Eligibility groups: one ArrayList per matching user segment value
LinkedHashMap
<
String
,
ArrayList
<
Couponset
>>
eligibilityGroups
=
new
LinkedHashMap
<>();
ArrayList
<
Couponset
>
topOffers
=
new
ArrayList
<>();
ArrayList
<
Couponset
>
green
=
new
ArrayList
<>();
LinkedHashMap
<
String
,
ArrayList
<
Couponset
>>
categoryGroups
=
new
LinkedHashMap
<>();
for
(
Couponset
couponset
:
resultCouponsets
)
{
if
(
couponset
.
isPromoted
())
{
String
segmentValue
=
couponset
.
getSegmentValue
();
if
(
"sustainability"
.
equals
(
segmentValue
))
{
// Only add to Green if user has GreenPass, otherwise ignore
if
(
userHasGreenPass
)
{
green
.
add
(
couponset
);
}
}
else
if
(
segmentValue
!=
null
&&
!
segmentValue
.
isEmpty
()
&&
userSegments
.
contains
(
segmentValue
))
{
// Eligibility: one dedicated category per matching segment value
eligibilityGroups
.
computeIfAbsent
(
segmentValue
,
k
->
new
ArrayList
<>()).
add
(
couponset
);
}
else
if
(
couponset
.
isPromoted
())
{
// Top Offers
topOffers
.
add
(
couponset
);
}
else
{
// Rest: group by offerCategory
String
category
=
couponset
.
getOfferCategory
();
if
(
category
==
null
||
category
.
isEmpty
())
{
category
=
"Other"
;
}
// If this category is a child, map it to its parent
if
(
childToParentMap
.
containsKey
(
category
))
{
category
=
childToParentMap
.
get
(
category
);
}
...
...
@@ -448,16 +470,19 @@ public class WarplyManager {
}
}
// Build final map in order: Eligibilities → Top Offers → Green → Rest
for
(
Map
.
Entry
<
String
,
ArrayList
<
Couponset
>>
entry
:
eligibilityGroups
.
entrySet
())
{
if
(!
entry
.
getValue
().
isEmpty
())
{
categorizedMap
.
put
(
entry
.
getKey
(),
entry
.
getValue
());
}
}
if
(!
topOffers
.
isEmpty
())
{
categorizedMap
.
put
(
"Top offers"
,
topOffers
);
}
String
[]
priorityCategories
=
{
"Αγορές"
,
"Φαγητό και καφές"
};
for
(
String
priorityCategory
:
priorityCategories
)
{
ArrayList
<
Couponset
>
priorityList
=
categoryGroups
.
remove
(
priorityCategory
);
if
(
priorityList
!=
null
&&
!
priorityList
.
isEmpty
())
{
categorizedMap
.
put
(
priorityCategory
,
priorityList
);
}
if
(!
green
.
isEmpty
())
{
categorizedMap
.
put
(
"Green"
,
green
);
}
for
(
Map
.
Entry
<
String
,
ArrayList
<
Couponset
>>
entry
:
categoryGroups
.
entrySet
())
{
...
...
Please
register
or
login
to post a comment