Created
July 23, 2015 07:31
-
-
Save vgaidarji/cb7329820c60ab535953 to your computer and use it in GitHub Desktop.
Wadi API Android
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.wadi.android.api.services; | |
import com.wadi.android.model.api.ApiContent; | |
import com.wadi.android.model.api.Message; | |
import com.wadi.android.model.appConfig.AppConfigResult; | |
import com.wadi.android.model.order.OrderReview; | |
import com.wadi.android.model.order.OrderReviewResponse; | |
import com.wadi.android.model.product.ProductBrand; | |
import com.wadi.android.model.product.ProductDetails; | |
import com.wadi.android.model.product.ProductsResult; | |
import com.wadi.android.model.user.User; | |
import java.util.List; | |
import retrofit.Callback; | |
import retrofit.client.Response; | |
import retrofit.http.Body; | |
import retrofit.http.Field; | |
import retrofit.http.FormUrlEncoded; | |
import retrofit.http.GET; | |
import retrofit.http.Headers; | |
import retrofit.http.POST; | |
import retrofit.http.Path; | |
import retrofit.http.Query; | |
/** | |
* Created by vturcan on 1/23/15. | |
*/ | |
public interface Api { | |
/** | |
* | |
* @param serviceUrl any api service url. serviceUrl should start with '/' | |
* @param callback | |
*/ | |
@GET("/sawa/v1/u{serviceUrl}") // | |
void callApiService(@Path(value="serviceUrl", encode = false) String serviceUrl, | |
Callback<Response> callback); | |
/** | |
* | |
* @param serviceUrl any api service url. serviceUrl should start with '/' | |
* @param callback | |
*/ | |
@GET("/sawa/v1/u{serviceUrl}") // serviceUrl should start with '/' | |
void callApiWebContentService(@Path(value="serviceUrl", encode = true) String serviceUrl, | |
Callback<ApiContent> callback); | |
/** | |
* | |
* @param callback | |
*/ | |
@GET("/sawa/v1/u/all-brands") | |
void getBrands(Callback<List<ProductBrand>> callback); | |
/** | |
* | |
* @param callback | |
*/ | |
@GET("/rose/u/_meta/config") | |
void getAppConfig(Callback<AppConfigResult> callback); | |
/** | |
* | |
* @param productSku | |
* @param callback | |
*/ | |
//@GET("sawa/v1/products/{productSku}") - // this one is also a valid call, but unrecomended by Razan | |
@GET("/sawa/v1/u/product/{productSku}") | |
void getProduct(@Path("productSku") String productSku, | |
Callback<ProductDetails> callback); | |
/** | |
* | |
* @param productCategoryURL | |
* @param callback | |
*/ | |
@GET("/sawa/v1/u/{productCategoryURL}") | |
void getProducts(@Path(value="productCategoryURL", encode = true) String productCategoryURL, | |
Callback<ProductsResult> callback); | |
/** | |
* | |
* @param urlParams search query | |
* @param callback | |
*/ | |
@GET("/sawa/v1/u/{urlParams}") | |
void searchProducts(@Path(value = "urlParams", encode = false) String urlParams, | |
Callback<ProductsResult> callback); | |
/** | |
* | |
* @param catalogUrl url to the catalog service | |
* @param limit max. results number | |
* @param callback | |
*/ | |
@GET("/sawa/v1/u/{catalogUrl}") | |
void getFeaturedProducts(@Path("catalogUrl") String catalogUrl, | |
@Query("limit") int limit, | |
Callback<ProductsResult> callback); | |
/** | |
* Register Service | |
* @param email Email address | |
* @param password Password | |
* @param firstName First name | |
* @param lastName Last name | |
* @param gender Gender | |
* @param subscribeNewsletter Subscribe to newsletter (true/false) | |
* @param callback Callback object | |
*/ | |
@Headers({ | |
"WWW-Authenticate: Basic realm=\"fake\"", | |
"Content-Type: application/x-www-form-urlencoded; charset=UTF-8" | |
}) | |
@FormUrlEncoded | |
@POST("/jerry/customers.json") | |
void registerUser(@Field("email") String email, @Field("password") String password, | |
@Field("firstName") String firstName, @Field("lastName") String lastName, | |
@Field("gender") String gender, | |
@Field("subscribeNewsletter") String subscribeNewsletter, | |
Callback<User> callback); | |
/** | |
* | |
* @param email user email. On this email user will receive a restore link. | |
* @param callback | |
*/ | |
@POST("/jerry/password-reset-request/{email}/") | |
void sendMailToRestorePassword(@Path("email") String email, Callback<Message> callback); | |
/** | |
* | |
* @param email user email | |
* @param password user password | |
* @param callback | |
*/ | |
@Headers({ | |
"WWW-Authenticate: Basic realm=\"fake\"", | |
"Content-Type: application/x-www-form-urlencoded; charset=UTF-8" | |
}) | |
@FormUrlEncoded | |
@POST("/jerry/login") | |
void login(@Field("email") String email, @Field("password") String password, | |
Callback<User> callback); | |
/** | |
* Log out method | |
*/ | |
@GET("/jerry/logout") | |
void logout(); | |
/** | |
* | |
* @param orderReview order review data to send | |
* @param callback | |
*/ | |
@POST("/checkout/v1/order/review") | |
void reviewOrder(@Body OrderReview orderReview, Callback<OrderReviewResponse> callback); | |
/** | |
* | |
* @param searchQuery search word | |
* @param callback | |
*/ | |
@GET("/sawa/v1/u/catalog") | |
void getSearchResults(@Query(value = "q", encodeValue = true) String searchQuery, | |
Callback<ProductsResult> callback); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment