Skip to content

Instantly share code, notes, and snippets.

@esafirm

esafirm/ObengAPI.java

Last active Feb 9, 2016
Embed
What would you like to do?
What's better than documentation? A sample code ..
package com.satulingkaran.obeng.http;
import com.satulingkaran.obeng.data.model.Area;
import com.satulingkaran.obeng.data.model.BaseResponse;
import com.satulingkaran.obeng.data.model.Bengkel;
import com.satulingkaran.obeng.data.model.Category;
import com.satulingkaran.obeng.data.model.EditResponse;
import com.satulingkaran.obeng.data.model.JenisUsaha;
import com.satulingkaran.obeng.data.model.User;
import com.satulingkaran.obeng.data.model.UserReview;
import java.util.List;
import retrofit.http.GET;
import retrofit.http.Multipart;
import retrofit.http.POST;
import retrofit.http.Part;
import retrofit.http.Query;
import rx.Observable;
/**
* Created by esa on 04/08/15, with awesomeness
*/
public interface ApiService {
/* --------------------------------------------------- */
/* > Account
/* --------------------------------------------------- */
@GET("/svc_api.php?type=login")
Observable<User>
login(@Query(value = "username", encodeValue = false) String username,
@Query(value = "password", encodeValue = false) String password);
@GET("/svc_api.php?type=loginPemilik")
Observable<List<Bengkel>>
loginOwner(@Query(value = "email", encodeValue = false) String username,
@Query(value = "password", encodeValue = false) String password);
@Multipart
@POST("/svc_api.php?type=registerUser")
Observable<User>
register(@Part("username") String username,
@Part("password") String password,
@Part("nama_lengkap") String nama,
@Part("email") String email,
@Part("telp") String telp);
@Multipart
@POST("/svc_api.php?type=registerUserLogin")
Observable<User>
registerLogin(@Part("username") String username,
@Part("password") String password,
@Part("nama_lengkap") String nama,
@Part("email") String email,
@Part("telp") String telp);
/* --------------------------------------------------- */
/* > Profile
/* --------------------------------------------------- */
@GET("/svc_api.php?type=getUserBookmark")
Observable<List<Bengkel>>
getUserBookmars(@Query("id_user") String idUser);
@GET("/svc_api.php?type=getUserProfile")
Observable<User>
getUserProfile(@Query("id_user") String idUser);
@GET("/svc_api.php?type=getUserReview")
Observable<List<UserReview>>
getUserReviews(@Query("id_user") String idUser);
@GET("/svc_api.php?type=getBengkelReview")
Observable<List<UserReview>>
getBengkelReviews(@Query("id_bengkel") String idBengkel);
@GET("/svc_api.php?type=getUserBengkel")
Observable<List<Bengkel>>
getUserBengkel(@Query("id_user") String idUser);
@GET("/svc_api.php?type=getBengkelOwnedByUser")
Observable<List<Bengkel>>
getBengkelOwnedByUser(@Query("id_user") String idUser);
@Multipart
@POST("/svc_api.php?type=resetPassword")
Observable<BaseResponse>
resetPassword(@Part("email") String email);
// id_user, email, nama_lengkap, telp, img_user, motor, merk_motor, mobil, merk_mobil, password(jika ingin ganti password)
@Multipart
@POST("/svc_api.php?type=editUserProfile")
Observable<BaseResponse>
editUserProfile(@Part("id_user") String idUser,
@Part("email") String email,
@Part("nama_lengkap") String namaLengkap,
@Part("telp") String telp,
@Part("img_user") String imgUser,
@Part("motor") String motor,
@Part("merk_motor") String merkMotor,
@Part("mobil") String mobile,
@Part("merk_mobil") String merkMobil,
@Part("password") String password);
/* --------------------------------------------------- */
/* > Bengkel
/* --------------------------------------------------- */
@GET("/svc_api.php?type=getArea")
Observable<List<Area>> getArea();
@GET("/svc_api.php?type=getJenisUsaha")
Observable<List<JenisUsaha>> getJenisUsaha();
@GET("/svc_api.php?type=getKategori")
Observable<List<Category>> getCategory();
@GET("/svc_api.php?type=getKategori")
Observable<List<Category>>
getCategory(@Query("id_jenis_usaha") String idJenisUsaha);
@GET("/svc_api.php?type=getBengkel")
Observable<List<Bengkel>>
getBengkel(@Query("id_jenis_usaha") String idUsaha,
@Query("id_area") String idArea,
@Query("id_user") String idUser,
@Query("id_kategori") String idKategori);
@GET("/svc_api.php?type=getBengkel")
Observable<List<Bengkel>>
getAllBengkel(@Query("id_user") String idUser);
@GET("/svc_api.php?type=searchBengkelNear")
Observable<List<Bengkel>>
getNearbyBengkel(@Query(value = "lat", encodeValue = false) String lat,
@Query(value = "lng", encodeValue = false) String lng,
@Query(value = "id_jenis_usaha") String idUsaha,
@Query(value = "id_kategori") String idcategory,
@Query("id_user") String idUser);
@GET("/svc_api.php?type=getTop10Bengkel")
Observable<List<Bengkel>>
getTopTenBengkel(@Query("id_user") String idUser,
@Query(value = "lat", encodeValue = false) String lat,
@Query(value = "lng", encodeValue = false) String lng,
@Query("id_kategori") String idCategory);
@Multipart
@POST("/svc_api.php?type=rateBengkel")
Observable<BaseResponse>
rateBengkel(@Part("id_bengkel") String idBengkel,
@Part("id_user") String idUser,
@Part("rate_review") String rateReview,
@Part("comment") String comment);
@Multipart
@POST("/svc_api.php?type=bookmarkBengkel")
Observable<BaseResponse>
bookmarkBengkel(@Part("id_user") String idUser,
@Part("id_bengkel") String idBengkel,
@Part("deskripsi") String description);
@Multipart
@POST("/svc_api.php?type=unbookmarkBengkel")
Observable<BaseResponse>
unbookmarkBengkel(@Part("id_user") String idUser,
@Part("id_bengkel") String idBengkel);
// id_user, nama_bengkel, nama_pemilik,email, telp, alamat, lat, lng,
// jenis_usaha(ID), kategori(ID), image_file, website, keterangan, password
@Multipart
@POST("/svc_api.php")
Observable<EditResponse>
registerBengkel(@Part("type") String type,
@Part("id_bengkel") String idBengkel,
@Part("id_user") String idUser,
@Part("nama_bengkel") String bengkelName,
@Part("nama_pemilik") String ownerName,
@Part("email") String email,
@Part("telp") String telp,
@Part("alamat") String alamat,
@Part("lat") String lat,
@Part("lng") String lng,
@Part("jenis_usaha") String jenisUsaha,
@Part("kategori") String category,
@Part("image_file") String imageFile,
@Part("website") String website,
@Part("keterangan") String description,
@Part("password") String password,
@Part("hari_buka") String hariBuka,
@Part("jam_buka") String jamBuka,
@Part("jam_tutup") String jamTututp);
@Multipart
@POST("/svc_api.php?type=userCheckin")
Observable<BaseResponse>
checkInBengkel(@Part("id_user") String idUser,
@Part("id_bengkel") String idBengkel);
@GET("/svc_api.php?type=searchBengkel")
Observable<List<Bengkel>> searchBengkel(@Query("id_user") String idUser,
@Query("search") String query);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.