initial commit

This commit is contained in:
cimenmus
2018-05-26 12:04:22 +03:00
parent 2f57316d7a
commit 24eef0ed59
132 changed files with 856 additions and 879 deletions

View File

@@ -0,0 +1,153 @@
package ch.pizzapp.android.api;
import java.util.HashMap;
import ch.pizzapp.android.model.AddNewAddressResponseModel;
import ch.pizzapp.android.model.AddProductToBasketResponseModel;
import ch.pizzapp.android.model.AddressModel;
import ch.pizzapp.android.model.AppVersionModel;
import ch.pizzapp.android.model.CheckCouponModel;
import ch.pizzapp.android.model.CountryModel;
import ch.pizzapp.android.model.DeleteAddressResponseModel;
import ch.pizzapp.android.model.PaymentMethodsResponseModel;
import ch.pizzapp.android.model.RemoveProductFromCartResponseModel;
import ch.pizzapp.android.model.ShippingMethodModel;
import ch.pizzapp.android.model.StoreInfoModel;
import ch.pizzapp.android.model.CityModel;
import ch.pizzapp.android.model.ZoneModel;
import ch.pizzapp.android.model.cart.CartInfoModel;
import ch.pizzapp.android.model.CategoryModel;
import ch.pizzapp.android.model.history.OrderHistoryModel;
import ch.pizzapp.android.model.UserModel;
import ch.pizzapp.android.model.history.OrderHistoryProductModel;
import ch.pizzapp.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.Query;
import retrofit2.http.Url;
/**
* Created by cimenmus on 04/02/2017.
*/
public interface ApiInterface {
@GET(ApiEndPoints.API_GET_ALL_CATEGORIES)
Call<ResponseArray<CategoryModel>> getAllCategories();
@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);
@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);
}