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-07 11:51:18 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
1227a0577295ef711ca399fb740cff4f156fb043
1227a057
1 parent
864bc934
new internal version
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
235 additions
and
7 deletions
app/src/main/java/warp/ly/android_sdk/activities/SplashActivity.java
warply_android_sdk/build.gradle
warply_android_sdk/src/main/java/ly/warp/sdk/Warply.java
warply_android_sdk/src/main/java/ly/warp/sdk/io/request/WarplyCosmoteUserRequest.java
warply_android_sdk/src/main/java/ly/warp/sdk/io/volley/toolbox/HttpClientStack.java
warply_android_sdk/src/main/java/ly/warp/sdk/utils/managers/WarplyManager.java
app/src/main/java/warp/ly/android_sdk/activities/SplashActivity.java
View file @
1227a05
...
...
@@ -15,6 +15,7 @@ import ly.warp.sdk.io.callbacks.CallbackReceiver;
import
ly.warp.sdk.io.callbacks.SimpleCallbackReceiver
;
import
ly.warp.sdk.io.callbacks.WarplyReadyCallback
;
import
ly.warp.sdk.io.request.WarplyConsumerRequest
;
import
ly.warp.sdk.io.request.WarplyCosmoteUserRequest
;
import
ly.warp.sdk.io.request.WarplyLoginRequest
;
import
ly.warp.sdk.io.request.WarplyVerifyTicketRequest
;
import
ly.warp.sdk.utils.WarplyInitializer
;
...
...
@@ -34,11 +35,15 @@ public class SplashActivity extends BaseActivity {
@Override
public
void
onWarplyReady
()
{
if
(!
WarplyDBHelper
.
getInstance
(
SplashActivity
.
this
).
isTableNotEmpty
(
"auth"
))
{
WarplyManager
.
login
(
new
WarplyLoginRequest
()
.
setId
(
"6981234567"
)
.
setPassword
(
"123456"
),
mLoginReceiver
);
// WarplyManager.login(new WarplyLoginRequest()
// .setId("6981234567")
// .setPassword("123456"),
// mLoginReceiver
// );
WarplyManager
.
getCosmoteUser
(
new
WarplyCosmoteUserRequest
()
.
setGuid
(
"6012049321"
),
mLoginReceiver
);
// WarplyManager.verifyTicket(new WarplyVerifyTicketRequest()
// .setGuid("6012139059")
...
...
warply_android_sdk/build.gradle
View file @
1227a05
...
...
@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
ext
{
PUBLISH_GROUP_ID
=
'ly.warp'
PUBLISH_VERSION
=
'4.5.4-cosbeta27'
PUBLISH_VERSION
=
'4.5.4-cosbeta27
a
'
PUBLISH_ARTIFACT_ID
=
'warply-android-sdk'
}
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/Warply.java
View file @
1227a05
...
...
@@ -339,7 +339,12 @@ public enum Warply {
return
;
}
postToServerInternal
(
hasAuthHeaders
,
path
,
jObj
,
receiver
,
null
);
String
tag
=
null
;
if
(
path
.
equals
(
"cosuser"
))
{
tag
=
"cosuser"
;
}
postToServerInternal
(
hasAuthHeaders
,
path
,
jObj
,
receiver
,
tag
);
}
private
void
postReceiveMicroappDataInternal
(
String
microappName
,
boolean
hasAuthHeaders
,
String
path
,
...
...
@@ -1489,12 +1494,17 @@ public enum Warply {
sb
=
new
StringBuilder
(
WarplyProperty
.
getBaseUrl
(
mContext
.
get
())
+
WarpConstants
.
BASE_URL_API
);
else
if
(
warplyPath
.
equals
(
"verify"
))
sb
=
new
StringBuilder
(
WarplyProperty
.
getBaseUrl
(
mContext
.
get
())
+
WarplyProperty
.
getVerifyUrl
(
mContext
.
get
()));
else
if
(
warplyPath
.
equals
(
"cosuser"
))
sb
=
new
StringBuilder
(
WarplyProperty
.
getBaseUrl
(
mContext
.
get
())
+
"/partners/oauth/"
+
WarplyProperty
.
getAppUuid
(
mContext
.
get
())
+
"/token"
);
else
sb
=
new
StringBuilder
(
WarplyProperty
.
getBaseUrl
(
mContext
.
get
())
+
WarpConstants
.
BASE_URL_AUTH
);
}
if
(
warplyPath
!=
null
)
{
if
(!
warplyPath
.
equals
(
"verify"
))
{
if
(
warplyPath
.
equals
(
"cosuser"
))
{
return
sb
.
toString
();
}
sb
.
append
(
WarplyProperty
.
getAppUuid
(
mContext
.
get
())).
append
(
"/"
);
if
(
warplyPath
.
equals
(
"generate"
))
{
sb
.
append
(
WarpConstants
.
BASE_URL_OTP
);
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/io/request/WarplyCosmoteUserRequest.java
0 → 100644
View file @
1227a05
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.Warply
;
import
ly.warp.sdk.utils.WarplyProperty
;
import
ly.warp.sdk.utils.constants.WarpConstants
;
/**
* Created by Panagiotis Triantafyllou on 07-July-22.
*/
public
class
WarplyCosmoteUserRequest
{
// ===========================================================
// Constants
// ===========================================================
private
final
String
KEY_USER_ID
=
"user_identifier"
;
// ===========================================================
// Fields
// ===========================================================
private
HashMap
<
String
,
String
>
mFilters
;
private
long
mCacheUpdateInterval
=
0
;
private
String
mGuid
=
""
;
// ===========================================================
// Constructor
// ===========================================================
/**
* Default constructor of WarplyCosmoteUserRequest, initializes an empty filters HashMap
*/
public
WarplyCosmoteUserRequest
()
{
mFilters
=
new
HashMap
<>();
}
public
WarplyCosmoteUserRequest
(
WarplyCosmoteUserRequest
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
WarplyCosmoteUserRequest
)
{
WarplyCosmoteUserRequest
other
=
(
WarplyCosmoteUserRequest
)
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
WarplyCosmoteUserRequest
setGuid
(
String
guid
)
{
mGuid
=
guid
;
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 WarplyCosmoteUserRequest
*/
public
WarplyCosmoteUserRequest
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 WarplyCosmoteUserRequest
*/
public
WarplyCosmoteUserRequest
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
{
bodyJsonObject
.
putOpt
(
KEY_USER_ID
,
mGuid
);
}
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_user_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/volley/toolbox/HttpClientStack.java
View file @
1227a05
...
...
@@ -151,6 +151,9 @@ public class HttpClientStack implements HttpStack {
if
(
request
.
getTag
()
!=
null
&&
request
.
getTag
().
equals
(
"true"
))
{
headers
.
add
(
new
BasicHeader
(
WarpConstants
.
HEADER_AUTHORIZATION
,
"Bearer "
+
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getAuthValue
(
"access_token"
)));
}
else
if
(
request
.
getTag
()
!=
null
&&
request
.
getTag
().
equals
(
"cosuser"
))
{
headers
.
add
(
new
BasicHeader
(
WarpConstants
.
HEADER_AUTHORIZATION
,
"Basic MWlTM0EyNjcxT2Q0a1B5QkIydEs1ZU5uRENhR0NWQjQ6MjI4MjA4ZTliMTQzNGQ2MmIxNGI3ZDAzYjM2ZjUwMzg="
));
}
httpPost
.
setHeaders
(
headers
.
toArray
(
new
Header
[
headers
.
size
()]));
byte
[]
body
=
request
.
getBody
();
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/utils/managers/WarplyManager.java
View file @
1227a05
...
...
@@ -76,6 +76,7 @@ import ly.warp.sdk.io.request.WarplyChangePasswordRequest;
import
ly.warp.sdk.io.request.WarplyConsumerRequest
;
import
ly.warp.sdk.io.request.WarplyContactRequest
;
import
ly.warp.sdk.io.request.WarplyContentRequest
;
import
ly.warp.sdk.io.request.WarplyCosmoteUserRequest
;
import
ly.warp.sdk.io.request.WarplyDeleteAddressRequest
;
import
ly.warp.sdk.io.request.WarplyDeleteCardRequest
;
import
ly.warp.sdk.io.request.WarplyEditAddressRequest
;
...
...
@@ -1585,4 +1586,48 @@ public class WarplyManager {
}
});
}
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"
);
WarpUtils
.
log
(
"**************************************************"
);
Warply
.
postReceiveMicroappData
(
false
,
"cosuser"
,
request
.
toJson
(),
new
CallbackReceiver
<
JSONObject
>()
{
@Override
public
void
onSuccess
(
JSONObject
result
)
{
int
status
=
result
.
optInt
(
"status"
,
2
);
if
(
status
==
1
)
{
JSONObject
tokens
=
result
.
optJSONObject
(
"result"
);
if
(
tokens
!=
null
)
{
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
saveClientAccess
(
tokens
.
optString
(
"client_id"
,
""
),
tokens
.
optString
(
"client_secret"
,
""
)
);
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
saveAuthAccess
(
tokens
.
optString
(
"access_token"
,
""
),
tokens
.
optString
(
"refresh_token"
,
""
)
);
JSONObject
newResult
=
new
JSONObject
();
try
{
newResult
.
putOpt
(
"status"
,
1
);
newResult
.
putOpt
(
"message"
,
"Success"
);
receiver
.
onSuccess
(
newResult
);
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
receiver
.
onFailure
(
2
);
}
}
else
receiver
.
onFailure
(
2
);
}
else
receiver
.
onFailure
(
status
);
}
@Override
public
void
onFailure
(
int
errorCode
)
{
receiver
.
onFailure
(
errorCode
);
}
});
}
}
...
...
Please
register
or
login
to post a comment