388 lines
17 KiB
Java
388 lines
17 KiB
Java
package ch.pizzamaxx.android.api;
|
||
|
||
import java.util.HashMap;
|
||
|
||
import ch.pizzamaxx.android.model.AddNewAddressResponseModel;
|
||
import ch.pizzamaxx.android.model.AddProductToBasketResponseModel;
|
||
import ch.pizzamaxx.android.model.AddressModel;
|
||
import ch.pizzamaxx.android.model.AppVersionModel;
|
||
import ch.pizzamaxx.android.model.CampaignModel;
|
||
import ch.pizzamaxx.android.model.CheckCouponModel;
|
||
import ch.pizzamaxx.android.model.CountryModel;
|
||
import ch.pizzamaxx.android.model.DeleteAddressResponseModel;
|
||
import ch.pizzamaxx.android.model.PaymentMethodsResponseModel;
|
||
import ch.pizzamaxx.android.model.PaymentTokenModel;
|
||
import ch.pizzamaxx.android.model.RemoveProductFromCartResponseModel;
|
||
import ch.pizzamaxx.android.model.ShippingMethodModel;
|
||
import ch.pizzamaxx.android.model.StoreInfoModel;
|
||
import ch.pizzamaxx.android.model.CityModel;
|
||
import ch.pizzamaxx.android.model.StoreModel;
|
||
import ch.pizzamaxx.android.model.StoreShiftModel;
|
||
import ch.pizzamaxx.android.model.ZoneModel;
|
||
import ch.pizzamaxx.android.model.cart.CartInfoModel;
|
||
import ch.pizzamaxx.android.model.CategoryModel;
|
||
import ch.pizzamaxx.android.model.history.OrderHistoryModel;
|
||
import ch.pizzamaxx.android.model.UserModel;
|
||
import ch.pizzamaxx.android.model.history.OrderHistoryProductModel;
|
||
import ch.pizzamaxx.android.model.menu.MenuProductModel;
|
||
import okhttp3.RequestBody;
|
||
import retrofit2.Call;
|
||
import retrofit2.http.Body;
|
||
import retrofit2.http.Field;
|
||
import retrofit2.http.FieldMap;
|
||
import retrofit2.http.FormUrlEncoded;
|
||
import retrofit2.http.GET;
|
||
import retrofit2.http.POST;
|
||
import retrofit2.http.Path;
|
||
import retrofit2.http.Query;
|
||
import retrofit2.http.Url;
|
||
|
||
/**
|
||
* Created by cimenmus on 04/02/2017.
|
||
*/
|
||
|
||
public interface ApiInterface {
|
||
|
||
|
||
@GET("{storeName}" + ApiEndPoints.API_GET_ALL_CATEGORIES)
|
||
Call<ResponseArray<CategoryModel>> getAllCategories(@Path("storeName") String storeName);
|
||
|
||
@GET("{storeName}" + ApiEndPoints.API_GET_IGNORED_CATEGORY_IDS)
|
||
Call<ResponseArray<Integer>> getIgnoredCategoryIds(@Path("storeName") String storeName);
|
||
|
||
@GET("{storeName}" + ApiEndPoints.API_GET_PIZZA_CATEGORY_IDS)
|
||
Call<ResponseArray<Integer>> getPizzaCategoryIds(@Path("storeName") String storeName);
|
||
|
||
@FormUrlEncoded
|
||
@POST("{storeName}" + ApiEndPoints.API_REGISTER)
|
||
Call<ResponseObject<UserModel>> register(@Path("storeName") String storeName,
|
||
@FieldMap HashMap<String, Object> body);
|
||
|
||
@FormUrlEncoded
|
||
@POST("{storeName}" + ApiEndPoints.API_LOGIN)
|
||
Call<ResponseObject<UserModel>> login(@Path("storeName") String storeName,
|
||
@Field("email") String email,
|
||
@Field("password") String password);
|
||
|
||
@FormUrlEncoded
|
||
@POST("{storeName}" + ApiEndPoints.API_LOGOUT)
|
||
Call<ResponseObject> logout(@Path("storeName") String storeName,
|
||
@Field("token") String customerToken);
|
||
|
||
@GET("{storeName}" + ApiEndPoints.API_GET_ORDER_HISTORY)
|
||
Call<ResponseArray<OrderHistoryModel>> getOrderHistory(@Path("storeName") String storeName,
|
||
@Query("token") String token);
|
||
|
||
/*
|
||
// OK
|
||
@POST
|
||
Call<ResponseObject<CartInfoModel>> getCartProducts(@Url String url);
|
||
|
||
// OK
|
||
@FormUrlEncoded
|
||
@POST
|
||
Call<ResponseObject<CartInfoModel>> getCartProductsForCommission(@Url String url,
|
||
@Field("payment_method") String paymentMethodCode,
|
||
@Field("shipping_method") String shippingMethodCode);
|
||
|
||
@FormUrlEncoded
|
||
@POST
|
||
Call<ResponseObject<CartInfoModel>> getCartProductsWithCoupon(@Url String url,
|
||
@FieldMap HashMap<String, Object> body);
|
||
*/
|
||
|
||
@FormUrlEncoded
|
||
@POST
|
||
Call<ResponseObject<CartInfoModel>> getCartProducts(@Url String url,
|
||
@FieldMap HashMap<String, Object> body);
|
||
|
||
@GET("{storeName}" + ApiEndPoints.API_GET_CLEAR_CART)
|
||
Call<ResponseObject> clearCart(@Path("storeName") String storeName,
|
||
@Query("token") String token);
|
||
|
||
@GET("{storeName}" + ApiEndPoints.API_GET_PRODUCTS_BY_CATEGORY)
|
||
Call<ResponseArray<MenuProductModel>> getProductsByCategory(@Path("storeName") String storeName,
|
||
@Query("category_id") String categoryId);
|
||
|
||
@FormUrlEncoded
|
||
@POST("{storeName}" + ApiEndPoints.API_GET_PRODUCT)
|
||
Call<ResponseArray<MenuProductModel>> getProductById(@Path("storeName") String storeName,
|
||
@Field("product_id") int productId);
|
||
|
||
|
||
// * Bu projedeki post servisler bizden form-data bekliyor. Bu serviste @FormUrlEncoded yapınca ve
|
||
// * body'i @FieldMap HashMap<String, Object> body olarak verince, body içindeki alanlar
|
||
// * encode ediliyor, mesela body içindeki "[" karakteri "%5D" ye falan dönüşüyor, dolayısı ile servis bunları okuyamıyor.
|
||
// * Bu sebeple body olarak RequestBody verdim ve servisi çağırırken bod içindeki alanları FormBody olarak ekledim.
|
||
// OK
|
||
@POST
|
||
Call<ResponseObject<AddProductToBasketResponseModel>> addProductsToBasket(@Url String url,
|
||
@Body RequestBody body);
|
||
@GET("{storeName}" + ApiEndPoints.API_GET_SHIPPING_METHODS)
|
||
Call<ResponseArray<ShippingMethodModel>> getShippingMethods(@Path("storeName") String storeName,
|
||
@Query("token") String token);
|
||
|
||
@GET("{storeName}" + ApiEndPoints.API_GET_CUSTOMER_ADDRESSES)
|
||
Call<ResponseArray<AddressModel>> getCustomerAddresses(@Path("storeName") String storeName,
|
||
@Query("token") String token);
|
||
|
||
@FormUrlEncoded
|
||
@POST
|
||
Call<ResponseObject<AddNewAddressResponseModel>> addNewAddress(@Url String url,
|
||
@FieldMap HashMap<String, Object> body);
|
||
@FormUrlEncoded
|
||
@POST
|
||
Call<ResponseObject<DeleteAddressResponseModel>> deleteAddress(@Url String url,
|
||
@Field("address_id") String addressId);
|
||
@GET("{storeName}" + ApiEndPoints.API_GET_PAYMENT_METHODS)
|
||
Call<ResponseObject<PaymentMethodsResponseModel>> getPaymentMethods(@Path("storeName") String storeName,
|
||
@Query("token") String token);
|
||
|
||
@FormUrlEncoded
|
||
@POST
|
||
Call<ResponseObject<Integer>> createOrder(@Url String url, @FieldMap HashMap<String, Object> body);
|
||
|
||
@FormUrlEncoded
|
||
@POST("{storeName}" + ApiEndPoints.API_CHECK_UPDATE)
|
||
Call<ResponseObject<AppVersionModel>> checkUpdate(@Path("storeName") String storeName,
|
||
@FieldMap HashMap<String, Object> body);
|
||
|
||
@FormUrlEncoded
|
||
@POST("{storeName}" + ApiEndPoints.API_FORGOT_PASSWORD)
|
||
Call<ResponseObject> forgotPassword(@Path("storeName") String storeName,
|
||
@Field("email") String emailAddress);
|
||
|
||
@GET("{storeName}" + ApiEndPoints.API_GET_CITY_LIST)
|
||
Call<ResponseArray<CityModel>> getCityList(@Path("storeName") String storeName);
|
||
|
||
@GET("{storeName}" + ApiEndPoints.API_GET_COUNTRY_LIST)
|
||
Call<ResponseArray<CountryModel>> getCountryList(@Path("storeName") String storeName);
|
||
|
||
@FormUrlEncoded
|
||
@POST("{storeName}" + ApiEndPoints.API_GET_ZONE_LIST)
|
||
Call<ResponseArray<ZoneModel>> getZoneList(@Path("storeName") String storeName,
|
||
@Field("country_id") String countryId);
|
||
|
||
@GET("{storeName}" + ApiEndPoints.API_GET_CUSTOMER_PROFILE)
|
||
Call<ResponseObject<UserModel>> getCustomerProfile(@Path("storeName") String storeName,
|
||
@Query("token") String token);
|
||
|
||
@FormUrlEncoded
|
||
@POST
|
||
Call<ResponseObject> updatePassword(@Url String url,
|
||
@FieldMap HashMap<String, Object> body);
|
||
|
||
@FormUrlEncoded
|
||
@POST
|
||
Call<ResponseObject<UserModel>> updateProfile(@Url String url,
|
||
@FieldMap HashMap<String, Object> body);
|
||
|
||
@FormUrlEncoded
|
||
@POST
|
||
Call<ResponseObject<RemoveProductFromCartResponseModel>> removeProductFromCart(@Url String url,
|
||
@FieldMap HashMap<String, Object> body);
|
||
@GET("{storeName}" + ApiEndPoints.API_GET_STORE_INFO)
|
||
Call<ResponseObject<StoreInfoModel>> getStoreInfo(@Path("storeName") String storeName);
|
||
|
||
@FormUrlEncoded
|
||
@POST
|
||
Call<ResponseArray<OrderHistoryProductModel>> getOrderProductList(@Url String url,
|
||
@Field("order_id") String orderId);
|
||
@FormUrlEncoded
|
||
@POST
|
||
Call<ResponseObject<CheckCouponModel>> checkCoupon(@Url String url,
|
||
@Field("coupon") String couponCode);
|
||
|
||
@GET("{storeName}" + ApiEndPoints.API_CHECK_CAMPAIGN_PIZZAPASS)
|
||
Call<ResponseObject<CampaignModel>> checkPizzapassCampaign(@Path("storeName") String storeName,
|
||
@Query("token") String token);
|
||
|
||
@GET("{storeName}" + ApiEndPoints.API_CHECK_CAMPAIGN_CHAMPAGNE)
|
||
Call<ResponseObject<CampaignModel>> checkChampagneCampaign(@Path("storeName") String storeName,
|
||
@Query("token") String token);
|
||
|
||
@GET("{storeName}" + ApiEndPoints.API_CHECK_DELIVERY_TIME)
|
||
Call<ResponseObject<Boolean>> checkDeliveryTime(@Path("storeName") String storeName);
|
||
|
||
@FormUrlEncoded
|
||
@POST("{storeName}" + ApiEndPoints.API_CHECK_DELIVERY_TIME)
|
||
Call<ResponseObject<Boolean>> checkDeliveryTimeWithDateAndTime(@Path("storeName") String storeName,
|
||
@Field("delivery_date") String deliveryDateAndTime);
|
||
|
||
@FormUrlEncoded
|
||
@POST
|
||
Call<ResponseObject> createPayment(@Url String url,
|
||
@FieldMap HashMap<String, Object> body);
|
||
|
||
@FormUrlEncoded
|
||
@POST
|
||
Call<ResponseObject> repeatOrder(@Url String url,
|
||
@FieldMap HashMap<String, Object> body);
|
||
|
||
@GET(ApiEndPoints.API_GET_STORE_LIST)
|
||
Call<ResponseArray<StoreModel>> getStoreList();
|
||
|
||
@GET("{storeName}" + ApiEndPoints.API_GET_DELIVERY_TIME_OF_STORE)
|
||
Call<ResponseObject<StoreShiftModel>> getDeliveryTimeOfStore(@Path("storeName") String storeName);
|
||
|
||
@FormUrlEncoded
|
||
@POST
|
||
Call<ResponseObject> checkOrderPrice(@Url String url,
|
||
@FieldMap HashMap<String, Object> body);
|
||
|
||
@GET
|
||
Call<ResponseObject<PaymentTokenModel>> createPaymentToken(@Url String url);
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
/*
|
||
@GET(ApiEndPoints.API_GET_ALL_CATEGORIES)
|
||
Call<ResponseArray<CategoryModel>> getAllCategories(@Path("id") int id);
|
||
|
||
@GET(ApiEndPoints.API_GET_IGNORED_CATEGORY_IDS)
|
||
Call<ResponseArray<Integer>> getIgnoredCategoryIds();
|
||
|
||
@GET(ApiEndPoints.API_GET_PIZZA_CATEGORY_IDS)
|
||
Call<ResponseArray<Integer>> getPizzaCategoryIds();
|
||
|
||
@FormUrlEncoded
|
||
@POST(ApiEndPoints.API_REGISTER)
|
||
Call<ResponseObject<UserModel>> register(@FieldMap HashMap<String, Object> body);
|
||
|
||
@FormUrlEncoded
|
||
@POST(ApiEndPoints.API_LOGIN)
|
||
Call<ResponseObject<UserModel>> login(@Field("email") String email, @Field("password") String password);
|
||
|
||
@FormUrlEncoded
|
||
@POST(ApiEndPoints.API_LOGOUT)
|
||
Call<ResponseObject> logout(@Field("token") String customerToken);
|
||
|
||
@GET(ApiEndPoints.API_GET_ORDER_HISTORY)
|
||
Call<ResponseArray<OrderHistoryModel>> getOrderHistory(@Query("token") String token);
|
||
|
||
@POST
|
||
Call<ResponseObject<CartInfoModel>> getCartProducts(@Url String url);
|
||
|
||
@FormUrlEncoded
|
||
@POST
|
||
Call<ResponseObject<CartInfoModel>> getCartProductsForCommission(@Url String url,
|
||
@Field("payment_method") String paymentMethodCode,
|
||
@Field("shipping_method") String shippingMethodCode);
|
||
|
||
@GET(ApiEndPoints.API_GET_CLEAR_CART)
|
||
Call<ResponseObject> clearCart(@Query("token") String token);
|
||
|
||
@GET(ApiEndPoints.API_GET_PRODUCTS_BY_CATEGORY)
|
||
Call<ResponseArray<MenuProductModel>> getProductsByCategory(@Query("category_id") String categoryId);
|
||
|
||
@FormUrlEncoded
|
||
@POST(ApiEndPoints.API_GET_PRODUCT)
|
||
Call<ResponseArray<MenuProductModel>> getProductById(@Field("product_id") int productId);
|
||
|
||
|
||
// * Bu projedeki post servisler bizden form-data bekliyor. Bu serviste @FormUrlEncoded yapınca ve
|
||
// * body'i @FieldMap HashMap<String, Object> body olarak verince, body içindeki alanlar
|
||
// * encode ediliyor, mesela body içindeki "[" karakteri "%5D" ye falan dönüşüyor, dolayısı ile servis bunları okuyamıyor.
|
||
// * Bu sebeple body olarak RequestBody verdim ve servisi çağırırken bod içindeki alanları FormBody olarak ekledim.
|
||
@POST
|
||
Call<ResponseObject<AddProductToBasketResponseModel>> addProductsToBasket(@Url String url,
|
||
@Body RequestBody body);
|
||
@GET(ApiEndPoints.API_GET_SHIPPING_METHODS)
|
||
Call<ResponseArray<ShippingMethodModel>> getShippingMethods(@Query("token") String token);
|
||
|
||
@GET(ApiEndPoints.API_GET_CUSTOMER_ADDRESSES)
|
||
Call<ResponseArray<AddressModel>> getCustomerAddresses(@Query("token") String token);
|
||
|
||
@FormUrlEncoded
|
||
@POST
|
||
Call<ResponseObject<AddNewAddressResponseModel>> addNewAddress(@Url String url,
|
||
@FieldMap HashMap<String, Object> body);
|
||
@FormUrlEncoded
|
||
@POST
|
||
Call<ResponseObject<DeleteAddressResponseModel>> deleteAddress(@Url String url,
|
||
@Field("address_id") String addressId);
|
||
@GET(ApiEndPoints.API_GET_PAYMENT_METHODS)
|
||
Call<ResponseObject<PaymentMethodsResponseModel>> getPaymentMethods(@Query("token") String token);
|
||
|
||
@FormUrlEncoded
|
||
@POST
|
||
Call<ResponseObject<Integer>> createOrder(@Url String url, @FieldMap HashMap<String, Object> body);
|
||
|
||
@FormUrlEncoded
|
||
@POST(ApiEndPoints.API_CHECK_UPDATE)
|
||
Call<ResponseObject<AppVersionModel>> checkUpdate(@FieldMap HashMap<String, Object> body);
|
||
|
||
@FormUrlEncoded
|
||
@POST(ApiEndPoints.API_FORGOT_PASSWORD)
|
||
Call<ResponseObject> forgotPassword(@Field("email") String emailAddress);
|
||
|
||
@GET(ApiEndPoints.API_GET_CITY_LIST)
|
||
Call<ResponseArray<CityModel>> getCityList();
|
||
|
||
@GET(ApiEndPoints.API_GET_COUNTRY_LIST)
|
||
Call<ResponseArray<CountryModel>> getCountryList();
|
||
|
||
@FormUrlEncoded
|
||
@POST(ApiEndPoints.API_GET_ZONE_LIST)
|
||
Call<ResponseArray<ZoneModel>> getZoneList(@Field("country_id") String countryId);
|
||
|
||
@GET(ApiEndPoints.API_GET_CUSTOMER_PROFILE)
|
||
Call<ResponseObject<UserModel>> getCustomerProfile(@Query("token") String token);
|
||
|
||
@FormUrlEncoded
|
||
@POST
|
||
Call<ResponseObject> updatePassword(@Url String url, @FieldMap HashMap<String, Object> body);
|
||
|
||
@FormUrlEncoded
|
||
@POST
|
||
Call<ResponseObject<UserModel>> updateProfile(@Url String url, @FieldMap HashMap<String, Object> body);
|
||
|
||
@FormUrlEncoded
|
||
@POST
|
||
Call<ResponseObject<RemoveProductFromCartResponseModel>> removeProductFromCart(@Url String url,
|
||
@FieldMap HashMap<String, Object> body);
|
||
@GET(ApiEndPoints.API_GET_STORE_INFO)
|
||
Call<ResponseObject<StoreInfoModel>> getStoreInfo();
|
||
|
||
@FormUrlEncoded
|
||
@POST
|
||
Call<ResponseArray<OrderHistoryProductModel>> getOrderProductList(@Url String url,
|
||
@Field("order_id") String orderId);
|
||
@FormUrlEncoded
|
||
@POST
|
||
Call<ResponseObject<CheckCouponModel>> checkCoupon(@Url String url, @Field("coupon") String couponCode);
|
||
|
||
@GET(ApiEndPoints.API_CHECK_CAMPAIGN_PIZZAPASS)
|
||
Call<ResponseObject<CampaignModel>> checkPizzapassCampaign(@Query("token") String token);
|
||
|
||
@GET(ApiEndPoints.API_CHECK_CAMPAIGN_CHAMPAGNE)
|
||
Call<ResponseObject<CampaignModel>> checkChampagneCampaign(@Query("token") String token);
|
||
|
||
@GET(ApiEndPoints.API_CHECK_DELIVERY_TIME)
|
||
Call<ResponseObject<Boolean>> checkDeliveryTime();
|
||
|
||
@FormUrlEncoded
|
||
@POST(ApiEndPoints.API_CHECK_DELIVERY_TIME)
|
||
Call<ResponseObject<Boolean>> checkDeliveryTimeWithDateAndTime(@Field("delivery_date") String deliveryDateAndTime);
|
||
|
||
@FormUrlEncoded
|
||
@POST
|
||
Call<ResponseObject> createPayment(@Url String url, @FieldMap HashMap<String, Object> body);
|
||
|
||
@FormUrlEncoded
|
||
@POST
|
||
Call<ResponseObject> repeatOrder(@Url String url, @FieldMap HashMap<String, Object> body);
|
||
|
||
@GET(ApiEndPoints.API_GET_STORE_LIST)
|
||
Call<ResponseArray<StoreModel>> getStoreList();
|
||
*/
|
||
|
||
|
||
}
|