Panagiotis Triantafyllou

retrofit

......@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
ext {
PUBLISH_GROUP_ID = 'ly.warp'
PUBLISH_VERSION = '4.5.4.6rc12'
PUBLISH_VERSION = '4.5.4.6rc20'
PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
}
......@@ -90,6 +90,10 @@ dependencies {
//------------------------------ Calligraphy -----------------------------//
api 'io.github.inflationx:calligraphy3:3.1.1'
api 'io.github.inflationx:viewpump:2.0.3'
//------------------------------ Retrofit -----------------------------//
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
}
// In every export please update the version number
......
......@@ -58,14 +58,10 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation
mBottomNavigationView = findViewById(R.id.bt_tabs);
new Thread(() -> {
if (!Thread.currentThread().isInterrupted()) {
// WarplyManager.getConsumer(new WarplyConsumerRequest(), mConsumerReceiver);
// Warply.getInbox(new WarplyInboxRequest().setUseCache(false), mInboxReceiver);
// WarplyManager.getUserCouponsWithCouponsets(new WarplyUserCouponsRequest(), mUserCouponsReceiver);
WarplyManager.getUserCouponsWithCouponsets(mUserCouponsReceiver);
WarplyManager.getCampaigns(new WarplyGetCampaignsRequest().setLanguage("en"), mCampaignsCallback);
}
}).start();
}
@Override
protected void onStart() {
......@@ -80,6 +76,7 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation
@Override
protected void onResume() {
super.onResume();
initViews();
}
@Override
......@@ -139,57 +136,15 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation
// Inner and Anonymous Classes
// ===========================================================
// private final CallbackReceiver<Consumer> mConsumerReceiver = new CallbackReceiver<Consumer>() {
// @Override
// public void onSuccess(Consumer result) {
// mConsumer = result;
//// WarplyManagerHelper.setConsumer(result);
//// Thread.currentThread().interrupt();
// Warply.getInbox(new WarplyInboxRequest().setUseCache(false), mInboxReceiver);
// }
//
// @Override
// public void onFailure(int errorCode) {
// Thread.currentThread().interrupt();
// }
// };
private final CallbackReceiver<CampaignList> mInboxReceiver = new CallbackReceiver<CampaignList>() {
@Override
public void onSuccess(CampaignList result) {
for (Campaign campaign : result) {
if (mUniqueCampaignList.containsKey(campaign.getOfferCategory().trim())) {
CampaignList tempCampaignList = (CampaignList) mUniqueCampaignList.get(campaign.getOfferCategory().trim());
tempCampaignList.add(campaign);
mUniqueCampaignList.put(campaign.getOfferCategory().trim(), tempCampaignList);
} else {
CampaignList tempCampaignList = new CampaignList();
tempCampaignList.add(campaign);
mUniqueCampaignList.put(campaign.getOfferCategory().trim(), tempCampaignList);
}
}
// Thread.currentThread().interrupt();
WarplyManager.getUserCouponsWithCouponsets(new WarplyUserCouponsRequest(), mUserCouponsReceiver);
}
@Override
public void onFailure(int errorCode) {
Thread.currentThread().interrupt();
}
};
private CallbackReceiver<ArrayList<Campaign>> mCampaignsCallback = new CallbackReceiver<ArrayList<Campaign>>() {
@Override
public void onSuccess(ArrayList<Campaign> result) {
WarplyManager.getUserCouponsWithCouponsets(new WarplyUserCouponsRequest(), mUserCouponsReceiver);
}
@Override
public void onFailure(int errorCode) {
Thread.currentThread().interrupt();
}
};
......@@ -197,15 +152,12 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation
private final CallbackReceiver<CouponList> mUserCouponsReceiver = new CallbackReceiver<CouponList>() {
@Override
public void onSuccess(CouponList result) {
Thread.currentThread().interrupt();
new Handler(Looper.getMainLooper()).post(() -> {
initViews();
});
}
@Override
public void onFailure(int errorCode) {
Thread.currentThread().interrupt();
}
};
......
......@@ -88,6 +88,28 @@ public class Coupon implements Parcelable, Serializable {
private String discount_type = "";
private double final_price = 0.0d;
public Coupon() {
this.barcode = "";
this.category = "";
this.coupon = "";
this.created = "";
this.description = "";
this.discount = "";
this.expiration = "";
this.image = "";
this.name = "";
this.status = 0;
this.transactionDate = "";
this.transactionUuid = "";
this.changesDates = new JSONObject();
this.couponsetUuid = "";
this.merchantUuid = "";
this.innerText = "";
this.expirationDate = new Date();
this.discount_type = "";
this.final_price = 0.0d;
}
/**
* Basic constructor used to create an object from a String, representing a
* JSON Object
......
package ly.warp.sdk.io.models;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.util.ArrayList;
import java.util.Date;
/**
* Created by Panagiotis Triantafyllou on 24/Νοε/2022.
*/
public class CouponModel {
@SerializedName("msg")
@Expose
private String msg;
@SerializedName("result")
@Expose
private ArrayList<CouponResult> result = null;
@SerializedName("status")
@Expose
private Integer status;
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public ArrayList<CouponResult> getResult() {
return result;
}
public void setResult(ArrayList<CouponResult> result) {
this.result = result;
}
public class CouponResult {
@SerializedName("changes_dates")
@Expose
private ChangesDates changesDates;
@SerializedName("communication_uuid")
@Expose
private String communicationUuid;
@SerializedName("coupon")
@Expose
private String coupon;
@SerializedName("couponset_uuid")
@Expose
private String couponsetUuid;
@SerializedName("description")
@Expose
private String description;
@SerializedName("discount")
@Expose
private String discount;
@SerializedName("expiration")
@Expose
private String expiration;
@SerializedName("image")
@Expose
private String image;
@SerializedName("name")
@Expose
private String name;
@SerializedName("status")
@Expose
private Integer status;
private String merchantUuid = "";
private String innerText = "";
private Date expirationDate = new Date();
private String discount_type = "";
private double final_price = 0.0d;
public ChangesDates getChangesDates() {
return changesDates;
}
public void setChangesDates(ChangesDates changesDates) {
this.changesDates = changesDates;
}
public String getCommunicationUuid() {
return communicationUuid;
}
public void setCommunicationUuid(String communicationUuid) {
this.communicationUuid = communicationUuid;
}
public String getCoupon() {
return coupon;
}
public void setCoupon(String coupon) {
this.coupon = coupon;
}
public String getCouponsetUuid() {
return couponsetUuid;
}
public void setCouponsetUuid(String couponsetUuid) {
this.couponsetUuid = couponsetUuid;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getDiscount() {
return discount;
}
public void setDiscount(String discount) {
this.discount = discount;
}
public String getExpiration() {
return expiration;
}
public void setExpiration(String expiration) {
this.expiration = expiration;
}
public String getImage() {
return image;
}
public void setImage(String image) {
this.image = image;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getMerchantUuid() {
return merchantUuid;
}
public void setMerchantUuid(String merchantUuid) {
this.merchantUuid = merchantUuid;
}
public String getInnerText() {
return innerText;
}
public void setInnerText(String innerText) {
this.innerText = innerText;
}
public Date getExpirationDate() {
return expirationDate;
}
public void setExpirationDate(Date expirationDate) {
this.expirationDate = expirationDate;
}
public String getDiscount_type() {
return discount_type;
}
public void setDiscount_type(String discount_type) {
this.discount_type = discount_type;
}
public double getFinal_price() {
return final_price;
}
public void setFinal_price(double final_price) {
this.final_price = final_price;
}
}
public class ChangesDates {
@SerializedName("assigned")
@Expose
private String assigned;
@SerializedName("created")
@Expose
private String created;
public String getAssigned() {
return assigned;
}
public void setAssigned(String assigned) {
this.assigned = assigned;
}
public String getCreated() {
return created;
}
public void setCreated(String created) {
this.created = created;
}
}
}
package ly.warp.sdk.io.models;
import org.json.JSONArray;
import ly.warp.sdk.Warply;
import ly.warp.sdk.utils.WarplyProperty;
/**
* Created by Panagiotis Triantafyllou on 24/Νοε/2022.
*/
public class CouponRequestModel {
private CouponsetRequestInnerModel coupon;
public CouponRequestModel() {
this.coupon = new CouponsetRequestInnerModel();
}
private class CouponsetRequestInnerModel {
private String action;
private JSONArray fetch_data;
public CouponsetRequestInnerModel() {
this.action = "get_user_coupons";
JSONArray fetch = new JSONArray();
fetch.put("transaction");
fetch.put("communication");
this.fetch_data = fetch;
}
}
}
......@@ -109,6 +109,37 @@ public class Couponset implements Parcelable, Serializable {
private String discount_type = "";
private double final_price = 0.0d;
public Couponset() {
this.uuid = "";
this.admin_name = "";
this.created = "";
this.updated = "";
this.app_uuid = "";
this.img = new JSONArray();
this.img_preview = "";
this.sorting = 0;
this.active = false;
this.visible = false;
this.buyable = false;
this.user_generated = false;
this.limits = new JSONObject();
this.points = 0;
this.points_cause = "";
this.expiration = "";
this.third_party_service = false;
this.name = "";
this.description = "";
this.short_description = "";
this.discount = "";
this.category = "";
this.terms = "";
this.availability = 0;
this.merchantUuid = "";
this.innerText = "";
this.discount_type = "";
this.final_price = 0.0d;
}
/**
* Basic constructor used to create an object from a String, representing a
* JSON Object
......@@ -411,6 +442,118 @@ public class Couponset implements Parcelable, Serializable {
return final_price;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public void setAdmin_name(String admin_name) {
this.admin_name = admin_name;
}
public void setCreated(String created) {
this.created = created;
}
public void setUpdated(String updated) {
this.updated = updated;
}
public void setApp_uuid(String app_uuid) {
this.app_uuid = app_uuid;
}
public void setImg(JSONArray img) {
this.img = img;
}
public void setImg_preview(String img_preview) {
this.img_preview = img_preview;
}
public void setSorting(int sorting) {
this.sorting = sorting;
}
public void setActive(boolean active) {
this.active = active;
}
public void setVisible(boolean visible) {
this.visible = visible;
}
public void setBuyable(boolean buyable) {
this.buyable = buyable;
}
public void setUser_generated(boolean user_generated) {
this.user_generated = user_generated;
}
public void setLimits(JSONObject limits) {
this.limits = limits;
}
public void setPoints(int points) {
this.points = points;
}
public void setPoints_cause(String points_cause) {
this.points_cause = points_cause;
}
public void setExpiration(String expiration) {
this.expiration = expiration;
}
public void setThird_party_service(boolean third_party_service) {
this.third_party_service = third_party_service;
}
public void setName(String name) {
this.name = name;
}
public void setDescription(String description) {
this.description = description;
}
public void setShort_description(String short_description) {
this.short_description = short_description;
}
public void setDiscount(String discount) {
this.discount = discount;
}
public void setCategory(String category) {
this.category = category;
}
public void setTerms(String terms) {
this.terms = terms;
}
public void setAvailability(int availability) {
this.availability = availability;
}
public void setMerchantUuid(String merchantUuid) {
this.merchantUuid = merchantUuid;
}
public void setInnerText(String innerText) {
this.innerText = innerText;
}
public void setDiscount_type(String discount_type) {
this.discount_type = discount_type;
}
public void setFinal_price(double final_price) {
this.final_price = final_price;
}
@Override
public int describeContents() {
return 0;
......
package ly.warp.sdk.io.models;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.util.ArrayList;
/**
* Created by Panagiotis Triantafyllou on 24/Νοε/2022.
*/
public class CouponsetModel {
@SerializedName("status")
@Expose
private String status;
@SerializedName("context")
@Expose
private CouponsetContext context;
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public CouponsetContext getContext() {
return context;
}
public void setContext(CouponsetContext context) {
this.context = context;
}
public class CouponsetContext {
@SerializedName("MAPP_COUPON-status")
@Expose
private Integer mAPPCOUPONStatus;
@SerializedName("events_processed")
@Expose
private Integer eventsProcessed;
@SerializedName("MAPP_COUPON")
@Expose
private ArrayList<MappCoupon> mappCoupon = null;
public ArrayList<MappCoupon> getMappCoupon() {
return mappCoupon;
}
public void setMappCoupon(ArrayList<MappCoupon> mappCoupon) {
this.mappCoupon = mappCoupon;
}
public Integer getMAPPCOUPONStatus() {
return mAPPCOUPONStatus;
}
public void setMAPPCOUPONStatus(Integer mAPPCOUPONStatus) {
this.mAPPCOUPONStatus = mAPPCOUPONStatus;
}
public Integer getEventsProcessed() {
return eventsProcessed;
}
public void setEventsProcessed(Integer eventsProcessed) {
this.eventsProcessed = eventsProcessed;
}
}
public class MappCoupon {
@SerializedName("uuid")
@Expose
private String uuid;
@SerializedName("img_preview")
@Expose
private String imgPreview;
@SerializedName("final_price")
@Expose
private Integer finalPrice;
@SerializedName("start_date")
@Expose
private String startDate;
@SerializedName("end_date")
@Expose
private String endDate;
@SerializedName("discount_type")
@Expose
private String discountType;
@SerializedName("promoted")
@Expose
private Boolean promoted;
@SerializedName("expiration")
@Expose
private CouponsetExpiration expiration;
@SerializedName("name")
@Expose
private String name;
@SerializedName("description")
@Expose
private String description;
@SerializedName("short_description")
@Expose
private String shortDescription;
@SerializedName("discount")
@Expose
private String discount;
@SerializedName("terms")
@Expose
private String terms;
@SerializedName("inner_text")
@Expose
private String innerText;
@SerializedName("merchant_uuid")
@Expose
private String merchantUuid;
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public String getImgPreview() {
return imgPreview;
}
public void setImgPreview(String imgPreview) {
this.imgPreview = imgPreview;
}
public Integer getFinalPrice() {
return finalPrice;
}
public void setFinalPrice(Integer finalPrice) {
this.finalPrice = finalPrice;
}
public String getStartDate() {
return startDate;
}
public void setStartDate(String startDate) {
this.startDate = startDate;
}
public String getEndDate() {
return endDate;
}
public void setEndDate(String endDate) {
this.endDate = endDate;
}
public String getDiscountType() {
return discountType;
}
public void setDiscountType(String discountType) {
this.discountType = discountType;
}
public Boolean getPromoted() {
return promoted;
}
public void setPromoted(Boolean promoted) {
this.promoted = promoted;
}
public CouponsetExpiration getExpiration() {
return expiration;
}
public void setExpiration(CouponsetExpiration expiration) {
this.expiration = expiration;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getShortDescription() {
return shortDescription;
}
public void setShortDescription(String shortDescription) {
this.shortDescription = shortDescription;
}
public String getDiscount() {
return discount;
}
public void setDiscount(String discount) {
this.discount = discount;
}
public String getTerms() {
return terms;
}
public void setTerms(String terms) {
this.terms = terms;
}
public String getInnerText() {
return innerText;
}
public void setInnerText(String innerText) {
this.innerText = innerText;
}
public String getMerchantUuid() {
return merchantUuid;
}
public void setMerchantUuid(String merchantUuid) {
this.merchantUuid = merchantUuid;
}
}
public class CouponsetExpiration {
@SerializedName("type")
@Expose
private String type;
@SerializedName("value")
@Expose
private String value;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
}
package ly.warp.sdk.io.models;
import org.json.JSONArray;
import org.json.JSONObject;
import java.util.ArrayList;
import ly.warp.sdk.Warply;
import ly.warp.sdk.utils.WarplyProperty;
/**
* Created by Panagiotis Triantafyllou on 24/Νοε/2022.
*/
public class CouponsetRequestModel {
private CouponsetRequestInnerModel coupon;
public CouponsetRequestModel() {
this.coupon = new CouponsetRequestInnerModel();
}
private class CouponsetRequestInnerModel {
private String action;
private boolean active;
private boolean visible;
private String language;
public CouponsetRequestInnerModel() {
this.action = "retrieve_multilingual";
this.active = true;
this.visible = true;
this.language = WarplyProperty.getLanguage(Warply.getWarplyContext());
}
}
}
......@@ -565,6 +565,170 @@ public class Merchant implements Parcelable, Serializable, ClusterItem {
return product;
}
public void setAddress(String address) {
this.address = address;
}
public void setId(String id) {
this.id = id;
}
public void setStore_id(String store_id) {
this.store_id = store_id;
}
public void setName(String name) {
this.name = name;
}
public void setLogo(String logo) {
this.logo = logo;
}
public void setWebsite(String website) {
this.website = website;
}
public void setEmail(String email) {
this.email = email;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
public void setCategory(String category) {
this.category = category;
}
public void setDescription(String description) {
this.description = description;
}
public void setShort_description(String short_description) {
this.short_description = short_description;
}
public void setRegion(String region) {
this.region = region;
}
public void setLatitude(double latitude) {
this.latitude = latitude;
}
public void setLongitude(double longitude) {
this.longitude = longitude;
}
public void setImage(String image) {
this.image = image;
}
public void setExtra_fields(JSONObject extra_fields) {
this.extra_fields = extra_fields;
}
public void setActive(boolean active) {
this.active = active;
}
public void setCity(String city) {
this.city = city;
}
public void setCountry(String country) {
this.country = country;
}
public void setPostal_code(String postal_code) {
this.postal_code = postal_code;
}
public void setVat(String vat) {
this.vat = vat;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public void setCategory_uuid(String category_uuid) {
this.category_uuid = category_uuid;
}
public void setCreated(String created) {
this.created = created;
}
public void setParent(String parent) {
this.parent = parent;
}
public void setImg(JSONArray img) {
this.img = img;
}
public void setImg_preview(String img_preview) {
this.img_preview = img_preview;
}
public void setAdmin_name(String admin_name) {
this.admin_name = admin_name;
}
public void setSorting(int sorting) {
this.sorting = sorting;
}
public void setBody(String body) {
this.body = body;
}
public void setOwner_name(String owner_name) {
this.owner_name = owner_name;
}
public void setPreview(String preview) {
this.preview = preview;
}
public void setMerchant_metadata(JSONObject merchant_metadata) {
this.merchant_metadata = merchant_metadata;
}
public void setPromoted(boolean promoted) {
this.promoted = promoted;
}
public void setDistance(int distance) {
this.distance = distance;
}
public void setDefault_shown(boolean default_shown) {
this.default_shown = default_shown;
}
public void setHidden(boolean hidden) {
this.hidden = hidden;
}
public void setWorking_hours(JSONObject working_hours) {
this.working_hours = working_hours;
}
public void setTags(JSONArray tags) {
this.tags = tags;
}
public void setProduct(JSONObject product) {
this.product = product;
}
public void setCoordinates(LatLng coordinates) {
this.coordinates = coordinates;
}
@Override
public int describeContents() {
return 0;
......
package ly.warp.sdk.io.models;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.util.ArrayList;
import java.util.Date;
/**
* Created by Panagiotis Triantafyllou on 24/Νοε/2022.
*/
public class MerchantModel {
@SerializedName("status")
@Expose
private String status;
@SerializedName("context")
@Expose
private MerchantContext context;
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public MerchantContext getContext() {
return context;
}
public void setContext(MerchantContext context) {
this.context = context;
}
public class MerchantContext {
@SerializedName("MAPP_SHOPS")
@Expose
private MappShops mappShops;
@SerializedName("MAPP_SHOPS-status")
@Expose
private Integer mAPPSHOPSStatus;
@SerializedName("events_processed")
@Expose
private Integer eventsProcessed;
public MappShops getMappShops() {
return mappShops;
}
public void setMappShops(MappShops mappShops) {
this.mappShops = mappShops;
}
public Integer getMAPPSHOPSStatus() {
return mAPPSHOPSStatus;
}
public void setMAPPSHOPSStatus(Integer mAPPSHOPSStatus) {
this.mAPPSHOPSStatus = mAPPSHOPSStatus;
}
public Integer getEventsProcessed() {
return eventsProcessed;
}
public void setEventsProcessed(Integer eventsProcessed) {
this.eventsProcessed = eventsProcessed;
}
}
public class MappShops {
@SerializedName("msg")
@Expose
private String msg;
@SerializedName("result")
@Expose
private ArrayList<MerchantResult> result = null;
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public ArrayList<MerchantResult> getResult() {
return result;
}
public void setResult(ArrayList<MerchantResult> result) {
this.result = result;
}
}
public class MerchantResult {
@SerializedName("uuid")
@Expose
private String uuid;
@SerializedName("img_preview")
@Expose
private String imgPreview;
@SerializedName("admin_name")
@Expose
private String adminName;
@SerializedName("address")
@Expose
private String address;
@SerializedName("name")
@Expose
private String name;
@SerializedName("latitude")
@Expose
private double latitude;
@SerializedName("longitude")
@Expose
private double longitude;
@SerializedName("telephone")
@Expose
private String telephone;
@SerializedName("website")
@Expose
private String website;
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public String getImgPreview() {
return imgPreview;
}
public void setImgPreview(String imgPreview) {
this.imgPreview = imgPreview;
}
public String getAdminName() {
return adminName;
}
public void setAdminName(String adminName) {
this.adminName = adminName;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getLatitude() {
return latitude;
}
public void setLatitude(double latitude) {
this.latitude = latitude;
}
public double getLongitude() {
return longitude;
}
public void setLongitude(double longitude) {
this.longitude = longitude;
}
public String getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
public String getWebsite() {
return website;
}
public void setWebsite(String website) {
this.website = website;
}
}
}
package ly.warp.sdk.io.models;
import org.json.JSONArray;
import org.json.JSONObject;
import ly.warp.sdk.Warply;
import ly.warp.sdk.utils.WarplyProperty;
/**
* Created by Panagiotis Triantafyllou on 24/Νοε/2022.
*/
public class MerchantsRequestModel {
private MerchantsRequestInnerModel shops;
public MerchantsRequestModel() {
this.shops = new MerchantsRequestInnerModel();
}
private class MerchantsRequestInnerModel {
private String action;
private JSONArray categories;
private boolean active;
private JSONObject location;
private JSONArray parent_uuids;
private String language;
public MerchantsRequestInnerModel() {
this.action = "retrieve_multilingual";
this.categories = new JSONArray();
this.active = true;
this.location = null;
this.parent_uuids = null;
this.language = WarplyProperty.getLanguage(Warply.getWarplyContext());
}
}
}
package ly.warp.sdk.io.volley;
import java.util.concurrent.TimeUnit;
import ly.warp.sdk.Warply;
import ly.warp.sdk.utils.WarplyProperty;
import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
/**
* Created by Panagiotis Triantafyllou on 24/Νοε/2022.
*/
public class ApiClient {
// ===========================================================
// Constants
// ===========================================================
// ===========================================================
// Fields
// ===========================================================
private static Retrofit retrofit;
// ===========================================================
// Methods for/from SuperClass/Interfaces
// ===========================================================
// ===========================================================
// Methods
// ===========================================================
public static Retrofit getRetrofitInstance() {
// Gson gson = new GsonBuilder()
// .setLenient()
// .create();
if (retrofit == null) {
retrofit = new Retrofit.Builder()
.baseUrl(WarplyProperty.getBaseUrl(Warply.getWarplyContext()))
.client(getClient())
.addConverterFactory(GsonConverterFactory.create(/*gson*/))
.build();
}
return retrofit;
}
private static OkHttpClient getClient() {
return new OkHttpClient.Builder()
.connectTimeout(30, TimeUnit.SECONDS)
.writeTimeout(30, TimeUnit.SECONDS)
.readTimeout(30, TimeUnit.SECONDS)
.build();
}
// ===========================================================
// Getter & Setter
// ===========================================================
// ===========================================================
// Inner and Anonymous Classes
// ===========================================================
}
package ly.warp.sdk.io.volley;
import ly.warp.sdk.io.models.CouponModel;
import ly.warp.sdk.io.models.CouponRequestModel;
import ly.warp.sdk.io.models.CouponsetModel;
import ly.warp.sdk.io.models.CouponsetRequestModel;
import ly.warp.sdk.io.models.MerchantModel;
import ly.warp.sdk.io.models.MerchantsRequestModel;
import ly.warp.sdk.utils.constants.WarpConstants;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.Header;
import retrofit2.http.POST;
import retrofit2.http.Path;
/**
* Created by Panagiotis Triantafyllou on 24/Νοε/2022.
*/
public interface ApiService {
// ===========================================================
// Constants
// ===========================================================
// ===========================================================
// Fields
// ===========================================================
// ===========================================================
// Methods for/from SuperClass/Interfaces
// ===========================================================
// ===========================================================
// Methods
// ===========================================================
@POST("/api/mobile/v2/{appUuid}/context/")
Call<CouponsetModel> getCouponsets(@Path("appUuid") String appUuid,
@Body CouponsetRequestModel request,
@Header(WarpConstants.HEADER_DATE) String timeStamp,
@Header(WarpConstants.HEADER_LOYALTY_BUNDLE_ID) String bundleId,
@Header(WarpConstants.HEADER_UNIQUE_DEVICE_ID) String deviceId,
@Header(WarpConstants.HEADER_CHANNEL) String channel,
@Header(WarpConstants.HEADER_WEB_ID) String webId,
@Header(WarpConstants.HEADER_SIGNATURE) String signature);
@POST("/oauth/{appUuid}/context")
Call<CouponModel> getUserCoupons(@Path("appUuid") String appUuid,
@Body CouponRequestModel request,
@Header(WarpConstants.HEADER_DATE) String timeStamp,
@Header(WarpConstants.HEADER_LOYALTY_BUNDLE_ID) String bundleId,
@Header(WarpConstants.HEADER_UNIQUE_DEVICE_ID) String deviceId,
@Header(WarpConstants.HEADER_CHANNEL) String channel,
@Header(WarpConstants.HEADER_WEB_ID) String webId,
@Header(WarpConstants.HEADER_SIGNATURE) String signature,
@Header(WarpConstants.HEADER_AUTHORIZATION) String bearer);
@POST("/api/mobile/v2/{appUuid}/context/")
Call<MerchantModel> getMerchants(@Path("appUuid") String appUuid,
@Body MerchantsRequestModel request,
@Header(WarpConstants.HEADER_DATE) String timeStamp,
@Header(WarpConstants.HEADER_LOYALTY_BUNDLE_ID) String bundleId,
@Header(WarpConstants.HEADER_UNIQUE_DEVICE_ID) String deviceId,
@Header(WarpConstants.HEADER_CHANNEL) String channel,
@Header(WarpConstants.HEADER_WEB_ID) String webId,
@Header(WarpConstants.HEADER_SIGNATURE) String signature);
// ===========================================================
// Getter & Setter
// ===========================================================
// ===========================================================
// Inner and Anonymous Classes
// ===========================================================
}