Panagiotis Triantafyllou

new version 4.5.4.3

...@@ -2,7 +2,7 @@ apply plugin: 'com.android.library' ...@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
2 2
3 ext { 3 ext {
4 PUBLISH_GROUP_ID = 'ly.warp' 4 PUBLISH_GROUP_ID = 'ly.warp'
5 - PUBLISH_VERSION = '4.5.4.2' 5 + PUBLISH_VERSION = '4.5.4.3'
6 PUBLISH_ARTIFACT_ID = 'warply-android-sdk' 6 PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
7 } 7 }
8 8
......
...@@ -1487,6 +1487,8 @@ public enum Warply { ...@@ -1487,6 +1487,8 @@ public enum Warply {
1487 if (path.equals("register") || path.equals("change_password") || path.equals("password_reset") 1487 if (path.equals("register") || path.equals("change_password") || path.equals("password_reset")
1488 || path.equals("generate")) 1488 || path.equals("generate"))
1489 url = buildWarplyAuthRequestUrl(path, true); 1489 url = buildWarplyAuthRequestUrl(path, true);
1490 + else if (path.equals("campaigns"))
1491 + url = buildWarplyRequestUrl(null);
1490 else 1492 else
1491 url = buildWarplyAuthRequestUrl(path, false); 1493 url = buildWarplyAuthRequestUrl(path, false);
1492 requestToServerInternal(Method.POST, url, data, listener, tag, hasAuthHeaders); 1494 requestToServerInternal(Method.POST, url, data, listener, tag, hasAuthHeaders);
......
1 +/*
2 + * Copyright 2010-2013 Warply Ltd. All rights reserved.
3 + *
4 + * Redistribution and use in source and binary forms, without modification, are
5 + * permitted provided that the following conditions are met:
6 + *
7 + * 1. Redistributions of source code must retain the above copyright notice,
8 + * this list of conditions and the following disclaimer.
9 + *
10 + * 2. Redistributions in binary form must reproduce the above copyright notice,
11 + * this list of conditions and the following disclaimer in the documentation
12 + * and/or other materials provided with the distribution.
13 + *
14 + * THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR
15 + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16 + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
17 + * EVENT SHALL WARPLY LTD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
18 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
19 + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
20 + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21 + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22 + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
23 + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 + */
25 +
26 +package ly.warp.sdk.io.callbacks;
27 +
28 +import org.json.JSONObject;
29 +
30 +import ly.warp.sdk.io.models.NewCampaignList;
31 +
32 +/**
33 + * Created by Panagiotis Triantafyllou on 12-May-22.
34 + */
35 +
36 +public class NewCampaignsHook implements CallbackReceiver<JSONObject> {
37 +
38 + private final CallbackReceiver<NewCampaignList> mListener;
39 + private final String mRequestSignature;
40 +
41 + public NewCampaignsHook(CallbackReceiver<NewCampaignList> listener, String requestSignature) {
42 + this.mListener = listener;
43 + this.mRequestSignature = requestSignature;
44 + }
45 +
46 + @Override
47 + public void onSuccess(JSONObject result) {
48 + if (mListener != null) {
49 + int status = result.optInt("status", 2);
50 + if (status == 1) {
51 + mListener.onSuccess(new NewCampaignList(result, mRequestSignature));
52 + } else
53 + mListener.onFailure(status);
54 + }
55 +
56 + }
57 +
58 + @Override
59 + public void onFailure(int errorCode) {
60 + if (mListener != null)
61 + mListener.onFailure(errorCode);
62 + }
63 +}
1 +/*
2 + * Copyright 2010-2013 Warply Ltd. All rights reserved.
3 + *
4 + * Redistribution and use in source and binary forms, without modification, are
5 + * permitted provided that the following conditions are met:
6 + *
7 + * 1. Redistributions of source code must retain the above copyright notice,
8 + * this list of conditions and the following disclaimer.
9 + *
10 + * 2. Redistributions in binary form must reproduce the above copyright notice,
11 + * this list of conditions and the following disclaimer in the documentation
12 + * and/or other materials provided with the distribution.
13 + *
14 + * THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR
15 + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
16 + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
17 + * EVENT SHALL WARPLY LTD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
18 + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
19 + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
20 + * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21 + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22 + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
23 + * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 + */
25 +
26 +package ly.warp.sdk.io.models;
27 +
28 +import androidx.annotation.NonNull;
29 +
30 +import org.json.JSONArray;
31 +import org.json.JSONObject;
32 +
33 +import java.util.ArrayList;
34 +
35 +/**
36 + * Created by Panagiotis Triantafyllou on 12-May-22.
37 + */
38 +
39 +public class NewCampaignList extends ArrayList<NewCampaign> {
40 +
41 + /**
42 + * Generated for serialized class
43 + */
44 + private static final long serialVersionUID = -188843583823948267L;
45 +
46 + private static final String JSON_KEY_MAPP = "MAPP_CAMPAIGNING";
47 + private static final String JSON_KEY_MAPP_VALUE = "campaigns";
48 + private static final String JSON_KEY_CONTEXT = "context";
49 +
50 + private String mRequestSignature = "";
51 +
52 + private NewCampaignList(String requestSignature) {
53 + this.mRequestSignature = requestSignature;
54 + }
55 +
56 + public NewCampaignList() {
57 + super();
58 + }
59 +
60 + /**
61 + * Constructor used to create the CampaignList from a JSON Object.
62 + *
63 + * @param campaignListJSONObject The JSON Object, used to create the CampaignList
64 + */
65 + public NewCampaignList(JSONObject campaignListJSONObject, String requestSignature) {
66 + this(requestSignature);
67 +
68 + campaignListJSONObject = campaignListJSONObject.optJSONObject(JSON_KEY_CONTEXT);
69 + if (campaignListJSONObject == null)
70 + return;
71 + JSONObject jsonObject = campaignListJSONObject.optJSONObject(JSON_KEY_MAPP);
72 + if(jsonObject == null)
73 + return;;
74 + JSONArray jArray = jsonObject.optJSONArray(JSON_KEY_MAPP_VALUE);
75 + if (jArray != null) {
76 + for (int i = 0, lim = jArray.length(); i < lim; ++i) {
77 + add(new NewCampaign(jArray.optJSONObject(i)));
78 + }
79 + }
80 + }
81 +
82 + @NonNull
83 + public String getRequestSignature() {
84 + return mRequestSignature;
85 + }
86 +}
...@@ -13,6 +13,8 @@ import java.security.NoSuchAlgorithmException; ...@@ -13,6 +13,8 @@ import java.security.NoSuchAlgorithmException;
13 import java.util.ArrayList; 13 import java.util.ArrayList;
14 import java.util.HashMap; 14 import java.util.HashMap;
15 15
16 +import ly.warp.sdk.Warply;
17 +import ly.warp.sdk.utils.WarplyProperty;
16 import ly.warp.sdk.utils.constants.WarpConstants; 18 import ly.warp.sdk.utils.constants.WarpConstants;
17 19
18 /** 20 /**
...@@ -40,7 +42,7 @@ public class WarplyContentRequest { ...@@ -40,7 +42,7 @@ public class WarplyContentRequest {
40 private long mCacheUpdateInterval = 0; 42 private long mCacheUpdateInterval = 0;
41 private String mContentCategory = ""; 43 private String mContentCategory = "";
42 private ArrayList<String> mTags = new ArrayList<>(); 44 private ArrayList<String> mTags = new ArrayList<>();
43 - private String mLanguage = ""; 45 + private String mLanguage = WarplyProperty.getLanguage(Warply.getWarplyContext());
44 46
45 // =========================================================== 47 // ===========================================================
46 // Constructor 48 // Constructor
......
1 +package ly.warp.sdk.io.request;
2 +
3 +import android.util.Base64;
4 +
5 +import org.json.JSONException;
6 +import org.json.JSONObject;
7 +
8 +import java.io.UnsupportedEncodingException;
9 +import java.security.MessageDigest;
10 +import java.security.NoSuchAlgorithmException;
11 +
12 +import ly.warp.sdk.Warply;
13 +import ly.warp.sdk.utils.WarplyProperty;
14 +import ly.warp.sdk.utils.constants.WarpConstants;
15 +
16 +/**
17 + * Created by Panagiotis Triantafyllou on 12-May-22.
18 + */
19 +
20 +public class WarplyGetCampaignsRequest {
21 +
22 + // ===========================================================
23 + // Constants
24 + // ===========================================================
25 +
26 + private final String KEY_ACTION = "action";
27 + private final String KEY_ACTION_VALUE = "retrieve";
28 + private final String KEY_LANGUAGE = "language";
29 + private final String KEY_FILTERS = "filters";
30 +
31 + // ===========================================================
32 + // Fields
33 + // ===========================================================
34 +
35 + private JSONObject mFilters = new JSONObject();
36 + private long mCacheUpdateInterval = 0;
37 + private String mLanguage = WarplyProperty.getLanguage(Warply.getWarplyContext());
38 +
39 + // ===========================================================
40 + // Constructor
41 + // ===========================================================
42 +
43 + /**
44 + * Default constructor of WarplyGetCampaignsRequest, initializes an empty filters HashMap
45 + */
46 + public WarplyGetCampaignsRequest() {
47 + mFilters = new JSONObject();
48 + }
49 +
50 + public WarplyGetCampaignsRequest(WarplyGetCampaignsRequest copy) {
51 + if (copy != null) {
52 + this.mFilters = copy.mFilters;
53 + this.mCacheUpdateInterval = copy.mCacheUpdateInterval;
54 + }
55 + }
56 +
57 + // ===========================================================
58 + // Methods for/from SuperClass/Interfaces
59 + // ===========================================================
60 +
61 + @Override
62 + public boolean equals(Object object) {
63 + if (object instanceof WarplyGetCampaignsRequest) {
64 + WarplyGetCampaignsRequest other = (WarplyGetCampaignsRequest) object;
65 + return other == this || (this.mFilters == other.mFilters || (this.mFilters != null && this.mFilters.equals(other.mFilters)));
66 + }
67 + return false;
68 + }
69 +
70 + @Override
71 + public int hashCode() {
72 + return mFilters.hashCode();
73 + }
74 +
75 + // ===========================================================
76 + // Methods
77 + // ===========================================================
78 +
79 + // ===========================================================
80 + // Getter & Setter
81 + // ===========================================================
82 +
83 + public WarplyGetCampaignsRequest setLanguage(String language) {
84 + mLanguage = language;
85 + return this;
86 + }
87 +
88 + public WarplyGetCampaignsRequest setFilters(JSONObject filters) {
89 + mFilters = filters;
90 + return this;
91 + }
92 +
93 + /**
94 + * Call this to get how often the cached data will be updated.
95 + *
96 + * @return mCacheUpdateInterval
97 + */
98 + public long getCacheUpdateInterval() {
99 + return mCacheUpdateInterval;
100 + }
101 +
102 + /**
103 + * Call this to set how often the cached data will be updated.
104 + *
105 + * @param updateInterval The time that data will be cached
106 + * @return WarplyGetCampaignsRequest
107 + */
108 + public WarplyGetCampaignsRequest setCacheUpdateInterval(long updateInterval) {
109 +
110 + this.mCacheUpdateInterval = updateInterval;
111 + if (mCacheUpdateInterval < 0) {
112 + mCacheUpdateInterval = 0;
113 + }
114 + return this;
115 + }
116 +
117 + /**
118 + * Call this to check if the Application uses Cache
119 + *
120 + * @return <p>true - the Application is using Cache</p>
121 + * <p>false - the Application is not using Cache</p>
122 + */
123 + public boolean isUseCache() {
124 + return mCacheUpdateInterval > 0;
125 + }
126 +
127 + /**
128 + * Call this to check whether the cached data need to be updated
129 + *
130 + * @param useCache <p>true - the Application is using Cache</p>
131 + * <p>false - the Application is not using Cache</p>
132 + * @return WarplyGetCampaignsRequest
133 + */
134 + public WarplyGetCampaignsRequest setUseCache(boolean useCache) {
135 +
136 + if (useCache) {
137 + mCacheUpdateInterval = mCacheUpdateInterval > 0 ? mCacheUpdateInterval
138 + : WarpConstants.INBOX_UPDATE_INTERVAL;
139 + } else {
140 + mCacheUpdateInterval = 0;
141 + }
142 + return this;
143 + }
144 +
145 + /**
146 + * Call this to build the campaigns Json object
147 + *
148 + * @return bodyJsonObject
149 + */
150 + public JSONObject toJson() {
151 + JSONObject bodyJsonObject = new JSONObject();
152 + try {
153 + bodyJsonObject.putOpt(KEY_ACTION, KEY_ACTION_VALUE);
154 + bodyJsonObject.putOpt(KEY_LANGUAGE, mLanguage);
155 + if (mFilters != null && mFilters.length() > 0)
156 + bodyJsonObject.putOpt(KEY_FILTERS, mFilters);
157 + else
158 + bodyJsonObject.putOpt(KEY_FILTERS, new JSONObject());
159 + } catch (JSONException e) {
160 + if (WarpConstants.DEBUG)
161 + e.printStackTrace();
162 + }
163 + return bodyJsonObject;
164 + }
165 +
166 + public String getSignature() {
167 + String signature = mFilters != null && mFilters.length() > 0 ? String.valueOf(mFilters.hashCode()) : "default_get_campaigns_request";
168 + try {
169 + byte[] hash = MessageDigest.getInstance("SHA-256").digest(signature.getBytes("UTF-8"));
170 + signature = Base64.encodeToString(hash, Base64.NO_WRAP);
171 + } catch (NullPointerException | NoSuchAlgorithmException
172 + | UnsupportedEncodingException e) {
173 + e.printStackTrace();
174 + }
175 + return signature;
176 + }
177 +}
...@@ -12,6 +12,8 @@ import java.security.NoSuchAlgorithmException; ...@@ -12,6 +12,8 @@ import java.security.NoSuchAlgorithmException;
12 import java.util.ArrayList; 12 import java.util.ArrayList;
13 import java.util.HashMap; 13 import java.util.HashMap;
14 14
15 +import ly.warp.sdk.Warply;
16 +import ly.warp.sdk.utils.WarplyProperty;
15 import ly.warp.sdk.utils.constants.WarpConstants; 17 import ly.warp.sdk.utils.constants.WarpConstants;
16 18
17 /** 19 /**
...@@ -40,7 +42,7 @@ public class WarplyGetCouponsetsRequest { ...@@ -40,7 +42,7 @@ public class WarplyGetCouponsetsRequest {
40 private boolean mActive = true; 42 private boolean mActive = true;
41 private boolean mVisible = true; 43 private boolean mVisible = true;
42 private ArrayList<String> mUuids = new ArrayList<>(); 44 private ArrayList<String> mUuids = new ArrayList<>();
43 - private String mLanguage = ""; 45 + private String mLanguage = WarplyProperty.getLanguage(Warply.getWarplyContext());
44 46
45 // =========================================================== 47 // ===========================================================
46 // Constructor 48 // Constructor
......
...@@ -10,6 +10,8 @@ import java.security.MessageDigest; ...@@ -10,6 +10,8 @@ import java.security.MessageDigest;
10 import java.security.NoSuchAlgorithmException; 10 import java.security.NoSuchAlgorithmException;
11 import java.util.HashMap; 11 import java.util.HashMap;
12 12
13 +import ly.warp.sdk.Warply;
14 +import ly.warp.sdk.utils.WarplyProperty;
13 import ly.warp.sdk.utils.constants.WarpConstants; 15 import ly.warp.sdk.utils.constants.WarpConstants;
14 16
15 /** 17 /**
...@@ -32,7 +34,7 @@ public class WarplyMerchantCategoriesRequest { ...@@ -32,7 +34,7 @@ public class WarplyMerchantCategoriesRequest {
32 34
33 private HashMap<String, String> mFilters; 35 private HashMap<String, String> mFilters;
34 private long mCacheUpdateInterval = 0; 36 private long mCacheUpdateInterval = 0;
35 - private String mLanguage = ""; 37 + private String mLanguage = WarplyProperty.getLanguage(Warply.getWarplyContext());
36 38
37 // =========================================================== 39 // ===========================================================
38 // Constructor 40 // Constructor
......
...@@ -13,6 +13,8 @@ import java.security.NoSuchAlgorithmException; ...@@ -13,6 +13,8 @@ import java.security.NoSuchAlgorithmException;
13 import java.util.ArrayList; 13 import java.util.ArrayList;
14 import java.util.HashMap; 14 import java.util.HashMap;
15 15
16 +import ly.warp.sdk.Warply;
17 +import ly.warp.sdk.utils.WarplyProperty;
16 import ly.warp.sdk.utils.constants.WarpConstants; 18 import ly.warp.sdk.utils.constants.WarpConstants;
17 19
18 /** 20 /**
...@@ -51,7 +53,7 @@ public class WarplyMerchantsRequest { ...@@ -51,7 +53,7 @@ public class WarplyMerchantsRequest {
51 private String mUuid = ""; 53 private String mUuid = "";
52 private int mDistance = 0; 54 private int mDistance = 0;
53 private ArrayList<Double> mCenter = new ArrayList<>(); 55 private ArrayList<Double> mCenter = new ArrayList<>();
54 - private String mLanguage = ""; 56 + private String mLanguage = WarplyProperty.getLanguage(Warply.getWarplyContext());
55 57
56 // =========================================================== 58 // ===========================================================
57 // Constructor 59 // Constructor
......
...@@ -39,7 +39,7 @@ public class WarplyProductsRequest { ...@@ -39,7 +39,7 @@ public class WarplyProductsRequest {
39 private HashMap<String, String> mFilters; 39 private HashMap<String, String> mFilters;
40 private long mCacheUpdateInterval = 0; 40 private long mCacheUpdateInterval = 0;
41 private String mProductsCategory = ""; 41 private String mProductsCategory = "";
42 - private String mLanguage = ""; 42 + private String mLanguage = WarplyProperty.getLanguage(Warply.getWarplyContext());
43 43
44 // =========================================================== 44 // ===========================================================
45 // Constructor 45 // Constructor
......
...@@ -10,6 +10,8 @@ import java.security.MessageDigest; ...@@ -10,6 +10,8 @@ import java.security.MessageDigest;
10 import java.security.NoSuchAlgorithmException; 10 import java.security.NoSuchAlgorithmException;
11 import java.util.HashMap; 11 import java.util.HashMap;
12 12
13 +import ly.warp.sdk.Warply;
14 +import ly.warp.sdk.utils.WarplyProperty;
13 import ly.warp.sdk.utils.constants.WarpConstants; 15 import ly.warp.sdk.utils.constants.WarpConstants;
14 16
15 /** 17 /**
...@@ -33,7 +35,7 @@ public class WarplyTagsCategoriesRequest { ...@@ -33,7 +35,7 @@ public class WarplyTagsCategoriesRequest {
33 35
34 private HashMap<String, String> mFilters; 36 private HashMap<String, String> mFilters;
35 private long mCacheUpdateInterval = 0; 37 private long mCacheUpdateInterval = 0;
36 - private String mLanguage = ""; 38 + private String mLanguage = WarplyProperty.getLanguage(Warply.getWarplyContext());
37 39
38 // =========================================================== 40 // ===========================================================
39 // Constructor 41 // Constructor
......
...@@ -10,6 +10,8 @@ import java.security.MessageDigest; ...@@ -10,6 +10,8 @@ import java.security.MessageDigest;
10 import java.security.NoSuchAlgorithmException; 10 import java.security.NoSuchAlgorithmException;
11 import java.util.HashMap; 11 import java.util.HashMap;
12 12
13 +import ly.warp.sdk.Warply;
14 +import ly.warp.sdk.utils.WarplyProperty;
13 import ly.warp.sdk.utils.constants.WarpConstants; 15 import ly.warp.sdk.utils.constants.WarpConstants;
14 16
15 /** 17 /**
...@@ -33,7 +35,7 @@ public class WarplyTagsRequest { ...@@ -33,7 +35,7 @@ public class WarplyTagsRequest {
33 35
34 private HashMap<String, String> mFilters; 36 private HashMap<String, String> mFilters;
35 private long mCacheUpdateInterval = 0; 37 private long mCacheUpdateInterval = 0;
36 - private String mLanguage = ""; 38 + private String mLanguage = WarplyProperty.getLanguage(Warply.getWarplyContext());
37 39
38 // =========================================================== 40 // ===========================================================
39 // Constructor 41 // Constructor
......
...@@ -30,7 +30,7 @@ public class WarpConstants { ...@@ -30,7 +30,7 @@ public class WarpConstants {
30 /** 30 /**
31 * The version of the SDK installed in the device 31 * The version of the SDK installed in the device
32 */ 32 */
33 - public static final String SDK_VERSION = "4.5.4.2"; 33 + public static final String SDK_VERSION = "4.5.4.3";
34 34
35 /** 35 /**
36 * The URL of the server where it should ping 36 * The URL of the server where it should ping
...@@ -126,6 +126,7 @@ public class WarpConstants { ...@@ -126,6 +126,7 @@ public class WarpConstants {
126 public static final String MICROAPP_CONTACT = "contact"; 126 public static final String MICROAPP_CONTACT = "contact";
127 public static final String MICROAPP_CARDS = "cards"; 127 public static final String MICROAPP_CARDS = "cards";
128 public static final String MICROAPP_COUPONS = "coupon"; 128 public static final String MICROAPP_COUPONS = "coupon";
129 + public static final String MICROAPP_NEW_CAMPAIGNS = "campaigns";
129 public static final String MICROAPP_TRANSACTIONS = "transactions"; 130 public static final String MICROAPP_TRANSACTIONS = "transactions";
130 public static final String MICROAPP_CONTENT = "content"; 131 public static final String MICROAPP_CONTENT = "content";
131 public static final String MICROAPP_APPLICATION_DATA = "application_data"; 132 public static final String MICROAPP_APPLICATION_DATA = "application_data";
......
...@@ -39,6 +39,7 @@ import ly.warp.sdk.io.callbacks.CouponsHook; ...@@ -39,6 +39,7 @@ import ly.warp.sdk.io.callbacks.CouponsHook;
39 import ly.warp.sdk.io.callbacks.CouponsetsHook; 39 import ly.warp.sdk.io.callbacks.CouponsetsHook;
40 import ly.warp.sdk.io.callbacks.MerchantCategoriesHook; 40 import ly.warp.sdk.io.callbacks.MerchantCategoriesHook;
41 import ly.warp.sdk.io.callbacks.MerchantsHook; 41 import ly.warp.sdk.io.callbacks.MerchantsHook;
42 +import ly.warp.sdk.io.callbacks.NewCampaignsHook;
42 import ly.warp.sdk.io.callbacks.PointsHook; 43 import ly.warp.sdk.io.callbacks.PointsHook;
43 import ly.warp.sdk.io.callbacks.ProductsHook; 44 import ly.warp.sdk.io.callbacks.ProductsHook;
44 import ly.warp.sdk.io.callbacks.TagsCategoriesHook; 45 import ly.warp.sdk.io.callbacks.TagsCategoriesHook;
...@@ -53,6 +54,7 @@ import ly.warp.sdk.io.models.CouponList; ...@@ -53,6 +54,7 @@ import ly.warp.sdk.io.models.CouponList;
53 import ly.warp.sdk.io.models.CouponsetsList; 54 import ly.warp.sdk.io.models.CouponsetsList;
54 import ly.warp.sdk.io.models.MerchantCategoriesList; 55 import ly.warp.sdk.io.models.MerchantCategoriesList;
55 import ly.warp.sdk.io.models.MerchantList; 56 import ly.warp.sdk.io.models.MerchantList;
57 +import ly.warp.sdk.io.models.NewCampaignList;
56 import ly.warp.sdk.io.models.PointsList; 58 import ly.warp.sdk.io.models.PointsList;
57 import ly.warp.sdk.io.models.ProductList; 59 import ly.warp.sdk.io.models.ProductList;
58 import ly.warp.sdk.io.models.TagsCategoriesList; 60 import ly.warp.sdk.io.models.TagsCategoriesList;
...@@ -71,6 +73,7 @@ import ly.warp.sdk.io.request.WarplyEditAddressRequest; ...@@ -71,6 +73,7 @@ import ly.warp.sdk.io.request.WarplyEditAddressRequest;
71 import ly.warp.sdk.io.request.WarplyEditConsumerRequest; 73 import ly.warp.sdk.io.request.WarplyEditConsumerRequest;
72 import ly.warp.sdk.io.request.WarplyForgotPasswordRequest; 74 import ly.warp.sdk.io.request.WarplyForgotPasswordRequest;
73 import ly.warp.sdk.io.request.WarplyGetAddressRequest; 75 import ly.warp.sdk.io.request.WarplyGetAddressRequest;
76 +import ly.warp.sdk.io.request.WarplyGetCampaignsRequest;
74 import ly.warp.sdk.io.request.WarplyGetCardsRequest; 77 import ly.warp.sdk.io.request.WarplyGetCardsRequest;
75 import ly.warp.sdk.io.request.WarplyGetCouponsetsRequest; 78 import ly.warp.sdk.io.request.WarplyGetCouponsetsRequest;
76 import ly.warp.sdk.io.request.WarplyLoginRequest; 79 import ly.warp.sdk.io.request.WarplyLoginRequest;
...@@ -1267,4 +1270,43 @@ public class WarplyManager { ...@@ -1267,4 +1270,43 @@ public class WarplyManager {
1267 } 1270 }
1268 }); 1271 });
1269 } 1272 }
1273 +
1274 + public static void getCampaigns(WarplyGetCampaignsRequest request, boolean auth, final CallbackReceiver<NewCampaignList> receiver) {
1275 + WarpUtils.log("************* WARPLY Get Campaigns Request ********************");
1276 + WarpUtils.log("[WARP Trace] WARPLY Get Campaigns Request is active");
1277 + WarpUtils.log("**************************************************");
1278 +
1279 + Warply.postReceiveMicroappData(WarpConstants.MICROAPP_NEW_CAMPAIGNS, auth, "campaigns", request.toJson(), new NewCampaignsHook(new CallbackReceiver<NewCampaignList>() {
1280 + @Override
1281 + public void onSuccess(NewCampaignList result) {
1282 + receiver.onSuccess(result);
1283 + }
1284 +
1285 + @Override
1286 + public void onFailure(int errorCode) {
1287 + if (auth) {
1288 + if (errorCode == 401) {
1289 + refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() {
1290 + @Override
1291 + public void onSuccess(JSONObject result) {
1292 + int status = result.optInt("status", 2);
1293 + if (status == 1)
1294 + getCampaigns(request, auth, receiver);
1295 + else
1296 + receiver.onFailure(status);
1297 + }
1298 +
1299 + @Override
1300 + public void onFailure(int errorCode) {
1301 + receiver.onFailure(errorCode);
1302 + }
1303 + });
1304 + } else
1305 + receiver.onFailure(errorCode);
1306 + } else
1307 + receiver.onFailure(errorCode);
1308 + }
1309 + },
1310 + request.getSignature()));
1311 + }
1270 } 1312 }
......