Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: sharing account #771

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions mifosng-android/src/main/java/com/mifos/api/BaseApiManager.java
Expand Up @@ -5,6 +5,8 @@


package com.mifos.api; package com.mifos.api;


import android.support.annotation.NonNull;

import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import com.mifos.api.services.AuthService; import com.mifos.api.services.AuthService;
Expand All @@ -22,6 +24,7 @@
import com.mifos.api.services.RunReportsService; import com.mifos.api.services.RunReportsService;
import com.mifos.api.services.SavingsAccountService; import com.mifos.api.services.SavingsAccountService;
import com.mifos.api.services.SearchService; import com.mifos.api.services.SearchService;
import com.mifos.api.services.SharingService;
import com.mifos.api.services.StaffService; import com.mifos.api.services.StaffService;
import com.mifos.api.services.SurveyService; import com.mifos.api.services.SurveyService;
import com.mifos.utils.JsonDateSerializer; import com.mifos.utils.JsonDateSerializer;
Expand All @@ -48,6 +51,7 @@ public class BaseApiManager {
private static DataTableService dataTableApi; private static DataTableService dataTableApi;
private static LoanService loanApi; private static LoanService loanApi;
private static SavingsAccountService savingsApi; private static SavingsAccountService savingsApi;
private static SharingService sharingApi;
private static ChargeService chargeApi; private static ChargeService chargeApi;
private static SearchService searchApi; private static SearchService searchApi;
private static GroupService groupApi; private static GroupService groupApi;
Expand All @@ -71,6 +75,7 @@ public static void init() {
dataTableApi = createApi(DataTableService.class); dataTableApi = createApi(DataTableService.class);
loanApi = createApi(LoanService.class); loanApi = createApi(LoanService.class);
savingsApi = createApi(SavingsAccountService.class); savingsApi = createApi(SavingsAccountService.class);
sharingApi = createApi(SharingService.class);
searchApi = createApi(SearchService.class); searchApi = createApi(SearchService.class);
groupApi = createApi(GroupService.class); groupApi = createApi(GroupService.class);
documentApi = createApi(DocumentService.class); documentApi = createApi(DocumentService.class);
Expand Down Expand Up @@ -130,6 +135,11 @@ public SavingsAccountService getSavingsApi() {
return savingsApi; return savingsApi;
} }


@NonNull
public SharingService getSharingApi() {
return sharingApi;
}

public SearchService getSearchApi() { public SearchService getSearchApi() {
return searchApi; return searchApi;
} }
Expand Down
@@ -0,0 +1,69 @@
package com.mifos.api.datamanager;

import android.support.annotation.NonNull;

import com.mifos.api.BaseApiManager;
import com.mifos.objects.response.ShareResponse;
import com.mifos.objects.templates.sharing.SharingProductTemplate;
import com.mifos.objects.templates.sharing.SharingAccountsTemplate;
import com.mifos.services.data.SharingPayload;

import javax.inject.Inject;

import rx.Observable;

/**
* Created by mayankjindal on 18/08/17.
*/
/**
* This DataManager is for Managing Client's Share Account, In which Request is going to Server
* and In Response, We are getting Client's Share Account Observable Response using Retrofit2 .
*/
public class DataManagerSharing {

public final BaseApiManager baseApiManager;

@Inject
public DataManagerSharing(@NonNull BaseApiManager baseApiManager) {
this.baseApiManager = baseApiManager;
}

/**
* This Method to request the SharingAccountsTemplate according to Client Id and Product Id
* and get SharingAccountsTemplate in Response. Request goes to the Server End Point directly.
* Here is End Point :
* {https://demo.openmf.org/fineract-provider/api/v1/accounts/share/template?clientId=1&productId=1}
* @param clientId productId
* @return SharingAccountsTemplate
*/
@NonNull
public Observable<SharingAccountsTemplate> getClientSharingAccountTemplateByProduct(
int clientId, int productId) {
return baseApiManager.getSharingApi().
getClientSharingAccountTemplateByProduct(clientId, productId);
}

/**
* This Method to request the SharingProductTemplate according to Client Id
* and get SharingProductTemplate in Response. Request goes to the Server End Point directly.
* Here is End Point :
* {https://demo.openmf.org/fineract-provider/api/v1/accounts/share/template?clientId=1}
* @param clientId productId
* @return SharingAccountsTemplate
*/
@NonNull
public Observable<SharingProductTemplate> getSharingAccountTemplate(int clientId) {
return baseApiManager.getSharingApi().getSharingAccountTemplate(clientId);
}

/**
* This Method create the Sharing account by making directly request to server
* and give response
* @param sharingPayload Share Account details filled by user
* @return ShareResponse
*/
@NonNull
public Observable<ShareResponse> createSharingAccount(@NonNull SharingPayload sharingPayload) {
return baseApiManager.getSharingApi().createSharingAccount(sharingPayload);
}
}
Expand Up @@ -19,20 +19,21 @@ public class APIEndPoint {
public static final String LOANS = "loans"; public static final String LOANS = "loans";
public static final String SURVEYS = "surveys"; public static final String SURVEYS = "surveys";
public static final String SEARCH = "search"; public static final String SEARCH = "search";
public static final String CREATESAVINGSACCOUNTS = "savingsaccounts"; public static final String CREATE_SAVINGS_ACCOUNTS = "savingsaccounts";
public static final String CREATESAVINGSPRODUCTS = "savingsproducts"; public static final String CREATE_SAVINGS_PRODUCTS = "savingsproducts";
public static final String CREATELOANSACCOUNTS = "loans"; public static final String CREATE_SHARING_ACCOUNTS = "accounts/share";
public static final String CREATELOANSPRODUCTS = "loanproducts"; public static final String CREATE_LOANS_ACCOUNTS = "loans";
public static final String CREATE_LOANS_PRODUCTS = "loanproducts";
public static final String DATATABLES = "datatables"; public static final String DATATABLES = "datatables";
public static final String GROUPS = "groups"; public static final String GROUPS = "groups";
public static final String DOCUMENTS = "documents"; public static final String DOCUMENTS = "documents";
public static final String IDENTIFIERS = "identifiers"; public static final String IDENTIFIERS = "identifiers";
public static final String OFFICES = "offices"; public static final String OFFICES = "offices";
public static final String STAFF = "staff"; public static final String STAFF = "staff";
public static final String RUNREPORTS = "runreports"; public static final String RUN_REPORTS = "runreports";
public static final String COLLECTIONSHEET = "collectionsheet"; public static final String COLLECTION_SHEET = "collectionsheet";


public static final String SAVINGSACCOUNTS = "savingsaccounts"; public static final String SAVINGS_ACCOUNTS = "savingsaccounts";
public static final String RECURRING_ACCOUNTS = "recurringdepositaccounts"; public static final String RECURRING_ACCOUNTS = "recurringdepositaccounts";


public static final String DISBURSE = "disburse"; public static final String DISBURSE = "disburse";
Expand Down
Expand Up @@ -28,11 +28,11 @@
public interface CollectionSheetService { public interface CollectionSheetService {




@POST(APIEndPoint.COLLECTIONSHEET + "?command=generateCollectionSheet") @POST(APIEndPoint.COLLECTION_SHEET + "?command=generateCollectionSheet")
Observable<IndividualCollectionSheet> getIndividualCollectionSheet( Observable<IndividualCollectionSheet> getIndividualCollectionSheet(
@Body RequestCollectionSheetPayload payload); @Body RequestCollectionSheetPayload payload);


@POST(APIEndPoint.COLLECTIONSHEET + "?command=saveCollectionSheet") @POST(APIEndPoint.COLLECTION_SHEET + "?command=saveCollectionSheet")
Observable<GenericResponse> saveindividualCollectionSheet( Observable<GenericResponse> saveindividualCollectionSheet(
@Body IndividualCollectionSheetPayload payload); @Body IndividualCollectionSheetPayload payload);


Expand Down
Expand Up @@ -66,15 +66,15 @@ Observable<LoanRepaymentResponse> submitPayment(
@GET(APIEndPoint.LOANS + "/{loanId}?associations=transactions") @GET(APIEndPoint.LOANS + "/{loanId}?associations=transactions")
Observable<LoanWithAssociations> getLoanWithTransactions(@Path("loanId") int loanId); Observable<LoanWithAssociations> getLoanWithTransactions(@Path("loanId") int loanId);


@GET(APIEndPoint.CREATELOANSPRODUCTS) @GET(APIEndPoint.CREATE_LOANS_PRODUCTS)
Observable<List<LoanProducts>> getAllLoans(); Observable<List<LoanProducts>> getAllLoans();




@POST(APIEndPoint.CREATELOANSACCOUNTS) @POST(APIEndPoint.CREATE_LOANS_ACCOUNTS)
Observable<Loans> createLoansAccount(@Body LoansPayload loansPayload); Observable<Loans> createLoansAccount(@Body LoansPayload loansPayload);




@GET(APIEndPoint.CREATELOANSACCOUNTS + "/template?templateType=individual") @GET(APIEndPoint.CREATE_LOANS_ACCOUNTS + "/template?templateType=individual")
Observable<LoanTemplate> getLoansAccountTemplate(@Query("clientId") int clientId, Observable<LoanTemplate> getLoansAccountTemplate(@Query("clientId") int clientId,
@Query("productId") int productId); @Query("productId") int productId);


Expand All @@ -98,10 +98,10 @@ Observable<LoanTransactionTemplate> getLoanTransactionTemplate(
@Query("command") String command); @Query("command") String command);




@POST(APIEndPoint.CREATELOANSACCOUNTS) @POST(APIEndPoint.CREATE_LOANS_ACCOUNTS)
Observable<Loans> createGroupLoansAccount(@Body GroupLoanPayload loansPayload); Observable<Loans> createGroupLoansAccount(@Body GroupLoanPayload loansPayload);


@GET(APIEndPoint.CREATELOANSACCOUNTS + "/template?templateType=group") @GET(APIEndPoint.CREATE_LOANS_ACCOUNTS + "/template?templateType=group")
Observable<GroupLoanTemplate> getGroupLoansAccountTemplate(@Query("groupId") int groupId, Observable<GroupLoanTemplate> getGroupLoansAccountTemplate(@Query("groupId") int groupId,
@Query("productId") int productId); @Query("productId") int productId);


Expand Down
Expand Up @@ -14,7 +14,7 @@
*/ */
public interface RunReportsService { public interface RunReportsService {


@GET(APIEndPoint.RUNREPORTS + "/GroupSummaryCounts") @GET(APIEndPoint.RUN_REPORTS + "/GroupSummaryCounts")
Observable<List<CenterInfo>> getCenterSummaryInfo( Observable<List<CenterInfo>> getCenterSummaryInfo(
@Query("R_groupId") int centerId, @Query("R_groupId") int centerId,
@Query("genericResultSet") boolean genericResultSet); @Query("genericResultSet") boolean genericResultSet);
Expand Down
Expand Up @@ -89,31 +89,31 @@ Observable<SavingsAccountTransactionResponse> processTransaction(
@Body SavingsAccountTransactionRequest savingsAccountTransactionRequest); @Body SavingsAccountTransactionRequest savingsAccountTransactionRequest);




@POST(APIEndPoint.CREATESAVINGSACCOUNTS + "/{savingsAccountId}/?command=activate") @POST(APIEndPoint.CREATE_SAVINGS_ACCOUNTS + "/{savingsAccountId}/?command=activate")
Observable<GenericResponse> activateSavings(@Path("savingsAccountId") int savingsAccountId, Observable<GenericResponse> activateSavings(@Path("savingsAccountId") int savingsAccountId,
@Body HashMap<String, Object> genericRequest); @Body HashMap<String, Object> genericRequest);


@POST(APIEndPoint.CREATESAVINGSACCOUNTS + "/{savingsAccountId}?command=approve") @POST(APIEndPoint.CREATE_SAVINGS_ACCOUNTS + "/{savingsAccountId}?command=approve")
Observable<GenericResponse> approveSavingsApplication( Observable<GenericResponse> approveSavingsApplication(
@Path("savingsAccountId") int savingsAccountId, @Path("savingsAccountId") int savingsAccountId,
@Body SavingsApproval savingsApproval); @Body SavingsApproval savingsApproval);




@GET(APIEndPoint.CREATESAVINGSPRODUCTS) @GET(APIEndPoint.CREATE_SAVINGS_PRODUCTS)
Observable<List<ProductSavings>> getAllSavingsAccounts(); Observable<List<ProductSavings>> getAllSavingsAccounts();


@POST(APIEndPoint.CREATESAVINGSACCOUNTS) @POST(APIEndPoint.CREATE_SAVINGS_ACCOUNTS)
Observable<Savings> createSavingsAccount(@Body SavingsPayload savingsPayload); Observable<Savings> createSavingsAccount(@Body SavingsPayload savingsPayload);


@GET(APIEndPoint.CREATESAVINGSPRODUCTS + "/template") @GET(APIEndPoint.CREATE_SAVINGS_PRODUCTS + "/template")
Observable<SavingProductsTemplate> getSavingsAccountTemplate(); Observable<SavingProductsTemplate> getSavingsAccountTemplate();


@GET(APIEndPoint.CREATESAVINGSACCOUNTS + "/template") @GET(APIEndPoint.CREATE_SAVINGS_ACCOUNTS + "/template")
Observable<SavingProductsTemplate> Observable<SavingProductsTemplate>
getClientSavingsAccountTemplateByProduct(@Query("clientId") int clientId, getClientSavingsAccountTemplateByProduct(@Query("clientId") int clientId,
@Query("productId") int productId); @Query("productId") int productId);


@GET(APIEndPoint.CREATESAVINGSACCOUNTS + "/template") @GET(APIEndPoint.CREATE_SAVINGS_ACCOUNTS + "/template")
Observable<SavingProductsTemplate> Observable<SavingProductsTemplate>
getGroupSavingsAccountTemplateByProduct(@Query("groupId") int groupId, getGroupSavingsAccountTemplateByProduct(@Query("groupId") int groupId,
@Query("productId") int productId); @Query("productId") int productId);
Expand Down
@@ -0,0 +1,61 @@
package com.mifos.api.services;

import android.support.annotation.NonNull;

import com.mifos.api.model.APIEndPoint;
import com.mifos.objects.response.ShareResponse;
import com.mifos.objects.templates.sharing.SharingProductTemplate;
import com.mifos.objects.templates.sharing.SharingAccountsTemplate;
import com.mifos.services.data.SharingPayload;
import com.mifos.utils.Constants;

import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Query;
import rx.Observable;

/**
* Created by mayankjindal on 18/08/17.
*/

public interface SharingService {

/**
* This Service is for fetching the SharingProductTemplate.
* REST END POINT:
* https://demo.openmf.org/fineract-provider/api/v1/accounts/share/template?clientId={clientId}
*
* @param clientId Client Id
* @return SharingProductTemplate
*/
@NonNull
@GET(APIEndPoint.CREATE_SHARING_ACCOUNTS + "/template")
Observable<SharingProductTemplate> getSharingAccountTemplate(@Query(Constants.CLIENT_ID)
int clientId);

/**
* This Service is for fetching the SharingAccountsTemplate.
* REST END POINT:
* https://demo.openmf.org/fineract-provider/api/v1/accounts/share/template?clientId={clientId}&productId={productId}
*
* @param clientId Client Id
* @return SharingProductTemplate
*/
@NonNull
@GET(APIEndPoint.CREATE_SHARING_ACCOUNTS + "/template")
Observable<SharingAccountsTemplate> getClientSharingAccountTemplateByProduct(
@Query(Constants.CLIENT_ID) int clientId, @Query(Constants.PRODUCT_ID) int productId);

/**
* This Service is for creating the SharingAccount.
* REST END POINT:
* https://demo.openmf.org/fineract-provider/api/v1/accounts/share
*
* @param sharingPayload SharingPayload
* @return ShareResponse
*/
@NonNull
@POST(APIEndPoint.CREATE_SHARING_ACCOUNTS)
Observable<ShareResponse> createSharingAccount(@Body SharingPayload sharingPayload);
}