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-07-15 13:50:43 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ed4958b57cd6c498af78bd572fe854e63edead6d
ed4958b5
1 parent
33d2b4c2
customer state model
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
309 additions
and
18 deletions
warply_android_sdk/build.gradle
warply_android_sdk/src/main/java/ly/warp/sdk/io/request/CosmoteSubmitOrderRequest.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/WarplyManager.java
warply_android_sdk/build.gradle
View file @
ed4958b
...
...
@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
ext
{
PUBLISH_GROUP_ID
=
'ly.warp'
PUBLISH_VERSION
=
'4.5.4-cosbeta3
3
'
PUBLISH_VERSION
=
'4.5.4-cosbeta3
4
'
PUBLISH_ARTIFACT_ID
=
'warply-android-sdk'
}
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/io/request/CosmoteSubmitOrderRequest.java
0 → 100644
View file @
ed4958b
package
ly
.
warp
.
sdk
.
io
.
request
;
import
android.util.Base64
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
java.io.UnsupportedEncodingException
;
import
java.security.MessageDigest
;
import
java.security.NoSuchAlgorithmException
;
import
java.util.HashMap
;
import
ly.warp.sdk.utils.constants.WarpConstants
;
/**
* Created by Panagiotis Triantafyllou on 15-July-22.
*/
public
class
CosmoteSubmitOrderRequest
{
// ===========================================================
// Constants
// ===========================================================
private
final
String
KEY_MAPP
=
"wallet"
;
private
final
String
KEY_ACTION
=
"action"
;
private
final
String
KEY_ACTION_VALUE
=
"add_product"
;
private
final
String
KEY_PRODUCT_UUID
=
"product_uuid"
;
private
final
String
KEY_PRODUCT_UUID_VALUE
=
"011d21908d984e3cbecbdfd2920a5d3b"
;
private
final
String
KEY_COMMUNICATION_UUID
=
"communication_uuid"
;
private
final
String
KEY_EXTRA_DATA
=
"extra_data"
;
private
final
String
KEY_USER_MSISDN
=
"user_msisdn"
;
private
final
String
KEY_BUSINESS_SERVICE
=
"businessService"
;
private
final
String
KEY_OFFER_NAME
=
"offerName"
;
private
final
String
KEY_PRODUCT_TYPE
=
"productType"
;
private
final
String
KEY_PROV_DURATION
=
"provDuration"
;
private
final
String
KEY_NO_OF_RECURRANCE
=
"noOfRecurrance"
;
private
final
String
KEY_PRICE
=
"price"
;
private
final
String
KEY_DISCOUNT
=
"discount"
;
private
final
String
KEY_VOICE_CATEGORY
=
"voiceCategory"
;
private
final
String
KEY_DATA_CATEGORY
=
"dataCategory"
;
private
final
String
KEY_MINS_VALUE
=
"minsValue"
;
private
final
String
KEY_DATA_VALUE
=
"dataValue"
;
private
final
String
KEY_PROV_STEP_VALUE_MINS
=
"provStepValueMins"
;
// ===========================================================
// Fields
// ===========================================================
private
HashMap
<
String
,
String
>
mFilters
;
private
long
mCacheUpdateInterval
=
0
;
private
String
mCommunicationUuid
=
""
;
private
String
mUserMsisdn
=
""
;
private
String
mBusinessService
=
""
;
private
String
mOfferName
=
""
;
private
String
mProductType
=
""
;
private
String
mProvDuration
=
""
;
private
String
mNoOfRecurrance
=
""
;
private
String
mPrice
=
""
;
private
String
mDiscount
=
""
;
private
String
mVoiceCategory
=
""
;
private
String
mDataCategory
=
""
;
private
String
mMinsValue
=
""
;
private
String
mDataValue
=
""
;
private
String
mProvStepValueMins
=
""
;
// ===========================================================
// Constructor
// ===========================================================
/**
* Default constructor of CosmoteSharingRequest, initializes an empty filters HashMap
*/
public
CosmoteSubmitOrderRequest
()
{
mFilters
=
new
HashMap
<>();
}
public
CosmoteSubmitOrderRequest
(
CosmoteSubmitOrderRequest
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
CosmoteSubmitOrderRequest
)
{
CosmoteSubmitOrderRequest
other
=
(
CosmoteSubmitOrderRequest
)
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
// ===========================================================
public
CosmoteSubmitOrderRequest
setCommunicationUuid
(
String
communicationUuid
)
{
mCommunicationUuid
=
communicationUuid
;
return
this
;
}
public
CosmoteSubmitOrderRequest
setUserMsisdn
(
String
userMsisdn
)
{
mUserMsisdn
=
userMsisdn
;
return
this
;
}
public
CosmoteSubmitOrderRequest
setBusinessService
(
String
businessService
)
{
mBusinessService
=
businessService
;
return
this
;
}
public
CosmoteSubmitOrderRequest
setOfferName
(
String
offerName
)
{
mOfferName
=
offerName
;
return
this
;
}
public
CosmoteSubmitOrderRequest
setProductType
(
String
productType
)
{
mProductType
=
productType
;
return
this
;
}
public
CosmoteSubmitOrderRequest
setProvDuration
(
String
provDuration
)
{
mProvDuration
=
provDuration
;
return
this
;
}
public
CosmoteSubmitOrderRequest
setNoOfRecurrance
(
String
noOfRecurrance
)
{
mNoOfRecurrance
=
noOfRecurrance
;
return
this
;
}
public
CosmoteSubmitOrderRequest
setPrice
(
String
price
)
{
mPrice
=
price
;
return
this
;
}
public
CosmoteSubmitOrderRequest
setDiscount
(
String
discount
)
{
mDiscount
=
discount
;
return
this
;
}
public
CosmoteSubmitOrderRequest
setVoiceCategory
(
String
voiceCategory
)
{
mVoiceCategory
=
voiceCategory
;
return
this
;
}
public
CosmoteSubmitOrderRequest
setDataCategory
(
String
dataCategory
)
{
mDataCategory
=
dataCategory
;
return
this
;
}
public
CosmoteSubmitOrderRequest
setMinsValue
(
String
minsValue
)
{
mMinsValue
=
minsValue
;
return
this
;
}
public
CosmoteSubmitOrderRequest
setDataValue
(
String
dataValue
)
{
mDataValue
=
dataValue
;
return
this
;
}
public
CosmoteSubmitOrderRequest
setProvStepValueMins
(
String
provStepValueMins
)
{
mProvStepValueMins
=
provStepValueMins
;
return
this
;
}
/**
* 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 CosmoteSharingRequest
*/
public
CosmoteSubmitOrderRequest
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 CosmoteSharingRequest
*/
public
CosmoteSubmitOrderRequest
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
);
extraJson
.
putOpt
(
KEY_PRODUCT_UUID
,
KEY_PRODUCT_UUID_VALUE
);
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_cosmote_sharing_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/io/request/WarplyIntegrationRequest.java
View file @
ed4958b
...
...
@@ -38,10 +38,10 @@ public class WarplyIntegrationRequest {
private
HashMap
<
String
,
String
>
mFilters
;
private
long
mCacheUpdateInterval
=
0
;
private
boolean
i
sNonTelco
=
false
;
private
boolean
h
asAcceptedConsent
=
false
;
private
String
g
uid
=
""
;
private
ArrayList
<
String
>
p
honeList
=
new
ArrayList
<>();
private
boolean
mI
sNonTelco
=
false
;
private
boolean
mH
asAcceptedConsent
=
false
;
private
String
mG
uid
=
""
;
private
ArrayList
<
String
>
mP
honeList
=
new
ArrayList
<>();
// ===========================================================
// Constructor
...
...
@@ -51,7 +51,11 @@ public class WarplyIntegrationRequest {
* Default constructor of WarplyIntegrationRequest, initializes an empty filters HashMap
*/
public
WarplyIntegrationRequest
()
{
mFilters
=
new
HashMap
<>();
this
.
mFilters
=
new
HashMap
<>();
this
.
mIsNonTelco
=
false
;
this
.
mHasAcceptedConsent
=
false
;
this
.
mGuid
=
""
;
this
.
mPhoneList
=
new
ArrayList
<>();
}
public
WarplyIntegrationRequest
(
WarplyIntegrationRequest
copy
)
{
...
...
@@ -88,22 +92,22 @@ public class WarplyIntegrationRequest {
// ===========================================================
public
WarplyIntegrationRequest
setIsNoTelco
(
boolean
isNonTelco
)
{
i
sNonTelco
=
isNonTelco
;
this
.
mI
sNonTelco
=
isNonTelco
;
return
this
;
}
public
WarplyIntegrationRequest
setHasAcceptedConsent
(
boolean
hasAcceptedConsent
)
{
h
asAcceptedConsent
=
hasAcceptedConsent
;
this
.
mH
asAcceptedConsent
=
hasAcceptedConsent
;
return
this
;
}
public
WarplyIntegrationRequest
setMsisdnList
(
ArrayList
<
String
>
phoneList
)
{
p
honeList
=
phoneList
;
this
.
mP
honeList
=
phoneList
;
return
this
;
}
public
WarplyIntegrationRequest
setGuid
(
String
guid
)
{
g
uid
=
guid
;
this
.
mG
uid
=
guid
;
return
this
;
}
...
...
@@ -171,10 +175,10 @@ public class WarplyIntegrationRequest {
extraJson
.
putOpt
(
KEY_ACTION
,
KEY_ACTION_VALUE
);
extraJson
.
putOpt
(
KEY_METHOD
,
KEY_METHOD_VALUE
);
JSONObject
data
=
new
JSONObject
();
data
.
putOpt
(
"nonTelco"
,
i
sNonTelco
);
data
.
putOpt
(
"acceptedConsent"
,
h
asAcceptedConsent
);
data
.
putOpt
(
"msisdnList"
,
new
JSONArray
(
p
honeList
));
data
.
putOpt
(
"guid"
,
g
uid
);
data
.
putOpt
(
"nonTelco"
,
mI
sNonTelco
);
data
.
putOpt
(
"acceptedConsent"
,
mH
asAcceptedConsent
);
data
.
putOpt
(
"msisdnList"
,
new
JSONArray
(
mP
honeList
));
data
.
putOpt
(
"guid"
,
mG
uid
);
extraJson
.
putOpt
(
KEY_DATA
,
data
);
bodyJsonObject
.
putOpt
(
KEY_MAPP
,
extraJson
);
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/utils/WarplyManagerHelper.java
View file @
ed4958b
...
...
@@ -579,10 +579,10 @@ public class WarplyManagerHelper {
mCustomerStateModel
=
customerState
;
WarplyIntegrationRequest
request
=
new
WarplyIntegrationRequest
();
request
.
setIsNoTelco
(
customerState
.
isNonTelco
())
;
request
.
setHasAcceptedConsent
(
customerState
.
isAcceptedConsent
());
request
.
setGuid
(
customerState
.
getGuid
());
request
.
setMsisdnList
(
customerState
.
getMsisdnList
());
request
.
setIsNoTelco
(
customerState
.
isNonTelco
())
.
setHasAcceptedConsent
(
customerState
.
isAcceptedConsent
())
.
setGuid
(
customerState
.
getGuid
())
.
setMsisdnList
(
customerState
.
getMsisdnList
());
WarplyManager
.
consumerIntegration
(
request
,
new
CallbackReceiver
<
JSONObject
>()
{
@Override
public
void
onSuccess
(
JSONObject
result
)
{
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/utils/managers/WarplyManager.java
View file @
ed4958b
...
...
@@ -75,6 +75,7 @@ import ly.warp.sdk.io.models.TransactionsList;
import
ly.warp.sdk.io.request.CosmoteCouponSharingRequest
;
import
ly.warp.sdk.io.request.CosmoteRetrieveSharingRequest
;
import
ly.warp.sdk.io.request.CosmoteSharingRequest
;
import
ly.warp.sdk.io.request.CosmoteSubmitOrderRequest
;
import
ly.warp.sdk.io.request.PacingDetailsRequest
;
import
ly.warp.sdk.io.request.WarplyAddAddressRequest
;
import
ly.warp.sdk.io.request.WarplyAddCardRequest
;
...
...
@@ -2244,4 +2245,26 @@ public class WarplyManager {
}
});
}
public
static
void
submitOrder
(
CosmoteSubmitOrderRequest
request
,
final
CallbackReceiver
<
JSONObject
>
receiver
)
{
WarpUtils
.
log
(
"************* WARPLY Submit Order Request ********************"
);
WarpUtils
.
log
(
"[WARP Trace] WARPLY Submit Order 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
)
{
}
else
receiver
.
onFailure
(
status
);
}
@Override
public
void
onFailure
(
int
errorCode
)
{
receiver
.
onFailure
(
errorCode
);
}
});
}
}
...
...
Please
register
or
login
to post a comment