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
2022-11-24 19:35:43 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
19c70aba06498425b672b7b2ac90dc6796fa5fe8
19c70aba
1 parent
bf8219dd
retrofit
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
1591 additions
and
56 deletions
warply_android_sdk/build.gradle
warply_android_sdk/src/main/java/ly/warp/sdk/activities/BaseFragmentActivity.java
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/Coupon.java
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/CouponModel.java
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/CouponRequestModel.java
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/Couponset.java
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/CouponsetModel.java
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/CouponsetRequestModel.java
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/Merchant.java
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/MerchantModel.java
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/MerchantsRequestModel.java
warply_android_sdk/src/main/java/ly/warp/sdk/io/volley/ApiClient.java
warply_android_sdk/src/main/java/ly/warp/sdk/io/volley/ApiService.java
warply_android_sdk/src/main/java/ly/warp/sdk/utils/managers/WarplyManager.java
warply_android_sdk/build.gradle
View file @
19c70ab
...
...
@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
ext
{
PUBLISH_GROUP_ID
=
'ly.warp'
PUBLISH_VERSION
=
'4.5.4.6rc
12
'
PUBLISH_VERSION
=
'4.5.4.6rc
20
'
PUBLISH_ARTIFACT_ID
=
'warply-android-sdk'
}
...
...
@@ -90,6 +90,10 @@ dependencies {
//------------------------------ Calligraphy -----------------------------//
api
'io.github.inflationx:calligraphy3:3.1.1'
api
'io.github.inflationx:viewpump:2.0.3'
//------------------------------ Retrofit -----------------------------//
implementation
'com.squareup.retrofit2:retrofit:2.9.0'
implementation
'com.squareup.retrofit2:converter-gson:2.9.0'
}
// In every export please update the version number
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/activities/BaseFragmentActivity.java
View file @
19c70ab
...
...
@@ -58,14 +58,10 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation
mBottomNavigationView
=
findViewById
(
R
.
id
.
bt_tabs
);
new
Thread
(()
->
{
if
(!
Thread
.
currentThread
().
isInterrupted
())
{
// WarplyManager.getConsumer(new WarplyConsumerRequest(), mConsumerReceiver);
// Warply.getInbox(new WarplyInboxRequest().setUseCache(false), mInboxReceiver);
// WarplyManager.getUserCouponsWithCouponsets(new WarplyUserCouponsRequest(), mUserCouponsReceiver);
WarplyManager
.
getUserCouponsWithCouponsets
(
mUserCouponsReceiver
);
WarplyManager
.
getCampaigns
(
new
WarplyGetCampaignsRequest
().
setLanguage
(
"en"
),
mCampaignsCallback
);
}
}).
start
();
}
@Override
protected
void
onStart
()
{
...
...
@@ -80,6 +76,7 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation
@Override
protected
void
onResume
()
{
super
.
onResume
();
initViews
();
}
@Override
...
...
@@ -139,57 +136,15 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation
// Inner and Anonymous Classes
// ===========================================================
// private final CallbackReceiver<Consumer> mConsumerReceiver = new CallbackReceiver<Consumer>() {
// @Override
// public void onSuccess(Consumer result) {
// mConsumer = result;
//// WarplyManagerHelper.setConsumer(result);
//// Thread.currentThread().interrupt();
// Warply.getInbox(new WarplyInboxRequest().setUseCache(false), mInboxReceiver);
// }
//
// @Override
// public void onFailure(int errorCode) {
// Thread.currentThread().interrupt();
// }
// };
private
final
CallbackReceiver
<
CampaignList
>
mInboxReceiver
=
new
CallbackReceiver
<
CampaignList
>()
{
@Override
public
void
onSuccess
(
CampaignList
result
)
{
for
(
Campaign
campaign
:
result
)
{
if
(
mUniqueCampaignList
.
containsKey
(
campaign
.
getOfferCategory
().
trim
()))
{
CampaignList
tempCampaignList
=
(
CampaignList
)
mUniqueCampaignList
.
get
(
campaign
.
getOfferCategory
().
trim
());
tempCampaignList
.
add
(
campaign
);
mUniqueCampaignList
.
put
(
campaign
.
getOfferCategory
().
trim
(),
tempCampaignList
);
}
else
{
CampaignList
tempCampaignList
=
new
CampaignList
();
tempCampaignList
.
add
(
campaign
);
mUniqueCampaignList
.
put
(
campaign
.
getOfferCategory
().
trim
(),
tempCampaignList
);
}
}
// Thread.currentThread().interrupt();
WarplyManager
.
getUserCouponsWithCouponsets
(
new
WarplyUserCouponsRequest
(),
mUserCouponsReceiver
);
}
@Override
public
void
onFailure
(
int
errorCode
)
{
Thread
.
currentThread
().
interrupt
();
}
};
private
CallbackReceiver
<
ArrayList
<
Campaign
>>
mCampaignsCallback
=
new
CallbackReceiver
<
ArrayList
<
Campaign
>>()
{
@Override
public
void
onSuccess
(
ArrayList
<
Campaign
>
result
)
{
WarplyManager
.
getUserCouponsWithCouponsets
(
new
WarplyUserCouponsRequest
(),
mUserCouponsReceiver
);
}
@Override
public
void
onFailure
(
int
errorCode
)
{
Thread
.
currentThread
().
interrupt
();
}
};
...
...
@@ -197,15 +152,12 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation
private
final
CallbackReceiver
<
CouponList
>
mUserCouponsReceiver
=
new
CallbackReceiver
<
CouponList
>()
{
@Override
public
void
onSuccess
(
CouponList
result
)
{
Thread
.
currentThread
().
interrupt
();
new
Handler
(
Looper
.
getMainLooper
()).
post
(()
->
{
initViews
();
});
}
@Override
public
void
onFailure
(
int
errorCode
)
{
Thread
.
currentThread
().
interrupt
();
}
};
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/Coupon.java
View file @
19c70ab
...
...
@@ -88,6 +88,28 @@ public class Coupon implements Parcelable, Serializable {
private
String
discount_type
=
""
;
private
double
final_price
=
0.0d
;
public
Coupon
()
{
this
.
barcode
=
""
;
this
.
category
=
""
;
this
.
coupon
=
""
;
this
.
created
=
""
;
this
.
description
=
""
;
this
.
discount
=
""
;
this
.
expiration
=
""
;
this
.
image
=
""
;
this
.
name
=
""
;
this
.
status
=
0
;
this
.
transactionDate
=
""
;
this
.
transactionUuid
=
""
;
this
.
changesDates
=
new
JSONObject
();
this
.
couponsetUuid
=
""
;
this
.
merchantUuid
=
""
;
this
.
innerText
=
""
;
this
.
expirationDate
=
new
Date
();
this
.
discount_type
=
""
;
this
.
final_price
=
0.0d
;
}
/**
* Basic constructor used to create an object from a String, representing a
* JSON Object
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/CouponModel.java
0 → 100644
View file @
19c70ab
package
ly
.
warp
.
sdk
.
io
.
models
;
import
com.google.gson.annotations.Expose
;
import
com.google.gson.annotations.SerializedName
;
import
java.util.ArrayList
;
import
java.util.Date
;
/**
* Created by Panagiotis Triantafyllou on 24/Νοε/2022.
*/
public
class
CouponModel
{
@SerializedName
(
"msg"
)
@Expose
private
String
msg
;
@SerializedName
(
"result"
)
@Expose
private
ArrayList
<
CouponResult
>
result
=
null
;
@SerializedName
(
"status"
)
@Expose
private
Integer
status
;
public
String
getMsg
()
{
return
msg
;
}
public
void
setMsg
(
String
msg
)
{
this
.
msg
=
msg
;
}
public
Integer
getStatus
()
{
return
status
;
}
public
void
setStatus
(
Integer
status
)
{
this
.
status
=
status
;
}
public
ArrayList
<
CouponResult
>
getResult
()
{
return
result
;
}
public
void
setResult
(
ArrayList
<
CouponResult
>
result
)
{
this
.
result
=
result
;
}
public
class
CouponResult
{
@SerializedName
(
"changes_dates"
)
@Expose
private
ChangesDates
changesDates
;
@SerializedName
(
"communication_uuid"
)
@Expose
private
String
communicationUuid
;
@SerializedName
(
"coupon"
)
@Expose
private
String
coupon
;
@SerializedName
(
"couponset_uuid"
)
@Expose
private
String
couponsetUuid
;
@SerializedName
(
"description"
)
@Expose
private
String
description
;
@SerializedName
(
"discount"
)
@Expose
private
String
discount
;
@SerializedName
(
"expiration"
)
@Expose
private
String
expiration
;
@SerializedName
(
"image"
)
@Expose
private
String
image
;
@SerializedName
(
"name"
)
@Expose
private
String
name
;
@SerializedName
(
"status"
)
@Expose
private
Integer
status
;
private
String
merchantUuid
=
""
;
private
String
innerText
=
""
;
private
Date
expirationDate
=
new
Date
();
private
String
discount_type
=
""
;
private
double
final_price
=
0.0d
;
public
ChangesDates
getChangesDates
()
{
return
changesDates
;
}
public
void
setChangesDates
(
ChangesDates
changesDates
)
{
this
.
changesDates
=
changesDates
;
}
public
String
getCommunicationUuid
()
{
return
communicationUuid
;
}
public
void
setCommunicationUuid
(
String
communicationUuid
)
{
this
.
communicationUuid
=
communicationUuid
;
}
public
String
getCoupon
()
{
return
coupon
;
}
public
void
setCoupon
(
String
coupon
)
{
this
.
coupon
=
coupon
;
}
public
String
getCouponsetUuid
()
{
return
couponsetUuid
;
}
public
void
setCouponsetUuid
(
String
couponsetUuid
)
{
this
.
couponsetUuid
=
couponsetUuid
;
}
public
String
getDescription
()
{
return
description
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
public
String
getDiscount
()
{
return
discount
;
}
public
void
setDiscount
(
String
discount
)
{
this
.
discount
=
discount
;
}
public
String
getExpiration
()
{
return
expiration
;
}
public
void
setExpiration
(
String
expiration
)
{
this
.
expiration
=
expiration
;
}
public
String
getImage
()
{
return
image
;
}
public
void
setImage
(
String
image
)
{
this
.
image
=
image
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
Integer
getStatus
()
{
return
status
;
}
public
void
setStatus
(
Integer
status
)
{
this
.
status
=
status
;
}
public
String
getMerchantUuid
()
{
return
merchantUuid
;
}
public
void
setMerchantUuid
(
String
merchantUuid
)
{
this
.
merchantUuid
=
merchantUuid
;
}
public
String
getInnerText
()
{
return
innerText
;
}
public
void
setInnerText
(
String
innerText
)
{
this
.
innerText
=
innerText
;
}
public
Date
getExpirationDate
()
{
return
expirationDate
;
}
public
void
setExpirationDate
(
Date
expirationDate
)
{
this
.
expirationDate
=
expirationDate
;
}
public
String
getDiscount_type
()
{
return
discount_type
;
}
public
void
setDiscount_type
(
String
discount_type
)
{
this
.
discount_type
=
discount_type
;
}
public
double
getFinal_price
()
{
return
final_price
;
}
public
void
setFinal_price
(
double
final_price
)
{
this
.
final_price
=
final_price
;
}
}
public
class
ChangesDates
{
@SerializedName
(
"assigned"
)
@Expose
private
String
assigned
;
@SerializedName
(
"created"
)
@Expose
private
String
created
;
public
String
getAssigned
()
{
return
assigned
;
}
public
void
setAssigned
(
String
assigned
)
{
this
.
assigned
=
assigned
;
}
public
String
getCreated
()
{
return
created
;
}
public
void
setCreated
(
String
created
)
{
this
.
created
=
created
;
}
}
}
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/CouponRequestModel.java
0 → 100644
View file @
19c70ab
package
ly
.
warp
.
sdk
.
io
.
models
;
import
org.json.JSONArray
;
import
ly.warp.sdk.Warply
;
import
ly.warp.sdk.utils.WarplyProperty
;
/**
* Created by Panagiotis Triantafyllou on 24/Νοε/2022.
*/
public
class
CouponRequestModel
{
private
CouponsetRequestInnerModel
coupon
;
public
CouponRequestModel
()
{
this
.
coupon
=
new
CouponsetRequestInnerModel
();
}
private
class
CouponsetRequestInnerModel
{
private
String
action
;
private
JSONArray
fetch_data
;
public
CouponsetRequestInnerModel
()
{
this
.
action
=
"get_user_coupons"
;
JSONArray
fetch
=
new
JSONArray
();
fetch
.
put
(
"transaction"
);
fetch
.
put
(
"communication"
);
this
.
fetch_data
=
fetch
;
}
}
}
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/Couponset.java
View file @
19c70ab
...
...
@@ -109,6 +109,37 @@ public class Couponset implements Parcelable, Serializable {
private
String
discount_type
=
""
;
private
double
final_price
=
0.0d
;
public
Couponset
()
{
this
.
uuid
=
""
;
this
.
admin_name
=
""
;
this
.
created
=
""
;
this
.
updated
=
""
;
this
.
app_uuid
=
""
;
this
.
img
=
new
JSONArray
();
this
.
img_preview
=
""
;
this
.
sorting
=
0
;
this
.
active
=
false
;
this
.
visible
=
false
;
this
.
buyable
=
false
;
this
.
user_generated
=
false
;
this
.
limits
=
new
JSONObject
();
this
.
points
=
0
;
this
.
points_cause
=
""
;
this
.
expiration
=
""
;
this
.
third_party_service
=
false
;
this
.
name
=
""
;
this
.
description
=
""
;
this
.
short_description
=
""
;
this
.
discount
=
""
;
this
.
category
=
""
;
this
.
terms
=
""
;
this
.
availability
=
0
;
this
.
merchantUuid
=
""
;
this
.
innerText
=
""
;
this
.
discount_type
=
""
;
this
.
final_price
=
0.0d
;
}
/**
* Basic constructor used to create an object from a String, representing a
* JSON Object
...
...
@@ -411,6 +442,118 @@ public class Couponset implements Parcelable, Serializable {
return
final_price
;
}
public
void
setUuid
(
String
uuid
)
{
this
.
uuid
=
uuid
;
}
public
void
setAdmin_name
(
String
admin_name
)
{
this
.
admin_name
=
admin_name
;
}
public
void
setCreated
(
String
created
)
{
this
.
created
=
created
;
}
public
void
setUpdated
(
String
updated
)
{
this
.
updated
=
updated
;
}
public
void
setApp_uuid
(
String
app_uuid
)
{
this
.
app_uuid
=
app_uuid
;
}
public
void
setImg
(
JSONArray
img
)
{
this
.
img
=
img
;
}
public
void
setImg_preview
(
String
img_preview
)
{
this
.
img_preview
=
img_preview
;
}
public
void
setSorting
(
int
sorting
)
{
this
.
sorting
=
sorting
;
}
public
void
setActive
(
boolean
active
)
{
this
.
active
=
active
;
}
public
void
setVisible
(
boolean
visible
)
{
this
.
visible
=
visible
;
}
public
void
setBuyable
(
boolean
buyable
)
{
this
.
buyable
=
buyable
;
}
public
void
setUser_generated
(
boolean
user_generated
)
{
this
.
user_generated
=
user_generated
;
}
public
void
setLimits
(
JSONObject
limits
)
{
this
.
limits
=
limits
;
}
public
void
setPoints
(
int
points
)
{
this
.
points
=
points
;
}
public
void
setPoints_cause
(
String
points_cause
)
{
this
.
points_cause
=
points_cause
;
}
public
void
setExpiration
(
String
expiration
)
{
this
.
expiration
=
expiration
;
}
public
void
setThird_party_service
(
boolean
third_party_service
)
{
this
.
third_party_service
=
third_party_service
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
public
void
setShort_description
(
String
short_description
)
{
this
.
short_description
=
short_description
;
}
public
void
setDiscount
(
String
discount
)
{
this
.
discount
=
discount
;
}
public
void
setCategory
(
String
category
)
{
this
.
category
=
category
;
}
public
void
setTerms
(
String
terms
)
{
this
.
terms
=
terms
;
}
public
void
setAvailability
(
int
availability
)
{
this
.
availability
=
availability
;
}
public
void
setMerchantUuid
(
String
merchantUuid
)
{
this
.
merchantUuid
=
merchantUuid
;
}
public
void
setInnerText
(
String
innerText
)
{
this
.
innerText
=
innerText
;
}
public
void
setDiscount_type
(
String
discount_type
)
{
this
.
discount_type
=
discount_type
;
}
public
void
setFinal_price
(
double
final_price
)
{
this
.
final_price
=
final_price
;
}
@Override
public
int
describeContents
()
{
return
0
;
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/CouponsetModel.java
0 → 100644
View file @
19c70ab
package
ly
.
warp
.
sdk
.
io
.
models
;
import
com.google.gson.annotations.Expose
;
import
com.google.gson.annotations.SerializedName
;
import
java.util.ArrayList
;
/**
* Created by Panagiotis Triantafyllou on 24/Νοε/2022.
*/
public
class
CouponsetModel
{
@SerializedName
(
"status"
)
@Expose
private
String
status
;
@SerializedName
(
"context"
)
@Expose
private
CouponsetContext
context
;
public
String
getStatus
()
{
return
status
;
}
public
void
setStatus
(
String
status
)
{
this
.
status
=
status
;
}
public
CouponsetContext
getContext
()
{
return
context
;
}
public
void
setContext
(
CouponsetContext
context
)
{
this
.
context
=
context
;
}
public
class
CouponsetContext
{
@SerializedName
(
"MAPP_COUPON-status"
)
@Expose
private
Integer
mAPPCOUPONStatus
;
@SerializedName
(
"events_processed"
)
@Expose
private
Integer
eventsProcessed
;
@SerializedName
(
"MAPP_COUPON"
)
@Expose
private
ArrayList
<
MappCoupon
>
mappCoupon
=
null
;
public
ArrayList
<
MappCoupon
>
getMappCoupon
()
{
return
mappCoupon
;
}
public
void
setMappCoupon
(
ArrayList
<
MappCoupon
>
mappCoupon
)
{
this
.
mappCoupon
=
mappCoupon
;
}
public
Integer
getMAPPCOUPONStatus
()
{
return
mAPPCOUPONStatus
;
}
public
void
setMAPPCOUPONStatus
(
Integer
mAPPCOUPONStatus
)
{
this
.
mAPPCOUPONStatus
=
mAPPCOUPONStatus
;
}
public
Integer
getEventsProcessed
()
{
return
eventsProcessed
;
}
public
void
setEventsProcessed
(
Integer
eventsProcessed
)
{
this
.
eventsProcessed
=
eventsProcessed
;
}
}
public
class
MappCoupon
{
@SerializedName
(
"uuid"
)
@Expose
private
String
uuid
;
@SerializedName
(
"img_preview"
)
@Expose
private
String
imgPreview
;
@SerializedName
(
"final_price"
)
@Expose
private
Integer
finalPrice
;
@SerializedName
(
"start_date"
)
@Expose
private
String
startDate
;
@SerializedName
(
"end_date"
)
@Expose
private
String
endDate
;
@SerializedName
(
"discount_type"
)
@Expose
private
String
discountType
;
@SerializedName
(
"promoted"
)
@Expose
private
Boolean
promoted
;
@SerializedName
(
"expiration"
)
@Expose
private
CouponsetExpiration
expiration
;
@SerializedName
(
"name"
)
@Expose
private
String
name
;
@SerializedName
(
"description"
)
@Expose
private
String
description
;
@SerializedName
(
"short_description"
)
@Expose
private
String
shortDescription
;
@SerializedName
(
"discount"
)
@Expose
private
String
discount
;
@SerializedName
(
"terms"
)
@Expose
private
String
terms
;
@SerializedName
(
"inner_text"
)
@Expose
private
String
innerText
;
@SerializedName
(
"merchant_uuid"
)
@Expose
private
String
merchantUuid
;
public
String
getUuid
()
{
return
uuid
;
}
public
void
setUuid
(
String
uuid
)
{
this
.
uuid
=
uuid
;
}
public
String
getImgPreview
()
{
return
imgPreview
;
}
public
void
setImgPreview
(
String
imgPreview
)
{
this
.
imgPreview
=
imgPreview
;
}
public
Integer
getFinalPrice
()
{
return
finalPrice
;
}
public
void
setFinalPrice
(
Integer
finalPrice
)
{
this
.
finalPrice
=
finalPrice
;
}
public
String
getStartDate
()
{
return
startDate
;
}
public
void
setStartDate
(
String
startDate
)
{
this
.
startDate
=
startDate
;
}
public
String
getEndDate
()
{
return
endDate
;
}
public
void
setEndDate
(
String
endDate
)
{
this
.
endDate
=
endDate
;
}
public
String
getDiscountType
()
{
return
discountType
;
}
public
void
setDiscountType
(
String
discountType
)
{
this
.
discountType
=
discountType
;
}
public
Boolean
getPromoted
()
{
return
promoted
;
}
public
void
setPromoted
(
Boolean
promoted
)
{
this
.
promoted
=
promoted
;
}
public
CouponsetExpiration
getExpiration
()
{
return
expiration
;
}
public
void
setExpiration
(
CouponsetExpiration
expiration
)
{
this
.
expiration
=
expiration
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getDescription
()
{
return
description
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
public
String
getShortDescription
()
{
return
shortDescription
;
}
public
void
setShortDescription
(
String
shortDescription
)
{
this
.
shortDescription
=
shortDescription
;
}
public
String
getDiscount
()
{
return
discount
;
}
public
void
setDiscount
(
String
discount
)
{
this
.
discount
=
discount
;
}
public
String
getTerms
()
{
return
terms
;
}
public
void
setTerms
(
String
terms
)
{
this
.
terms
=
terms
;
}
public
String
getInnerText
()
{
return
innerText
;
}
public
void
setInnerText
(
String
innerText
)
{
this
.
innerText
=
innerText
;
}
public
String
getMerchantUuid
()
{
return
merchantUuid
;
}
public
void
setMerchantUuid
(
String
merchantUuid
)
{
this
.
merchantUuid
=
merchantUuid
;
}
}
public
class
CouponsetExpiration
{
@SerializedName
(
"type"
)
@Expose
private
String
type
;
@SerializedName
(
"value"
)
@Expose
private
String
value
;
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
this
.
type
=
type
;
}
public
String
getValue
()
{
return
value
;
}
public
void
setValue
(
String
value
)
{
this
.
value
=
value
;
}
}
}
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/CouponsetRequestModel.java
0 → 100644
View file @
19c70ab
package
ly
.
warp
.
sdk
.
io
.
models
;
import
org.json.JSONArray
;
import
org.json.JSONObject
;
import
java.util.ArrayList
;
import
ly.warp.sdk.Warply
;
import
ly.warp.sdk.utils.WarplyProperty
;
/**
* Created by Panagiotis Triantafyllou on 24/Νοε/2022.
*/
public
class
CouponsetRequestModel
{
private
CouponsetRequestInnerModel
coupon
;
public
CouponsetRequestModel
()
{
this
.
coupon
=
new
CouponsetRequestInnerModel
();
}
private
class
CouponsetRequestInnerModel
{
private
String
action
;
private
boolean
active
;
private
boolean
visible
;
private
String
language
;
public
CouponsetRequestInnerModel
()
{
this
.
action
=
"retrieve_multilingual"
;
this
.
active
=
true
;
this
.
visible
=
true
;
this
.
language
=
WarplyProperty
.
getLanguage
(
Warply
.
getWarplyContext
());
}
}
}
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/Merchant.java
View file @
19c70ab
...
...
@@ -565,6 +565,170 @@ public class Merchant implements Parcelable, Serializable, ClusterItem {
return
product
;
}
public
void
setAddress
(
String
address
)
{
this
.
address
=
address
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
void
setStore_id
(
String
store_id
)
{
this
.
store_id
=
store_id
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
void
setLogo
(
String
logo
)
{
this
.
logo
=
logo
;
}
public
void
setWebsite
(
String
website
)
{
this
.
website
=
website
;
}
public
void
setEmail
(
String
email
)
{
this
.
email
=
email
;
}
public
void
setTelephone
(
String
telephone
)
{
this
.
telephone
=
telephone
;
}
public
void
setCategory
(
String
category
)
{
this
.
category
=
category
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
public
void
setShort_description
(
String
short_description
)
{
this
.
short_description
=
short_description
;
}
public
void
setRegion
(
String
region
)
{
this
.
region
=
region
;
}
public
void
setLatitude
(
double
latitude
)
{
this
.
latitude
=
latitude
;
}
public
void
setLongitude
(
double
longitude
)
{
this
.
longitude
=
longitude
;
}
public
void
setImage
(
String
image
)
{
this
.
image
=
image
;
}
public
void
setExtra_fields
(
JSONObject
extra_fields
)
{
this
.
extra_fields
=
extra_fields
;
}
public
void
setActive
(
boolean
active
)
{
this
.
active
=
active
;
}
public
void
setCity
(
String
city
)
{
this
.
city
=
city
;
}
public
void
setCountry
(
String
country
)
{
this
.
country
=
country
;
}
public
void
setPostal_code
(
String
postal_code
)
{
this
.
postal_code
=
postal_code
;
}
public
void
setVat
(
String
vat
)
{
this
.
vat
=
vat
;
}
public
void
setUuid
(
String
uuid
)
{
this
.
uuid
=
uuid
;
}
public
void
setCategory_uuid
(
String
category_uuid
)
{
this
.
category_uuid
=
category_uuid
;
}
public
void
setCreated
(
String
created
)
{
this
.
created
=
created
;
}
public
void
setParent
(
String
parent
)
{
this
.
parent
=
parent
;
}
public
void
setImg
(
JSONArray
img
)
{
this
.
img
=
img
;
}
public
void
setImg_preview
(
String
img_preview
)
{
this
.
img_preview
=
img_preview
;
}
public
void
setAdmin_name
(
String
admin_name
)
{
this
.
admin_name
=
admin_name
;
}
public
void
setSorting
(
int
sorting
)
{
this
.
sorting
=
sorting
;
}
public
void
setBody
(
String
body
)
{
this
.
body
=
body
;
}
public
void
setOwner_name
(
String
owner_name
)
{
this
.
owner_name
=
owner_name
;
}
public
void
setPreview
(
String
preview
)
{
this
.
preview
=
preview
;
}
public
void
setMerchant_metadata
(
JSONObject
merchant_metadata
)
{
this
.
merchant_metadata
=
merchant_metadata
;
}
public
void
setPromoted
(
boolean
promoted
)
{
this
.
promoted
=
promoted
;
}
public
void
setDistance
(
int
distance
)
{
this
.
distance
=
distance
;
}
public
void
setDefault_shown
(
boolean
default_shown
)
{
this
.
default_shown
=
default_shown
;
}
public
void
setHidden
(
boolean
hidden
)
{
this
.
hidden
=
hidden
;
}
public
void
setWorking_hours
(
JSONObject
working_hours
)
{
this
.
working_hours
=
working_hours
;
}
public
void
setTags
(
JSONArray
tags
)
{
this
.
tags
=
tags
;
}
public
void
setProduct
(
JSONObject
product
)
{
this
.
product
=
product
;
}
public
void
setCoordinates
(
LatLng
coordinates
)
{
this
.
coordinates
=
coordinates
;
}
@Override
public
int
describeContents
()
{
return
0
;
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/MerchantModel.java
0 → 100644
View file @
19c70ab
package
ly
.
warp
.
sdk
.
io
.
models
;
import
com.google.gson.annotations.Expose
;
import
com.google.gson.annotations.SerializedName
;
import
java.util.ArrayList
;
import
java.util.Date
;
/**
* Created by Panagiotis Triantafyllou on 24/Νοε/2022.
*/
public
class
MerchantModel
{
@SerializedName
(
"status"
)
@Expose
private
String
status
;
@SerializedName
(
"context"
)
@Expose
private
MerchantContext
context
;
public
String
getStatus
()
{
return
status
;
}
public
void
setStatus
(
String
status
)
{
this
.
status
=
status
;
}
public
MerchantContext
getContext
()
{
return
context
;
}
public
void
setContext
(
MerchantContext
context
)
{
this
.
context
=
context
;
}
public
class
MerchantContext
{
@SerializedName
(
"MAPP_SHOPS"
)
@Expose
private
MappShops
mappShops
;
@SerializedName
(
"MAPP_SHOPS-status"
)
@Expose
private
Integer
mAPPSHOPSStatus
;
@SerializedName
(
"events_processed"
)
@Expose
private
Integer
eventsProcessed
;
public
MappShops
getMappShops
()
{
return
mappShops
;
}
public
void
setMappShops
(
MappShops
mappShops
)
{
this
.
mappShops
=
mappShops
;
}
public
Integer
getMAPPSHOPSStatus
()
{
return
mAPPSHOPSStatus
;
}
public
void
setMAPPSHOPSStatus
(
Integer
mAPPSHOPSStatus
)
{
this
.
mAPPSHOPSStatus
=
mAPPSHOPSStatus
;
}
public
Integer
getEventsProcessed
()
{
return
eventsProcessed
;
}
public
void
setEventsProcessed
(
Integer
eventsProcessed
)
{
this
.
eventsProcessed
=
eventsProcessed
;
}
}
public
class
MappShops
{
@SerializedName
(
"msg"
)
@Expose
private
String
msg
;
@SerializedName
(
"result"
)
@Expose
private
ArrayList
<
MerchantResult
>
result
=
null
;
public
String
getMsg
()
{
return
msg
;
}
public
void
setMsg
(
String
msg
)
{
this
.
msg
=
msg
;
}
public
ArrayList
<
MerchantResult
>
getResult
()
{
return
result
;
}
public
void
setResult
(
ArrayList
<
MerchantResult
>
result
)
{
this
.
result
=
result
;
}
}
public
class
MerchantResult
{
@SerializedName
(
"uuid"
)
@Expose
private
String
uuid
;
@SerializedName
(
"img_preview"
)
@Expose
private
String
imgPreview
;
@SerializedName
(
"admin_name"
)
@Expose
private
String
adminName
;
@SerializedName
(
"address"
)
@Expose
private
String
address
;
@SerializedName
(
"name"
)
@Expose
private
String
name
;
@SerializedName
(
"latitude"
)
@Expose
private
double
latitude
;
@SerializedName
(
"longitude"
)
@Expose
private
double
longitude
;
@SerializedName
(
"telephone"
)
@Expose
private
String
telephone
;
@SerializedName
(
"website"
)
@Expose
private
String
website
;
public
String
getUuid
()
{
return
uuid
;
}
public
void
setUuid
(
String
uuid
)
{
this
.
uuid
=
uuid
;
}
public
String
getImgPreview
()
{
return
imgPreview
;
}
public
void
setImgPreview
(
String
imgPreview
)
{
this
.
imgPreview
=
imgPreview
;
}
public
String
getAdminName
()
{
return
adminName
;
}
public
void
setAdminName
(
String
adminName
)
{
this
.
adminName
=
adminName
;
}
public
String
getAddress
()
{
return
address
;
}
public
void
setAddress
(
String
address
)
{
this
.
address
=
address
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
double
getLatitude
()
{
return
latitude
;
}
public
void
setLatitude
(
double
latitude
)
{
this
.
latitude
=
latitude
;
}
public
double
getLongitude
()
{
return
longitude
;
}
public
void
setLongitude
(
double
longitude
)
{
this
.
longitude
=
longitude
;
}
public
String
getTelephone
()
{
return
telephone
;
}
public
void
setTelephone
(
String
telephone
)
{
this
.
telephone
=
telephone
;
}
public
String
getWebsite
()
{
return
website
;
}
public
void
setWebsite
(
String
website
)
{
this
.
website
=
website
;
}
}
}
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/MerchantsRequestModel.java
0 → 100644
View file @
19c70ab
package
ly
.
warp
.
sdk
.
io
.
models
;
import
org.json.JSONArray
;
import
org.json.JSONObject
;
import
ly.warp.sdk.Warply
;
import
ly.warp.sdk.utils.WarplyProperty
;
/**
* Created by Panagiotis Triantafyllou on 24/Νοε/2022.
*/
public
class
MerchantsRequestModel
{
private
MerchantsRequestInnerModel
shops
;
public
MerchantsRequestModel
()
{
this
.
shops
=
new
MerchantsRequestInnerModel
();
}
private
class
MerchantsRequestInnerModel
{
private
String
action
;
private
JSONArray
categories
;
private
boolean
active
;
private
JSONObject
location
;
private
JSONArray
parent_uuids
;
private
String
language
;
public
MerchantsRequestInnerModel
()
{
this
.
action
=
"retrieve_multilingual"
;
this
.
categories
=
new
JSONArray
();
this
.
active
=
true
;
this
.
location
=
null
;
this
.
parent_uuids
=
null
;
this
.
language
=
WarplyProperty
.
getLanguage
(
Warply
.
getWarplyContext
());
}
}
}
warply_android_sdk/src/main/java/ly/warp/sdk/io/volley/ApiClient.java
0 → 100644
View file @
19c70ab
package
ly
.
warp
.
sdk
.
io
.
volley
;
import
java.util.concurrent.TimeUnit
;
import
ly.warp.sdk.Warply
;
import
ly.warp.sdk.utils.WarplyProperty
;
import
okhttp3.OkHttpClient
;
import
retrofit2.Retrofit
;
import
retrofit2.converter.gson.GsonConverterFactory
;
/**
* Created by Panagiotis Triantafyllou on 24/Νοε/2022.
*/
public
class
ApiClient
{
// ===========================================================
// Constants
// ===========================================================
// ===========================================================
// Fields
// ===========================================================
private
static
Retrofit
retrofit
;
// ===========================================================
// Methods for/from SuperClass/Interfaces
// ===========================================================
// ===========================================================
// Methods
// ===========================================================
public
static
Retrofit
getRetrofitInstance
()
{
// Gson gson = new GsonBuilder()
// .setLenient()
// .create();
if
(
retrofit
==
null
)
{
retrofit
=
new
Retrofit
.
Builder
()
.
baseUrl
(
WarplyProperty
.
getBaseUrl
(
Warply
.
getWarplyContext
()))
.
client
(
getClient
())
.
addConverterFactory
(
GsonConverterFactory
.
create
(
/*gson*/
))
.
build
();
}
return
retrofit
;
}
private
static
OkHttpClient
getClient
()
{
return
new
OkHttpClient
.
Builder
()
.
connectTimeout
(
30
,
TimeUnit
.
SECONDS
)
.
writeTimeout
(
30
,
TimeUnit
.
SECONDS
)
.
readTimeout
(
30
,
TimeUnit
.
SECONDS
)
.
build
();
}
// ===========================================================
// Getter & Setter
// ===========================================================
// ===========================================================
// Inner and Anonymous Classes
// ===========================================================
}
warply_android_sdk/src/main/java/ly/warp/sdk/io/volley/ApiService.java
0 → 100644
View file @
19c70ab
package
ly
.
warp
.
sdk
.
io
.
volley
;
import
ly.warp.sdk.io.models.CouponModel
;
import
ly.warp.sdk.io.models.CouponRequestModel
;
import
ly.warp.sdk.io.models.CouponsetModel
;
import
ly.warp.sdk.io.models.CouponsetRequestModel
;
import
ly.warp.sdk.io.models.MerchantModel
;
import
ly.warp.sdk.io.models.MerchantsRequestModel
;
import
ly.warp.sdk.utils.constants.WarpConstants
;
import
retrofit2.Call
;
import
retrofit2.http.Body
;
import
retrofit2.http.Header
;
import
retrofit2.http.POST
;
import
retrofit2.http.Path
;
/**
* Created by Panagiotis Triantafyllou on 24/Νοε/2022.
*/
public
interface
ApiService
{
// ===========================================================
// Constants
// ===========================================================
// ===========================================================
// Fields
// ===========================================================
// ===========================================================
// Methods for/from SuperClass/Interfaces
// ===========================================================
// ===========================================================
// Methods
// ===========================================================
@POST
(
"/api/mobile/v2/{appUuid}/context/"
)
Call
<
CouponsetModel
>
getCouponsets
(
@Path
(
"appUuid"
)
String
appUuid
,
@Body
CouponsetRequestModel
request
,
@Header
(
WarpConstants
.
HEADER_DATE
)
String
timeStamp
,
@Header
(
WarpConstants
.
HEADER_LOYALTY_BUNDLE_ID
)
String
bundleId
,
@Header
(
WarpConstants
.
HEADER_UNIQUE_DEVICE_ID
)
String
deviceId
,
@Header
(
WarpConstants
.
HEADER_CHANNEL
)
String
channel
,
@Header
(
WarpConstants
.
HEADER_WEB_ID
)
String
webId
,
@Header
(
WarpConstants
.
HEADER_SIGNATURE
)
String
signature
);
@POST
(
"/oauth/{appUuid}/context"
)
Call
<
CouponModel
>
getUserCoupons
(
@Path
(
"appUuid"
)
String
appUuid
,
@Body
CouponRequestModel
request
,
@Header
(
WarpConstants
.
HEADER_DATE
)
String
timeStamp
,
@Header
(
WarpConstants
.
HEADER_LOYALTY_BUNDLE_ID
)
String
bundleId
,
@Header
(
WarpConstants
.
HEADER_UNIQUE_DEVICE_ID
)
String
deviceId
,
@Header
(
WarpConstants
.
HEADER_CHANNEL
)
String
channel
,
@Header
(
WarpConstants
.
HEADER_WEB_ID
)
String
webId
,
@Header
(
WarpConstants
.
HEADER_SIGNATURE
)
String
signature
,
@Header
(
WarpConstants
.
HEADER_AUTHORIZATION
)
String
bearer
);
@POST
(
"/api/mobile/v2/{appUuid}/context/"
)
Call
<
MerchantModel
>
getMerchants
(
@Path
(
"appUuid"
)
String
appUuid
,
@Body
MerchantsRequestModel
request
,
@Header
(
WarpConstants
.
HEADER_DATE
)
String
timeStamp
,
@Header
(
WarpConstants
.
HEADER_LOYALTY_BUNDLE_ID
)
String
bundleId
,
@Header
(
WarpConstants
.
HEADER_UNIQUE_DEVICE_ID
)
String
deviceId
,
@Header
(
WarpConstants
.
HEADER_CHANNEL
)
String
channel
,
@Header
(
WarpConstants
.
HEADER_WEB_ID
)
String
webId
,
@Header
(
WarpConstants
.
HEADER_SIGNATURE
)
String
signature
);
// ===========================================================
// Getter & Setter
// ===========================================================
// ===========================================================
// Inner and Anonymous Classes
// ===========================================================
}
warply_android_sdk/src/main/java/ly/warp/sdk/utils/managers/WarplyManager.java
View file @
19c70ab
...
...
@@ -33,7 +33,10 @@ import android.app.PendingIntent;
import
android.content.Context
;
import
android.content.Intent
;
import
android.os.Build
;
import
android.os.Handler
;
import
android.os.Looper
;
import
android.os.SystemClock
;
import
android.text.format.DateFormat
;
import
androidx.work.OneTimeWorkRequest
;
import
androidx.work.WorkManager
;
...
...
@@ -50,6 +53,8 @@ import java.util.Collections;
import
java.util.Date
;
import
java.util.LinkedHashSet
;
import
java.util.Set
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.Executors
;
import
ly.warp.sdk.Warply
;
import
ly.warp.sdk.db.WarplyDBHelper
;
...
...
@@ -79,12 +84,19 @@ import ly.warp.sdk.io.models.Consumer;
import
ly.warp.sdk.io.models.ContentList
;
import
ly.warp.sdk.io.models.Coupon
;
import
ly.warp.sdk.io.models.CouponList
;
import
ly.warp.sdk.io.models.CouponModel
;
import
ly.warp.sdk.io.models.CouponRequestModel
;
import
ly.warp.sdk.io.models.Couponset
;
import
ly.warp.sdk.io.models.CouponsetModel
;
import
ly.warp.sdk.io.models.CouponsetRequestModel
;
import
ly.warp.sdk.io.models.CouponsetsList
;
import
ly.warp.sdk.io.models.LoyaltyContextualOfferModel
;
import
ly.warp.sdk.io.models.LoyaltySDKDynatraceEventModel
;
import
ly.warp.sdk.io.models.Merchant
;
import
ly.warp.sdk.io.models.MerchantCategoriesList
;
import
ly.warp.sdk.io.models.MerchantList
;
import
ly.warp.sdk.io.models.MerchantModel
;
import
ly.warp.sdk.io.models.MerchantsRequestModel
;
import
ly.warp.sdk.io.models.PacingDetails
;
import
ly.warp.sdk.io.models.PointsList
;
import
ly.warp.sdk.io.models.ProductList
;
...
...
@@ -139,13 +151,19 @@ import ly.warp.sdk.io.request.WarplyUserCouponsRequest;
import
ly.warp.sdk.io.request.WarplyValidateCouponRequest
;
import
ly.warp.sdk.io.request.WarplyVerifyOTPRequest
;
import
ly.warp.sdk.io.request.WarplyVerifyTicketRequest
;
import
ly.warp.sdk.io.volley.ApiClient
;
import
ly.warp.sdk.io.volley.ApiService
;
import
ly.warp.sdk.services.EventCampaignService
;
import
ly.warp.sdk.services.WarplyHealthService
;
import
ly.warp.sdk.utils.WarpJSONParser
;
import
ly.warp.sdk.utils.WarpUtils
;
import
ly.warp.sdk.utils.WarplyDeviceInfoCollector
;
import
ly.warp.sdk.utils.WarplyManagerHelper
;
import
ly.warp.sdk.utils.WarplyProperty
;
import
ly.warp.sdk.utils.constants.WarpConstants
;
import
retrofit2.Call
;
import
retrofit2.Callback
;
import
retrofit2.Response
;
/**
* Created by Panagiotis Triantafyllou on 15-Dec-21.
...
...
@@ -2531,6 +2549,307 @@ public class WarplyManager {
});
}
public
static
void
getUserCouponsWithCouponsets
(
final
CallbackReceiver
<
CouponList
>
receiver
)
{
WarpUtils
.
log
(
"************* WARPLY User Coupons Request ********************"
);
WarpUtils
.
log
(
"[WARP Trace] WARPLY User Coupons Request is active"
);
WarpUtils
.
log
(
"**************************************************"
);
getMerchantsRetro
(
new
Callback
<
MerchantModel
>()
{
@Override
public
void
onResponse
(
Call
<
MerchantModel
>
call
,
Response
<
MerchantModel
>
response
)
{
if
(
response
.
code
()
==
200
)
{
if
(
response
.
body
()
!=
null
&&
response
.
body
().
getStatus
().
equals
(
"1"
))
{
MerchantList
mMerchantList
=
new
MerchantList
();
final
ExecutorService
executorShops
=
Executors
.
newFixedThreadPool
(
2
);
executorShops
.
submit
(()
->
{
for
(
MerchantModel
.
MerchantResult
shop
:
response
.
body
().
getContext
().
getMappShops
().
getResult
())
{
Merchant
merchant
=
new
Merchant
();
merchant
.
setAddress
(
shop
.
getAddress
());
merchant
.
setName
(
shop
.
getName
());
merchant
.
setWebsite
(
shop
.
getWebsite
());
merchant
.
setTelephone
(
shop
.
getTelephone
());
merchant
.
setLatitude
(
shop
.
getLatitude
());
merchant
.
setLongitude
(
shop
.
getLongitude
());
merchant
.
setUuid
(
shop
.
getUuid
());
merchant
.
setImg_preview
(
shop
.
getImgPreview
());
merchant
.
setAdmin_name
(
shop
.
getAdminName
());
mMerchantList
.
add
(
merchant
);
}
WarplyManagerHelper
.
setMerchantList
(
mMerchantList
);
});
executorShops
.
shutdownNow
();
getCouponsetsRetro
(
new
Callback
<
CouponsetModel
>()
{
@Override
public
void
onResponse
(
Call
<
CouponsetModel
>
call
,
Response
<
CouponsetModel
>
response
)
{
if
(
response
.
code
()
==
200
)
{
if
(
response
.
body
()
!=
null
&&
response
.
body
().
getStatus
().
equals
(
"1"
))
{
getUserCouponsRetro
(
new
Callback
<
CouponModel
>()
{
@Override
public
void
onResponse
(
Call
<
CouponModel
>
call
,
Response
<
CouponModel
>
responseCoupons
)
{
if
(
responseCoupons
.
code
()
==
200
)
{
if
(
responseCoupons
.
body
()
!=
null
&&
responseCoupons
.
body
().
getStatus
()
==
1
)
{
LoyaltySDKDynatraceEventModel
dynatraceEvent
=
new
LoyaltySDKDynatraceEventModel
();
dynatraceEvent
.
setEventName
(
"custom_success_user_coupons_loyalty"
);
EventBus
.
getDefault
().
post
(
new
WarplyEventBusManager
(
dynatraceEvent
));
CouponList
mActiveCouponList
=
new
CouponList
();
final
ExecutorService
executor
=
Executors
.
newFixedThreadPool
(
2
);
executor
.
submit
(()
->
{
CouponList
mCouponList
=
new
CouponList
();
for
(
CouponModel
.
CouponResult
coupon
:
responseCoupons
.
body
().
getResult
())
{
for
(
CouponsetModel
.
MappCoupon
couponset
:
response
.
body
().
getContext
().
getMappCoupon
())
{
if
(
coupon
.
getCouponsetUuid
().
equals
(
couponset
.
getUuid
()))
{
Coupon
newCoupon
=
new
Coupon
();
newCoupon
.
setStatus
(
coupon
.
getStatus
());
JSONObject
obj
=
new
JSONObject
();
try
{
obj
.
putOpt
(
"assigned"
,
coupon
.
getChangesDates
().
getAssigned
());
obj
.
putOpt
(
"created"
,
coupon
.
getChangesDates
().
getCreated
());
newCoupon
.
setChangesDates
(
obj
);
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
newCoupon
.
setImage
(
coupon
.
getImage
());
newCoupon
.
setMerchantUuid
(
coupon
.
getMerchantUuid
());
newCoupon
.
setCoupon
(
coupon
.
getCoupon
());
newCoupon
.
setCouponsetUuid
(
coupon
.
getCouponsetUuid
());
newCoupon
.
setDiscount
(
coupon
.
getDiscount
());
newCoupon
.
setExpiration
(
coupon
.
getExpiration
());
newCoupon
.
setDescription
(
couponset
.
getShortDescription
());
newCoupon
.
setName
(
couponset
.
getName
());
newCoupon
.
setMerchantUuid
(
couponset
.
getMerchantUuid
());
newCoupon
.
setInnerText
(
couponset
.
getInnerText
());
newCoupon
.
setDiscount_type
(
couponset
.
getDiscountType
());
newCoupon
.
setFinal_price
(
couponset
.
getFinalPrice
());
mCouponList
.
add
(
newCoupon
);
}
}
}
WarplyManagerHelper
.
setCouponList
(
mCouponList
);
for
(
Coupon
coupon
:
mCouponList
)
{
if
(
coupon
.
getStatus
()
==
1
)
{
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd hh:mm"
);
Date
newDate
=
new
Date
();
try
{
newDate
=
simpleDateFormat
.
parse
(
coupon
.
getExpiration
());
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
coupon
.
setExpirationDate
(
newDate
);
mActiveCouponList
.
add
(
coupon
);
}
}
Collections
.
sort
(
mActiveCouponList
,
(
coupon1
,
coupon2
)
->
coupon1
.
getExpirationDate
().
compareTo
(
coupon2
.
getExpirationDate
()));
CouponsetsList
newCouponstList
=
new
CouponsetsList
();
for
(
CouponsetModel
.
MappCoupon
couponsetOld
:
response
.
body
().
getContext
().
getMappCoupon
())
{
Couponset
newCouponset
=
new
Couponset
();
newCouponset
.
setUuid
(
couponsetOld
.
getUuid
());
newCouponset
.
setImg_preview
(
couponsetOld
.
getImgPreview
());
newCouponset
.
setExpiration
(
couponsetOld
.
getExpiration
().
getValue
());
newCouponset
.
setName
(
couponsetOld
.
getName
());
newCouponset
.
setDescription
(
couponsetOld
.
getDescription
());
newCouponset
.
setShort_description
(
couponsetOld
.
getShortDescription
());
newCouponset
.
setDiscount
(
couponsetOld
.
getDiscount
());
newCouponset
.
setTerms
(
couponsetOld
.
getTerms
());
newCouponset
.
setMerchantUuid
(
couponsetOld
.
getMerchantUuid
());
newCouponset
.
setInnerText
(
couponsetOld
.
getInnerText
());
newCouponset
.
setDiscount_type
(
couponsetOld
.
getDiscountType
());
newCouponset
.
setFinal_price
(
couponsetOld
.
getFinalPrice
());
newCouponstList
.
add
(
newCouponset
);
}
WarplyManagerHelper
.
setCouponsets
(
newCouponstList
);
});
executor
.
shutdownNow
();
new
Handler
(
Looper
.
getMainLooper
()).
post
(()
->
receiver
.
onSuccess
(
mActiveCouponList
));
}
else
{
LoyaltySDKDynatraceEventModel
dynatraceEvent
=
new
LoyaltySDKDynatraceEventModel
();
dynatraceEvent
.
setEventName
(
"custom_error_user_coupons_loyalty"
);
EventBus
.
getDefault
().
post
(
new
WarplyEventBusManager
(
dynatraceEvent
));
receiver
.
onFailure
(
2
);
}
}
else
{
LoyaltySDKDynatraceEventModel
dynatraceEvent
=
new
LoyaltySDKDynatraceEventModel
();
dynatraceEvent
.
setEventName
(
"custom_error_user_coupons_loyalty"
);
EventBus
.
getDefault
().
post
(
new
WarplyEventBusManager
(
dynatraceEvent
));
receiver
.
onFailure
(
responseCoupons
.
code
());
}
}
@Override
public
void
onFailure
(
Call
<
CouponModel
>
call
,
Throwable
t
)
{
LoyaltySDKDynatraceEventModel
dynatraceEvent
=
new
LoyaltySDKDynatraceEventModel
();
dynatraceEvent
.
setEventName
(
"custom_error_user_coupons_loyalty"
);
EventBus
.
getDefault
().
post
(
new
WarplyEventBusManager
(
dynatraceEvent
));
receiver
.
onFailure
(
2
);
}
});
}
else
{
LoyaltySDKDynatraceEventModel
dynatraceEvent
=
new
LoyaltySDKDynatraceEventModel
();
dynatraceEvent
.
setEventName
(
"custom_error_couponsets_loyalty"
);
EventBus
.
getDefault
().
post
(
new
WarplyEventBusManager
(
dynatraceEvent
));
receiver
.
onFailure
(
2
);
}
}
else
{
LoyaltySDKDynatraceEventModel
dynatraceEvent
=
new
LoyaltySDKDynatraceEventModel
();
dynatraceEvent
.
setEventName
(
"custom_error_couponsets_loyalty"
);
EventBus
.
getDefault
().
post
(
new
WarplyEventBusManager
(
dynatraceEvent
));
receiver
.
onFailure
(
2
);
}
}
@Override
public
void
onFailure
(
Call
<
CouponsetModel
>
call
,
Throwable
t
)
{
LoyaltySDKDynatraceEventModel
dynatraceEvent
=
new
LoyaltySDKDynatraceEventModel
();
dynatraceEvent
.
setEventName
(
"custom_error_couponsets_loyalty"
);
EventBus
.
getDefault
().
post
(
new
WarplyEventBusManager
(
dynatraceEvent
));
receiver
.
onFailure
(
2
);
}
});
}
else
{
LoyaltySDKDynatraceEventModel
dynatraceEvent
=
new
LoyaltySDKDynatraceEventModel
();
dynatraceEvent
.
setEventName
(
"custom_error_shops_loyalty"
);
EventBus
.
getDefault
().
post
(
new
WarplyEventBusManager
(
dynatraceEvent
));
receiver
.
onFailure
(
2
);
}
}
else
{
LoyaltySDKDynatraceEventModel
dynatraceEvent
=
new
LoyaltySDKDynatraceEventModel
();
dynatraceEvent
.
setEventName
(
"custom_error_shops_loyalty"
);
EventBus
.
getDefault
().
post
(
new
WarplyEventBusManager
(
dynatraceEvent
));
receiver
.
onFailure
(
2
);
}
}
@Override
public
void
onFailure
(
Call
<
MerchantModel
>
call
,
Throwable
t
)
{
LoyaltySDKDynatraceEventModel
dynatraceEvent
=
new
LoyaltySDKDynatraceEventModel
();
dynatraceEvent
.
setEventName
(
"custom_error_shops_loyalty"
);
EventBus
.
getDefault
().
post
(
new
WarplyEventBusManager
(
dynatraceEvent
));
receiver
.
onFailure
(
2
);
}
});
}
private
static
void
getCouponsetsRetro
(
Callback
<
CouponsetModel
>
callback
)
{
String
timeStamp
=
DateFormat
.
format
(
"yyyy-MM-dd hh:mm:ss"
,
System
.
currentTimeMillis
()).
toString
();
String
apiKey
=
WarpUtils
.
getApiKey
(
Warply
.
getWarplyContext
());
String
webId
=
WarpUtils
.
getWebId
(
Warply
.
getWarplyContext
());
ApiService
service
=
ApiClient
.
getRetrofitInstance
().
create
(
ApiService
.
class
);
CouponsetRequestModel
couponsetRequest
=
new
CouponsetRequestModel
();
Call
<
CouponsetModel
>
couponsetCall
=
service
.
getCouponsets
(
WarplyProperty
.
getAppUuid
(
Warply
.
getWarplyContext
()),
couponsetRequest
,
timeStamp
,
"android:"
+
Warply
.
getWarplyContext
().
getPackageName
(),
new
WarplyDeviceInfoCollector
(
Warply
.
getWarplyContext
()).
getUniqueDeviceId
(),
"mobile"
,
webId
,
WarpUtils
.
produceSignature
(
apiKey
+
timeStamp
)
);
couponsetCall
.
enqueue
(
new
Callback
<
CouponsetModel
>()
{
/* =================================== Couponsets Start =================================== */
@Override
public
void
onResponse
(
Call
<
CouponsetModel
>
call
,
Response
<
CouponsetModel
>
response
)
{
callback
.
onResponse
(
call
,
response
);
}
@Override
public
void
onFailure
(
Call
<
CouponsetModel
>
call
,
Throwable
t
)
{
callback
.
onFailure
(
call
,
t
);
}
});
/* ====================================================================================== Couponsets nd =========================================== */
}
private
static
void
getMerchantsRetro
(
Callback
<
MerchantModel
>
callback
)
{
String
timeStamp
=
DateFormat
.
format
(
"yyyy-MM-dd hh:mm:ss"
,
System
.
currentTimeMillis
()).
toString
();
String
apiKey
=
WarpUtils
.
getApiKey
(
Warply
.
getWarplyContext
());
String
webId
=
WarpUtils
.
getWebId
(
Warply
.
getWarplyContext
());
ApiService
service
=
ApiClient
.
getRetrofitInstance
().
create
(
ApiService
.
class
);
MerchantsRequestModel
merchantsRequest
=
new
MerchantsRequestModel
();
Call
<
MerchantModel
>
merchantsCall
=
service
.
getMerchants
(
WarplyProperty
.
getAppUuid
(
Warply
.
getWarplyContext
()),
merchantsRequest
,
timeStamp
,
"android:"
+
Warply
.
getWarplyContext
().
getPackageName
(),
new
WarplyDeviceInfoCollector
(
Warply
.
getWarplyContext
()).
getUniqueDeviceId
(),
"mobile"
,
webId
,
WarpUtils
.
produceSignature
(
apiKey
+
timeStamp
)
);
merchantsCall
.
enqueue
(
new
Callback
<
MerchantModel
>()
{
/* =================================== Merchants Start =================================== */
@Override
public
void
onResponse
(
Call
<
MerchantModel
>
call
,
Response
<
MerchantModel
>
response
)
{
callback
.
onResponse
(
call
,
response
);
}
@Override
public
void
onFailure
(
Call
<
MerchantModel
>
call
,
Throwable
t
)
{
callback
.
onFailure
(
call
,
t
);
}
});
/* ====================================================================================== Merchants End ======================================= */
}
private
static
void
getUserCouponsRetro
(
Callback
<
CouponModel
>
callback
)
{
String
timeStamp
=
DateFormat
.
format
(
"yyyy-MM-dd hh:mm:ss"
,
System
.
currentTimeMillis
()).
toString
();
String
apiKey
=
WarpUtils
.
getApiKey
(
Warply
.
getWarplyContext
());
String
webId
=
WarpUtils
.
getWebId
(
Warply
.
getWarplyContext
());
ApiService
service
=
ApiClient
.
getRetrofitInstance
().
create
(
ApiService
.
class
);
CouponRequestModel
couponRequest
=
new
CouponRequestModel
();
Call
<
CouponModel
>
couponCall
=
service
.
getUserCoupons
(
WarplyProperty
.
getAppUuid
(
Warply
.
getWarplyContext
()),
couponRequest
,
timeStamp
,
"android:"
+
Warply
.
getWarplyContext
().
getPackageName
(),
new
WarplyDeviceInfoCollector
(
Warply
.
getWarplyContext
()).
getUniqueDeviceId
(),
"mobile"
,
webId
,
WarpUtils
.
produceSignature
(
apiKey
+
timeStamp
),
"Bearer "
+
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getAuthValue
(
"access_token"
)
);
couponCall
.
enqueue
(
new
Callback
<
CouponModel
>()
{
/* ================================== Coupons Start ================================== */
@Override
public
void
onResponse
(
Call
<
CouponModel
>
call
,
Response
<
CouponModel
>
response
)
{
if
(
response
.
code
()
==
401
)
{
refreshToken
(
new
WarplyRefreshTokenRequest
(),
new
CallbackReceiver
<
JSONObject
>()
{
@Override
public
void
onSuccess
(
JSONObject
result
)
{
int
status
=
result
.
optInt
(
"status"
,
2
);
if
(
status
==
1
)
getUserCouponsRetro
(
callback
);
else
callback
.
onFailure
(
call
,
new
Throwable
());
}
@Override
public
void
onFailure
(
int
errorCode
)
{
callback
.
onFailure
(
call
,
new
Throwable
());
}
});
}
else
if
(
response
.
code
()
==
200
)
{
callback
.
onResponse
(
call
,
response
);
}
}
@Override
public
void
onFailure
(
Call
<
CouponModel
>
call
,
Throwable
t
)
{
callback
.
onFailure
(
call
,
t
);
}
});
/* ============================================================================== Coupons nd ====================================== */
}
public
static
void
getCosmoteUser
(
WarplyCosmoteUserRequest
request
,
final
CallbackReceiver
<
JSONObject
>
receiver
)
{
WarpUtils
.
log
(
"************* WARPLY Cosmote User Request ********************"
);
WarpUtils
.
log
(
"[WARP Trace] WARPLY Cosmote User Request is active"
);
...
...
Please
register
or
login
to post a comment