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-06-15 19:38:34 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
09ff79b4358ee6e437be7e2f5528a8fc3478b334
09ff79b4
1 parent
6036e2be
new version
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
281 additions
and
7 deletions
warply_android_sdk/build.gradle
warply_android_sdk/src/main/java/ly/warp/sdk/activities/GiftsForYouActivity.java
warply_android_sdk/src/main/java/ly/warp/sdk/activities/MoreForYouActivity.java
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/CustomerStateModel.java
warply_android_sdk/src/main/java/ly/warp/sdk/io/request/WarplyIntegrationRequest.java
warply_android_sdk/src/main/java/ly/warp/sdk/utils/WarplyManagerHelper.java
warply_android_sdk/src/main/java/ly/warp/sdk/utils/managers/WarplyEventBusManager.java
warply_android_sdk/src/main/java/ly/warp/sdk/utils/managers/WarplyManager.java
warply_android_sdk/build.gradle
View file @
09ff79b
...
...
@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
ext
{
PUBLISH_GROUP_ID
=
'ly.warp'
PUBLISH_VERSION
=
'4.5.4-cosbeta1
0
'
PUBLISH_VERSION
=
'4.5.4-cosbeta1
1
'
PUBLISH_ARTIFACT_ID
=
'warply-android-sdk'
}
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/activities/GiftsForYouActivity.java
View file @
09ff79b
...
...
@@ -180,11 +180,11 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene
mAdapterMergedGifts
.
getPositionClicks
()
.
doOnNext
(
dataItem
->
{
if
(
dataItem
.
getDataType
()
==
1
)
{
EventBus
.
getDefault
().
post
(
new
WarplyEventBusManager
(
).
postWarplyEventBus
(
"gifts"
,
new
LoyaltyGiftsForYouOfferClickEvent
()));
EventBus
.
getDefault
().
post
(
new
WarplyEventBusManager
(
new
LoyaltyGiftsForYouOfferClickEvent
()));
startActivity
(
WarpViewActivity
.
createIntentFromURL
(
this
,
WarplyManagerHelper
.
constructCampaignUrl
(
dataItem
.
getCampaign
())));
}
else
if
(
dataItem
.
getDataType
()
==
2
)
{
EventBus
.
getDefault
().
post
(
new
WarplyEventBusManager
(
).
postWarplyEventBus
(
"ccms"
,
new
LoyaltyContextualOfferModel
()));
EventBus
.
getDefault
().
post
(
new
WarplyEventBusManager
(
new
LoyaltyContextualOfferModel
()));
Intent
intent
=
new
Intent
(
GiftsForYouActivity
.
this
,
CouponsetInfoActivity
.
class
);
intent
.
putExtra
(
"couponset"
,
(
Serializable
)
dataItem
.
getCouponset
());
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/activities/MoreForYouActivity.java
View file @
09ff79b
...
...
@@ -90,7 +90,7 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener
mRecyclerMore
.
setAdapter
(
mAdapterMore
);
mAdapterMore
.
getPositionClicks
()
.
doOnNext
(
gift
->
{
EventBus
.
getDefault
().
post
(
new
WarplyEventBusManager
(
).
postWarplyEventBus
(
"firebase"
,
new
LoyaltySDKFirebaseEventModel
()));
EventBus
.
getDefault
().
post
(
new
WarplyEventBusManager
(
new
LoyaltySDKFirebaseEventModel
()));
startActivity
(
WarpViewActivity
.
createIntentFromURL
(
this
,
WarplyManagerHelper
.
constructCampaignUrl
(
gift
)));
})
.
doOnError
(
error
->
{
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/CustomerStateModel.java
View file @
09ff79b
...
...
@@ -9,10 +9,14 @@ import java.util.ArrayList;
public
class
CustomerStateModel
{
private
boolean
nonTelco
=
false
;
private
boolean
acceptedConsent
=
false
;
private
ArrayList
<
String
>
msisdnList
=
new
ArrayList
<>();
private
String
guid
=
""
;
public
CustomerStateModel
()
{
this
.
nonTelco
=
false
;
this
.
acceptedConsent
=
false
;
this
.
msisdnList
=
new
ArrayList
<>();
this
.
guid
=
""
;
}
public
boolean
isNonTelco
()
{
...
...
@@ -30,4 +34,20 @@ public class CustomerStateModel {
public
void
setAcceptedConsent
(
boolean
acceptedConsent
)
{
this
.
acceptedConsent
=
acceptedConsent
;
}
public
ArrayList
<
String
>
getMsisdnList
()
{
return
msisdnList
;
}
public
void
setMsisdnList
(
ArrayList
<
String
>
msisdnList
)
{
this
.
msisdnList
=
msisdnList
;
}
public
String
getGuid
()
{
return
guid
;
}
public
void
setGuid
(
String
guid
)
{
this
.
guid
=
guid
;
}
}
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/io/request/WarplyIntegrationRequest.java
0 → 100644
View file @
09ff79b
package
ly
.
warp
.
sdk
.
io
.
request
;
import
android.util.Base64
;
import
org.json.JSONArray
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
java.io.UnsupportedEncodingException
;
import
java.security.MessageDigest
;
import
java.security.NoSuchAlgorithmException
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
ly.warp.sdk.utils.WarplyManagerHelper
;
import
ly.warp.sdk.utils.constants.WarpConstants
;
/**
* Created by Panagiotis Triantafyllou on 15-June-22.
*/
public
class
WarplyIntegrationRequest
{
// ===========================================================
// Constants
// ===========================================================
private
final
String
KEY_MAPP
=
"consumer_data"
;
private
final
String
KEY_ACTION
=
"action"
;
private
final
String
KEY_ACTION_VALUE
=
"integration"
;
private
final
String
KEY_DATA
=
"data"
;
// ===========================================================
// Fields
// ===========================================================
private
HashMap
<
String
,
String
>
mFilters
;
private
long
mCacheUpdateInterval
=
0
;
// ===========================================================
// Constructor
// ===========================================================
/**
* Default constructor of WarplyIntegrationRequest, initializes an empty filters HashMap
*/
public
WarplyIntegrationRequest
()
{
mFilters
=
new
HashMap
<>();
}
public
WarplyIntegrationRequest
(
WarplyIntegrationRequest
copy
)
{
if
(
copy
!=
null
)
{
this
.
mFilters
=
copy
.
mFilters
;
this
.
mCacheUpdateInterval
=
copy
.
mCacheUpdateInterval
;
}
}
// ===========================================================
// Methods for/from SuperClass/Interfaces
// ===========================================================
@Override
public
boolean
equals
(
Object
object
)
{
if
(
object
instanceof
WarplyIntegrationRequest
)
{
WarplyIntegrationRequest
other
=
(
WarplyIntegrationRequest
)
object
;
return
other
==
this
||
(
this
.
mFilters
==
other
.
mFilters
||
(
this
.
mFilters
!=
null
&&
this
.
mFilters
.
equals
(
other
.
mFilters
)));
}
return
false
;
}
@Override
public
int
hashCode
()
{
return
mFilters
.
hashCode
();
}
// ===========================================================
// Methods
// ===========================================================
// ===========================================================
// Getter & Setter
// ===========================================================
/**
* Call this to get how often the cached data will be updated.
*
* @return mCacheUpdateInterval
*/
public
long
getCacheUpdateInterval
()
{
return
mCacheUpdateInterval
;
}
/**
* Call this to set how often the cached data will be updated.
*
* @param updateInterval The time that data will be cached
* @return WarplyIntegrationRequest
*/
public
WarplyIntegrationRequest
setCacheUpdateInterval
(
long
updateInterval
)
{
this
.
mCacheUpdateInterval
=
updateInterval
;
if
(
mCacheUpdateInterval
<
0
)
{
mCacheUpdateInterval
=
0
;
}
return
this
;
}
/**
* Call this to check if the Application uses Cache
*
* @return <p>true - the Application is using Cache</p>
* <p>false - the Application is not using Cache</p>
*/
public
boolean
isUseCache
()
{
return
mCacheUpdateInterval
>
0
;
}
/**
* Call this to check whether the cached data need to be updated
*
* @param useCache <p>true - the Application is using Cache</p>
* <p>false - the Application is not using Cache</p>
* @return WarplyIntegrationRequest
*/
public
WarplyIntegrationRequest
setUseCache
(
boolean
useCache
)
{
if
(
useCache
)
{
mCacheUpdateInterval
=
mCacheUpdateInterval
>
0
?
mCacheUpdateInterval
:
WarpConstants
.
INBOX_UPDATE_INTERVAL
;
}
else
{
mCacheUpdateInterval
=
0
;
}
return
this
;
}
/**
* Call this to build the offers Json object
*
* @return bodyJsonObject
*/
public
JSONObject
toJson
()
{
JSONObject
bodyJsonObject
=
new
JSONObject
();
try
{
JSONObject
extraJson
=
new
JSONObject
();
extraJson
.
putOpt
(
KEY_ACTION
,
KEY_ACTION_VALUE
);
JSONObject
data
=
new
JSONObject
();
data
.
putOpt
(
"nonTelco"
,
WarplyManagerHelper
.
loadCustomerState
().
isNonTelco
());
data
.
putOpt
(
"acceptedConsent"
,
WarplyManagerHelper
.
loadCustomerState
().
isAcceptedConsent
());
data
.
putOpt
(
"msisdnList"
,
new
JSONArray
(
WarplyManagerHelper
.
loadCustomerState
().
getMsisdnList
()));
data
.
putOpt
(
"guid"
,
WarplyManagerHelper
.
loadCustomerState
().
getGuid
());
extraJson
.
putOpt
(
KEY_DATA
,
data
);
bodyJsonObject
.
putOpt
(
KEY_MAPP
,
extraJson
);
}
catch
(
JSONException
e
)
{
if
(
WarpConstants
.
DEBUG
)
e
.
printStackTrace
();
}
return
bodyJsonObject
;
}
public
String
getSignature
()
{
String
signature
=
mFilters
!=
null
&&
mFilters
.
size
()
>
0
?
String
.
valueOf
(
mFilters
.
hashCode
())
:
"default_integration_request"
;
try
{
byte
[]
hash
=
MessageDigest
.
getInstance
(
"SHA-256"
).
digest
(
signature
.
getBytes
(
"UTF-8"
));
signature
=
Base64
.
encodeToString
(
hash
,
Base64
.
NO_WRAP
);
}
catch
(
NullPointerException
|
NoSuchAlgorithmException
|
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
}
return
signature
;
}
}
warply_android_sdk/src/main/java/ly/warp/sdk/utils/WarplyManagerHelper.java
View file @
09ff79b
...
...
@@ -56,6 +56,7 @@ public class WarplyManagerHelper {
private
static
HashMap
<
String
,
CampaignList
>
mUniqueCampaignList
=
new
HashMap
<
String
,
CampaignList
>();
private
static
CouponList
mCouponList
=
new
CouponList
();
private
static
CouponsetsList
mCouponsetsList
=
new
CouponsetsList
();
private
static
CustomerStateModel
mCustomerStateModel
;
// ===========================================================
// Methods for/from SuperClass/Interfaces
...
...
@@ -89,6 +90,30 @@ public class WarplyManagerHelper {
}
/**
* Open Warply campaign with sharing id
*/
public
static
String
constructCampaignUrlForShare
(
Campaign
item
,
String
deeplink
)
{
item
.
setNew
(
false
);
String
url
=
item
.
getIndexUrl
()
+
"?web_id="
+
WarpUtils
.
getWebId
(
Warply
.
getWarplyContext
())
+
"&app_uuid="
+
WarplyProperty
.
getAppUuid
(
Warply
.
getWarplyContext
())
+
"&api_key="
+
WarpUtils
.
getApiKey
(
Warply
.
getWarplyContext
())
+
"&session_uuid="
+
item
.
getSessionUUID
()
+
"&access_token="
+
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getAuthValue
(
"access_token"
)
+
"&refresh_token="
+
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getAuthValue
(
"refresh_token"
)
+
"&client_id="
+
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getClientValue
(
"client_id"
)
+
"&client_secret="
+
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getClientValue
(
"client_secret"
);
/*+ "&sharing_id=" + sharingId;*/
if
(
mConsumer
!=
null
)
url
=
url
+
"&auth_token="
+
(
mConsumer
.
getUuid
());
else
url
=
url
+
"&auth_token="
;
return
url
;
}
/**
* Open CCMS campaign
*/
public
static
String
constructCcmsUrl
(
LoyaltyContextualOfferModel
item
)
{
...
...
@@ -108,14 +133,25 @@ public class WarplyManagerHelper {
* Open Questionnaire
*/
public
static
void
openQuestionnaire
()
{
if
(
mUniqueCampaignList
!=
null
&&
mUniqueCampaignList
.
get
(
"questionnaire"
)
!=
null
&&
mUniqueCampaignList
.
get
(
"questionnaire"
).
size
()
>
0
)
{
constructCampaignUrl
(
mUniqueCampaignList
.
get
(
"questionnaire"
).
get
(
0
));
}
}
/**
* Save if customer is nonTelco and if he/she has accepted the consents,
* And his msisdn list
*/
public
static
void
saveCustomerState
(
CustomerStateModel
customerState
)
{
mCustomerStateModel
=
customerState
;
}
/**
* Save if customer is nonTelco and if he/she has accepted the consents
* Get if customer is nonTelco and if he/she has accepted the consents
* And his msisdn list
*/
public
static
void
loadCustomerState
(
CustomerStateModel
customerState
)
{
//TODO: write code to save the parameter
public
static
CustomerStateModel
loadCustomerState
(
)
{
return
mCustomerStateModel
;
}
/**
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/utils/managers/WarplyEventBusManager.java
View file @
09ff79b
...
...
@@ -22,6 +22,7 @@ public class WarplyEventBusManager {
private
WarplyPacingCardServiceEnabledModel
pacingService
;
private
WarplyDealsAnalysisEventModel
dealsAnalysis
;
private
WarplyCCMSEnabledModel
ccmsActivated
;
private
LoyaltyGiftsForYouOfferClickEvent
giftsYou
;
public
WarplyEventBusManager
()
{
...
...
@@ -73,6 +74,10 @@ public class WarplyEventBusManager {
return
this
;
}
public
WarplyEventBusManager
(
LoyaltyGiftsForYouOfferClickEvent
giftsYou
)
{
this
.
giftsYou
=
giftsYou
;
}
public
HashMap
<
String
,
Object
>
subscribeWarplyEventBus
()
{
return
mWarplyEventBusManager
;
}
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/utils/managers/WarplyManager.java
View file @
09ff79b
...
...
@@ -76,6 +76,7 @@ import ly.warp.sdk.io.request.WarplyGetAddressRequest;
import
ly.warp.sdk.io.request.WarplyGetCampaignsRequest
;
import
ly.warp.sdk.io.request.WarplyGetCardsRequest
;
import
ly.warp.sdk.io.request.WarplyGetCouponsetsRequest
;
import
ly.warp.sdk.io.request.WarplyIntegrationRequest
;
import
ly.warp.sdk.io.request.WarplyLoginRequest
;
import
ly.warp.sdk.io.request.WarplyMerchantCategoriesRequest
;
import
ly.warp.sdk.io.request.WarplyMerchantsRequest
;
...
...
@@ -1309,4 +1310,43 @@ public class WarplyManager {
},
request
.
getSignature
()));
}
public
static
void
consumerIntegration
(
WarplyIntegrationRequest
request
,
final
CallbackReceiver
<
JSONObject
>
receiver
)
{
WarpUtils
.
log
(
"************* WARPLY Integration Consumer Request ********************"
);
WarpUtils
.
log
(
"[WARP Trace] WARPLY Integration Consumer Request is active"
);
WarpUtils
.
log
(
"**************************************************"
);
Warply
.
postReceiveMicroappData
(
true
,
"context"
,
request
.
toJson
(),
new
CallbackReceiver
<
JSONObject
>()
{
@Override
public
void
onSuccess
(
JSONObject
result
)
{
int
status
=
result
.
optInt
(
"status"
,
2
);
if
(
status
==
1
)
receiver
.
onSuccess
(
result
);
else
receiver
.
onFailure
(
status
);
}
@Override
public
void
onFailure
(
int
errorCode
)
{
if
(
errorCode
==
401
)
{
refreshToken
(
new
WarplyRefreshTokenRequest
(),
new
CallbackReceiver
<
JSONObject
>()
{
@Override
public
void
onSuccess
(
JSONObject
result
)
{
int
status
=
result
.
optInt
(
"status"
,
2
);
if
(
status
==
1
)
consumerIntegration
(
request
,
receiver
);
else
receiver
.
onFailure
(
status
);
}
@Override
public
void
onFailure
(
int
errorCode
)
{
receiver
.
onFailure
(
errorCode
);
}
});
}
else
receiver
.
onFailure
(
errorCode
);
}
});
}
}
...
...
Please
register
or
login
to post a comment