-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first commit after about 2 mounth. Today I create Api ServiceGenerato…
…r and RentalHouseApi classes.
- Loading branch information
1 parent
a5843ba
commit a5e63da
Showing
20 changed files
with
250 additions
and
37 deletions.
There are no files selected for viewing
Binary file not shown.
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
7 changes: 7 additions & 0 deletions
7
app/src/main/java/mohamadamin/soft/com/rentalhouseproject/Models/ActiveUserModel.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package mohamadamin.soft.com.rentalhouseproject.Models; | ||
|
||
public class ActiveUserModel | ||
{ | ||
public String UserMobileNumber; | ||
public String UserActiveCode; | ||
} |
13 changes: 13 additions & 0 deletions
13
app/src/main/java/mohamadamin/soft/com/rentalhouseproject/Models/FilterModel.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package mohamadamin.soft.com.rentalhouseproject.Models; | ||
|
||
public class FilterModel | ||
{ | ||
public String Zone; | ||
public int FromMortgage; | ||
public int ToMortgage; | ||
public int FromRent; | ||
public int ToRent; | ||
public int Type; | ||
public int Gender; | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
app/src/main/java/mohamadamin/soft/com/rentalhouseproject/Models/LoginUserModel.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package mohamadamin.soft.com.rentalhouseproject.Models; | ||
|
||
public class LoginUserModel | ||
{ | ||
public String UserMobileNumber; | ||
public String UserPassword; | ||
} |
18 changes: 18 additions & 0 deletions
18
app/src/main/java/mohamadamin/soft/com/rentalhouseproject/Models/RegisterUserModel.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package mohamadamin.soft.com.rentalhouseproject.Models; | ||
|
||
public class RegisterUserModel | ||
{ | ||
public static final int UserSignedUp = 3; | ||
public static final int UserActivated = 2; | ||
public static final int UserNotActivated = 1; | ||
public static final int UserExist = 0; | ||
public static final int UserNotExist = -1; | ||
|
||
public String UserFirstName; | ||
public String UserLastName; | ||
public int UserStateCode; | ||
public int UserCityCode ; | ||
public int UserRole; | ||
public String UserMobileNumber; | ||
public String UserPassword; | ||
} |
23 changes: 23 additions & 0 deletions
23
app/src/main/java/mohamadamin/soft/com/rentalhouseproject/Models/Slide.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package mohamadamin.soft.com.rentalhouseproject.Models; | ||
|
||
public class Slide { | ||
|
||
private String SliderTitle; | ||
private String SliderImage; | ||
|
||
public String getSliderTitle() { | ||
return SliderTitle; | ||
} | ||
|
||
public String getSliderImage() { | ||
return SliderImage; | ||
} | ||
|
||
public void setSliderTitle(String sliderTitle) { | ||
SliderTitle = sliderTitle; | ||
} | ||
|
||
public void setSliderImage(String sliderImage) { | ||
SliderImage = sliderImage; | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
app/src/main/java/mohamadamin/soft/com/rentalhouseproject/ServerApi/ApiServiceGenerator.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package mohamadamin.soft.com.rentalhouseproject.ServerApi; | ||
|
||
import com.google.gson.Gson; | ||
import com.google.gson.GsonBuilder; | ||
|
||
import java.io.IOException; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import okhttp3.Interceptor; | ||
import okhttp3.OkHttpClient; | ||
import okhttp3.Request; | ||
import okhttp3.Response; | ||
import retrofit2.Retrofit; | ||
import retrofit2.converter.gson.GsonConverterFactory; | ||
|
||
public class ApiServiceGenerator { | ||
|
||
private static Retrofit RetrofitInstance; | ||
private static Gson GsonInstance; | ||
private static OkHttpClient Client; | ||
private static OkHttpClient.Builder HttpClient; | ||
private final static String BASE_URL = "http://rentalhouse.aryasoft.org/"; | ||
|
||
public static RentalHouseApi getApiService() | ||
{ | ||
initializeComponents(); | ||
return RetrofitInstance.create(RentalHouseApi.class); | ||
} | ||
|
||
private static void initializeComponents() | ||
{ | ||
if(HttpClient == null) | ||
{ | ||
initializeHttpClient(); | ||
} | ||
if (Client == null) | ||
{ | ||
Client = HttpClient.build(); | ||
} | ||
if (GsonInstance == null) | ||
{ | ||
GsonInstance = new GsonBuilder().setLenient().serializeNulls().create(); | ||
} | ||
if (RetrofitInstance == null) | ||
{ | ||
initializeRetrofit(); | ||
} | ||
} | ||
|
||
private static void initializeHttpClient() | ||
{ | ||
HttpClient = new OkHttpClient.Builder() | ||
.retryOnConnectionFailure(true) | ||
.connectTimeout(60, TimeUnit.SECONDS) | ||
.writeTimeout(60, TimeUnit.SECONDS) | ||
.readTimeout(60, TimeUnit.SECONDS); | ||
} | ||
|
||
private static void initializeRetrofit() | ||
{ | ||
RetrofitInstance = new Retrofit.Builder() | ||
.baseUrl(BASE_URL) | ||
.client(Client) | ||
.addConverterFactory(GsonConverterFactory.create(GsonInstance)) | ||
.build(); | ||
} | ||
|
||
|
||
} |
68 changes: 68 additions & 0 deletions
68
app/src/main/java/mohamadamin/soft/com/rentalhouseproject/ServerApi/RentalHouseApi.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package mohamadamin.soft.com.rentalhouseproject.ServerApi; | ||
|
||
import java.util.List; | ||
|
||
import mohamadamin.soft.com.rentalhouseproject.Models.ActiveUserModel; | ||
import mohamadamin.soft.com.rentalhouseproject.Models.FilterModel; | ||
import mohamadamin.soft.com.rentalhouseproject.Models.House; | ||
import mohamadamin.soft.com.rentalhouseproject.Models.LoginUserModel; | ||
import mohamadamin.soft.com.rentalhouseproject.Models.RegisterUserModel; | ||
import mohamadamin.soft.com.rentalhouseproject.Models.SecondaryHouse; | ||
import mohamadamin.soft.com.rentalhouseproject.Models.Slide; | ||
import mohamadamin.soft.com.rentalhouseproject.Models.SliderModel; | ||
import retrofit2.Call; | ||
import retrofit2.http.Body; | ||
import retrofit2.http.GET; | ||
import retrofit2.http.Headers; | ||
import retrofit2.http.POST; | ||
import retrofit2.http.Query; | ||
|
||
public interface RentalHouseApi { | ||
|
||
@Headers("User-Agent: <RentalHouse>") | ||
@GET("Api/HouseApi/GetHouseSliders") | ||
Call<List<Slide>> getSlides(); | ||
|
||
@Headers("User-Agent: <RentalHouse>") | ||
@POST("Api/HouseApi/SearchHouse") | ||
Call<List<Slide>> searchHouse(String searchTerm, int skipItem, int takeItem);/*???*/ | ||
|
||
@Headers("User-Agent: <RentalHouse>") | ||
@GET("Api/HouseApi/GetHouseDetails") | ||
Call<List<House>> getHouseDetails(@Query("houseId")int houseId);/*3???*/ | ||
|
||
@Headers("User-Agent: <RentalHouse>") | ||
@GET("Api/HouseApi/GetAllHouses") | ||
Call<List<SecondaryHouse>> getAllHouses(@Query("houseId")int skipNumber, @Query("houseId")int takeNumber); | ||
|
||
@Headers("User-Agent: <RentalHouse>") | ||
@GET("Api/HouseApi/GetHousesWithFilter") | ||
Call<List<SecondaryHouse>> getHousesWithFilter(FilterModel filter, int skipNumber, int takeNumber);/*???*/ | ||
|
||
@Headers("User-Agent: <RentalHouse>") | ||
@POST("Api/RegisterationApi/RegisterUser") | ||
Call<Integer> signUp(@Body RegisterUserModel registerUserModel);/*???*/ | ||
/*Conditions: | ||
If Success=> return ActiveCode and SMS ActiveCode; | ||
ELSE => RegisterUserState(ENUM)*/ | ||
|
||
@Headers("User-Agent: <RentalHouse>") | ||
@POST("Api/RegisterationApi/LoginUser") | ||
Call<Integer> signIn(@Body LoginUserModel loginUserObject); | ||
/*IF UserExistAnd Active THEN | ||
IF USERNAME AND PASSWORD ARE CORRECT THEN | ||
return user.UserId; | ||
ELSE | ||
return 0;//password incorrect | ||
ELSE => RegisterUserState(ENUM)*/ | ||
|
||
@Headers("User-Agent: <RentalHouse>") | ||
@POST("Api/RegisterationApi/ActiveUser") | ||
Call<Boolean> activeUser(@Body ActiveUserModel activeUserObject); | ||
|
||
@Headers("User-Agent: <RentalHouse>") | ||
@POST("Api/RegisterationApi/GenerateActiveCode") | ||
Call<Integer> generateActivationCode(@Query("") String userMobileNumber); | ||
/*CONDITION->LIKE ARACHOOB*/ | ||
|
||
} |
This file contains 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
Oops, something went wrong.