Panagiotis Triantafyllou

new release

......@@ -3,6 +3,8 @@ package ly.warp.sdk.activities;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
......@@ -26,7 +28,9 @@ import ly.warp.sdk.io.models.Couponset;
import ly.warp.sdk.io.models.CouponsetsList;
import ly.warp.sdk.io.models.LoyaltyContextualOfferModel;
import ly.warp.sdk.io.models.LoyaltyGiftsForYouOfferClickEvent;
import ly.warp.sdk.io.models.LoyaltyGiftsForYouPackage;
import ly.warp.sdk.io.models.MergedGifts;
import ly.warp.sdk.utils.WarpJSONParser;
import ly.warp.sdk.utils.WarpUtils;
import ly.warp.sdk.utils.WarplyManagerHelper;
import ly.warp.sdk.utils.managers.WarplyEventBusManager;
......@@ -45,13 +49,7 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene
private ImageView mIvBack, mIvPopupClose;
private TextView mTvTitle;
/**** Old functionality ****/
// private RecyclerView mRecyclerGifts, mRecyclerRewards, mRecyclerCoupons;
// private ProfileCampaignAdapter mAdapterGifts, mAdapterRewards;
// private CouponsetsAdapter mAdapterCoupons;
// private ConstraintLayout mClGiftsOuter, mClRewardsOuter, mClCouponsOuter;
private HashMap<String, CampaignList> mUniqueGiftsList = new HashMap<String, CampaignList>();
/**** Old functionality ****/
private LinearLayout mLlGiftsPopup;
private ArrayList<MergedGifts> mData = new ArrayList();
private RecyclerView mRecyclerMergedGifts;
......@@ -64,10 +62,7 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_gifts_for_you);
/**** Old functionality ****/
// getCampaignsBySubcategory();
/**** Old functionality ****/
ArrayList<LoyaltyGiftsForYouPackage> list = new ArrayList();
mergeDatasets(
WarplyManagerHelper.getUniqueCampaignList().get("gifts_for_you"),
WarplyManagerHelper.getCouponsets()
......@@ -78,17 +73,6 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene
mIvPopupClose = findViewById(R.id.iv_popup_gifts_close);
mLlGiftsPopup = findViewById(R.id.ll_gifts_popup);
/**** Old functionality ****/
// mClGiftsOuter = findViewById(R.id.cl_recycler_inner);
// mRecyclerGifts = findViewById(R.id.rv_gifts);
// mClRewardsOuter = findViewById(R.id.cl_recycler_inner2);
// mRecyclerRewards = findViewById(R.id.rv_rewards);
// mClCouponsOuter = findViewById(R.id.cl_recycler_inner3);
// mRecyclerCoupons = findViewById(R.id.rv_coupons);
/**** Old functionality ****/
mRecyclerMergedGifts = findViewById(R.id.rv_merged_gifts);
initViews();
......@@ -123,55 +107,6 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene
if (WarpUtils.getGiftsPopup(this))
mLlGiftsPopup.setVisibility(View.VISIBLE);
/**** Old functionality ****/
// if (mUniqueGiftsList.get("gifts") != null && mUniqueGiftsList.get("gifts").size() > 0) {
// mRecyclerGifts.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
// mAdapterGifts = new ProfileCampaignAdapter(this, mUniqueGiftsList.get("gifts"));
// mRecyclerGifts.setAdapter(mAdapterGifts);
// mAdapterGifts.getPositionClicks()
// .doOnNext(gift -> {
// startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(gift)));
// })
// .doOnError(error -> {
// })
// .subscribe();
// } else {
// mClGiftsOuter.setVisibility(View.GONE);
// }
// if (mUniqueGiftsList.get("rewards") != null && mUniqueGiftsList.get("rewards").size() > 0) {
// mRecyclerRewards.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
// mAdapterRewards = new ProfileCampaignAdapter(this, mUniqueGiftsList.get("rewards"));
// mRecyclerRewards.setAdapter(mAdapterRewards);
// mAdapterRewards.getPositionClicks()
// .doOnNext(reward -> {
// startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(reward)));
// })
// .doOnError(error -> {
// })
// .subscribe();
// } else {
// mClRewardsOuter.setVisibility(View.GONE);
// }
// if (WarplyManagerHelper.getCouponsets() != null && WarplyManagerHelper.getCouponsets().size() > 0) {
// mRecyclerCoupons.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
// mAdapterCoupons = new CouponsetsAdapter(this, WarplyManagerHelper.getCouponsets());
// mRecyclerCoupons.setAdapter(mAdapterCoupons);
// mAdapterCoupons.getPositionClicks()
// .doOnNext(couponset -> {
// Intent intent = new Intent(GiftsForYouActivity.this, CouponsetInfoActivity.class);
// intent.putExtra("couponset", (Serializable) couponset);
// startActivity(intent);
// })
// .doOnError(error -> {
// })
// .subscribe();
// } else {
// mClCouponsOuter.setVisibility(View.GONE);
// }
/**** Old functionality ****/
if (mData != null && mData.size() > 0) {
mRecyclerMergedGifts.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
mAdapterMergedGifts = new MergedGiftsAdapter(this, mData);
......@@ -181,7 +116,21 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene
if (dataItem.getDataType() == 1) {
EventBus.getDefault().post(new WarplyEventBusManager(new LoyaltyGiftsForYouOfferClickEvent()));
try {
String key = WarpJSONParser.getJSONFromString(dataItem.getCampaign().getExtraFields()).keys().next();
if (!TextUtils.isEmpty(key) && key.equals("loyaltyCampaignId")) {
String value = WarpJSONParser.getJSONFromString(dataItem.getCampaign().getExtraFields()).optString("loyaltyCampaignId");
for (LoyaltyContextualOfferModel ccms : WarplyManagerHelper.getCCMSLoyaltyCampaigns()) {
if (ccms.getLoyaltyCampaignId().equals(value)) {
startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCcmsUrl(dataItem.getCampaign(), ccms.getSessionId())));
return;
}
}
}
startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(dataItem.getCampaign())));
} catch (Exception exception) {
startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(dataItem.getCampaign())));
}
} else if (dataItem.getDataType() == 2) {
EventBus.getDefault().post(new WarplyEventBusManager(new LoyaltyContextualOfferModel()));
......@@ -193,33 +142,6 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene
.doOnError(error -> {
})
.subscribe();
} else {
// mClCouponsOuter.setVisibility(View.GONE);
}
}
private void getCampaignsBySubcategory() {
if (WarplyManagerHelper.getUniqueCampaignList().get("gifts_for_you") != null && WarplyManagerHelper.getUniqueCampaignList().get("gifts_for_you").size() > 0) {
for (Campaign campaign : WarplyManagerHelper.getUniqueCampaignList().get("gifts_for_you")) {
JSONObject campaignExtra = null;
try {
campaignExtra = new JSONObject(campaign.getExtraFields());
} catch (JSONException e) {
e.printStackTrace();
}
if (campaignExtra != null) {
if (mUniqueGiftsList.containsKey(campaignExtra.optString("subcategory").trim())) {
CampaignList tempCampaignList = mUniqueGiftsList.get(campaignExtra.optString("subcategory").trim());
tempCampaignList.add(campaign);
mUniqueGiftsList.put(campaignExtra.optString("subcategory").trim(), tempCampaignList);
} else {
CampaignList tempCampaignList = new CampaignList();
tempCampaignList.add(campaign);
mUniqueGiftsList.put(campaignExtra.optString("subcategory").trim(), tempCampaignList);
}
}
}
}
}
......
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 23-June-22.
*/
public class CosmoteRetrieveSharingRequest {
// ===========================================================
// Constants
// ===========================================================
private final String KEY_MAPP = "wallet";
private final String KEY_ACTION = "action";
private final String KEY_ACTION_VALUE = "sharing_response";
private final String KEY_SHARING_ID_KEY = "sharing_id";
private final String KEY_ACCEPT_KEY = "accept";
// ===========================================================
// Fields
// ===========================================================
private HashMap<String, String> mFilters;
private long mCacheUpdateInterval = 0;
private String mSharingId = "";
private boolean mIsAccept = false;
// ===========================================================
// Constructor
// ===========================================================
/**
* Default constructor of CosmoteRetrieveSharingRequest, initializes an empty filters HashMap
*/
public CosmoteRetrieveSharingRequest() {
mFilters = new HashMap<>();
}
public CosmoteRetrieveSharingRequest(CosmoteRetrieveSharingRequest 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 CosmoteRetrieveSharingRequest) {
CosmoteRetrieveSharingRequest other = (CosmoteRetrieveSharingRequest) 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 CosmoteRetrieveSharingRequest setSharingId(String sharingId) {
mSharingId = sharingId;
return this;
}
public CosmoteRetrieveSharingRequest setAccept(boolean acceptGift) {
mIsAccept = acceptGift;
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 CosmoteRetrieveSharingRequest
*/
public CosmoteRetrieveSharingRequest 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 CosmoteRetrieveSharingRequest
*/
public CosmoteRetrieveSharingRequest 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_SHARING_ID_KEY, mSharingId);
extraJson.putOpt(KEY_ACCEPT_KEY, mIsAccept);
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_retrieve_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;
}
}
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.constants.WarpConstants;
/**
* Created by Panagiotis Triantafyllou on 23-June-22.
*/
public class CosmoteSharingRequest {
// ===========================================================
// Constants
// ===========================================================
private final String KEY_MAPP = "wallet";
private final String KEY_ACTION = "action";
private final String KEY_ACTION_VALUE = "sharing_info";
private final String KEY_SHARING_ID_KEY = "sharing_id";
// ===========================================================
// Fields
// ===========================================================
private HashMap<String, String> mFilters;
private long mCacheUpdateInterval = 0;
private String mSharingId = "";
// ===========================================================
// Constructor
// ===========================================================
/**
* Default constructor of CosmoteSharingRequest, initializes an empty filters HashMap
*/
public CosmoteSharingRequest() {
mFilters = new HashMap<>();
}
public CosmoteSharingRequest(CosmoteSharingRequest 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 CosmoteSharingRequest) {
CosmoteSharingRequest other = (CosmoteSharingRequest) 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 CosmoteSharingRequest setSharingId(String sharingId) {
mSharingId = sharingId;
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 CosmoteSharingRequest 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 CosmoteSharingRequest 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_SHARING_ID_KEY, mSharingId);
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;
}
}
......@@ -12,6 +12,7 @@ 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;
/**
......@@ -145,15 +146,11 @@ public class WarplyIntegrationRequest {
JSONObject extraJson = new JSONObject();
extraJson.putOpt(KEY_ACTION, KEY_ACTION_VALUE);
extraJson.putOpt(KEY_METHOD, KEY_METHOD_VALUE);
ArrayList list = new ArrayList();
list.add("6982853746");
list.add("6982853747");
list.add("6982853748");
JSONObject data = new JSONObject();
data.putOpt("nonTelco", false);
data.putOpt("acceptedConsent", true);
data.putOpt("msisdnList", new JSONArray(list));
data.putOpt("guid", "12345678");
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);
......
......@@ -60,6 +60,8 @@ import ly.warp.sdk.io.models.ProductList;
import ly.warp.sdk.io.models.TagsCategoriesList;
import ly.warp.sdk.io.models.TagsList;
import ly.warp.sdk.io.models.TransactionsList;
import ly.warp.sdk.io.request.CosmoteRetrieveSharingRequest;
import ly.warp.sdk.io.request.CosmoteSharingRequest;
import ly.warp.sdk.io.request.WarplyAddAddressRequest;
import ly.warp.sdk.io.request.WarplyAddCardRequest;
import ly.warp.sdk.io.request.WarplyAuthorizeRequest;
......@@ -1349,4 +1351,82 @@ public class WarplyManager {
}
});
}
public static void cosmoteSharing(CosmoteSharingRequest request, final CallbackReceiver<JSONObject> receiver) {
WarpUtils.log("************* WARPLY Cosmote Sharing Request ********************");
WarpUtils.log("[WARP Trace] WARPLY Cosmote Sharing 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)
cosmoteSharing(request, receiver);
else
receiver.onFailure(status);
}
@Override
public void onFailure(int errorCode) {
receiver.onFailure(errorCode);
}
});
} else
receiver.onFailure(errorCode);
}
});
}
public static void cosmoteRetrieveSharing(CosmoteRetrieveSharingRequest request, final CallbackReceiver<JSONObject> receiver) {
WarpUtils.log("************* WARPLY Cosmote Retrieve Sharing Request ********************");
WarpUtils.log("[WARP Trace] WARPLY Cosmote Retrieve Sharing 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)
cosmoteRetrieveSharing(request, receiver);
else
receiver.onFailure(status);
}
@Override
public void onFailure(int errorCode) {
receiver.onFailure(errorCode);
}
});
} else
receiver.onFailure(errorCode);
}
});
}
}
......
......@@ -35,7 +35,6 @@
<string name="cos_coupons_title">ΚΟΥΠΟΝΙΑ</string>
<string name="cos_coupon_terms_title">Όροι χρήσης</string>
<string name="cos_redeem_coupon">Απόκτησέ το</string>
<string name="cos_dlg_success_title">Συγχαρητήρια</string>
<string name="cos_dlg_success_subtitle">Το κουπόνι εξαργυρώθηκε με επιτυχία</string>
<string name="cos_dlg_error_title">Αποτυχία</string>
<string name="cos_dlg_error_subtitle">Κάτι πήγε στραβά</string>
......@@ -75,6 +74,16 @@
<string name="cos_active_gifts_title">Ενεργά δώρα</string>
<string name="cos_loyalty_analysis">Ανάλυση συναλλαγών</string>
<string name="cos_value">%1$s€</string>
<string name="cos_dlg_success_title">Συγχαρητήρια!</string>
<string name="cos_dlg_reject_title">Είσαι σίγουρος;</string>
<string name="cod_dlg_return_title">Επιστροφή δώρου</string>
<string name="cos_dlg_positive_button">Ενεργοποίηση</string>
<string name="cos_dlg_negative_button">Απόρριψη</string>
<string name="cos_dlg_positive_button2">ΟΚ</string>
<string name="cos_dlg_positive_button_text">Μόλις έλαβες το δώρο σου!</string>
<string name="cos_dlg_reject_text">Είσαι σίγουρος ότι θέλεις να απορρίψεις το δώρο που μόλις έλαβες;</string>
<string name="cos_dlg_return_text">Έλαβες πίσω το δώρο σου, κουπόνι αξίας 100€ για τα Intersport</string>
<string name="cos_dlg_negative_button2">Άκυρο</string>
<string-array name="coupons_array">
<item>Κουπόνια</item>
......