From 8817e7fa8144603b0234b63ca0612683185937fc Mon Sep 17 00:00:00 2001 From: Sanyam Goel Date: Sun, 18 Mar 2018 01:43:21 +0530 Subject: [PATCH] Gci swagger integration (#33) * Swagger Documentation of StandingInstructionApiResource.java * Swagger Documentation of StandingInstructionHistoryApiResource.java * Swagger Documentation for ChargesApiResource.java * Swagger Documentation of EntityFieldConfigurationApiResources.java and LoanChargesApiResource.java * Swagger Documentation for CollateralsApiResource.java and InterestRateChartsApiResource.java (#5) * Swagger Documentation for InterestRateChartSlabsApiResource.java (#8) * Swagger Documentation for FundsApiResource.java (#9) * Swagger Documentation for LoansApiResource.java (#10) * Swagger Documentation for TaxGroupApiResource.java (#12) * Swagger Documentation for FixedDepositAccountsApiResource.java (#13) * Swagger Documentation for FixedDepositAccountsApiResource.java * Added Example Request in GET Endpoint {accountId} Added Example Request in GET Endpoint in "fixeddepositaccounts/{accountId}" * Swagger Documentation for AccountTransfersApiResource.java (#14) * Swagger Documentation for CollectionSheetApiResource.java and FloatingRatesApiResource.java (#15) * Swagger Documentation for CentersApiResource.java (#16) * Swagger documentation for GroupsApiResource.java (#11) * Swagger Documentation for SelfBeneficiariesTPTApiResource.java and SelfAuthenticationApiResource.java (#21) * Swagger Documentation for SelfClientsApiResource.java (#20) * Swagger Documentation for AccountsApiResource.java (#19) * Swagger Documentation for SelfUserApiResource.java, TaxComponentApiResource.java & SelfUserDetailsApiResource.java (#18) * Swagger Documentation for FixedDepositProductsApiResource.java (#22) * Swagger Documentation for SelfSavingsApiResource.java (#23) * Swagger Documentation for RecurringDepositAccountsApiResource.java (#24) * Swagger Documentation for SelfLoansApiResource.java (#17) * Swagger Documentation for SelfLoansApiResource.java * Added documentation for POST endpoint * Swagger Documentation for SavingsAccountsApiResource.java (#26) * Swagger Documentation for RecurringDepositAccountTransactionsApiResource.java (#29) * Swagger Documentation for LoanProductsApiResource.java and NotesApiResource,java (#25) * Swagger Documentation for RecurringDepositProductsApiResource.java & SavingAccountChargesApiResource.java (#27) * Swagger Documenatation for LoanScheduleApiResource.java & LoanTransactionsApiResource.java (#28) * Swagger Documentation for PaymentTypeApiResource.java and ProductsApiResource.java (#31) * Swagger Documentation for SavingsProductsApiResource.java (#30) * Swagger Documentation for Clients API (#32) * Swagger Documentation for Clients API * Changed the file name * Fixed minor bugs/errors * Requested Changes * Some more changes --- .../api/AccountTransfersApiResource.java | 64 +- .../AccountTransfersApiResourceSwagger.java | 572 +++++++++ .../api/StandingInstructionApiResource.java | 110 +- ...StandingInstructionApiResourceSwagger.java | 549 ++++++++ ...StandingInstructionHistoryApiResource.java | 37 +- ...gInstructionHistoryApiResourceSwagger.java | 123 ++ .../accounts/api/AccountsApiResource.java | 52 +- .../api/AccountsApiResourceSwagger.java | 529 ++++++++ .../EntityFieldConfigurationApiResources.java | 34 +- ...FieldConfigurationApiResourcesSwagger.java | 52 + .../charge/api/ChargesApiResource.java | 50 +- .../charge/api/ChargesApiResourceSwagger.java | 230 ++++ .../client/api/ClientAddressApiResources.java | 49 +- .../api/ClientAddressApiResourcesSwagger.java | 127 ++ .../client/api/ClientChargesApiResource.java | 59 +- .../api/ClientChargesApiResourceSwagger.java | 196 +++ .../api/ClientIdentifiersApiResource.java | 65 +- .../ClientIdentifiersApiResourceSwagger.java | 144 +++ .../api/ClientTransactionsApiResource.java | 41 +- .../ClientTransactionsApiResourceSwagger.java | 133 ++ .../client/api/ClientsApiResource.java | 100 +- .../client/api/ClientsApiResourceSwagger.java | 464 +++++++ .../api/CollateralsApiResource.java | 54 +- .../api/CollateralsApiResourceSwagger.java | 147 +++ .../CollectionSheetApiResourceSwagger.java | 90 ++ .../api/CollectionSheetApiResourse.java | 24 +- .../api/FloatingRatesApiResource.java | 45 +- .../api/FloatingRatesApiResourceSwagger.java | 171 +++ .../portfolio/fund/api/FundsApiResource.java | 43 +- .../fund/api/FundsApiResourceSwagger.java | 78 ++ .../group/api/CentersApiResource.java | 82 +- .../group/api/CentersApiResourceSwagger.java | 343 +++++ .../group/api/GroupsApiResource.java | 93 +- .../group/api/GroupsApiResourceSwagger.java | 529 ++++++++ .../InterestRateChartSlabsApiResource.java | 67 +- ...erestRateChartSlabsApiResourceSwagger.java | 195 +++ .../api/InterestRateChartsApiResource.java | 65 +- .../InterestRateChartsApiResourceSwagger.java | 157 +++ .../api/LoanChargesApiResource.java | 92 +- .../api/LoanChargesApiResourceSwagger.java | 277 ++++ .../api/LoanScheduleApiResource.java | 27 +- .../api/LoanScheduleApiResourceSwagger.java | 56 + .../api/LoanTransactionsApiResource.java | 53 +- .../LoanTransactionsApiResourceSwagger.java | 191 +++ .../loanaccount/api/LoansApiResource.java | 93 +- .../api/LoansApiResourceSwagger.java | 692 ++++++++++ .../api/LoanProductsApiResource.java | 47 +- .../api/LoanProductsApiResourceSwagger.java | 1109 +++++++++++++++++ .../portfolio/note/api/NotesApiResource.java | 60 +- .../note/api/NotesApiResourceSwagger.java | 157 +++ .../api/PaymentTypeApiResource.java | 42 +- .../api/PaymentTypeApiResourceSwagger.java | 121 ++ .../products/api/ProductsApiResource.java | 45 +- .../api/ProductsApiResourceSwagger.java | 597 +++++++++ .../api/FixedDepositAccountsApiResource.java | 84 +- ...ixedDepositAccountsApiResourceSwagger.java | 523 ++++++++ .../api/FixedDepositProductsApiResource.java | 55 +- ...ixedDepositProductsApiResourceSwagger.java | 583 +++++++++ ...DepositAccountTransactionsApiResource.java | 56 +- ...AccountTransactionsApiResourceSwagger.java | 279 +++++ .../RecurringDepositAccountsApiResource.java | 80 +- ...ringDepositAccountsApiResourceSwagger.java | 516 ++++++++ .../RecurringDepositProductsApiResource.java | 55 +- ...ringDepositProductsApiResourceSwagger.java | 612 +++++++++ .../api/SavingsAccountChargesApiResource.java | 76 +- ...vingsAccountChargesApiResourceSwagger.java | 323 +++++ .../api/SavingsAccountsApiResource.java | 81 +- .../SavingsAccountsApiResourceSwagger.java | 359 ++++++ .../api/SavingsProductsApiResource.java | 56 +- .../SavingsProductsApiResourceSwagger.java | 737 +++++++++++ .../api/SelfBeneficiariesTPTApiResource.java | 48 +- ...elfBeneficiariesTPTApiResourceSwagger.java | 141 +++ .../client/api/SelfClientsApiResource.java | 86 +- .../api/SelfClientsApiResourceSwagger.java | 439 +++++++ .../loanaccount/api/SelfLoansApiResource.java | 71 +- .../api/SelfLoansApiResourceSwagger.java | 845 +++++++++++++ .../savings/api/SelfSavingsApiResource.java | 42 +- .../api/SelfSavingsApiResourceSwagger.java | 358 ++++++ .../api/SelfAuthenticationApiResource.java | 20 +- .../SelfAuthenticationApiResourceSwagger.java | 88 ++ .../security/api/SelfUserApiResource.java | 25 +- .../api/SelfUserApiResourceSwagger.java | 62 + .../api/SelfUserDetailsApiResource.java | 18 +- .../SelfUserDetailsApiResourceSwagger.java | 88 ++ .../tax/api/TaxComponentApiResource.java | 37 +- .../api/TaxComponentApiResourceSwagger.java | 149 +++ .../tax/api/TaxGroupApiResource.java | 37 +- .../tax/api/TaxGroupApiResourceSwagger.java | 157 +++ 88 files changed, 15616 insertions(+), 1192 deletions(-) create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/account/api/AccountTransfersApiResourceSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/account/api/StandingInstructionApiResourceSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/account/api/StandingInstructionHistoryApiResourceSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/api/AccountsApiResourceSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/address/api/EntityFieldConfigurationApiResourcesSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/charge/api/ChargesApiResourceSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientAddressApiResourcesSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientChargesApiResourceSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientIdentifiersApiResourceSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientTransactionsApiResourceSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientsApiResourceSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/collateral/api/CollateralsApiResourceSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/collectionsheet/api/CollectionSheetApiResourceSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/floatingrates/api/FloatingRatesApiResourceSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/fund/api/FundsApiResourceSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/group/api/CentersApiResourceSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/group/api/GroupsApiResourceSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/api/InterestRateChartSlabsApiResourceSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/api/InterestRateChartsApiResourceSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoanChargesApiResourceSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoanScheduleApiResourceSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoanTransactionsApiResourceSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoansApiResourceSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/api/LoanProductsApiResourceSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/note/api/NotesApiResourceSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/paymenttype/api/PaymentTypeApiResourceSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/products/api/ProductsApiResourceSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/FixedDepositAccountsApiResourceSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/FixedDepositProductsApiResourceSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/RecurringDepositAccountTransactionsApiResourceSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/RecurringDepositAccountsApiResourceSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/RecurringDepositProductsApiResourceSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsAccountChargesApiResourceSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsAccountsApiResourceSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsProductsApiResourceSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/self/account/api/SelfBeneficiariesTPTApiResourceSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/self/client/api/SelfClientsApiResourceSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/self/loanaccount/api/SelfLoansApiResourceSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/self/savings/api/SelfSavingsApiResourceSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/self/security/api/SelfAuthenticationApiResourceSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/self/security/api/SelfUserApiResourceSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/self/security/api/SelfUserDetailsApiResourceSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/tax/api/TaxComponentApiResourceSwagger.java create mode 100644 fineract-provider/src/main/java/org/apache/fineract/portfolio/tax/api/TaxGroupApiResourceSwagger.java diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/api/AccountTransfersApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/api/AccountTransfersApiResource.java index 84fa436bc..12556664b 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/api/AccountTransfersApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/api/AccountTransfersApiResource.java @@ -18,17 +18,7 @@ */ package org.apache.fineract.portfolio.account.api; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriInfo; - +import io.swagger.annotations.*; import org.apache.fineract.commands.domain.CommandWrapper; import org.apache.fineract.commands.service.CommandWrapperBuilder; import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService; @@ -45,9 +35,15 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; + @Path("/accounttransfers") @Component @Scope("singleton") +@Api(value = "Account Transfers", description = "Ability to be able to transfer monetary funds from one account to another.\n\n" + "\n\n" + "Note: At present only savings account to savings account transfers are supported.") public class AccountTransfersApiResource { private final PlatformSecurityContext context; @@ -73,11 +69,13 @@ public class AccountTransfersApiResource { @Path("template") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String template(@QueryParam("fromOfficeId") final Long fromOfficeId, @QueryParam("fromClientId") final Long fromClientId, - @QueryParam("fromAccountId") final Long fromAccountId, @QueryParam("fromAccountType") final Integer fromAccountType, - @QueryParam("toOfficeId") final Long toOfficeId, @QueryParam("toClientId") final Long toClientId, - @QueryParam("toAccountId") final Long toAccountId, @QueryParam("toAccountType") final Integer toAccountType, - @Context final UriInfo uriInfo) { + @ApiOperation(value = "Retrieve Account Transfer Template", httpMethod = "GET", notes = "This is a convenience resource. It can be useful when building maintenance user interface screens for client applications. The template data returned consists of any or all of:\n\n" + "\n\n" + "Field Defaults\n\n" + "Allowed Value Lists\n\n" + "Example Requests:\n\n" + "\n\n" + "accounttransfers/template?fromAccountType=2&fromOfficeId=1\n\n" + "\n\n" + "accounttransfers/template?fromAccountType=2&fromOfficeId=1&fromClientId=1\n\n" + "\n\n" + "accounttransfers/template?fromClientId=1&fromAccountType=2&fromAccountId=1") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = AccountTransfersApiResourceSwagger.GetAccountTransfersTemplateResponse.class)}) + public String template(@QueryParam("fromOfficeId") @ApiParam(value = "fromOfficeId") final Long fromOfficeId, @QueryParam("fromClientId") @ApiParam(value = "fromClientId") final Long fromClientId, + @QueryParam("fromAccountId") @ApiParam(value = "fromAccountId") final Long fromAccountId, @QueryParam("fromAccountType") @ApiParam(value = "fromAccountType") final Integer fromAccountType, + @QueryParam("toOfficeId") @ApiParam(value = "toOfficeId") final Long toOfficeId, @QueryParam("toClientId") @ApiParam(value = "toClientId") final Long toClientId, + @QueryParam("toAccountId") @ApiParam(value = "toAccountId") final Long toAccountId, @QueryParam("toAccountType") @ApiParam(value = "toAccountType") final Integer toAccountType, + @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(AccountTransfersApiConstants.ACCOUNT_TRANSFER_RESOURCE_NAME); @@ -91,7 +89,10 @@ public class AccountTransfersApiResource { @POST @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String create(final String apiRequestBodyAsJson) { + @ApiOperation(value = "Create new Transfer", httpMethod = "POST", notes = "Ability to create new transfer of monetary funds from one account to another.") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = AccountTransfersApiResourceSwagger.PostAccountTransfersRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = AccountTransfersApiResourceSwagger.PostAccountTransfersResponse.class)}) + public String create(@ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder().createAccountTransfer().withJson(apiRequestBodyAsJson).build(); @@ -103,10 +104,12 @@ public class AccountTransfersApiResource { @GET @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveAll(@Context final UriInfo uriInfo, @QueryParam("sqlSearch") final String sqlSearch, - @QueryParam("externalId") final String externalId, @QueryParam("offset") final Integer offset, - @QueryParam("limit") final Integer limit, @QueryParam("orderBy") final String orderBy, - @QueryParam("sortOrder") final String sortOrder,@QueryParam("accountDetailId") final Long accountDetailId) { + @ApiOperation(value = "List account transfers", httpMethod = "GET", notes = "Lists account's transfers\n\n" + "Example Requests:\n\n" + "\n\n" + "accounttransfers") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = AccountTransfersApiResourceSwagger.GetAccountTransfersResponse.class)}) + public String retrieveAll(@Context final UriInfo uriInfo, @QueryParam("sqlSearch") @ApiParam(value = "sqlSearch") final String sqlSearch, + @QueryParam("externalId") @ApiParam(value = "externalId") final String externalId, @QueryParam("offset") @ApiParam(value = "offset") final Integer offset, + @QueryParam("limit") @ApiParam(example = "limit") final Integer limit, @QueryParam("orderBy") @ApiParam(value = "orderBy") final String orderBy, + @QueryParam("sortOrder") @ApiParam(value = "sortOrder") final String sortOrder,@QueryParam("accountDetailId") @ApiParam(value = "accountDetailId") final Long accountDetailId) { this.context.authenticatedUser().validateHasReadPermission(AccountTransfersApiConstants.ACCOUNT_TRANSFER_RESOURCE_NAME); @@ -123,7 +126,9 @@ public class AccountTransfersApiResource { @Path("{transferId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveOne(@PathParam("transferId") final Long transferId, @Context final UriInfo uriInfo) { + @ApiOperation(value = "Retrieve account transfer", httpMethod = "GET", notes = "Retrieves account transfer\n\n" + "Example Requests :\n\n" + "\n\n" + "accounttransfers/1") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = AccountTransfersApiResourceSwagger.GetAccountTransfersResponse.GetAccountTransfersPageItems.class)}) + public String retrieveOne(@PathParam("transferId") @ApiParam(value = "transferId") final Long transferId, @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(AccountTransfersApiConstants.ACCOUNT_TRANSFER_RESOURCE_NAME); @@ -137,10 +142,12 @@ public class AccountTransfersApiResource { @Path("templateRefundByTransfer") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String templateRefundByTransfer(@QueryParam("fromOfficeId") final Long fromOfficeId, @QueryParam("fromClientId") final Long fromClientId, - @QueryParam("fromAccountId") final Long fromAccountId, @QueryParam("fromAccountType") final Integer fromAccountType, - @QueryParam("toOfficeId") final Long toOfficeId, @QueryParam("toClientId") final Long toClientId, - @QueryParam("toAccountId") final Long toAccountId, @QueryParam("toAccountType") final Integer toAccountType, + @ApiOperation(value = "Retrieve Refund of an Active Loan by Transfer Template", httpMethod = "GET", notes = "Retrieves Refund of an Active Loan by Transfer Template" + "Example Requests :\n\n" + "\n\n" + "accounttransfers/templateRefundByTransfer?fromAccountId=2&fromAccountType=1& toAccountId=1&toAccountType=2&toClientId=1&toOfficeId=1") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = AccountTransfersApiResourceSwagger.GetAccountTransfersTemplateRefundByTransferResponse.class)}) + public String templateRefundByTransfer(@QueryParam("fromOfficeId") @ApiParam(value = "fromOfficeId") final Long fromOfficeId, @QueryParam("fromClientId") @ApiParam(value = "fromClientId") final Long fromClientId, + @QueryParam("fromAccountId") @ApiParam(value = "fromAccountId") final Long fromAccountId, @QueryParam("fromAccountType") @ApiParam(value = "fromAccountType") final Integer fromAccountType, + @QueryParam("toOfficeId") @ApiParam(value = "toOfficeId") final Long toOfficeId, @QueryParam("toClientId") @ApiParam(value = "toClientId") final Long toClientId, + @QueryParam("toAccountId") @ApiParam(value = "toAccountId") final Long toAccountId, @QueryParam("toAccountType") @ApiParam(value = "toAccountType") final Integer toAccountType, @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(AccountTransfersApiConstants.ACCOUNT_TRANSFER_RESOURCE_NAME); @@ -156,7 +163,10 @@ public class AccountTransfersApiResource { @Path("refundByTransfer") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String templateRefundByTransferPost(final String apiRequestBodyAsJson) { + @ApiOperation(value = "Refund of an Active Loan by Transfer", httpMethod = "POST", notes = "Ability to refund an active loan by transferring to a savings account.") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = AccountTransfersApiResourceSwagger.PostAccountTransfersRefundByTransferRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = AccountTransfersApiResourceSwagger.PostAccountTransfersRefundByTransferResponse.class)}) + public String templateRefundByTransferPost(@ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder().refundByTransfer().withJson(apiRequestBodyAsJson).build(); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/api/AccountTransfersApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/api/AccountTransfersApiResourceSwagger.java new file mode 100644 index 000000000..a417c30ba --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/api/AccountTransfersApiResourceSwagger.java @@ -0,0 +1,572 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.account.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.time.LocalDate; +import java.util.Set; + +/** + * Created by Chirag Gupta on 12/16/17. + */ +final class AccountTransfersApiResourceSwagger { + private AccountTransfersApiResourceSwagger() { + } + + @ApiModel(value = "GetAccountTransfersTemplateResponse") + public final static class GetAccountTransfersTemplateResponse { + private GetAccountTransfersTemplateResponse() { + } + + final class GetAccountTransfersFromOffice { + private GetAccountTransfersFromOffice() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "HO") + public String name; + @ApiModelProperty(example = "HO") + public String nameDecorated; + @ApiModelProperty(example = "1") + public Integer externalId; + @ApiModelProperty(example = "[2009, 1, 1]") + public LocalDate openingDate; + @ApiModelProperty(example = ".") + public String hierarchy; + } + + final class GetAccountTransfersFromAccountType { + private GetAccountTransfersFromAccountType() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "accountType.savings") + public String code; + @ApiModelProperty(example = "Savings Account") + public String value; + } + + final class GetAccountTransfersFromOfficeOptions { + private GetAccountTransfersFromOfficeOptions() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "HO") + public String name; + @ApiModelProperty(example = "HO") + public String nameDecorated; + } + + final class GetAccountTransfersFromClientOptions { + private GetAccountTransfersFromClientOptions() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "Small shop") + public String displayName; + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "HO") + public String officeName; + } + + final class GetAccountTransfersFromAccountTypeOptions { + private GetAccountTransfersFromAccountTypeOptions() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "accountType.savings") + public String code; + @ApiModelProperty(example = "Savings Account") + public String value; + } + + final class GetAccountTransfersToOfficeOptions { + private GetAccountTransfersToOfficeOptions() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "HO") + public String name; + @ApiModelProperty(example = "HO") + public String nameDecorated; + } + + final class GetAccountTransfersToAccountTypeOptions { + private GetAccountTransfersToAccountTypeOptions() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "accountType.savings") + public String code; + @ApiModelProperty(example = "Savings Account") + public String value; + } + + @ApiModelProperty(example = "0") + public Long transferAmount; + @ApiModelProperty(example = "[2013, 8, 15]") + public LocalDate transferDate; + public GetAccountTransfersFromOffice fromOffice; + public GetAccountTransfersFromAccountType fromAccountType; + public Set fromOfficeOptions; + public Set fromClientOptions; + public Set fromAccountTypeOptions; + public Set toOfficeOptions; + public Set toAccountTypeOptions; + } + + @ApiModel(value = "PostAccountTransfersRequest") + public final static class PostAccountTransfersRequest { + private PostAccountTransfersRequest() { + } + + @ApiModelProperty(example = "1") + public Integer fromOfficeId; + @ApiModelProperty(example = "1") + public Integer fromClientId; + @ApiModelProperty(example = "2") + public Integer fromAccountType; + @ApiModelProperty(example = "1") + public Integer fromAccountId; + @ApiModelProperty(example = "1") + public Integer toOfficeId; + @ApiModelProperty(example = "1") + public Integer toClientId; + @ApiModelProperty(example = "2") + public Integer toAccountType; + @ApiModelProperty(example = "2") + public Integer toAccountId; + @ApiModelProperty(example = "dd MMMM yyyy") + public String dateFormat; + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "01 August 2011") + public String transferDate; + @ApiModelProperty(example = "112.45") + public Float transferAmount; + @ApiModelProperty(example = "A description of the transfer") + public String transferDescription; + } + + @ApiModel(value = "PostAccountTransfersResponse") + public final static class PostAccountTransfersResponse { + private PostAccountTransfersResponse() { + } + + @ApiModelProperty(example = "1") + public Integer savingsId; + @ApiModelProperty(example = "1") + public Integer resourceId; + } + + @ApiModel(value = "GetAccountTransfersResponse") + public final static class GetAccountTransfersResponse { + private GetAccountTransfersResponse() { + } + + final class GetAccountTransfersPageItems { + private GetAccountTransfersPageItems() { + } + + final class GetAccountTransfersPageItemsCurrency { + private GetAccountTransfersPageItemsCurrency() { + } + + @ApiModelProperty(example = "USD") + public String code; + @ApiModelProperty(example = "US Dollar") + public String name; + @ApiModelProperty(example = "2") + public Integer decimalPlaces; + @ApiModelProperty(example = "$") + public String displaySymbol; + @ApiModelProperty(example = "currency.USD") + public String nameCode; + @ApiModelProperty(example = "US Dollar ($)") + public String displayLabel; + } + + final class GetAccountTransfersPageItemsFromOffice { + private GetAccountTransfersPageItemsFromOffice() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "HO") + public String name; + } + + final class GetAccountTransfersPageItemsFromAccount { + private GetAccountTransfersPageItemsFromAccount() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "000000001") + public Long accountNo; + } + + final class GetAccountTransfersPageItemsToAccountType { + private GetAccountTransfersPageItemsToAccountType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "accountType.loan") + public String code; + @ApiModelProperty(example = "Loan Account") + public String value; + } + + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "false") + public Boolean reversed; + public GetAccountTransfersPageItemsCurrency currency; + @ApiModelProperty(example = "200") + public Float transferAmount; + @ApiModelProperty(example = "[2013, 4, 1]") + public LocalDate transferDate; + @ApiModelProperty(example = "pay off loan from savings.") + public String transferDescription; + public GetAccountTransfersPageItemsFromOffice fromOffice; + public GetAccountTransfersTemplateResponse.GetAccountTransfersFromClientOptions fromClient; + public GetAccountTransfersTemplateResponse.GetAccountTransfersFromAccountType fromAccountType; + public GetAccountTransfersPageItemsFromAccount fromAccount; + public GetAccountTransfersPageItemsFromOffice toOffice; + public GetAccountTransfersTemplateResponse.GetAccountTransfersFromClientOptions toClient; + public GetAccountTransfersPageItemsToAccountType toAccountType; + public GetAccountTransfersPageItemsFromAccount toAccount; + } + + @ApiModelProperty(example = "4") + public Integer totalFilteredRecords; + public Set pageItems; + } + + @ApiModel(value = "GetAccountTransfersTemplateRefundByTransferResponse") + public static final class GetAccountTransfersTemplateRefundByTransferResponse { + private GetAccountTransfersTemplateRefundByTransferResponse() { + } + + final class GetAccountTransfersTemplateRefundByTransferCurrency { + private GetAccountTransfersTemplateRefundByTransferCurrency() { + } + + @ApiModelProperty(example = "USD") + public String code; + @ApiModelProperty(example = "US Dollar") + public String name; + @ApiModelProperty(example = "0") + public Integer decimalPlaces; + @ApiModelProperty(example = "0") + public Integer inMultiplesOf; + @ApiModelProperty(example = "$") + public String displaySymbol; + @ApiModelProperty(example = "currency.USD") + public String nameCode; + @ApiModelProperty(example = "US Dollar ($)") + public String displayLabel; + } + + final class GetAccountTransfersTemplateRefundByTransferFromOffice { + private GetAccountTransfersTemplateRefundByTransferFromOffice() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "Head Office") + public String name; + @ApiModelProperty(example = "Head Office") + public String nameDecorated; + @ApiModelProperty(example = "1") + public Integer externalId; + @ApiModelProperty(example = "[2009, 1, 1]") + public LocalDate openingDate; + @ApiModelProperty(example = ".") + public String hierarchy; + } + + final class GetAccountTransfersTemplateRefundByTransferFromClient { + private GetAccountTransfersTemplateRefundByTransferFromClient() { + } + + final class GetAccountTransfersStatus { + private GetAccountTransfersStatus() { + } + + @ApiModelProperty(example = "300") + public Integer id; + @ApiModelProperty(example = "clientStatusType.active") + public String code; + @ApiModelProperty(example = "Active") + public String value; + } + + final class GetAccountTransfersGender { + private GetAccountTransfersGender() { + } + } + + final class GetAccountTransfersClientType { + private GetAccountTransfersClientType() { + } + } + + final class GetAccountTransfersClientClassification { + private GetAccountTransfersClientClassification() { + } + } + + final class GetAccountTransfersTimeline { + private GetAccountTransfersTimeline() { + } + + @ApiModelProperty(example = "[2012, 2, 1]") + public LocalDate submittedOnDate; + @ApiModelProperty(example = "mifos") + public String submittedByUsername; + @ApiModelProperty(example = "App") + public String submittedByFirstname; + @ApiModelProperty(example = "Administrator") + public String submittedByLastname; + @ApiModelProperty(example = "[2012, 2, 1]") + public LocalDate activatedOnDate; + @ApiModelProperty(example = "mifos") + public String activatedByUsername; + @ApiModelProperty(example = "App") + public String activatedByFirstname; + @ApiModelProperty(example = "Administrator") + public String activatedByLastname; + } + + final class GetAccountTransfersGroups { + private GetAccountTransfersGroups() { + } + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "000000001") + public Long accountNo; + public GetAccountTransfersStatus status; + @ApiModelProperty(example = "true") + public Boolean active; + @ApiModelProperty(example = "[2012, 2, 1]") + public LocalDate activationDate; + @ApiModelProperty(example = "Daniel") + public String firstname; + @ApiModelProperty(example = "Owusu") + public String lastname; + @ApiModelProperty(example = "Daniel Owusu") + public String displayName; + public GetAccountTransfersGender gender; + public GetAccountTransfersClientType clientType; + public GetAccountTransfersClientClassification clientClassification; + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "Head Office") + public String officeName; + public GetAccountTransfersTimeline timeline; + public GetAccountTransfersGroups groups; + } + + final class GetAccountTransfersTemplateRefundByTransferFromAccount { + private GetAccountTransfersTemplateRefundByTransferFromAccount() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "000000002") + public Long accountNo; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "Daniel Owusu") + public String clientName; + @ApiModelProperty(example = "1") + public Integer productId; + @ApiModelProperty(example = "CTRL") + public String productName; + @ApiModelProperty(example = "0") + public Integer fieldOfficerId; + public GetAccountTransfersTemplateRefundByTransferCurrency currency; + @ApiModelProperty(example = "130") + public Float amtForTransfer; + } + + final class GetAccountTransfersTemplateRefundByTransferToClient { + private GetAccountTransfersTemplateRefundByTransferToClient() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "Daniel Owusu") + public String displayName; + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "Head Office") + public String officeName; + } + + final class GetAccountTransfersTemplateRefundByTransferToAccount { + private GetAccountTransfersTemplateRefundByTransferToAccount() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "000000001") + public Long accountNo; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "Daniel Owusu") + public String clientName; + @ApiModelProperty(example = "1") + public Integer productId; + @ApiModelProperty(example = "TEST") + public String productName; + @ApiModelProperty(example = "0") + public Integer fieldOfficerId; + public GetAccountTransfersTemplateRefundByTransferCurrency currency; + } + + final class GetAccountTransfersTemplateRefundByTransferFromOfficeOptions { + private GetAccountTransfersTemplateRefundByTransferFromOfficeOptions() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "Head Office") + public String name; + @ApiModelProperty(example = "Head Office") + public String nameDecorated; + } + + final class GetAccountTransfersTemplateRefundByTransferFromClientOptions { + private GetAccountTransfersTemplateRefundByTransferFromClientOptions() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "Daniel Owusu") + public String displayName; + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "Head Office") + public String officeName; + } + + final class GetAccountTransfersTemplateRefundByTransferFromAccountOptions { + private GetAccountTransfersTemplateRefundByTransferFromAccountOptions() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "000000002") + public Long accountNo; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "Daniel Owusu") + public String clientName; + @ApiModelProperty(example = "1") + public Integer productId; + @ApiModelProperty(example = "CTRL") + public String productName; + @ApiModelProperty(example = "0") + public Integer fieldOfficerId; + public GetAccountTransfersTemplateRefundByTransferCurrency currency; + } + + public GetAccountTransfersTemplateRefundByTransferCurrency currency; + @ApiModelProperty(example = "130") + public Float transferAmount; + @ApiModelProperty(example = "[2014, 11, 1]") + public LocalDate transferDate; + public GetAccountTransfersTemplateRefundByTransferFromOffice fromOffice; + public GetAccountTransfersTemplateRefundByTransferFromClient fromClient; + public GetAccountTransfersResponse.GetAccountTransfersPageItems.GetAccountTransfersPageItemsToAccountType fromAccountType; + public GetAccountTransfersTemplateRefundByTransferFromAccount fromAccount; + public GetAccountTransfersTemplateRefundByTransferFromOffice toOffice; + public GetAccountTransfersTemplateRefundByTransferToClient toClient; + public GetAccountTransfersTemplateResponse.GetAccountTransfersFromAccountType toAccountType; + public GetAccountTransfersTemplateRefundByTransferToAccount toAccount; + public Set fromOfficeOptions; + public Set fromClientOptions; + public Set fromAccountTypeOptions; + public Set fromAccountOptions; + public Set toOfficeOptions; + public Set toClientOptions; + public Set toAccountTypeOptions; + public Set toAccountOptions; + } + + @ApiModel(value = "PostAccountTransfersRefundByTransferRequest") + public static final class PostAccountTransfersRefundByTransferRequest { + private PostAccountTransfersRefundByTransferRequest() { + } + + @ApiModelProperty(example = "2") + public Integer fromAccountId; + @ApiModelProperty(example = "1") + public Integer fromAccountType; + @ApiModelProperty(example = "1") + public Integer toOfficeId; + @ApiModelProperty(example = "1") + public Integer toClientId; + @ApiModelProperty(example = "2") + public Integer toAccountType; + @ApiModelProperty(example = "1") + public Integer toAccountId; + @ApiModelProperty(example = "130") + public Float transferAmount; + @ApiModelProperty(example = "31 October 2014") + public String transferDate; + @ApiModelProperty(example = "Transfer refund to my savings account") + public String transferDescription; + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "dd MMMM yyyy") + public String dateFormat; + @ApiModelProperty(example = "1") + public Integer fromClientId; + @ApiModelProperty(example = "1") + public Integer fromOfficeId; + } + + @ApiModel(value = "PostAccountTransfersRefundByTransferResponse") + public final static class PostAccountTransfersRefundByTransferResponse { + private PostAccountTransfersRefundByTransferResponse() { + } + + @ApiModelProperty(example = "1") + public Integer savingsId; + @ApiModelProperty(example = "1") + public Integer resourceId; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/api/StandingInstructionApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/api/StandingInstructionApiResource.java index 2d780e054..f2efc19ab 100755 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/api/StandingInstructionApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/api/StandingInstructionApiResource.java @@ -6,9 +6,7 @@ * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at - * * http://www.apache.org/licenses/LICENSE-2.0 - * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY @@ -18,22 +16,7 @@ */ package org.apache.fineract.portfolio.account.api; -import java.util.Arrays; -import java.util.Date; -import java.util.Set; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriInfo; - +import io.swagger.annotations.*; import org.apache.commons.lang.StringUtils; import org.apache.fineract.commands.domain.CommandWrapper; import org.apache.fineract.commands.service.CommandWrapperBuilder; @@ -56,9 +39,18 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; +import java.util.Arrays; +import java.util.Date; +import java.util.Set; + @Path("/standinginstructions") @Component @Scope("singleton") +@Api(value = "Standing Instructions", description = "Standing instructions (or standing orders) refer to instructions a bank account holder (\"the payer\") gives to his or her bank to pay a set amount at regular intervals to another's (\"the payee's\") account.\n" + "\n" + "Note: At present only savings account to savings account and savings account to Loan account transfers are permitted.") public class StandingInstructionApiResource { private final PlatformSecurityContext context; @@ -70,11 +62,11 @@ public class StandingInstructionApiResource { @Autowired public StandingInstructionApiResource(final PlatformSecurityContext context, - final DefaultToApiJsonSerializer toApiJsonSerializer, - final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService, - final ApiRequestParameterHelper apiRequestParameterHelper, - final StandingInstructionReadPlatformService standingInstructionReadPlatformService, - final AccountTransfersReadPlatformService accountTransfersReadPlatformService) { + final DefaultToApiJsonSerializer toApiJsonSerializer, + final PortfolioCommandSourceWritePlatformService commandsSourceWritePlatformService, + final ApiRequestParameterHelper apiRequestParameterHelper, + final StandingInstructionReadPlatformService standingInstructionReadPlatformService, + final AccountTransfersReadPlatformService accountTransfersReadPlatformService) { this.context = context; this.toApiJsonSerializer = toApiJsonSerializer; this.commandsSourceWritePlatformService = commandsSourceWritePlatformService; @@ -85,13 +77,15 @@ public class StandingInstructionApiResource { @GET @Path("template") - @Consumes({ MediaType.APPLICATION_JSON }) - @Produces({ MediaType.APPLICATION_JSON }) - public String template(@QueryParam("fromOfficeId") final Long fromOfficeId, @QueryParam("fromClientId") final Long fromClientId, - @QueryParam("fromAccountId") final Long fromAccountId, @QueryParam("fromAccountType") final Integer fromAccountType, - @QueryParam("toOfficeId") final Long toOfficeId, @QueryParam("toClientId") final Long toClientId, - @QueryParam("toAccountId") final Long toAccountId, @QueryParam("toAccountType") final Integer toAccountType, - @QueryParam("transferType") final Integer transferType, @Context final UriInfo uriInfo) { + @Consumes({MediaType.APPLICATION_JSON}) + @Produces({MediaType.APPLICATION_JSON}) + @ApiOperation(value = "Retrieve Standing Instruction Template", httpMethod = "GET", notes = "This is a convenience resource. " + "It can be useful when building maintenance user interface screens for client applications. " + "The template data returned consists of any or all of:\n" + "\n" + "Field Defaults\n" + "Allowed Value Lists\n" + "Example Requests:\n" + "\n" + "standinginstructions/template?fromAccountType=2&fromOfficeId=1\n" + "\n" + "standinginstructions/template?fromAccountType=2&fromOfficeId=1&fromClientId=1&transferType=1\n" + "\n" + "standinginstructions/template?fromClientId=1&fromAccountType=2&fromAccountId=1&transferType=1") + @ApiResponses(@ApiResponse(code = 200, message = "OK", response = StandingInstructionApiResourceSwagger.GetStandingInstructionsTemplateResponse.class)) + public String template(@QueryParam("fromOfficeId") @ApiParam(value = "fromOfficeId") final Long fromOfficeId, @QueryParam("fromClientId") @ApiParam(value = "fromClientId") final Long fromClientId, + @QueryParam("fromAccountId") @ApiParam(value = "fromAccountId") final Long fromAccountId, @QueryParam("fromAccountType") @ApiParam(value = "fromAccountType") final Integer fromAccountType, + @QueryParam("toOfficeId") @ApiParam(value = "toOfficeId") final Long toOfficeId, @QueryParam("toClientId") @ApiParam(value = "toClientId") final Long toClientId, + @QueryParam("toAccountId") @ApiParam(value = "toAccountId") final Long toAccountId, @QueryParam("toAccountType") @ApiParam(value = "toAccountType") final Integer toAccountType, + @QueryParam("transferType") @ApiParam(value = "transferType") final Integer transferType, @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(StandingInstructionApiConstants.STANDING_INSTRUCTION_RESOURCE_NAME); @@ -104,9 +98,12 @@ public class StandingInstructionApiResource { } @POST - @Consumes({ MediaType.APPLICATION_JSON }) - @Produces({ MediaType.APPLICATION_JSON }) - public String create(final String apiRequestBodyAsJson) { + @Consumes({MediaType.APPLICATION_JSON}) + @Produces({MediaType.APPLICATION_JSON}) + @ApiOperation(value = "Create new Standing Instruction", httpMethod = "POST", notes = "Ability to create new instruction for transfer of monetary funds from one account to another") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = StandingInstructionApiResourceSwagger.PostStandingInstructionsRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = StandingInstructionApiResourceSwagger.PostStandingInstructionsResponse.class)}) + public String create(@ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder().createStandingInstruction().withJson(apiRequestBodyAsJson) .build(); @@ -118,10 +115,13 @@ public class StandingInstructionApiResource { @PUT @Path("{standingInstructionId}") - @Consumes({ MediaType.APPLICATION_JSON }) - @Produces({ MediaType.APPLICATION_JSON }) - public String update(@PathParam("standingInstructionId") final Long standingInstructionId, final String apiRequestBodyAsJson, - @QueryParam("command") final String commandParam) { + @Consumes({MediaType.APPLICATION_JSON}) + @Produces({MediaType.APPLICATION_JSON}) + @ApiOperation(value = "Update Standing Instruction | Delete Standing Instruction", httpMethod = "PUT", notes = "Ability to modify existing instruction for transfer of monetary funds from one account to another.\n" + "\n" + "PUT https://DomainName/api/v1/standinginstructions/1?command=update\n" + "\n\n" + "Ability to modify existing instruction for transfer of monetary funds from one account to another.\n" + "\n" + "PUT https://DomainName/api/v1/standinginstructions/1?command=delete") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = false, paramType = "body", dataType = "body", format = "body", dataTypeClass = StandingInstructionApiResourceSwagger.PutStandingInstructionsStandingInstructionIdRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = StandingInstructionApiResourceSwagger.PutStandingInstructionsStandingInstructionIdResponse.class)}) + public String update(@PathParam("standingInstructionId") @ApiParam(value = "standingInstructionId") final Long standingInstructionId, @ApiParam(hidden = true) final String apiRequestBodyAsJson, + @QueryParam("command") @ApiParam(value = "command") final String commandParam) { CommandWrapper commandRequest = null; if (is(commandParam, "update")) { @@ -132,7 +132,9 @@ public class StandingInstructionApiResource { .build(); } - if (commandRequest == null) { throw new UnrecognizedQueryParamException("command", commandParam); } + if (commandRequest == null) { + throw new UnrecognizedQueryParamException("command", commandParam); + } final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); return this.toApiJsonSerializer.serialize(result); @@ -144,14 +146,16 @@ public class StandingInstructionApiResource { } @GET - @Consumes({ MediaType.APPLICATION_JSON }) - @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveAll(@Context final UriInfo uriInfo, @QueryParam("sqlSearch") final String sqlSearch, - @QueryParam("externalId") final String externalId, @QueryParam("offset") final Integer offset, - @QueryParam("limit") final Integer limit, @QueryParam("orderBy") final String orderBy, - @QueryParam("sortOrder") final String sortOrder, @QueryParam("transferType") final Integer transferType, - @QueryParam("clientName") final String clientName, @QueryParam("clientId") final Long clientId, - @QueryParam("fromAccountId") final Long fromAccount, @QueryParam("fromAccountType") final Integer fromAccountType) { + @Consumes({MediaType.APPLICATION_JSON}) + @Produces({MediaType.APPLICATION_JSON}) + @ApiOperation(value = "List Standing Instructions", httpMethod = "GET", notes = "Example Requests:\n" + "\n" + "standinginstructions") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = StandingInstructionApiResourceSwagger.GetStandingInstructionsResponse.class)}) + public String retrieveAll(@Context final UriInfo uriInfo, @QueryParam("sqlSearch") @ApiParam(value = "sqlSearch") final String sqlSearch, + @QueryParam("externalId") @ApiParam(value = "externalId") final String externalId, @QueryParam("offset") @ApiParam(value = "offset") final Integer offset, + @QueryParam("limit") @ApiParam(value = "limit") final Integer limit, @QueryParam("orderBy") @ApiParam(value = "orderBy") final String orderBy, + @QueryParam("sortOrder") @ApiParam(value = "sortOrder") final String sortOrder, @QueryParam("transferType") @ApiParam(value = "transferType") final Integer transferType, + @QueryParam("clientName") @ApiParam(value = "clientName") final String clientName, @QueryParam("clientId") @ApiParam(value = "clientId") final Long clientId, + @QueryParam("fromAccountId") @ApiParam(value = "fromAccountId") final Long fromAccount, @QueryParam("fromAccountType") @ApiParam(value = "fromAccountType") final Integer fromAccountType) { this.context.authenticatedUser().validateHasReadPermission(StandingInstructionApiConstants.STANDING_INSTRUCTION_RESOURCE_NAME); @@ -171,12 +175,14 @@ public class StandingInstructionApiResource { @GET @Path("{standingInstructionId}") - @Consumes({ MediaType.APPLICATION_JSON }) - @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveOne(@PathParam("standingInstructionId") final Long standingInstructionId, @Context final UriInfo uriInfo, - @QueryParam("sqlSearch") final String sqlSearch, @QueryParam("externalId") final String externalId, - @QueryParam("offset") final Integer offset, @QueryParam("limit") final Integer limit, - @QueryParam("orderBy") final String orderBy, @QueryParam("sortOrder") final String sortOrder) { + @Consumes({MediaType.APPLICATION_JSON}) + @Produces({MediaType.APPLICATION_JSON}) + @ApiOperation(value = "Retrieve Standing Instruction", httpMethod = "GET", notes = "Example Requests :\n" + "\n" + "standinginstructions/1") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = StandingInstructionApiResourceSwagger.GetStandingInstructionsStandingInstructionIdResponse.class)}) + public String retrieveOne(@PathParam("standingInstructionId") @ApiParam(value = "standingInstructionId") final Long standingInstructionId, @Context final UriInfo uriInfo, + @QueryParam("sqlSearch") @ApiParam(value = "sqlSearch") final String sqlSearch, @QueryParam("externalId") @ApiParam(value = "externalId") final String externalId, + @QueryParam("offset") @ApiParam(value = "offset") final Integer offset, @QueryParam("limit") @ApiParam(value = "limit") final Integer limit, + @QueryParam("orderBy") @ApiParam(value = "orderBy") final String orderBy, @QueryParam("sortOrder") @ApiParam(value = "sortOrder") final String sortOrder) { this.context.authenticatedUser().validateHasReadPermission(StandingInstructionApiConstants.STANDING_INSTRUCTION_RESOURCE_NAME); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/api/StandingInstructionApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/api/StandingInstructionApiResourceSwagger.java new file mode 100644 index 000000000..2022f19c2 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/api/StandingInstructionApiResourceSwagger.java @@ -0,0 +1,549 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.account.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.time.LocalDate; +import java.util.Set; + +/** + * Created by Chirag Gupta on 11/29/17. + */ +final class StandingInstructionApiResourceSwagger { + + private StandingInstructionApiResourceSwagger() { + // this class is only for Swagger Live Documentation + } + + @ApiModel(value = "GetStandingInstructionsTemplateResponse") + public static final class GetStandingInstructionsTemplateResponse { + private GetStandingInstructionsTemplateResponse() { + } + + final class GetFromOfficeResponseStandingInstructionSwagger { + private GetFromOfficeResponseStandingInstructionSwagger() { + } + + @ApiModelProperty(example = "1") + public Long id; + @ApiModelProperty(example = "Head Office") + public String name; + @ApiModelProperty(example = "Head Office") + public String decoratedName; + @ApiModelProperty(example = "1") + public Integer externalId; + @ApiModelProperty(example = "[2009, 1, 1]") + public LocalDate openingDate; + @ApiModelProperty(example = ".") + public String hierarchy; + } + + final class GetFromAccountTypeResponseStandingInstructionSwagger { + private GetFromAccountTypeResponseStandingInstructionSwagger() { + } + + @ApiModelProperty(example = "2") + public Long id; + @ApiModelProperty(example = "accountType.savings") + public String code; + @ApiModelProperty(example = "Savings Account") + public String value; + } + + final class GetFromOfficeOptionsResponseStandingInstructionSwagger { + private GetFromOfficeOptionsResponseStandingInstructionSwagger() { + } + + @ApiModelProperty(example = "1") + public Long id; + @ApiModelProperty(example = "Head Office") + public String name; + @ApiModelProperty(example = "Head Office") + public String nameDecorated; + } + + final class GetFromClientOptionsResponseStandingInstructionSwagger { + private GetFromClientOptionsResponseStandingInstructionSwagger() { + } + + @ApiModelProperty(example = "1") + public Long id; + @ApiModelProperty(example = "Client_FirstName_2VRAG Client_LastName_9QCY") + public String displayName; + @ApiModelProperty(example = "1") + public Long officeId; + @ApiModelProperty(example = "Head Office") + public String officeName; + } + + final class GetFromAccountTypeOptionsResponseStandingInstructionSwagger { + private GetFromAccountTypeOptionsResponseStandingInstructionSwagger() { + } + + @ApiModelProperty(example = "2") + public Long id; + @ApiModelProperty(example = "accountType.savings") + public String code; + @ApiModelProperty(example = "Savings Account") + public String value; + } + + final class GetToOfficeOptionsResponseStandingInstructionSwagger { + private GetToOfficeOptionsResponseStandingInstructionSwagger() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "Head Office") + public String name; + @ApiModelProperty(example = "Head Office") + public String nameDecorated; + } + + final class GetToAccountTypeOptionsResponseStandingInstructionSwagger { + private GetToAccountTypeOptionsResponseStandingInstructionSwagger() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "accountType.loan") + public String code; + @ApiModelProperty(example = "Loan Account") + public String value; + } + + final class GetTransferTypeOptionsResponseStandingInstructionSwagger { + private GetTransferTypeOptionsResponseStandingInstructionSwagger() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "accountTransferType.account.transfer") + public String code; + @ApiModelProperty(example = "Account Transfer") + public String value; + } + + final class GetStatusOptionsResponseStandingInstructionSwagger { + private GetStatusOptionsResponseStandingInstructionSwagger() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "standingInstructionStatus.active") + public String code; + @ApiModelProperty(example = "Active") + public String value; + } + + final class GetInstructionTypeOptionsResponseStandingInstructionSwagger { + private GetInstructionTypeOptionsResponseStandingInstructionSwagger() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "standingInstructionType.fixed") + public String code; + @ApiModelProperty(example = "Fixed") + public String value; + } + + final class GetPriorityOptionsResponseStandingInstructionSwagger { + private GetPriorityOptionsResponseStandingInstructionSwagger() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "standingInstructionPriority.urgent") + public String code; + @ApiModelProperty(example = "Urgent Priority") + public String value; + } + + final class GetRecurrenceTypeOptionsResponseStandingInstructionSwagger { + private GetRecurrenceTypeOptionsResponseStandingInstructionSwagger() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "accountTransferRecurrenceType.periodic") + public String code; + @ApiModelProperty(example = "Periodic Recurrence") + public String value; + } + + final class GetRecurrenceFrequencyOptionsResponseStandingInstructionSwagger { + private GetRecurrenceFrequencyOptionsResponseStandingInstructionSwagger() { + } + + @ApiModelProperty(example = "0") + public Integer id; + @ApiModelProperty(example = "frequencyperiodFrequencyType.days") + public String code; + @ApiModelProperty(example = "Days") + public String value; + } + + public GetFromOfficeResponseStandingInstructionSwagger fromOffice; + public GetFromAccountTypeResponseStandingInstructionSwagger fromAccountType; + public Set fromOfficeOptions; + public Set fromClientOptions; + public Set fromAccountTypeOptions; + public Set toOfficeOptions; + public Set toAccountTypeOptions; + public Set transferTypeOptions; + public Set statusOptions; + public Set instructionTypeOptions; + public Set priorityOptions; + public Set recurrenceTypeOptions; + public Set recurrenceFrequencyOptions; + } + + @ApiModel(value = "PostStandingInstructionsResponse") + public static final class PostStandingInstructionsResponse { + private PostStandingInstructionsResponse() { + } + + @ApiModelProperty(example = "1") + public Long clientId; + @ApiModelProperty(example = "65") + public Integer resourceId; + } + + @ApiModel(value = "GetStandingInstructionsResponse") + public static final class GetStandingInstructionsResponse { + private GetStandingInstructionsResponse() { + } + + final class GetPageItemsStandingInstructionSwagger { + final class GetFromOfficeStandingInstructionSwagger { + private GetFromOfficeStandingInstructionSwagger() { + } + + @ApiModelProperty(example = "1") + public Long id; + @ApiModelProperty(example = "Head Office") + public String name; + } + + final class GetFromClientStandingInstructionSwagger { + private GetFromClientStandingInstructionSwagger() { + } + + @ApiModelProperty(example = "1") + public Long id; + @ApiModelProperty(example = "Test test") + public String displayName; + @ApiModelProperty(example = "1") + public Long officeId; + @ApiModelProperty(example = "Head Office") + public String officeName; + } + + final class GetFromAccountTypeStandingInstructionSwagger { + private GetFromAccountTypeStandingInstructionSwagger() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "accountType.savings") + public String code; + @ApiModelProperty(example = "Savings Account") + public String value; + } + + final class GetFromAccountStandingInstructionSwagger { + private GetFromAccountStandingInstructionSwagger() { + } + + @ApiModelProperty(example = "14") + public Long id; + @ApiModelProperty(example = "000000014") + public Long accountNo; + @ApiModelProperty(example = "1") + public Long productId; + @ApiModelProperty(example = "savings old") + public String productName; + } + + final class GetToOfficeStandingInstructionSwagger { + private GetToOfficeStandingInstructionSwagger() { + } + + @ApiModelProperty(example = "1") + public Long id; + @ApiModelProperty(example = "Head Office") + public String name; + } + + final class GetToClientStandingInstructionSwagger { + private GetToClientStandingInstructionSwagger() { + } + + @ApiModelProperty(example = "1") + public Long id; + @ApiModelProperty(example = "Test test") + public String displayName; + @ApiModelProperty(example = "1") + public Long officeId; + @ApiModelProperty(example = "Head Office") + public String officeName; + } + + final class GetToAccountTypeStandingInstructionSwagger { + private GetToAccountTypeStandingInstructionSwagger() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "accountType.savings") + public String code; + @ApiModelProperty(example = "Savings Account") + public String value; + } + + final class GetToAccountStandingInstructionSwagger { + private GetToAccountStandingInstructionSwagger() { + } + + @ApiModelProperty(example = "3") + public Long id; + @ApiModelProperty(example = "000000003") + public Long accountNo; + @ApiModelProperty(example = "4") + public Long productId; + @ApiModelProperty(example = "account overdraft") + public String productName; + } + + final class GetTransferTypeStandingInstructionSwagger { + private GetTransferTypeStandingInstructionSwagger() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "accountTransferType.account.transfer") + public String code; + @ApiModelProperty(example = "Account Transfer") + public String value; + } + + final class GetPriorityStandingInstructionSwagger { + private GetPriorityStandingInstructionSwagger() { + } + + @ApiModelProperty(example = "3") + public Integer id; + @ApiModelProperty(example = "standingInstructionPriority.medium") + public String code; + @ApiModelProperty(example = "Medium Priority") + public String value; + } + + final class GetInstructionTypeStandingInstructionSwagger { + private GetInstructionTypeStandingInstructionSwagger() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "standingInstructionType.fixed") + public String code; + @ApiModelProperty(example = "Fixed") + public String value; + } + + final class GetStatusStandingInstructionSwagger { + private GetStatusStandingInstructionSwagger() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "standingInstructionStatus.deleted") + public String code; + @ApiModelProperty(example = "Deleted") + public String value; + } + + final class GetRecurrenceTypeStandingInstructionSwagger { + private GetRecurrenceTypeStandingInstructionSwagger() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "accountTransferRecurrenceType.periodic") + public String code; + @ApiModelProperty(example = "Periodic Recurrence") + public String value; + } + + final class GetRecurrenceFrequencyStandingInstructionSwagger { + private GetRecurrenceFrequencyStandingInstructionSwagger() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "frequencyperiodFrequencyType.months") + public String code; + @ApiModelProperty(example = "Months") + public String value; + } + + @ApiModelProperty(example = "1") + public Long id; + @ApiModelProperty(example = "6") + public Long accountDetailId; + @ApiModelProperty(example = "test standing") + public String name; + public GetFromOfficeStandingInstructionSwagger fromOffice; + public GetFromClientStandingInstructionSwagger fromClient; + public GetFromAccountTypeStandingInstructionSwagger fromAccountType; + public GetFromAccountStandingInstructionSwagger fromAccount; + public GetToOfficeStandingInstructionSwagger toOffice; + public GetToClientStandingInstructionSwagger toClient; + public GetToAccountTypeStandingInstructionSwagger toAccountType; + public GetToAccountStandingInstructionSwagger toAccount; + public GetTransferTypeStandingInstructionSwagger transferType; + public GetPriorityStandingInstructionSwagger priority; + public GetInstructionTypeStandingInstructionSwagger instructionType; + public GetStatusStandingInstructionSwagger status; + @ApiModelProperty(example = "150.000000") + public float amount; + @ApiModelProperty(example = "[2014, 4, 3]") + public LocalDate validFrom; + public GetRecurrenceTypeStandingInstructionSwagger recurrenceType; + public GetRecurrenceFrequencyStandingInstructionSwagger recurrenceFrequency; + @ApiModelProperty(example = "1") + public Integer recurrenceInterval; + @ApiModelProperty(example = "[4, 3]") + public LocalDate recurrenceOnMonthDay; + } + + @ApiModelProperty(example = "2") + public Integer totalFilteredRecords; + public Set pageItems; + } + + @ApiModel(value = "PostStandingInstructionsRequest") + public static final class PostStandingInstructionsRequest { + private PostStandingInstructionsRequest() { + } + + @ApiModelProperty(example = "1") + public Long fromOfficeId; + @ApiModelProperty(example = "1") + public Long fromClientId; + @ApiModelProperty(example = "2") + public Integer fromAccountType; + @ApiModelProperty(example = "standing instruction") + public String name; + @ApiModelProperty(example = "1") + public Integer transferType; + @ApiModelProperty(example = "2") + public Integer priority; + @ApiModelProperty(example = "1") + public Integer status; + @ApiModelProperty(example = "1") + public Long fromAccountId; + @ApiModelProperty(example = "1") + public Long toOfficeId; + @ApiModelProperty(example = "1") + public Long toClientId; + @ApiModelProperty(example = "2") + public Integer toAccountType; + @ApiModelProperty(example = "3") + public Long toAccountId; + @ApiModelProperty(example = "1") + public Integer instructionType; + @ApiModelProperty(example = "221") + public Integer amount; + @ApiModelProperty(example = "08 April 2014") + public String validFrom; + @ApiModelProperty(example = "1") + public Integer recurrenceType; + @ApiModelProperty(example = "1") + public Integer recurrenceInterval; + @ApiModelProperty(example = "2") + public Integer recurrenceFrequency; + @ApiModelProperty(value = "en") + public String locale; + @ApiModelProperty(example = "dd MMMM yyyy") + public String dateFormat; + @ApiModelProperty(example = "02 April") + public String recurrenceOnMonthDay; + @ApiModelProperty(example = "dd MMMM") + public String monthDayFormat; + } + + @ApiModel(value = "GetStandingInstructionsStandingInstructionIdResponse") + public static final class GetStandingInstructionsStandingInstructionIdResponse { + private GetStandingInstructionsStandingInstructionIdResponse() { + } + + @ApiModelProperty(example = "1") + public Long id; + @ApiModelProperty(example = "6") + public Long accountDetailId; + @ApiModelProperty(example = "test standing") + public String name; + public GetStandingInstructionsResponse.GetPageItemsStandingInstructionSwagger.GetFromOfficeStandingInstructionSwagger fromOffice; + public GetStandingInstructionsResponse.GetPageItemsStandingInstructionSwagger.GetFromClientStandingInstructionSwagger fromClient; + public GetStandingInstructionsResponse.GetPageItemsStandingInstructionSwagger.GetFromAccountTypeStandingInstructionSwagger fromAccountType; + public GetStandingInstructionsResponse.GetPageItemsStandingInstructionSwagger.GetFromAccountStandingInstructionSwagger fromAccount; + public GetStandingInstructionsResponse.GetPageItemsStandingInstructionSwagger.GetToOfficeStandingInstructionSwagger toOffice; + public GetStandingInstructionsResponse.GetPageItemsStandingInstructionSwagger.GetToClientStandingInstructionSwagger toClient; + public GetStandingInstructionsResponse.GetPageItemsStandingInstructionSwagger.GetToAccountTypeStandingInstructionSwagger toAccountType; + public GetStandingInstructionsResponse.GetPageItemsStandingInstructionSwagger.GetToAccountStandingInstructionSwagger toAccount; + public GetStandingInstructionsResponse.GetPageItemsStandingInstructionSwagger.GetTransferTypeStandingInstructionSwagger transferType; + public GetStandingInstructionsResponse.GetPageItemsStandingInstructionSwagger.GetPriorityStandingInstructionSwagger priority; + public GetStandingInstructionsResponse.GetPageItemsStandingInstructionSwagger.GetInstructionTypeStandingInstructionSwagger instructionType; + public GetStandingInstructionsResponse.GetPageItemsStandingInstructionSwagger.GetStatusStandingInstructionSwagger status; + @ApiModelProperty(example = "150.000000") + public float amount; + @ApiModelProperty(example = "[2014, 4, 3]") + public LocalDate validFrom; + public GetStandingInstructionsResponse.GetPageItemsStandingInstructionSwagger.GetRecurrenceTypeStandingInstructionSwagger recurrenceType; + public GetStandingInstructionsResponse.GetPageItemsStandingInstructionSwagger.GetRecurrenceFrequencyStandingInstructionSwagger recurrenceFrequency; + @ApiModelProperty(example = "1") + public Integer recurrenceInterval; + @ApiModelProperty(example = "[4, 3]") + public LocalDate recurrenceOnMonthDay; + } + + @ApiModel(value = "PutStandingInstructionsStandingInstructionIdResponse") + public static final class PutStandingInstructionsStandingInstructionIdResponse { + private PutStandingInstructionsStandingInstructionIdResponse() { + } + final class PutUpdateStandingInstructionChanges{ + @ApiModelProperty(example = "2") + public Integer recurrenceInterval; + } + @ApiModelProperty(example = "20") + public Integer resourceId; + public PutUpdateStandingInstructionChanges changes; + } + + @ApiModel(value = "PutStandingInstructionsStandingInstructionIdRequest") + public static final class PutStandingInstructionsStandingInstructionIdRequest{ + private PutStandingInstructionsStandingInstructionIdRequest(){} + @ApiModelProperty(example = "2") + public Integer recurrenceInterval; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/api/StandingInstructionHistoryApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/api/StandingInstructionHistoryApiResource.java index 616cf050f..a5e9867f0 100755 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/api/StandingInstructionHistoryApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/api/StandingInstructionHistoryApiResource.java @@ -18,17 +18,7 @@ */ package org.apache.fineract.portfolio.account.api; -import java.util.Date; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriInfo; - +import io.swagger.annotations.*; import org.apache.fineract.accounting.journalentry.api.DateParam; import org.apache.fineract.infrastructure.core.api.ApiRequestParameterHelper; import org.apache.fineract.infrastructure.core.serialization.ApiRequestJsonSerializationSettings; @@ -43,9 +33,16 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; +import java.util.Date; + @Path("/standinginstructionrunhistory") @Component @Scope("singleton") +@Api(value = "Standing Instructions History", description = "The list capability of history can support pagination and sorting.") public class StandingInstructionHistoryApiResource { private final PlatformSecurityContext context; @@ -67,14 +64,16 @@ public class StandingInstructionHistoryApiResource { @GET @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveAll(@Context final UriInfo uriInfo, @QueryParam("sqlSearch") final String sqlSearch, - @QueryParam("externalId") final String externalId, @QueryParam("offset") final Integer offset, - @QueryParam("limit") final Integer limit, @QueryParam("orderBy") final String orderBy, - @QueryParam("sortOrder") final String sortOrder, @QueryParam("transferType") final Integer transferType, - @QueryParam("clientName") final String clientName, @QueryParam("clientId") final Long clientId, - @QueryParam("fromAccountId") final Long fromAccount, @QueryParam("fromAccountType") final Integer fromAccountType, - @QueryParam("locale") final String locale, @QueryParam("dateFormat") final String dateFormat, - @QueryParam("fromDate") final DateParam fromDateParam, @QueryParam("toDate") final DateParam toDateParam) { + @ApiOperation(value = "Standing Instructions Logged History", httpMethod = "GET", notes = "The list capability of history can support pagination and sorting \n\n" +"Example Requests :\n" + "\n" + "standinginstructionrunhistory\n" + "\n" + "standinginstructionrunhistory?orderBy=name&sortOrder=DESC\n" + "\n" + "standinginstructionrunhistory?offset=10&limit=50") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = StandingInstructionHistoryApiResourceSwagger.GetStandingInstructionRunHistoryResponse.class)}) + public String retrieveAll(@Context final UriInfo uriInfo, @QueryParam("sqlSearch") @ApiParam(value = "sqlSearch") final String sqlSearch, + @QueryParam("externalId") @ApiParam(value = "externalId") final String externalId, @QueryParam("offset") @ApiParam(value = "offset") final Integer offset, + @QueryParam("limit") @ApiParam(value = "limit") final Integer limit, @QueryParam("orderBy") @ApiParam(value = "orderBy") final String orderBy, + @QueryParam("sortOrder") @ApiParam(value = "sortOrder") final String sortOrder, @QueryParam("transferType") @ApiParam(value = "transferType") final Integer transferType, + @QueryParam("clientName") @ApiParam(value = "clientName") final String clientName, @QueryParam("clientId") @ApiParam(value = "clientId") final Long clientId, + @QueryParam("fromAccountId") @ApiParam(value = "fromAccountId") final Long fromAccount, @QueryParam("fromAccountType") @ApiParam(value = "fromAccountType") final Integer fromAccountType, + @QueryParam("locale") @ApiParam(value = "locale") final String locale, @QueryParam("dateFormat") @ApiParam(value = "dateFormat") final String dateFormat, + @QueryParam("fromDate") @ApiParam(value = "fromDate") final DateParam fromDateParam, @QueryParam("toDate") @ApiParam(value = "toDate") final DateParam toDateParam) { this.context.authenticatedUser().validateHasReadPermission(StandingInstructionApiConstants.STANDING_INSTRUCTION_RESOURCE_NAME); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/api/StandingInstructionHistoryApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/api/StandingInstructionHistoryApiResourceSwagger.java new file mode 100644 index 000000000..521b2f901 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/api/StandingInstructionHistoryApiResourceSwagger.java @@ -0,0 +1,123 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.account.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.time.LocalDate; +import java.util.Set; + +/** + * Created by Chirag Gupta on 12/01/17. + */ +final class StandingInstructionHistoryApiResourceSwagger { + private StandingInstructionHistoryApiResourceSwagger() { + } + + @ApiModel(value = "GetStandingInstructionRunHistoryResponse") + public final static class GetStandingInstructionRunHistoryResponse { + private GetStandingInstructionRunHistoryResponse() { + } + + final class GetStandingInstructionHistoryPageItemsResponse { + + final class GetStandingInstructionHistoryPageItemsFromClient { + private GetStandingInstructionHistoryPageItemsFromClient() { + } + + @ApiModelProperty(example = "1") + public Long id; + @ApiModelProperty(example = "Test client") + public String displayName; + @ApiModelProperty(example = "1") + public Long officeId; + @ApiModelProperty(example = "Head Office") + public String officeName; + } + + final class GetStandingInstructionHistoryFromAccount { + private GetStandingInstructionHistoryFromAccount() { + } + + @ApiModelProperty(example = "2") + public Long id; + @ApiModelProperty(example = "000000002") + public Long accountNo; + @ApiModelProperty(example = "1") + public Long productId; + @ApiModelProperty(example = "General Savings") + public String productName; + } + + final class GetStandingInstructionHistoryToAccount { + private GetStandingInstructionHistoryToAccount() { + } + + @ApiModelProperty(example = "1") + public Long id; + @ApiModelProperty(example = "000000001") + public Long accountNo; + @ApiModelProperty(example = "1") + public Long productId; + @ApiModelProperty(example = "General Savings") + public String productName; + } + + final class GetStandingInstructionHistoryToClient { + private GetStandingInstructionHistoryToClient() { + } + + @ApiModelProperty(example = "1") + public Long id; + @ApiModelProperty(example = "Test client") + public String displayName; + @ApiModelProperty(example = "1") + public Long officeId; + @ApiModelProperty(example = "Head Office") + public String officeName; + } + + @ApiModelProperty(example = "1") + public Long standingInstructionId; + @ApiModelProperty(example = "ACC Transfer") + public String name; + public StandingInstructionApiResourceSwagger.GetStandingInstructionsResponse.GetPageItemsStandingInstructionSwagger.GetFromOfficeStandingInstructionSwagger fromOffice; + public GetStandingInstructionHistoryPageItemsFromClient fromClient; + public StandingInstructionApiResourceSwagger.GetStandingInstructionsResponse.GetPageItemsStandingInstructionSwagger.GetFromAccountTypeStandingInstructionSwagger fromAccountType; + public GetStandingInstructionHistoryFromAccount fromAccount; + public StandingInstructionApiResourceSwagger.GetStandingInstructionsResponse.GetPageItemsStandingInstructionSwagger.GetToAccountTypeStandingInstructionSwagger toAccountType; + public GetStandingInstructionHistoryToAccount toAccount; + public StandingInstructionApiResourceSwagger.GetStandingInstructionsResponse.GetPageItemsStandingInstructionSwagger.GetToOfficeStandingInstructionSwagger toOffice; + public GetStandingInstructionHistoryToClient toClient; + @ApiModelProperty(example = "10") + public Float amount; + @ApiModelProperty(example = "success") + public String status; + @ApiModelProperty(example = "[2014, 6, 30]") + public LocalDate executionTime; + @ApiModelProperty(example = " ") + public String errorLog; + } + + @ApiModelProperty(example = "2") + public Integer totalFilteredRecords; + public Set pageItems; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/api/AccountsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/api/AccountsApiResource.java index f627c89a3..16f410d2f 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/api/AccountsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/api/AccountsApiResource.java @@ -18,18 +18,7 @@ */ package org.apache.fineract.portfolio.accounts.api; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriInfo; - +import io.swagger.annotations.*; import org.apache.fineract.commands.domain.CommandWrapper; import org.apache.fineract.commands.service.CommandWrapperBuilder; import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService; @@ -49,10 +38,16 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; + @Path("/accounts/{type}") @Component @Scope("singleton") +@Api(value = "Share Account", description = "Share accounts are instances of a praticular share product created for an individual. An application process around the creation of accounts is also supported.") public class AccountsApiResource { private final ApplicationContext applicationContext ; @@ -78,9 +73,11 @@ public class AccountsApiResource { @Path("template") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String template(@PathParam("type") final String accountType, @QueryParam("clientId") final Long clientId, - @QueryParam("productId") final Long productId, - @Context final UriInfo uriInfo) { + @ApiOperation(value = "Retrieve Share Account Template", httpMethod = "GET", notes = "This is a convenience resource. It can be useful when building maintenance user interface screens for client applications. The template data returned consists of any or all of:\n" + "\n" + "Field Defaults\n" + "Allowed Value Lists\n\n" + "Example Requests:\n" + "\n" + "accounts/share/template?clientId=1\n" + "\n" + "\n" + "accounts/share/template?clientId=1&productId=1") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = AccountsApiResourceSwagger.GetAccountsTypeTemplateResponse.class)}) + public String template(@PathParam("type") @ApiParam(value = "type") final String accountType, @QueryParam("clientId") @ApiParam(value = "clientId") final Long clientId, + @QueryParam("productId") @ApiParam(value = "productId") final Long productId, + @Context final UriInfo uriInfo) { try { this.platformSecurityContext.authenticatedUser() ; String serviceName = accountType+AccountsApiConstants.READPLATFORM_NAME ; @@ -97,7 +94,9 @@ public class AccountsApiResource { @Path("{accountId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveAccount(@PathParam("accountId") final Long accountId, @PathParam("type") final String accountType, + @ApiOperation(value = "Retrieve a share application/account", httpMethod = "GET", notes = "Retrieves a share application/account\n\n" + "Example Requests :\n" + "\n" + "shareaccount/1") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = AccountsApiResourceSwagger.GetAccountsTypeAccountIdResponse.class)}) + public String retrieveAccount(@PathParam("accountId") @ApiParam(value = "accountId") final Long accountId, @PathParam("type") @ApiParam(value = "type") final String accountType, @Context final UriInfo uriInfo) { try { String serviceName = accountType+AccountsApiConstants.READPLATFORM_NAME ; @@ -113,7 +112,9 @@ public class AccountsApiResource { @GET @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveAllAccounts(@PathParam("type") final String accountType, @QueryParam("offset") final Integer offset, @QueryParam("limit") final Integer limit, @Context final UriInfo uriInfo) { + @ApiOperation(value = "List share applications/accounts", httpMethod = "GET", notes = "Lists share applications/accounts\n\n" + "Example Requests:\n" + "\n" + "shareaccount") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = AccountsApiResourceSwagger.GetAccountsTypeResponse.class)}) + public String retrieveAllAccounts(@PathParam("type") @ApiParam(value = "type") final String accountType, @QueryParam("offset") @ApiParam(value = "offset") final Integer offset, @QueryParam("limit") @ApiParam(value = "limit") final Integer limit, @Context final UriInfo uriInfo) { try { String serviceName = accountType+AccountsApiConstants.READPLATFORM_NAME ; AccountReadPlatformService service = (AccountReadPlatformService) this.applicationContext.getBean(serviceName) ; @@ -128,7 +129,10 @@ public class AccountsApiResource { @POST @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String createAccount(@PathParam("type") final String accountType, final String apiRequestBodyAsJson) { + @ApiOperation(value = "Submit new share application", httpMethod = "POST", notes = "Submits new share application\n\n" + "Mandatory Fields: clientId, productId, submittedDate, savingsAccountId, requestedShares, applicationDate\n\n" + "Optional Fields: accountNo, externalId\n\n" + "Inherited from Product (if not provided): minimumActivePeriod, minimumActivePeriodFrequencyType, lockinPeriodFrequency, lockinPeriodFrequencyType") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = AccountsApiResourceSwagger.PostAccountsTypeRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = AccountsApiResourceSwagger.PostAccountsTypeResponse.class)}) + public String createAccount(@PathParam("type") @ApiParam(value = "type") final String accountType, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { CommandWrapper commandWrapper = null; this.platformSecurityContext.authenticatedUser(); commandWrapper = new CommandWrapperBuilder().createAccount(accountType).withJson(apiRequestBodyAsJson).build(); @@ -140,8 +144,11 @@ public class AccountsApiResource { @Path("{accountId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String handleCommands(@PathParam("type") final String accountType, @PathParam("accountId") final Long accountId, @QueryParam("command") final String commandParam, - final String apiRequestBodyAsJson) { + @ApiOperation(value = "Approve share application | Undo approval share application | Reject share application | Activate a share account | Close a share account | Apply additional shares on a share account | Approve additional shares request on a share account | Reject additional shares request on a share account | Redeem shares on a share account", httpMethod = "POST", notes = "Approve share application:\n\n" + "Approves share application so long as its in 'Submitted and pending approval' state.\n\n" + "Undo approval share application:\n\n" + "Will move 'approved' share application back to 'Submitted and pending approval' state.\n\n" + "Reject share application:\n\n" + "Rejects share application so long as its in 'Submitted and pending approval' state.\n\n" + "Activate a share account:\n\n" + "Results in an approved share application being converted into an 'active' share account.\n\n" + "Close a share account:\n\n" + "Results in an Activated share application being converted into an 'closed' share account.\n" + "\n" + "closedDate is closure date of share account\n\n" + "Mandatory Fields: dateFormat,locale,closedDate\n\n" + "Apply additional shares on a share account:\n\n" + "requestedDate is requsted date of share purchase\n" + "\n" + "requestedShares is number of shares to be purchase\n\n" + "Mandatory Fields: dateFormat,locale,requestedDate, requestedShares\n\n" + "Approve additional shares request on a share account\n\n" + "requestedShares is Share purchase transaction ids\n\n" + "Mandatory Fields: requestedShares\n\n" + "Reject additional shares request on a share account:\n\n" + "requestedShares is Share purchase transaction ids\n\n" + "Mandatory Fields: requestedShares\n\n" + "Redeem shares on a share account:\n\n" + "Results redeem some/all shares from share account.\n" + "\n" + "requestedDate is requsted date of shares redeem\n" + "\n" + "requestedShares is number of shares to be redeemed\n\n" + "Mandatory Fields: dateFormat,locale,requestedDate,requestedShares\n\n" + "Showing request/response for 'Reject additional shares request on a share account'\n\n" + "For more info visit this link - https://demo.openmf.org/api-docs/apiLive.htm#shareaccounts") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = AccountsApiResourceSwagger.PostAccountsTypeAccountIdRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = AccountsApiResourceSwagger.PostAccountsTypeAccountIdResponse.class)}) + public String handleCommands(@PathParam("type") @ApiParam(value = "type") final String accountType, @PathParam("accountId") @ApiParam(value = "accountId") final Long accountId, @QueryParam("command") @ApiParam(value = "command") final String commandParam, + @ApiParam(hidden = true) final String apiRequestBodyAsJson) { CommandWrapper commandWrapper = null; this.platformSecurityContext.authenticatedUser(); commandWrapper = new CommandWrapperBuilder().createAccountCommand(accountType, accountId, commandParam).withJson(apiRequestBodyAsJson).build(); @@ -153,7 +160,10 @@ public class AccountsApiResource { @Path("{accountId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String updateAccount(@PathParam("type") final String accountType, @PathParam("accountId") final Long accountId, final String apiRequestBodyAsJson) { + @ApiOperation(value = "Modify a share application", httpMethod = "PUT", notes = "Share application can only be modified when in 'Submitted and pending approval' state. Once the application is approved, the details cannot be changed using this method. Specific api endpoints will be created to allow change of interest detail such as rate, compounding period, posting period etc") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = AccountsApiResourceSwagger.PutAccountsTypeAccountIdRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = AccountsApiResourceSwagger.PutAccountsTypeAccountIdResponse.class)}) + public String updateAccount(@PathParam("type") @ApiParam(value = "type") final String accountType, @PathParam("accountId") @ApiParam(value = "accountId") final Long accountId, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { this.platformSecurityContext.authenticatedUser(); final CommandWrapper commandRequest = new CommandWrapperBuilder().updateAccount(accountType, accountId) .withJson(apiRequestBodyAsJson).build(); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/api/AccountsApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/api/AccountsApiResourceSwagger.java new file mode 100644 index 000000000..bafb26106 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/api/AccountsApiResourceSwagger.java @@ -0,0 +1,529 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.accounts.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.time.LocalDate; +import java.util.List; +import java.util.Set; + +/** + * Created by Chirag Gupta on 12/20/17. + */ +final class AccountsApiResourceSwagger { + private AccountsApiResourceSwagger() { + } + + @ApiModel(value = "GetAccountsTypeTemplateResponse") + public final static class GetAccountsTypeTemplateResponse { + private GetAccountsTypeTemplateResponse() { + } + + final class GetAccountsTypeProductOptions { + private GetAccountsTypeProductOptions() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "Share Product") + public String name; + @ApiModelProperty(example = "SP") + public String shortName; + @ApiModelProperty(example = "100") + public Long totalShares; + } + + @ApiModelProperty(example = "7") + public Integer clientId; + @ApiModelProperty(example = "Client Name") + public String clientName; + public Set productOptions; + } + + @ApiModel(value = "GetAccountsTypeAccountIdResponse") + public final static class GetAccountsTypeAccountIdResponse { + private GetAccountsTypeAccountIdResponse() { + } + + final class GetAccountsStatus { + private GetAccountsStatus() { + } + + @ApiModelProperty(example = "300") + public Integer id; + @ApiModelProperty(example = "shareAccountStatusType.active") + public String code; + @ApiModelProperty(example = "Active") + public String value; + @ApiModelProperty(example = "false") + public Boolean submittedAndPendingApproval; + @ApiModelProperty(example = "false") + public Boolean approved; + @ApiModelProperty(example = "false") + public Boolean rejected; + @ApiModelProperty(example = "true") + public Boolean active; + @ApiModelProperty(example = "false") + public Boolean closed; + } + + final class GetAccountsTimeline { + private GetAccountsTimeline() { + } + + @ApiModelProperty(example = "[2016, 4, 1]") + public LocalDate submittedOnDate; + @ApiModelProperty(example = "mifos") + public String submittedByUsername; + @ApiModelProperty(example = "App") + public String submittedByFirstname; + @ApiModelProperty(example = "Administrator") + public String submittedByLastname; + @ApiModelProperty(example = "[2016, 4, 1]") + public LocalDate approvedDate; + @ApiModelProperty(example = "mifos") + public String approvedByUsername; + @ApiModelProperty(example = "App") + public String approvedByFirstname; + @ApiModelProperty(example = "Administrator") + public String approvedByLastname; + @ApiModelProperty(example = "[2016, 4, 1]") + public LocalDate activatedDate; + } + + final class GetAccountsCurrency { + private GetAccountsCurrency() { + } + + @ApiModelProperty(example = "USD") + public String code; + @ApiModelProperty(example = "US Dollar") + public String name; + @ApiModelProperty(example = "2") + public Integer decimalPlaces; + @ApiModelProperty(example = "100") + public Integer inMultiplesOf; + @ApiModelProperty(example = "$") + public String displaySymbol; + @ApiModelProperty(example = "currency.USD") + public String nameCode; + @ApiModelProperty(example = "US Dollar ($)") + public String displayLabel; + } + + final class GetAccountsSummary { + private GetAccountsSummary() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "000000002") + public Long accountNo; + @ApiModelProperty(example = "1") + public Integer totalApprovedShares; + @ApiModelProperty(example = "0") + public Integer totalPendingForApprovalShares; + @ApiModelProperty(example = "1") + public Integer productId; + @ApiModelProperty(example = "Conflux Share Product") + public String productName; + public GetAccountsStatus status; + public GetAccountsTimeline timeline; + public GetAccountsCurrency currency; + } + + final class GetAccountsPurchasedShares { + private GetAccountsPurchasedShares() { + } + + final class GetAccountsPurchasedSharesStatus { + private GetAccountsPurchasedSharesStatus() { + } + + @ApiModelProperty(example = "300") + public Integer id; + @ApiModelProperty(example = "purchasedSharesStatusType.approved") + public String code; + @ApiModelProperty(example = "Approved") + public String value; + } + + final class GetAccountsPurchasedSharesType { + private GetAccountsPurchasedSharesType() { + } + + @ApiModelProperty(example = "500") + public Integer id; + @ApiModelProperty(example = "purchasedSharesType.purchased") + public String code; + @ApiModelProperty(example = "Purchase") + public String value; + } + + @ApiModelProperty(example = "6") + public Integer id; + @ApiModelProperty(example = "2") + public Integer accountId; + @ApiModelProperty(example = "[2016, 4, 1]") + public LocalDate purchasedDate; + @ApiModelProperty(example = "10") + public Integer numberOfShares; + @ApiModelProperty(example = "0.5") + public Double purchasedPrice; + public GetAccountsPurchasedSharesStatus status; + public GetAccountsPurchasedSharesType type; + @ApiModelProperty(example = "5.05") + public Double amount; + @ApiModelProperty(example = "0.05") + public Double chargeAmount; + @ApiModelProperty(example = "5.05") + public Double amountPaid; + } + + final class GetAccountsLockPeriodTypeEnum { + private GetAccountsLockPeriodTypeEnum() { + } + + @ApiModelProperty(example = "0") + public Integer id; + @ApiModelProperty(example = "savings.lockin.sharePeriodFrequencyType.days") + public String code; + @ApiModelProperty(example = "Days") + public String value; + } + + final class GetAccountsCharges { + private GetAccountsCharges() { + } + + final class GetAccountsChargeTimeType { + private GetAccountsChargeTimeType() { + } + + @ApiModelProperty(example = "13") + public Integer id; + @ApiModelProperty(example = "chargeTimeType.activation") + public String code; + @ApiModelProperty(example = "Share Account Activate") + public String value; + } + + final class GetAccountsChargeCalculationType { + private GetAccountsChargeCalculationType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "chargeCalculationType.flat") + public String code; + @ApiModelProperty(example = "Flat") + public String value; + } + + final class GetAccountsChargesCurrency { + private GetAccountsChargesCurrency() { + } + + @ApiModelProperty(example = "USD") + public String code; + @ApiModelProperty(example = "US Dollar") + public String name; + @ApiModelProperty(example = "2") + public Integer decimalPlaces; + @ApiModelProperty(example = "$") + public String displaySymbol; + @ApiModelProperty(example = "currency.USD") + public String nameCode; + @ApiModelProperty(example = "US Dollar ($)") + public String displayLabel; + } + + @ApiModelProperty(example = "9") + public Integer id; + @ApiModelProperty(example = "20") + public Integer chargeId; + @ApiModelProperty(example = "2") + public Integer accountId; + @ApiModelProperty(example = "Share Account Activation Flat") + public String name; + public GetAccountsChargeTimeType chargeTimeType; + public GetAccountsChargeCalculationType chargeCalculationType; + @ApiModelProperty(example = "0") + public Double percentage; + @ApiModelProperty(example = "0") + public Double amountPercentageAppliedTo; + public GetAccountsChargesCurrency currency; + @ApiModelProperty(example = "1") + public Float amount; + @ApiModelProperty(example = "1") + public Float amountPaid; + @ApiModelProperty(example = "0") + public Float amountWaived; + @ApiModelProperty(example = "0") + public Float amountWrittenOff; + @ApiModelProperty(example = "0") + public Float amountOutstanding; + @ApiModelProperty(example = "1") + public Float amountOrPercentage; + @ApiModelProperty(example = "true") + public Boolean isActive; + } + + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "000000002") + public Long accountNo; + @ApiModelProperty(example = "000000013") + public Long savingsAccountNumber; + @ApiModelProperty(example = "7") + public Integer clientId; + @ApiModelProperty(example = "Client_FirstName_2KX8C Client_LastName_NWNG") + public String clientName; + @ApiModelProperty(example = "1") + public Integer productId; + @ApiModelProperty(example = "Share Product") + public String productName; + public GetAccountsStatus status; + public GetAccountsTimeline timeline; + public GetAccountsCurrency currency; + public GetAccountsSummary summary; + public Set purchasedShares; + @ApiModelProperty(example = "13") + public Integer savingsAccountId; + @ApiModelProperty(example = "5") + public Integer currentMarketPrice; + @ApiModelProperty(example = "1") + public Integer lockinPeriod; + public GetAccountsLockPeriodTypeEnum lockPeriodTypeEnum; + @ApiModelProperty(example = "1") + public Integer minimumActivePeriod; + public GetAccountsLockPeriodTypeEnum minimumActivePeriodTypeEnum; + @ApiModelProperty(example = "true") + public Boolean allowDividendCalculationForInactiveClients; + public Set charges; + @ApiModelProperty(example = "") + public List dividends; + } + + @ApiModel(value = "GetAccountsTypeResponse") + public final static class GetAccountsTypeResponse { + private GetAccountsTypeResponse() { + } + + final class GetAccountsPageItems { + private GetAccountsPageItems() { + } + + final class GetAccountsTypeStatus { + private GetAccountsTypeStatus() { + } + + @ApiModelProperty(example = "100") + public Integer id; + @ApiModelProperty(example = "shareAccountStatusType.submitted.and.pending.approval") + public String code; + @ApiModelProperty(example = "Submitted and pending approval") + public String value; + @ApiModelProperty(example = "true") + public Boolean submittedAndPendingApproval; + @ApiModelProperty(example = "false") + public Boolean approved; + @ApiModelProperty(example = "false") + public Boolean rejected; + @ApiModelProperty(example = "false") + public Boolean active; + @ApiModelProperty(example = "false") + public Boolean closed; + } + + final class GetAccountsTypeTimeline { + private GetAccountsTypeTimeline() { + } + + @ApiModelProperty(example = "[2013, 3, 1]") + public LocalDate submittedOnDate; + } + + final class GetAccountsTypePurchasedShares { + private GetAccountsTypePurchasedShares() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "01 May 2013") + public String purchasedDate; + @ApiModelProperty(example = "10") + public Integer numberOfShares; + @ApiModelProperty(example = "5") + public Integer purchasedPrice; + } + + final class GetAccountsTypeSummary { + private GetAccountsTypeSummary() { + } + + public GetAccountsTypeAccountIdResponse.GetAccountsCharges.GetAccountsChargesCurrency currency; + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "000000001") + public Long accountNo; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "Client Name") + public String clientName; + @ApiModelProperty(example = "1") + public Integer productId; + @ApiModelProperty(example = "Share Product Name") + public String productName; + public GetAccountsTypeStatus status; + public GetAccountsTypeTimeline timeline; + public GetAccountsTypeAccountIdResponse.GetAccountsCharges.GetAccountsChargesCurrency currency; + public Set purchasedShares; + public GetAccountsTypeSummary summary; + } + + @ApiModelProperty(example = "1") + public Integer totalFilteredRecords; + public Set pageItems; + } + + @ApiModel(value = "PostAccountsTypeRequest") + public final static class PostAccountsTypeRequest { + private PostAccountsTypeRequest() { + } + + final class PostAccountsCharges { + private PostAccountsCharges() { + } + + @ApiModelProperty(example = "20") + public Integer chargeId; + @ApiModelProperty(example = "1") + public Integer amount; + } + + @ApiModelProperty(example = "7") + public Integer clientId; + @ApiModelProperty(example = "1") + public Integer productId; + @ApiModelProperty(example = "100") + public Integer requestedShares; + @ApiModelProperty(example = "1") + public Integer externalId; + @ApiModelProperty(example = "01 May 2016") + public String submittedDate; + @ApiModelProperty(example = "1") + public Integer minimumActivePeriod; + @ApiModelProperty(example = "0") + public Integer minimumActivePeriodFrequencyType; + @ApiModelProperty(example = "1") + public Integer lockinPeriodFrequency; + @ApiModelProperty(example = "0") + public Integer lockinPeriodFrequencyType; + @ApiModelProperty(example = "01 May 2016") + public String applicationDate; + @ApiModelProperty(example = "true") + public Boolean allowDividendCalculationForInactiveClients; + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "dd MMMM yyyy") + public String dateFormat; + public Set charges; + @ApiModelProperty(example = "13") + public Integer savingsAccountId; + } + + @ApiModel(value = "PostAccountsTypeResponse") + public final static class PostAccountsTypeResponse { + private PostAccountsTypeResponse() { + } + + @ApiModelProperty(example = "1") + public Integer resourceId; + } + + @ApiModel(value = "PostAccountsTypeAccountIdRequest") + public final static class PostAccountsTypeAccountIdRequest { + private PostAccountsTypeAccountIdRequest() { + } + + final class PostAccountsRequestedShares { + private PostAccountsRequestedShares() { + } + + @ApiModelProperty(example = "35") + public Integer id; + } + + public Set requestedShares; + } + + @ApiModel(value = "PostAccountsTypeAccountIdResponse") + public final static class PostAccountsTypeAccountIdResponse { + private PostAccountsTypeAccountIdResponse() { + } + + @ApiModelProperty(example = "5") + public Integer resourceId; + } + + @ApiModel(value = "PutAccountsTypeAccountIdRequest") + public final static class PutAccountsTypeAccountIdRequest { + private PutAccountsTypeAccountIdRequest() { + } + + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "dd MMMM yyyy") + public String dateFormat; + @ApiModelProperty(example = "01 April 2016") + public String applicationDate; + @ApiModelProperty(example = "20") + public Integer requestedShares; + } + + @ApiModel(value = "PutAccountsTypeAccountIdResponse") + public final static class PutAccountsTypeAccountIdResponse { + private PutAccountsTypeAccountIdResponse() { + } + + final class PutAccountsChanges { + private PutAccountsChanges() { + } + + @ApiModelProperty(example = "dd MMMM yyyy") + public String dateFormat; + @ApiModelProperty(example = "01 April 2016") + public String applicationDate; + @ApiModelProperty(example = "20") + public Integer requestedShares; + @ApiModelProperty(example = "en") + public String locale; + } + + @ApiModelProperty(example = "1") + public Integer resourceId; + public PutAccountsChanges changes; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/address/api/EntityFieldConfigurationApiResources.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/address/api/EntityFieldConfigurationApiResources.java index 838e419fe..830557340 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/address/api/EntityFieldConfigurationApiResources.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/address/api/EntityFieldConfigurationApiResources.java @@ -18,40 +18,32 @@ */ package org.apache.fineract.portfolio.address.api; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriInfo; - -import org.apache.fineract.commands.domain.CommandWrapper; -import org.apache.fineract.commands.service.CommandWrapperBuilder; +import io.swagger.annotations.*; import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService; import org.apache.fineract.infrastructure.core.api.ApiRequestParameterHelper; -import org.apache.fineract.infrastructure.core.data.CommandProcessingResult; import org.apache.fineract.infrastructure.core.serialization.ApiRequestJsonSerializationSettings; import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSerializer; import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; import org.apache.fineract.portfolio.address.data.AddressData; import org.apache.fineract.portfolio.address.data.FieldConfigurationData; -import org.apache.fineract.portfolio.address.service.AddressReadPlatformServiceImpl; import org.apache.fineract.portfolio.address.service.FieldConfigurationReadPlatformService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + @Path("/fieldconfiguration/{entity}") @Component @Scope("singleton") +@Api(value = "Entity Field Configuration", description = "Entity Field configuration API is a generic and extensible \n" + "wherein various entities and subentities can be related.\n" + "Also it gives the user an ability to enable/disable fields,\n" + "add regular expression for validation") public class EntityFieldConfigurationApiResources { private final Set RESPONSE_DATA_PARAMETERS = new HashSet<>(Arrays.asList("clientAddressId", "client_id", @@ -83,7 +75,9 @@ public class EntityFieldConfigurationApiResources { @GET @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String getAddresses(@PathParam("entity") final String entityname, @Context final UriInfo uriInfo) { + @ApiOperation(httpMethod = "GET", value = "Retrieves the Entity Field Configuration", notes = "It retrieves all the Entity Field Configuration") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = EntityFieldConfigurationApiResourcesSwagger.GetFieldConfigurationEntityResponse.class, responseContainer = "List")}) + public String getAddresses(@PathParam("entity") @ApiParam(value = "entity") final String entityname, @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions); final Collection fldconfig = this.readPlatformServicefld diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/address/api/EntityFieldConfigurationApiResourcesSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/address/api/EntityFieldConfigurationApiResourcesSwagger.java new file mode 100644 index 000000000..9fb071469 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/address/api/EntityFieldConfigurationApiResourcesSwagger.java @@ -0,0 +1,52 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.address.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +/** + * Created by Chirag Gupta on 12/01/17. + */ +final class EntityFieldConfigurationApiResourcesSwagger { + private EntityFieldConfigurationApiResourcesSwagger() { + } + + @ApiModel(value = "GetFieldConfigurationEntityResponse") + public static final class GetFieldConfigurationEntityResponse { + private GetFieldConfigurationEntityResponse() { + } + + @ApiModelProperty(example = "1") + public Integer fieldConfigurationId; + @ApiModelProperty(example = "ADDRESS") + public String entity; + @ApiModelProperty(example = "CLIENT") + public String subentity; + @ApiModelProperty(example = "addressType") + public String field; + @ApiModelProperty(example = "true") + public String is_enabled; + @ApiModelProperty(example = "false") + public String is_mandatory; + @ApiModelProperty(example = " ") + public String validation_regex; + } +} + diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/charge/api/ChargesApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/charge/api/ChargesApiResource.java index eef68b3aa..3b115ad4f 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/charge/api/ChargesApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/charge/api/ChargesApiResource.java @@ -18,23 +18,7 @@ */ package org.apache.fineract.portfolio.charge.api; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriInfo; - +import io.swagger.annotations.*; import org.apache.fineract.commands.domain.CommandWrapper; import org.apache.fineract.commands.service.CommandWrapperBuilder; import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService; @@ -49,9 +33,19 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + @Path("/charges") @Component @Scope("singleton") +@Api(value = "Charges", description = "Its typical for MFIs to add extra costs for their financial products. These are typically Fees or Penalties.\n" + "\n" + "A Charge on fineract platform is what we use to model both Fees and Penalties.\n" + "\n" + "At present we support defining charges for use with Client accounts and both loan and saving products.") public class ChargesApiResource { private final Set CHARGES_DATA_PARAMETERS = new HashSet<>(Arrays.asList("id", "name", "amount", "currency", "penalty", "active", @@ -82,6 +76,8 @@ public class ChargesApiResource { @GET @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) + @ApiOperation(value = "Retrieve Charges", httpMethod = "GET", notes = "Returns the list of defined charges.\n" + "\n" + "Example Requests:\n" + "\n" + "charges") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ChargesApiResourceSwagger.GetChargesResponse.class, responseContainer = "List")}) public String retrieveAllCharges(@Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions); @@ -96,7 +92,9 @@ public class ChargesApiResource { @Path("{chargeId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveCharge(@PathParam("chargeId") final Long chargeId, @Context final UriInfo uriInfo) { + @ApiOperation(value = "Retrieve a Charge", httpMethod = "GET", notes = "Returns the details of a defined Charge.\n" + "\n" + "Example Requests:\n" + "\n" + "charges/1") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ChargesApiResourceSwagger.GetChargesResponse.class)}) + public String retrieveCharge(@PathParam("chargeId") @ApiParam(value = "chargeId") final Long chargeId, @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions); @@ -115,6 +113,8 @@ public class ChargesApiResource { @Path("template") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) + @ApiOperation(value = "Retrieve Charge Template", httpMethod = "GET", notes = "This is a convenience resource. It can be useful when building maintenance user interface screens for client applications. The template data returned consists of any or all of:\n" + "\n" + "Field Defaults\n" + "Allowed Value Lists\n" + "Example Request:\n" + "\n" + "charges/template\n") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ChargesApiResourceSwagger.GetChargesTemplateResponse.class)}) public String retrieveNewChargeDetails(@Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions); @@ -128,7 +128,10 @@ public class ChargesApiResource { @POST @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String createCharge(final String apiRequestBodyAsJson) { + @ApiOperation(value = "Create/Define a Charge", httpMethod = "POST", notes = "Define a new charge that can later be associated with loans and savings through their respective product definitions or directly on each account instance.") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = ChargesApiResourceSwagger.PostChargesRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ChargesApiResourceSwagger.PostChargesResponse.class)}) + public String createCharge(@ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder().createCharge().withJson(apiRequestBodyAsJson).build(); @@ -141,7 +144,10 @@ public class ChargesApiResource { @Path("{chargeId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String updateCharge(@PathParam("chargeId") final Long chargeId, final String apiRequestBodyAsJson) { + @ApiOperation(value = "Update a Charge", httpMethod = "PUT", notes = "Updates the details of a Charge.") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = ChargesApiResourceSwagger.PutChargesChargeIdRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ChargesApiResourceSwagger.PutChargesChargeIdResponse.class)}) + public String updateCharge(@PathParam("chargeId") @ApiParam(value = "chargeId") final Long chargeId, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder().updateCharge(chargeId).withJson(apiRequestBodyAsJson).build(); @@ -154,7 +160,9 @@ public class ChargesApiResource { @Path("{chargeId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String deleteCharge(@PathParam("chargeId") final Long chargeId) { + @ApiOperation(value = "Delete a Charge", httpMethod = "DELETE", notes = "Deletes a Charge.") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ChargesApiResourceSwagger.DeleteChargesChargeIdResponse.class)}) + public String deleteCharge(@PathParam("chargeId") @ApiParam(value = "chargeId") final Long chargeId) { final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteCharge(chargeId).build(); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/charge/api/ChargesApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/charge/api/ChargesApiResourceSwagger.java new file mode 100644 index 000000000..39abd4fa2 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/charge/api/ChargesApiResourceSwagger.java @@ -0,0 +1,230 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.charge.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Set; + +/** + * Created by Chirag Gupta on 12/01/17. + */ +final class ChargesApiResourceSwagger { + + @ApiModel(value = "GetChargesResponse") + public static final class GetChargesResponse { + private GetChargesResponse() { + } + + final class GetChargesCurrencyResponse { + @ApiModelProperty(example = "USD") + public String code; + @ApiModelProperty(example = "US Dollar") + public String name; + @ApiModelProperty(example = "2") + public Integer decimalPlaces; + @ApiModelProperty(example = "$") + public String displaySymbol; + @ApiModelProperty(example = "currency.USD") + public String nameCode; + @ApiModelProperty(example = "US Dollar ($)") + public String displayLabel; + } + + final class GetChargesTimeTypeResponse { + private GetChargesTimeTypeResponse() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "chargeTimeType.disbursement") + public String code; + @ApiModelProperty(example = "Disbursement") + public String value; + } + + final class GetChargesAppliesToResponse { + private GetChargesAppliesToResponse() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "chargeAppliesTo.loan") + public String code; + @ApiModelProperty(example = "Loan") + public String value; + } + + final class GetChargesCalculationTypeResponse { + private GetChargesCalculationTypeResponse() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "chargeCalculationType.flat") + public String code; + @ApiModelProperty(example = "Flat") + public String value; + } + + final class GetChargesPaymentModeResponse { + private GetChargesPaymentModeResponse() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "chargepaymentmode.accounttransfer") + public String code; + @ApiModelProperty(example = "Account Transfer") + public String value; + } + + @ApiModelProperty(example = "1") + public Long id; + @ApiModelProperty(example = "Loan Service fee") + public String name; + @ApiModelProperty(example = "true") + public String active; + @ApiModelProperty(example = "false") + public String penalty; + public GetChargesCurrencyResponse currency; + @ApiModelProperty(example = "230.56") + public Float amount; + public GetChargesTimeTypeResponse chargeTimeType; + public GetChargesAppliesToResponse chargeAppliesTo; + public GetChargesCalculationTypeResponse chargeCalculationType; + public GetChargesPaymentModeResponse chargePaymentMode; + } + + @ApiModel(value = "PostChargesRequest") + public static final class PostChargesRequest { + private PostChargesRequest() { + } + + @ApiModelProperty(example = "Loan Service fee") + public String name; + @ApiModelProperty(example = "1") + public Integer chargeAppliesTo; + @ApiModelProperty(example = "USD") + public String currencyCode; + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "230.56") + public Float amount; + @ApiModelProperty(example = "1") + public Integer chargeTimeType; + @ApiModelProperty(example = "1") + public Integer chargeCalculationType; + @ApiModelProperty(example = "1") + public Integer chargePaymentMode; + @ApiModelProperty(example = "true") + public String active; + } + + @ApiModel(value = "PostChargesResponse") + public static final class PostChargesResponse { + private PostChargesResponse() { + } + + @ApiModelProperty(example = "1") + public Integer resourceId; + } + + @ApiModel(value = "PutChargesChargeIdRequest") + public static final class PutChargesChargeIdRequest { + private PutChargesChargeIdRequest() { + } + + @ApiModelProperty(example = "Loan service fee(changed)") + public String name; + } + + @ApiModel(value = "PutChargesChargeIdResponse") + public static final class PutChargesChargeIdResponse { + private PutChargesChargeIdResponse() { + } + + @ApiModelProperty(example = "1") + public Integer resourceId; + public PutChargesChargeIdRequest changes; + } + + @ApiModel(value = "DeleteChargesChargeIdResponse") + public static final class DeleteChargesChargeIdResponse { + private DeleteChargesChargeIdResponse() { + } + + @ApiModelProperty(example = "1") + public Integer resourceId; + } + + @ApiModel(value = "GetChargesTemplateResponse") + public static final class GetChargesTemplateResponse { + private GetChargesTemplateResponse() { + } + + final class GetChargesTemplateLoanChargeCalculationTypeOptions { + private GetChargesTemplateLoanChargeCalculationTypeOptions() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "chargeCalculationType.flat") + public String code; + @ApiModelProperty(example = "Flat") + public String value; + } + + final class GetChargesTemplateLoanChargeTimeTypeOptions { + private GetChargesTemplateLoanChargeTimeTypeOptions() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "chargeTimeType.specifiedDueDate") + public String code; + @ApiModelProperty(example = "Specified due date") + public String value; + } + final class GetChargesTemplateFeeFrequencyOptions{ + private GetChargesTemplateFeeFrequencyOptions(){} + @ApiModelProperty(example = "0") + public Integer id; + @ApiModelProperty(example = "loanTermFrequency.periodFrequencyType.days") + public String code; + @ApiModelProperty(example = "Days") + public String value; + } + @ApiModelProperty(example = "false") + public String active; + @ApiModelProperty(example = "false") + public String penalty; + public Set currencyOptions; + public Set chargeCalculationTypeOptions; + public Set chargeAppliesToOptions; + public Set chargeTimeTypeOptions; + public Set chargePaymentModeOptions; + public Set loanChargeCalculationTypeOptions; + public Set loanChargeTimeTypeOptions; + public Set savingsChargeCalculationTypeOptions; + public Set savingsChargeTimeTypeOptions; + public Set feeFrequencyOptions; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientAddressApiResources.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientAddressApiResources.java index d4eb074ac..b0f675363 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientAddressApiResources.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientAddressApiResources.java @@ -18,23 +18,6 @@ */ package org.apache.fineract.portfolio.client.api; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriInfo; - import io.swagger.annotations.*; import org.apache.fineract.commands.domain.CommandWrapper; import org.apache.fineract.commands.service.CommandWrapperBuilder; @@ -46,12 +29,19 @@ import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSer import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; import org.apache.fineract.portfolio.address.data.AddressData; import org.apache.fineract.portfolio.address.service.AddressReadPlatformServiceImpl; -import org.apache.fineract.portfolio.client.data.ClientApiCollectionConstants; -import org.apache.fineract.portfolio.client.data.ClientData; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + @Path("/client") @Component @Scope("singleton") @@ -102,9 +92,10 @@ public class ClientAddressApiResources { @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) @ApiOperation(value = "Create an address for a Client", notes = "Mandatory Fields : \n" + "type and clientId") - @ApiResponses(value = { @ApiResponse(code = 200, message = "", response = CommandProcessingResult.class) }) - public String AddClientAddress(@QueryParam("type") final long addressTypeId, - @PathParam("clientid") final long clientid, final String apiRequestBodyAsJson) { + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = ClientAddressApiResourcesSwagger.PostClientClientIdAddressesRequest.class)}) + @ApiResponses({ @ApiResponse(code = 200, message = "OK", response = ClientAddressApiResourcesSwagger.PostClientClientIdAddressesResponse.class)}) + public String AddClientAddress(@QueryParam("type") @ApiParam(value = "type") final long addressTypeId, + @PathParam("clientid") @ApiParam(value = "clientId") final long clientid, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder().addClientAddress(clientid, addressTypeId) .withJson(apiRequestBodyAsJson).build(); @@ -119,9 +110,9 @@ public class ClientAddressApiResources { @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) @ApiOperation(value = "List all addresses for a Client", notes = "Example Requests:\n" + "\n" +"client/1/addresses\n" + "\n" + "\n" +"clients/1/addresses?status=false,true&&type=1,2,3" ) - @ApiResponses({@ApiResponse(code = 200, message = "", response = AddressData.class)}) - public String getAddresses(@QueryParam("status") final String status, @QueryParam("type") final long addressTypeId, - @PathParam("clientid") final long clientid, @Context final UriInfo uriInfo) { + @ApiResponses({@ApiResponse(code = 200, message = "OK", responseContainer = "List", response = ClientAddressApiResourcesSwagger.GetClientClientIdAddressesResponse.class)}) + public String getAddresses(@QueryParam("status") @ApiParam(value = "status") final String status, @QueryParam("type") @ApiParam(value = "type") final long addressTypeId, + @PathParam("clientid") @ApiParam(value = "clientId") final long clientid, @Context final UriInfo uriInfo) { Collection address; this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions); @@ -146,10 +137,10 @@ public class ClientAddressApiResources { @Path("/{clientid}/addresses") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - @ApiOperation(value = "update an address for a Client", notes = "All the address fields can be updated by using update client address API\n" + "\n" + "Mandatory Fields\n" + "type and addressId") - @ApiImplicitParams({@ApiImplicitParam(value = "body", dataType = "body", dataTypeClass = ClientApiConstants.class)}) - @ApiResponses(value = { @ApiResponse(code = 200, message = "", response = CommandProcessingResult.class) }) - public String UpdateClientAddress(@PathParam("clientid") final long clientid, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { + @ApiOperation(value = "Update an address for a Client", notes = "All the address fields can be updated by using update client address API\n" + "\n" + "Mandatory Fields\n" + "type and addressId") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = ClientAddressApiResourcesSwagger.PutClientClientIdAddressesRequest.class)}) + @ApiResponses(value = { @ApiResponse(code = 200, message = "OK", response = ClientAddressApiResourcesSwagger.PutClientClientIdAddressesResponse.class)}) + public String UpdateClientAddress(@PathParam("clientid") @ApiParam(value = "clientId") final long clientid, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder().updateClientAddress(clientid) .withJson(apiRequestBodyAsJson).build(); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientAddressApiResourcesSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientAddressApiResourcesSwagger.java new file mode 100644 index 000000000..8db0c8250 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientAddressApiResourcesSwagger.java @@ -0,0 +1,127 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.client.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +/** + * Created by Chirag Gupta on 01/12/18. + */ +final class ClientAddressApiResourcesSwagger { + private ClientAddressApiResourcesSwagger() { + } + + @ApiModel(value = "PostClientClientIdAddressesRequest") + public final static class PostClientClientIdAddressesRequest { + private PostClientClientIdAddressesRequest() { + } + + @ApiModelProperty(example = "Ipca") + public String street; + @ApiModelProperty(example = "Kandivali") + public String addressLine1; + @ApiModelProperty(example = "plot47") + public String addressLine2; + @ApiModelProperty(example = "charkop") + public String addressLine3; + @ApiModelProperty(example = "Mumbai") + public String city; + @ApiModelProperty(example = "800") + public Integer stateProvinceId; + @ApiModelProperty(example = "802") + public Integer countryId; + @ApiModelProperty(example = "400064") + public Long postalCode; + } + + @ApiModel(value = "PostClientClientIdAddressesResponse") + public final static class PostClientClientIdAddressesResponse { + private PostClientClientIdAddressesResponse() { + } + + @ApiModelProperty(example = "15") + public Integer resourceId; + } + + @ApiModel(value = "GetClientClientIdAddressesResponse") + public final static class GetClientClientIdAddressesResponse { + private GetClientClientIdAddressesResponse() { + } + + @ApiModelProperty(example = "111755") + public Long client_id; + @ApiModelProperty(example = "PERMANENT ADDRESS") + public String addressType; + @ApiModelProperty(example = "14") + public Integer addressId; + @ApiModelProperty(example = "804") + public Integer addressTypeId; + @ApiModelProperty(example = "false") + public Boolean isActive; + @ApiModelProperty(example = "anki's home") + public String street; + @ApiModelProperty(example = "test123") + public String addressLine1; + @ApiModelProperty(example = "iuyt") + public String addressLine2; + @ApiModelProperty(example = " ") + public String addressLine3; + @ApiModelProperty(example = " ") + public String townVillage; + @ApiModelProperty(example = "mumbai") + public String city; + @ApiModelProperty(example = " ") + public String countyDistrict; + @ApiModelProperty(example = "801") + public Integer stateProvinceId; + @ApiModelProperty(example = "UNITED STATES") + public String countryName; + @ApiModelProperty(example = "GUJRAT") + public String stateName; + @ApiModelProperty(example = "807") + public Integer countryId; + @ApiModelProperty(example = "400095") + public Long postalCode; + @ApiModelProperty(example = " ") + public String createdBy; + @ApiModelProperty(example = " ") + public String updatedBy; + } + + @ApiModel(value = "PutClientClientIdAddressesRequest") + public final static class PutClientClientIdAddressesRequest { + private PutClientClientIdAddressesRequest() { + } + + @ApiModelProperty(example = "67") + public Integer addressId; + @ApiModelProperty(example = "goldensource") + public String street; + } + + @ApiModel(value = "PutClientClientIdAddressesResponse") + public final static class PutClientClientIdAddressesResponse { + private PutClientClientIdAddressesResponse() { + } + + @ApiModelProperty(example = "67") + public Integer resourceId; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientChargesApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientChargesApiResource.java index 8baf881cc..4ccf4f2cd 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientChargesApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientChargesApiResource.java @@ -18,23 +18,6 @@ */ package org.apache.fineract.portfolio.client.api; -import java.util.Arrays; -import java.util.Collection; -import java.util.Set; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriInfo; - import io.swagger.annotations.*; import org.apache.commons.lang.StringUtils; import org.apache.fineract.commands.domain.CommandWrapper; @@ -52,15 +35,21 @@ import org.apache.fineract.infrastructure.security.service.PlatformSecurityConte import org.apache.fineract.portfolio.charge.data.ChargeData; import org.apache.fineract.portfolio.charge.service.ChargeReadPlatformService; import org.apache.fineract.portfolio.client.data.ClientChargeData; -import org.apache.fineract.portfolio.client.data.ClientData; import org.apache.fineract.portfolio.client.data.ClientTransactionData; -import org.apache.fineract.portfolio.client.domain.ClientCharge; import org.apache.fineract.portfolio.client.service.ClientChargeReadPlatformService; import org.apache.fineract.portfolio.client.service.ClientTransactionReadPlatformService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; +import java.util.Arrays; +import java.util.Collection; +import java.util.Set; + @Path("/clients/{clientId}/charges") @Component @Api(value = "Client Charges", description = "It is typical for MFI's to directly associate charges with an implicit Client account. These can be either fees or penalties\n" + "\n" + "Client Charges are client specific instances of Charges. Refer Charges for documentation of the various properties of a charge, Only additional properties ( specific to the context of a Charge being associated with a Client account) are described here") @@ -94,11 +83,11 @@ public class ClientChargesApiResource { @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) @ApiOperation(value = "List Client Charges", notes = "The list capability of client charges supports pagination." + "Example Requests:\n" + "clients/1/charges\n" + "\nclients/1/charges?offset=0&limit=5" ) - @ApiResponses(value = { @ApiResponse(code = 200, message = "", response = ClientCharge.class) }) - public String retrieveAllClientCharges(@PathParam("clientId") final Long clientId, - @DefaultValue(ClientApiConstants.CLIENT_CHARGE_QUERY_PARAM_STATUS_VALUE_ALL) @QueryParam(ClientApiConstants.CLIENT_CHARGE_QUERY_PARAM_STATUS) final String chargeStatus, - @QueryParam("pendingPayment") final Boolean pendingPayment, @Context final UriInfo uriInfo, - @QueryParam("limit") final Integer limit, @QueryParam("offset") final Integer offset) { + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ClientChargesApiResourceSwagger.GetClientsClientIdChargesResponse.class) }) + public String retrieveAllClientCharges(@PathParam("clientId") @ApiParam(value = "clientId") final Long clientId, + @DefaultValue(ClientApiConstants.CLIENT_CHARGE_QUERY_PARAM_STATUS_VALUE_ALL) @QueryParam(ClientApiConstants.CLIENT_CHARGE_QUERY_PARAM_STATUS) @ApiParam(value = "chargeStatus") final String chargeStatus, + @QueryParam("pendingPayment") @ApiParam(value = "pendingPayment") final Boolean pendingPayment, @Context final UriInfo uriInfo, + @QueryParam("limit") @ApiParam(value = "limit") final Integer limit, @QueryParam("offset") @ApiParam(value = "offset") final Integer offset) { this.context.authenticatedUser().validateHasReadPermission(ClientApiConstants.CLIENT_CHARGES_RESOURCE_NAME); final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); if (!(is(chargeStatus, ClientApiConstants.CLIENT_CHARGE_QUERY_PARAM_STATUS_VALUE_ALL) @@ -141,8 +130,8 @@ public class ClientChargesApiResource { @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) @ApiOperation(value = "Retrieve a Client Charge", notes = "Example Requests:\n" + "clients/1/charges/1\n" + "\n" + "\n" + "clients/1/charges/1?fields=name,id" ) - @ApiResponses(value = { @ApiResponse(code = 200, message = "", response = ClientChargeData.class) }) - public String retrieveClientCharge(@PathParam("clientId") final Long clientId, @PathParam("chargeId") final Long chargeId, + @ApiResponses({@ApiResponse(code = 200, message = "", response = ClientChargesApiResourceSwagger.GetClientsClientIdChargesResponse.GetClientsChargesPageItems.class) }) + public String retrieveClientCharge(@PathParam("clientId") @ApiParam(value = "clientId") final Long clientId, @PathParam("chargeId") @ApiParam(value = "chargeId") final Long chargeId, @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(ClientApiConstants.CLIENT_CHARGES_RESOURCE_NAME); @@ -170,9 +159,9 @@ public class ClientChargesApiResource { @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) @ApiOperation(value = "Add Client Charge", notes = " This API associates a Client charge with an implicit Client account\n" + "Mandatory Fields : \n" + "chargeId and dueDate \n" + "Optional Fields : \n" + "amount" ) - @ApiImplicitParams({@ApiImplicitParam(value = "body", dataType = "body", dataTypeClass = ClientData.class )}) - @ApiResponses(value = { @ApiResponse(code = 200, message = "", response = CommandProcessingResult.class) }) - public String applyClientCharge(@PathParam("clientId") final Long clientId, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = ClientChargesApiResourceSwagger.PostClientsClientIdChargesRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "", response = ClientChargesApiResourceSwagger.PostClientsClientIdChargesResponse.class) }) + public String applyClientCharge(@PathParam("clientId") @ApiParam(value = "clientId") final Long clientId, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder().createClientCharge(clientId).withJson(apiRequestBodyAsJson) .build(); @@ -186,9 +175,11 @@ public class ClientChargesApiResource { @Path("{chargeId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - @ApiOperation(value = "Pay a Client Charge", notes = "Mandatory Fields\n" + "transactionDate and amount " + "" + "\"Pay either a part of or the entire due amount for a charge.(command=paycharge)\n" + "\n" + "Waive a Client Charge\n" + "\n" + "\n" + "This API provides the facility of waiving off the remaining amount on a client charge (command=waive)\n" ) - public String payOrWaiveClientCharge(@PathParam("clientId") final Long clientId, @PathParam("chargeId") final Long chargeId, - @QueryParam("command") final String commandParam, final String apiRequestBodyAsJson) { + @ApiOperation(value = "Pay a Client Charge | Waive a Client Charge", notes = "Pay a Client Charge:\n\n" + "Mandatory Fields:" + "transactionDate and amount " + "" + "\"Pay either a part of or the entire due amount for a charge.(command=paycharge)\n" + "\n" + "Waive a Client Charge:\n" + "\n" + "\n" + "This API provides the facility of waiving off the remaining amount on a client charge (command=waive)\n\n" + "Showing request/response for 'Pay a Client Charge'" ) + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = ClientChargesApiResourceSwagger.PostClientsClientIdChargesChargeIdRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ClientChargesApiResourceSwagger.PostClientsClientIdChargesChargeIdResponse.class)}) + public String payOrWaiveClientCharge(@PathParam("clientId") @ApiParam(value = "clientId") final Long clientId, @PathParam("chargeId") @ApiParam(value = "chargeId") final Long chargeId, + @QueryParam("command") @ApiParam(value = "command") final String commandParam, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { String json = ""; if (is(commandParam, ClientApiConstants.CLIENT_CHARGE_COMMAND_WAIVE_CHARGE)) { @@ -224,8 +215,8 @@ public class ClientChargesApiResource { @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) @ApiOperation(value = "Delete a Client Charge", notes = "Deletes a Client Charge on which no transactions have taken place (either payments or waivers). ") - @ApiResponses({@ApiResponse(code = 200, message = "", response = CommandProcessingResult.class)}) - public String deleteClientCharge(@PathParam("clientId") final Long clientId, @PathParam("chargeId") final Long chargeId) { + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ClientChargesApiResourceSwagger.DeleteClientsClientIdChargesChargeIdResponse.class)}) + public String deleteClientCharge(@PathParam("clientId") @ApiParam(value = "clientId") final Long clientId, @PathParam("chargeId") @ApiParam(value = "chargeId") final Long chargeId) { final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteClientCharge(clientId, chargeId).build(); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientChargesApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientChargesApiResourceSwagger.java new file mode 100644 index 000000000..7239dac31 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientChargesApiResourceSwagger.java @@ -0,0 +1,196 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.client.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.math.BigDecimal; +import java.time.LocalDate; +import java.util.Set; + +/** + * Created by Chirag Gupta on 01/12/18. + */ +final class ClientChargesApiResourceSwagger { + private ClientChargesApiResourceSwagger() { + } + + @ApiModel(value = "GetClientsClientIdChargesResponse") + public final static class GetClientsClientIdChargesResponse { + private GetClientsClientIdChargesResponse() { + } + + final class GetClientsChargesPageItems { + private GetClientsChargesPageItems() { + } + + final class GetClientChargeTimeType { + private GetClientChargeTimeType() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "chargeTimeType.specifiedDueDate") + public String code; + @ApiModelProperty(example = "Specified due date") + public String value; + } + + final class GetClientChargeCalculationType { + private GetClientChargeCalculationType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "chargeCalculationType.flat") + public String code; + @ApiModelProperty(example = "Flat") + public String value; + } + + final class GetClientChargeCurrency { + private GetClientChargeCurrency() { + } + + @ApiModelProperty(example = "USD") + public String code; + @ApiModelProperty(example = "US Dollar") + public String name; + @ApiModelProperty(example = "2") + public Integer decimalPlaces; + @ApiModelProperty(example = "$") + public String displaySymbol; + @ApiModelProperty(example = "currency.USD") + public String nameCode; + @ApiModelProperty(example = "US Dollar ($)") + public String displayLabel; + } + + @ApiModelProperty(example = "3") + public Integer id; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "5") + public Integer chargeId; + @ApiModelProperty(example = "Client Fee 1") + public String name; + public GetClientChargeTimeType chargeTimeType; + @ApiModelProperty(example = "[2015, 8, 17]") + public LocalDate dueDate; + public GetClientChargeCalculationType chargeCalculationType; + public GetClientChargeCurrency currency; + @ApiModelProperty(example = "100.000000") + public BigDecimal amount; + @ApiModelProperty(example = "0") + public BigDecimal amountPaid; + @ApiModelProperty(example = "100.000000") + public BigDecimal amountWaived; + @ApiModelProperty(example = "0") + public BigDecimal amountWrittenOff; + @ApiModelProperty(example = "0.000000") + public BigDecimal amountOutstanding; + @ApiModelProperty(example = "true") + public Boolean penalty; + @ApiModelProperty(example = "true") + public Boolean isActive; + @ApiModelProperty(example = "false") + public Boolean isPaid; + @ApiModelProperty(example = "true") + public Boolean isWaived; + } + + @ApiModelProperty(example = "4") + public Integer totalFilteredRecords; + public Set pageItems; + } + + @ApiModel(value = "PostClientsClientIdChargesRequest") + public final static class PostClientsClientIdChargesRequest { + private PostClientsClientIdChargesRequest() { + } + + @ApiModelProperty(example = "100") + public Integer amount; + @ApiModelProperty(example = "226") + public Integer chargeId; + @ApiModelProperty(example = "dd MMMM yyyy") + public String dateFormat; + @ApiModelProperty(example = "01 September 2015") + public String dueDate; + @ApiModelProperty(example = "en") + public String locale; + } + + @ApiModel(value = "PostClientsClientIdChargesResponse") + public final static class PostClientsClientIdChargesResponse { + private PostClientsClientIdChargesResponse() { + } + + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "189") + public Integer chargeId; + @ApiModelProperty(example = "164") + public Integer resourceId; + } + + @ApiModel(value = "PostClientsClientIdChargesChargeIdRequest") + public final static class PostClientsClientIdChargesChargeIdRequest { + private PostClientsClientIdChargesChargeIdRequest() { + } + + @ApiModelProperty(example = "200") + public Integer amount; + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "dd MMMM yyyy") + public String dateFormat; + @ApiModelProperty(example = "01 September 2015") + public String transactionDate; + } + + @ApiModel(value = "PostClientsClientIdChargesChargeIdResponse") + public final static class PostClientsClientIdChargesChargeIdResponse { + private PostClientsClientIdChargesChargeIdResponse() { + } + + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "189") + public Integer clientId; + @ApiModelProperty(example = "157") + public Integer resourceId; + @ApiModelProperty(example = "221") + public Integer transactionId; + } + + @ApiModel(value = "DeleteClientsClientIdChargesChargeIdResponse") + public final static class DeleteClientsClientIdChargesChargeIdResponse { + private DeleteClientsClientIdChargesChargeIdResponse() { + } + + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "189") + public Integer clientId; + @ApiModelProperty(example = "164") + public Integer resourceId; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientIdentifiersApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientIdentifiersApiResource.java index 96c30ea32..cb28f5789 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientIdentifiersApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientIdentifiersApiResource.java @@ -18,23 +18,6 @@ */ package org.apache.fineract.portfolio.client.api; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriInfo; - import io.swagger.annotations.*; import org.apache.fineract.commands.domain.CommandWrapper; import org.apache.fineract.commands.service.CommandWrapperBuilder; @@ -48,7 +31,6 @@ import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSer import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; import org.apache.fineract.portfolio.client.data.ClientData; import org.apache.fineract.portfolio.client.data.ClientIdentifierData; -import org.apache.fineract.portfolio.client.domain.ClientIdentifier; import org.apache.fineract.portfolio.client.exception.DuplicateClientIdentifierException; import org.apache.fineract.portfolio.client.service.ClientIdentifierReadPlatformService; import org.apache.fineract.portfolio.client.service.ClientReadPlatformService; @@ -56,10 +38,19 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + @Path("/clients/{clientId}/identifiers") @Component @Scope("singleton") -@Api(value = "Client Identifier Api", description = "Client Identifiers refer to documents that are used to uniquely identify a customer\n" + "Ex: Drivers License, Passport, Ration card etc ") +@Api(value = "Client Identifier", description = "Client Identifiers refer to documents that are used to uniquely identify a customer\n" + "Ex: Drivers License, Passport, Ration card etc ") public class ClientIdentifiersApiResource { private static final Set CLIENT_IDENTIFIER_DATA_PARAMETERS = new HashSet<>(Arrays.asList("id", "clientId", @@ -95,8 +86,8 @@ public class ClientIdentifiersApiResource { @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) @ApiOperation(value = "List all Identifiers for a Client", notes = "Example Requests:\n" + "clients/1/identifiers\n" + "\n" + "\n" + "clients/1/identifiers?fields=documentKey,documentType,description") - @ApiResponses({@ApiResponse(code = 200, message = "", response = ClientIdentifierData.class)}) - public String retrieveAllClientIdentifiers(@Context final UriInfo uriInfo, @PathParam("clientId") final Long clientId) { + @ApiResponses({@ApiResponse(code = 200, message = "OK", responseContainer = "List", response = ClientIdentifiersApiResourceSwagger.GetClientsClientIdIdentifiersResponse.class)}) + public String retrieveAllClientIdentifiers(@Context final UriInfo uriInfo, @PathParam("clientId") @ApiParam(value = "clientId") final Long clientId) { this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions); @@ -112,7 +103,7 @@ public class ClientIdentifiersApiResource { @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) @ApiOperation(value = "Retrieve Client Identifier Details Template", notes = "This is a convenience resource useful for building maintenance user interface screens for client applications. The template data returned consists of any or all of:\n" + "\n" + " Field Defaults\n" + " Allowed Value Lists\n" + "\n\nExample Request:\n" + "clients/1/identifiers/template" ) - @ApiResponses({@ApiResponse(code = 200, message = "", response = ClientIdentifierData.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ClientIdentifiersApiResourceSwagger.GetClientsClientIdIdentifiersTemplateResponse.class)}) public String newClientIdentifierDetails(@Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions); @@ -128,9 +119,9 @@ public class ClientIdentifiersApiResource { @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) @ApiOperation(value = "Create an Identifier for a Client", notes = "Mandatory Fields\n" + "documentKey, documentTypeId " ) - @ApiImplicitParams({@ApiImplicitParam(value = "body", dataType = "body", dataTypeClass = ClientData.class)}) - @ApiResponses({@ApiResponse(code = 200, message = "", response = CommandProcessingResult.class)}) - public String createClientIdentifier(@PathParam("clientId") final Long clientId, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = ClientIdentifiersApiResourceSwagger.PostClientsClientIdIdentifiersRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ClientIdentifiersApiResourceSwagger.PostClientsClientIdIdentifiersResponse.class)}) + public String createClientIdentifier(@PathParam("clientId") @ApiParam(value = "clientId") final Long clientId, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { try { final CommandWrapper commandRequest = new CommandWrapperBuilder().createClientIdentifier(clientId) @@ -157,9 +148,9 @@ public class ClientIdentifiersApiResource { @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) @ApiOperation(value = "Retrieve a Client Identifier", notes = "Example Requests:\n" + "clients/1/identifier/2\n" + "\n" + "\n" + "clients/1/identifier/2?template=true\n" + "\n" + "clients/1/identifiers/2?fields=documentKey,documentType,description" ) - @ApiResponses({@ApiResponse(code = 200, message = "", response = ClientIdentifierData.class)}) - public String retrieveClientIdentifiers(@PathParam("clientId") final Long clientId, - @PathParam("identifierId") final Long clientIdentifierId, @Context final UriInfo uriInfo) { + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ClientIdentifiersApiResourceSwagger.GetClientsClientIdIdentifiersResponse.class)}) + public String retrieveClientIdentifiers(@PathParam("clientId") @ApiParam(value = "clientId") final Long clientId, + @PathParam("identifierId") @ApiParam(value = "identifierId") final Long clientIdentifierId, @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions); @@ -179,11 +170,11 @@ public class ClientIdentifiersApiResource { @Path("{identifierId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - @ApiOperation(value = "Update a Client Identifier") - @ApiImplicitParams({@ApiImplicitParam(value = "body", dataType = "body", dataTypeClass = ClientData.class)}) - @ApiResponses({@ApiResponse(code = 200, message = "", response = CommandProcessingResult.class)}) - public String updateClientIdentifer(@PathParam("clientId") final Long clientId, - @PathParam("identifierId") final Long clientIdentifierId, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { + @ApiOperation(value = "Update a Client Identifier", notes = "Updates a Client Identifier") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = ClientIdentifiersApiResourceSwagger.PutClientsClientIdIdentifiersIdentifierIdRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ClientIdentifiersApiResourceSwagger.PutClientsClientIdIdentifiersIdentifierIdResponse.class)}) + public String updateClientIdentifer(@PathParam("clientId") @ApiParam(value = "clientId") final Long clientId, + @PathParam("identifierId") @ApiParam(value = "identifierId") final Long clientIdentifierId, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { try { final CommandWrapper commandRequest = new CommandWrapperBuilder().updateClientIdentifier(clientId, clientIdentifierId) @@ -208,10 +199,10 @@ public class ClientIdentifiersApiResource { @Path("{identifierId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - @ApiOperation(value = "Delete a Client Identifier") - @ApiResponses({@ApiResponse(code = 200, message = "", response = CommandProcessingResult.class)}) - public String deleteClientIdentifier(@PathParam("clientId") final Long clientId, - @PathParam("identifierId") final Long clientIdentifierId) { + @ApiOperation(value = "Delete a Client Identifier", notes = "Deletes a Client Identifier") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ClientIdentifiersApiResourceSwagger.DeleteClientsClientIdIdentifiersIdentifierIdResponse.class)}) + public String deleteClientIdentifier(@PathParam("clientId") @ApiParam(value = "clientId") final Long clientId, + @PathParam("identifierId") @ApiParam(value = "identifierId") final Long clientIdentifierId) { final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteClientIdentifier(clientId, clientIdentifierId).build(); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientIdentifiersApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientIdentifiersApiResourceSwagger.java new file mode 100644 index 000000000..c55970917 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientIdentifiersApiResourceSwagger.java @@ -0,0 +1,144 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.client.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Set; + +/** + * Created by Chirag Gupta on 01/13/18. + */ +final class ClientIdentifiersApiResourceSwagger { + private ClientIdentifiersApiResourceSwagger() { + } + + @ApiModel(value = "GetClientsClientIdIdentifiersResponse") + public final static class GetClientsClientIdIdentifiersResponse { + private GetClientsClientIdIdentifiersResponse() { + } + + final class GetClientsDocumentType { + private GetClientsDocumentType() { + } + + @ApiModelProperty(example = "3") + public Integer id; + @ApiModelProperty(example = "Drivers License") + public String name; + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "1") + public Integer clientId; + public GetClientsDocumentType documentType; + @ApiModelProperty(example = "12345") + public String documentKey; + @ApiModelProperty(example = "Issued in the year 2--7") + public String description; + } + + @ApiModel(value = "GetClientsClientIdIdentifiersTemplateResponse") + public final static class GetClientsClientIdIdentifiersTemplateResponse { + private GetClientsClientIdIdentifiersTemplateResponse() { + } + + final class GetClientsAllowedDocumentTypes { + private GetClientsAllowedDocumentTypes() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "Passport") + public String name; + @ApiModelProperty(example = "0") + public Integer position; + } + + public Set allowedDocumentTypes; + } + + @ApiModel(value = "PostClientsClientIdIdentifiersRequest") + public final static class PostClientsClientIdIdentifiersRequest { + private PostClientsClientIdIdentifiersRequest() { + } + + @ApiModelProperty(example = "1") + public Integer documentTypeId; + @ApiModelProperty(example = "KA-54677") + public String documentKey; + @ApiModelProperty(example = "Document has been verified") + public String description; + } + + @ApiModel(value = "PutClientsClientIdIdentifiersIdentifierIdRequest") + public final static class PutClientsClientIdIdentifiersIdentifierIdRequest { + private PutClientsClientIdIdentifiersIdentifierIdRequest() { + } + + @ApiModelProperty(example = "4") + public Integer documentTypeId; + @ApiModelProperty(example = "KA-94667") + public String documentKey; + @ApiModelProperty(example = "Document has been updated") + public String description; + } + + @ApiModel(value = "PutClientsClientIdIdentifiersIdentifierIdResponse") + public final static class PutClientsClientIdIdentifiersIdentifierIdResponse { + private PutClientsClientIdIdentifiersIdentifierIdResponse() { + } + + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "3") + public Integer resourceId; + public PutClientsClientIdIdentifiersIdentifierIdRequest changes; + } + + @ApiModel(value = "PostClientsClientIdIdentifiersResponse") + public final static class PostClientsClientIdIdentifiersResponse { + private PostClientsClientIdIdentifiersResponse() { + } + + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "3") + public Integer resourceId; + } + + @ApiModel(value = "DeleteClientsClientIdIdentifiersIdentifierIdResponse") + public final static class DeleteClientsClientIdIdentifiersIdentifierIdResponse { + private DeleteClientsClientIdIdentifiersIdentifierIdResponse() { + } + + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "3") + public Integer resourceId; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientTransactionsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientTransactionsApiResource.java index ddcc76ee3..196cb5afa 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientTransactionsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientTransactionsApiResource.java @@ -18,17 +18,6 @@ */ package org.apache.fineract.portfolio.client.api; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriInfo; - import io.swagger.annotations.*; import org.apache.commons.lang.StringUtils; import org.apache.fineract.commands.domain.CommandWrapper; @@ -42,13 +31,16 @@ import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSer import org.apache.fineract.infrastructure.core.service.Page; import org.apache.fineract.infrastructure.core.service.SearchParameters; import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; -import org.apache.fineract.portfolio.client.data.ClientData; import org.apache.fineract.portfolio.client.data.ClientTransactionData; -import org.apache.fineract.portfolio.client.domain.ClientTransaction; import org.apache.fineract.portfolio.client.service.ClientTransactionReadPlatformService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; + @Path("/clients/{clientId}/transactions") @Component @Api(value = "Client Transaction", description = "Client Transactions refer to transactions made directly againt a Client's internal account. Currently, these transactions are only created as a result of charge payments/waivers. You are allowed to undo a transaction, however you cannot explicitly create one. ") @@ -76,10 +68,10 @@ public class ClientTransactionsApiResource { @GET @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - @ApiOperation(value = "List Client Transactions", notes = "The list capability of client transaction can support pagination." + "\n\nMandatory Arguments : " + "offset\n" + " Integer Mandatory, defaults to 0 \n" + " Indicates the result from which pagination starts\n" + "limit\n" + " Integer Mandatory, defaults to 200 \n" + " Restricts the size of results returned. To override the default and return all entries you must explicitly pass a non-positive integer value for limit e.g. limit=0, or limit=-1\n" + "\n" + "\n\n" + "Example Requests:\n" + "clients/189/transactions\n" + "clients/189/transactions?offset=10&limit=50" ) - @ApiResponses({@ApiResponse(code = 200, message = "", response = ClientTransactionData.class)}) - public String retrieveAllClientTransactions(@PathParam("clientId") final Long clientId, @Context final UriInfo uriInfo, - @QueryParam("offset") final Integer offset, @QueryParam("limit") final Integer limit) { + @ApiOperation(value = "List Client Transactions", notes = "The list capability of client transaction can support pagination." + "\n\n" + "Example Requests:\n\n" + "clients/189/transactions\n\n" + "clients/189/transactions?offset=10&limit=50" ) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ClientTransactionsApiResourceSwagger.GetClientsClientIdTransactionsResponse.class)}) + public String retrieveAllClientTransactions(@PathParam("clientId") @ApiParam(value = "clientId") final Long clientId, @Context final UriInfo uriInfo, + @QueryParam("offset") @ApiParam(value = "offset") final Integer offset, @QueryParam("limit") @ApiParam(value = "limit") final Integer limit) { this.context.authenticatedUser().validateHasReadPermission(ClientApiConstants.CLIENT_CHARGES_RESOURCE_NAME); SearchParameters searchParameters = SearchParameters.forPagination(offset, limit); @@ -96,9 +88,9 @@ public class ClientTransactionsApiResource { @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) @ApiOperation(value = "Retrieve a Client Transaction", notes = "Example Requests:\n" + "clients/1/transactions/1\n" + "\n" + "\n" + "clients/1/transactions/1?fields=id,officeName" ) - @ApiResponses({@ApiResponse(code = 200, message = "", response = ClientTransactionData.class)}) - public String retrieveClientTransaction(@PathParam("clientId") final Long clientId, - @PathParam("transactionId") final Long transactionId, @Context final UriInfo uriInfo) { + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ClientTransactionsApiResourceSwagger.GetClientsClientIdTransactionsTransactionIdResponse.class)}) + public String retrieveClientTransaction(@PathParam("clientId") @ApiParam(value = "clientId") final Long clientId, + @PathParam("transactionId") @ApiParam(value = "transactionId") final Long transactionId, @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(ClientApiConstants.CLIENT_CHARGES_RESOURCE_NAME); @@ -114,11 +106,10 @@ public class ClientTransactionsApiResource { @Path("{transactionId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - @ApiOperation(value = "Undo a Client Transaction") - @ApiImplicitParams({@ApiImplicitParam(value = "body", dataType = "body", dataTypeClass = ClientData.class)}) - @ApiResponses({@ApiResponse(code = 200, message = "", response = CommandProcessingResult.class)}) - public String undoClientTransaction(@PathParam("clientId") final Long clientId, @PathParam("transactionId") final Long transactionId, - @QueryParam("command") final String commandParam, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { + @ApiOperation(value = "Undo a Client Transaction", notes = "Undoes a Client Transaction") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ClientTransactionsApiResourceSwagger.PostClientsClientIdTransactionsTransactionIdResponse.class)}) + public String undoClientTransaction(@PathParam("clientId") @ApiParam(value = "clientId") final Long clientId, @PathParam("transactionId") @ApiParam(value = "transactionId") final Long transactionId, + @QueryParam("command") @ApiParam(value = "command") final String commandParam, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { String json = ""; if (is(commandParam, ClientApiConstants.CLIENT_TRANSACTION_COMMAND_UNDO)) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientTransactionsApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientTransactionsApiResourceSwagger.java new file mode 100644 index 000000000..c8ef2ff48 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientTransactionsApiResourceSwagger.java @@ -0,0 +1,133 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.client.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.math.BigDecimal; +import java.time.LocalDate; +import java.util.Set; + +/** + * Created by Chirag Gupta on 01/13/18. + */ +final class ClientTransactionsApiResourceSwagger { + private ClientTransactionsApiResourceSwagger() { + } + + @ApiModel(value = "GetClientsClientIdTransactionsResponse") + public final static class GetClientsClientIdTransactionsResponse { + private GetClientsClientIdTransactionsResponse() { + } + + final class GetClientsPageItems { + private GetClientsPageItems() { + } + + final class GetClientsClientIdTransactionsType { + private GetClientsClientIdTransactionsType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "clientTransactionType.payCharge") + public String code; + @ApiModelProperty(example = "PAY_CHARGE") + public String value; + } + + final class GetClientTransactionsCurrency { + private GetClientTransactionsCurrency() { + } + + @ApiModelProperty(example = "USD") + public String code; + @ApiModelProperty(example = "US Dollar") + public String name; + @ApiModelProperty(example = "2") + public Integer decimalPlaces; + @ApiModelProperty(example = "$") + public String displaySymbol; + @ApiModelProperty(example = "currency.USD") + public String nameCode; + @ApiModelProperty(example = "US Dollar ($)") + public String displayLabel; + } + + @ApiModelProperty(example = "226") + public Integer id; + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "Head Office") + public String officeName; + public GetClientsClientIdTransactionsType type; + @ApiModelProperty(example = "[2015, 9, 2]") + public LocalDate date; + public GetClientTransactionsCurrency currency; + @ApiModelProperty(example = "22") + public Double amount; + @ApiModelProperty(example = "[2015, 9, 2]") + public LocalDate submittedOnDate; + @ApiModelProperty(example = "false") + public Boolean reversed; + } + + @ApiModelProperty(example = "20") + public Integer totalFilteredRecords; + public Set pageItems; + } + + @ApiModel(value = "GetClientsClientIdTransactionsTransactionIdResponse") + public final static class GetClientsClientIdTransactionsTransactionIdResponse { + private GetClientsClientIdTransactionsTransactionIdResponse() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "Head Office") + public String officeName; + public GetClientsClientIdTransactionsResponse.GetClientsPageItems.GetClientsClientIdTransactionsType type; + @ApiModelProperty(example = "[2015, 8, 17]") + public LocalDate date; + public GetClientsClientIdTransactionsResponse.GetClientsPageItems.GetClientTransactionsCurrency currency; + @ApiModelProperty(example = "60.000000") + public BigDecimal amount; + @ApiModelProperty(example = "[2015, 8, 17]") + public LocalDate submittedOnDate; + @ApiModelProperty(example = "true") + public Boolean reversed; + } + + + @ApiModel(value = "PostClientsClientIdTransactionsTransactionIdResponse") + public final static class PostClientsClientIdTransactionsTransactionIdResponse { + private PostClientsClientIdTransactionsTransactionIdResponse() { + } + + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "189") + public Integer clientId; + @ApiModelProperty(example = "222") + public Integer resourceId; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientsApiResource.java index a457bca73..b5786cfcf 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientsApiResource.java @@ -18,26 +18,6 @@ */ package org.apache.fineract.portfolio.client.api; -import java.lang.reflect.Array; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriInfo; - import io.swagger.annotations.*; import org.apache.commons.lang.StringUtils; import org.apache.fineract.commands.domain.CommandWrapper; @@ -61,10 +41,19 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + @Path("/clients") @Component @Scope("singleton") -@Api(value = "Client Api", description = "Clients are people and businesses that have applied (or may apply) to an MFI for loans.\n" + "\n" + "Clients can be created in Pending or straight into Active state.") +@Api(value = "Client", description = "Clients are people and businesses that have applied (or may apply) to an MFI for loans.\n" + "\n" + "Clients can be created in Pending or straight into Active state.") public class ClientsApiResource { private final PlatformSecurityContext context; @@ -98,11 +87,10 @@ public class ClientsApiResource { @Path("template") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - @ApiOperation(value = "Retrieve Client Details Template", notes = "This is a convenience resource. It can be useful when building maintenance user interface screens for client applications. The template data returned consists of any or all of:\n" + "\n" + "Field Defaults\n" + "Allowed Value Lists" + "Example Request:\n" + "\n" + "clients/template") - @ApiResponses(value = { @ApiResponse(code = 200, message = "", response = ClientData.class) }) - public String retrieveTemplate(@Context final UriInfo uriInfo, @ApiParam(value = "optional") @QueryParam("officeId") final Long officeId, - @ApiParam(value = "optional If commandParam=close retrieves all closureReasons which are associated with \"ClientClosureReason\" value.", defaultValue = "false") @QueryParam("commandParam") final String commandParam, - @DefaultValue("false") @ApiParam(value = "optional Defaults to false if not provided. If staffInSelectedOfficeOnly=true only staff who are associated with the selected branch are returned.") @QueryParam("staffInSelectedOfficeOnly") final boolean staffInSelectedOfficeOnly) { + @ApiOperation(value = "Retrieve Client Details Template", notes = "This is a convenience resource. It can be useful when building maintenance user interface screens for client applications. The template data returned consists of any or all of:\n" + "\n" + "Field Defaults\n" + "Allowed Value Lists\n\n" + "Example Request:\n" + "\n" + "clients/template") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ClientsApiResourceSwagger.GetClientsTemplateResponse.class)}) + public String retrieveTemplate(@Context final UriInfo uriInfo, @ApiParam(value = "officeId") @QueryParam("officeId") final Long officeId, @QueryParam("commandParam") @ApiParam(value = "commandParam") final String commandParam, + @DefaultValue("false") @QueryParam("staffInSelectedOfficeOnly") @ApiParam(value = "staffInSelectedOfficeOnly")final boolean staffInSelectedOfficeOnly) { this.context.authenticatedUser().validateHasReadPermission(ClientApiConstants.CLIENT_RESOURCE_NAME); @@ -127,16 +115,15 @@ public class ClientsApiResource { @GET @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - @ApiOperation(value = "List Clients", - notes = "Example Requests:\n" + "\n" + "clients\n" + "\n" + "clients?fields=displayName,officeName,timeline\n" + "\n" + "clients?offset=10&limit=50\n" + "\n" + "clients?orderBy=displayName&sortOrder=DESC" ) - @ApiResponses({@ApiResponse(code = 200, message = "", response = ClientData.class)}) - public String retrieveAll(@Context final UriInfo uriInfo, @QueryParam("sqlSearch") final String sqlSearch, - @QueryParam("officeId") final Long officeId, @QueryParam("externalId") final String externalId, - @QueryParam("displayName") final String displayName, @QueryParam("firstName") final String firstname, - @QueryParam("lastName") final String lastname, @QueryParam("underHierarchy") final String hierarchy, - @QueryParam("offset") final Integer offset, @QueryParam("limit") final Integer limit, - @QueryParam("orderBy") final String orderBy, @QueryParam("sortOrder") final String sortOrder, - @QueryParam("orphansOnly") final Boolean orphansOnly) { + @ApiOperation(value = "List Clients", notes = "The list capability of clients can support pagination and sorting.\n\n" + "Example Requests:\n" + "\n" + "clients\n" + "\n" + "clients?fields=displayName,officeName,timeline\n" + "\n" + "clients?offset=10&limit=50\n" + "\n" + "clients?orderBy=displayName&sortOrder=DESC" ) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ClientsApiResourceSwagger.GetClientsResponse.class)}) + public String retrieveAll(@Context final UriInfo uriInfo, @QueryParam("sqlSearch") @ApiParam(value = "sqlSearch") final String sqlSearch, + @QueryParam("officeId") @ApiParam(value = "officeId") final Long officeId, @QueryParam("externalId") @ApiParam(value = "externalId") final String externalId, + @QueryParam("displayName") @ApiParam(value = "displayName") final String displayName, @QueryParam("firstName") @ApiParam(value = "firstName") final String firstname, + @QueryParam("lastName") @ApiParam(value = "lastName") final String lastname, @QueryParam("underHierarchy") @ApiParam(value = "underHierarchy") final String hierarchy, + @QueryParam("offset") @ApiParam(value = "offset") final Integer offset, @QueryParam("limit") @ApiParam(value = "limit") final Integer limit, + @QueryParam("orderBy") @ApiParam(value = "orderBy") final String orderBy, @QueryParam("sortOrder") @ApiParam(value = "sortOrder") final String sortOrder, + @QueryParam("orphansOnly") @ApiParam(value = "orphansOnly") final Boolean orphansOnly) { return this.retrieveAll(uriInfo, sqlSearch, officeId, externalId, displayName, firstname, lastname, hierarchy, offset, limit, orderBy, sortOrder, orphansOnly, false); @@ -166,9 +153,9 @@ public class ClientsApiResource { @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) @ApiOperation(value = "Retrieve a Client", notes = "Example Requests:\n" + "\n" + "clients/1\n" +"\n" + "\n" + "clients/1?template=true\n" + "\n" + "\n" + "clients/1?fields=id,displayName,officeName" ) - @ApiResponses({@ApiResponse(code = 200, message = "", response = ClientData.class)}) - public String retrieveOne(@PathParam("clientId") final Long clientId, @Context final UriInfo uriInfo, - @DefaultValue("false") @QueryParam("staffInSelectedOfficeOnly") final boolean staffInSelectedOfficeOnly) { + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ClientsApiResourceSwagger.GetClientsClientIdResponse.class)}) + public String retrieveOne(@PathParam("clientId") @ApiParam(value = "clientId") final Long clientId, @Context final UriInfo uriInfo, + @DefaultValue("false") @QueryParam("staffInSelectedOfficeOnly") @ApiParam(value = "staffInSelectedOfficeOnly") final boolean staffInSelectedOfficeOnly) { this.context.authenticatedUser().validateHasReadPermission(ClientApiConstants.CLIENT_RESOURCE_NAME); @@ -191,9 +178,9 @@ public class ClientsApiResource { @POST @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - @ApiOperation(value = "Create a Client", httpMethod = "POST", notes = "Note:" + "\n" + "1. You can enter either:firstname/middlename/lastname - for a person (middlename is optional) OR fullname - for a business or organisation (or person known by one name).\n" + "\n" + "2.If address is enable(enable-address=true), then additional field called address has to be passed.", response = CommandProcessingResult.class, consumes="application/json") - @ApiImplicitParams({@ApiImplicitParam( paramType = "body", dataType = "ClientData", required = true, type = "body", dataTypeClass = ClientData.class)}) - @ApiResponses(value = { @ApiResponse(code = 200, message = "Successfully Client Created", response = CommandProcessingResult.class) }) + @ApiOperation(value = "Create a Client", httpMethod = "POST", notes = "Note:\n\n" + "1. You can enter either:firstname/middlename/lastname - for a person (middlename is optional) OR fullname - for a business or organisation (or person known by one name).\n" + "\n" + "2.If address is enable(enable-address=true), then additional field called address has to be passed.\n\n" + "Mandatory Fields: firstname and lastname OR fullname, officeId, active=true and activationDate OR active=false, if(address enabled) address\n\n" + "Optional Fields: groupId, externalId, accountNo, staffId, mobileNo, savingsProductId, genderId, clientTypeId, clientClassificationId") + @ApiImplicitParams({@ApiImplicitParam(paramType = "body", dataType = "ClientData", required = true, type = "body", dataTypeClass = ClientsApiResourceSwagger.PostClientsRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ClientsApiResourceSwagger.PostClientsResponse.class) }) public String create(@ApiParam(hidden = true) final String apiRequestBodyAsJson) { @@ -211,10 +198,10 @@ public class ClientsApiResource { @Path("{clientId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - @ApiOperation(value = "Update a Client", notes = "You can update any of the basic attributes of a client (but not its associations) using this API.\n" + "\n" + "Changing the relationship between a client and its office is not supported through this API. An API specific to handling transfers of clients between offices is available for the same.\n" + "\n" + "The relationship between a client and a group must be removed through the Groups API." ) - @ApiImplicitParams({@ApiImplicitParam( paramType = "body", dataType = "ClientData", required = true, type = "body", dataTypeClass = ClientData.class)}) - @ApiResponses(value = { @ApiResponse(code = 200, message = "", response = CommandProcessingResult.class) }) - public String update(@ApiParam(value = "ClientId") @PathParam("clientId") final Long clientId, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { + @ApiOperation(value = "Update a Client", notes = "Note: You can update any of the basic attributes of a client (but not its associations) using this API.\n" + "\n" + "Changing the relationship between a client and its office is not supported through this API. An API specific to handling transfers of clients between offices is available for the same.\n" + "\n" + "The relationship between a client and a group must be removed through the Groups API." ) + @ApiImplicitParams({@ApiImplicitParam( paramType = "body", dataType = "ClientData", required = true, type = "body", dataTypeClass = ClientsApiResourceSwagger.PutClientsClientIdRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ClientsApiResourceSwagger.PutClientsClientIdResponse.class) }) + public String update(@ApiParam(value = "clientId") @PathParam("clientId") final Long clientId, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder() // .updateClient(clientId) // @@ -231,8 +218,9 @@ public class ClientsApiResource { @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) @ApiOperation(value = "Delete a Client", notes = "If a client is in Pending state, you are allowed to Delete it. The delete is a 'hard delete' and cannot be recovered from. Once clients become active or have loans or savings associated with them, you cannot delete the client but you may Close the client if they have left the program.") - @ApiResponses(value = {@ApiResponse(code = 200, message = "", response = CommandProcessingResult.class) }) - public String delete(@PathParam("clientId") final Long clientId) { + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = ClientsApiResourceSwagger.DeleteClientsClientIdRequest.class)}) + @ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = ClientsApiResourceSwagger.DeleteClientsClientIdResponse.class) }) + public String delete(@PathParam("clientId") @ApiParam(value = "clientId") final Long clientId) { final CommandWrapper commandRequest = new CommandWrapperBuilder() // .deleteClient(clientId) // @@ -247,11 +235,11 @@ public class ClientsApiResource { @Path("{clientId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - @ApiOperation(value = "Activate a Client | Close a Client | Reject a Client | Withdraw a Client | Reactivate a Client | UndoReject a Client | UndoWithdraw a Client | Assign a Staff | Unassign a Staff | Update Default Savings Account | Propose a Client Transfer | Withdraw a Client Transfer | Reject a Client Transfer | Accept a Client Transfer | Propose and Accept a Client Transfer | ", - notes = "\n[Reject a Client] Mandatory Fields : rejectionDate, rejectionReasonId\n" + "\n[Withdraw a Client] Mandatory Fields : withdrawalDate, withdrawalReasonId\n" + "\n[Reactivate a Client] Mandatory Fields : reactivationDate\n" + "\n[UndoReject a Client] Mandatory Fields : reopenedDate\n" + "\n[UndoWithdraw a Client]Mandatory Fields : reopenedDate\n" ) - @ApiImplicitParams({@ApiImplicitParam( paramType = "body", dataType = "body", required = true, type = "body")}) - public String activate(@PathParam("clientId") final Long clientId, @QueryParam("command") final String commandParam, - final String apiRequestBodyAsJson) { + @ApiOperation(value = "Activate a Client | Close a Client | Reject a Client | Withdraw a Client | Reactivate a Client | UndoReject a Client | UndoWithdraw a Client | Assign a Staff | Unassign a Staff | Update Default Savings Account | Propose a Client Transfer | Withdraw a Client Transfer | Reject a Client Transfer | Accept a Client Transfer | Propose and Accept a Client Transfer", notes = "Activate a Client:\n\n" + "Clients can be created in a Pending state. This API exists to enable client activation (for when a client becomes an approved member of the financial Institution).\n" + "\n" + "If the client happens to be already active this API will result in an error.\n\n" + "Close a Client:\n\n" + "Clients can be closed if they do not have any non-closed loans/savingsAccount. This API exists to close a client .\n" + "\n" + "If the client have any active loans/savingsAccount this API will result in an error.\n\n" + "Reject a Client:\n\n" + "Clients can be rejected when client is in pending for activation status.\n" + "\n" + "If the client is any other status, this API throws an error.\n\n" + "Mandatory Fields: rejectionDate, rejectionReasonId\n\n" + "Withdraw a Client:\n\n" + "Client applications can be withdrawn when client is in a pending for activation status.\n" + "\n" + "If the client is any other status, this API throws an error.\n\n" + "Mandatory Fields: withdrawalDate, withdrawalReasonId\n\n" + "Reactivate a Client: Clients can be reactivated after they have been closed.\n" + "\n" + "Trying to reactivate a client in any other state throws an error.\n\n" + "Mandatory Fields: reactivationDate\n\n" + "UndoReject a Client:\n\n" + "Clients can be reactivated after they have been rejected.\n" + "\n" + "Trying to reactivate a client in any other state throws an error.\n\n" + "Mandatory Fields: reopenedDate" + "UndoWithdraw a Client:\n\n" + "Clients can be reactivated after they have been withdrawn.\n" + "\n" + "Trying to reactivate a client in any other state throws an error.\n\n" + "Mandatory Fields: reopenedDate\n\n" + "Assign a Staff:\n\n" + "Allows you to assign a Staff for existed Client.\n" + "\n" + "The selected Staff should belong to the same office (or an officer higher up in the hierarchy) as the Client he manages.\n\n" + "Unassign a Staff:\n\n" + "Allows you to unassign the Staff assigned to a Client.\n\n" + "Update Default Savings Account:\n\n" + "Allows you to modify or assign a default savings account for an existing Client.\n" + "\n" + "The selected savings account should be one among the existing savings account for a particular customer.\n\n" + "Propose a Client Transfer:\n\n" + "Allows you to propose the transfer of a Client to a different Office.\n\n" + "Withdraw a Client Transfer:\n\n" + "Allows you to withdraw the proposed transfer of a Client to a different Office.\n" + "\n" + "Withdrawal can happen only if the destination Branch (to which the transfer was proposed) has not already accepted the transfer proposal\n\n" + "Reject a Client Transfer:\n\n" + "Allows the Destination Branch to reject the proposed Client Transfer.\n\n" + "Accept a Client Transfer:\n\n" + "Allows the Destination Branch to accept the proposed Client Transfer.\n" + "\n" + "The destination branch may also choose to link this client to a group (in which case, any existing active JLG loan of the client is rescheduled to match the meeting frequency of the group) and loan Officer at the time of accepting the transfer\n\n" + "Propose and Accept a Client Transfer:\n\n" + "Abstraction over the Propose and Accept Client Transfer API's which enable a user with Data Scope over both the Target and Destination Branches to directly transfer a Client to the destination Office.\n\n" + "Showing request/response for 'Reject a Client Transfer'") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = ClientsApiResourceSwagger.PostClientsClientIdRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK",response = ClientsApiResourceSwagger.PostClientsClientIdResponse.class)}) + public String activate(@PathParam("clientId") @ApiParam(value = "clientId") final Long clientId, @QueryParam("command") @ApiParam(value = "command") final String commandParam, + @ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapperBuilder builder = new CommandWrapperBuilder().withJson(apiRequestBodyAsJson); @@ -322,11 +310,11 @@ public class ClientsApiResource { @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) @ApiOperation(value = "Retrieve client accounts overview", notes = "An example of how a loan portfolio summary can be provided. This is requested in a specific use case of the community application.\n" + "It is quite reasonable to add resources like this to simplify User Interface development.\n" + "\n" + "Example Requests:\n " + "\n" + "clients/1/accounts\n"+ "\n" + "clients/1/accounts?fields=loanAccounts,savingsAccounts" ) - @ApiResponses(value = { - @ApiResponse(code = 200, message = "", response = AccountSummaryCollectionData.class), + @ApiResponses({ + @ApiResponse(code = 200, message = "OK", response = ClientsApiResourceSwagger.GetClientsClientIdAccountsResponse.class), @ApiResponse(code = 400, message = "Bad Request") }) - public String retrieveAssociatedAccounts(@PathParam("clientId") final Long clientId, @Context final UriInfo uriInfo) { + public String retrieveAssociatedAccounts(@PathParam("clientId") @ApiParam(value = "clientId") final Long clientId, @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(ClientApiConstants.CLIENT_RESOURCE_NAME); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientsApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientsApiResourceSwagger.java new file mode 100644 index 000000000..8ced9a833 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/client/api/ClientsApiResourceSwagger.java @@ -0,0 +1,464 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.client.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.time.LocalDate; +import java.util.List; +import java.util.Set; + +/** + * Created by Chirag Gupta on 01/13/18. + */ +final class ClientsApiResourceSwagger { + private ClientsApiResourceSwagger() { + } + + @ApiModel(value = "GetClientsTemplateResponse") + public final static class GetClientsTemplateResponse { + private GetClientsTemplateResponse() { + } + + final class GetClientsOfficeOptions { + private GetClientsOfficeOptions() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "Head Office") + public String name; + @ApiModelProperty(example = "Head Office") + public String nameDecorated; + } + + final class GetClientsStaffOptions { + private GetClientsStaffOptions() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "xyz") + public String firstname; + @ApiModelProperty(example = "sjs") + public String lastname; + @ApiModelProperty(example = "sjs, xyz") + public String displayName; + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "Head Office") + public String officeName; + @ApiModelProperty(example = "true") + public Boolean isLoanOfficer; + @ApiModelProperty(example = "true") + public Boolean isActive; + } + + final class GetClientsSavingProductOptions { + private GetClientsSavingProductOptions() { + } + + @ApiModelProperty(example = "4") + public Integer id; + @ApiModelProperty(example = "account overdraft") + public String name; + @ApiModelProperty(example = "false") + public Boolean withdrawalFeeForTransfers; + @ApiModelProperty(example = "false") + public Boolean allowOverdraft; + } + + final class GetClientsDataTables { + private GetClientsDataTables() { + } + + final class GetClientsColumnHeaderData { + private GetClientsColumnHeaderData() { + } + + @ApiModelProperty(example = "client_id") + public String columnName; + @ApiModelProperty(example = "bigint") + public String columnType; + @ApiModelProperty(example = "0") + public Integer columnLength; + @ApiModelProperty(example = "INTEGER") + public String columnDisplayType; + @ApiModelProperty(example = "false") + public Boolean isColumnNullable; + @ApiModelProperty(example = "true") + public Boolean isColumnPrimaryKey; + @ApiModelProperty(example = "[]") + public List columnValues; + } + + @ApiModelProperty(example = "m_client") + public String applicationTableName; + @ApiModelProperty(example = "Address Details") + public String registeredTableName; + public Set columnHeaderData; + } + + @ApiModelProperty(example = "[2014, 3, 4]") + public LocalDate activationDate; + @ApiModelProperty(example = "1") + public Integer officeId; + public Set officeOptions; + public Set staffOptions; + public Set savingProductOptions; + public Set datatables; + } + + @ApiModel(value = "GetClientsResponse") + public final static class GetClientsResponse { + private GetClientsResponse() { + } + + final class GetClientsPageItemsResponse { + private GetClientsPageItemsResponse() { + } + + final class GetClientStatus { + private GetClientStatus() { + } + + @ApiModelProperty(example = "100") + public Integer id; + @ApiModelProperty(example = "clientStatusType.pending") + public String code; + @ApiModelProperty(example = "Pending") + public String value; + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "000000002") + public String accountNo; + public GetClientStatus status; + @ApiModelProperty(example = "false") + public Boolean active; + @ApiModelProperty(example = "Home Farm Produce") + public String fullname; + @ApiModelProperty(example = "Home Farm Produce") + public String displayName; + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "Head Office") + public String officeName; + } + + @ApiModelProperty(example = "2") + public Integer totalFilteredRecords; + public Set pageItems; + } + + @ApiModel(value = "GetClientsClientIdResponse") + public final static class GetClientsClientIdResponse { + private GetClientsClientIdResponse() { + } + + final class GetClientsClientIdStatus { + private GetClientsClientIdStatus() { + } + + @ApiModelProperty(example = "300") + public Integer id; + @ApiModelProperty(example = "clientStatusType.active") + public String code; + @ApiModelProperty(example = "Active") + public String value; + } + + final class GetClientsTimeline { + private GetClientsTimeline() { + } + + @ApiModelProperty(example = "[2013, 1, 1]") + public LocalDate submittedOnDate; + @ApiModelProperty(example = "mifos") + public String submittedByUsername; + @ApiModelProperty(example = "App") + public String submittedByFirstname; + @ApiModelProperty(example = "Administrator") + public String submittedByLastname; + @ApiModelProperty(example = "[2013, 1, 1]") + public LocalDate activatedOnDate; + @ApiModelProperty(example = "mifos") + public String activatedByUsername; + @ApiModelProperty(example = "App") + public String activatedByFirstname; + @ApiModelProperty(example = "Administrator") + public String activatedByLastname; + + } + + @ApiModelProperty(example = "27") + public Integer id; + @ApiModelProperty(example = "000000027") + public Long accountNo; + public GetClientsClientIdStatus status; + @ApiModelProperty(example = "true") + public Boolean active; + @ApiModelProperty(example = "[2013, 1, 1]") + public LocalDate activationDate; + @ApiModelProperty(example = "savings") + public String firstname; + @ApiModelProperty(example = "test") + public String lastname; + @ApiModelProperty(example = "savings test") + public String displayName; + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "Head Office") + public String officeName; + public GetClientsTimeline timeline; + @ApiModelProperty(example = "4") + public Integer savingsProductId; + @ApiModelProperty(example = "account overdraft") + public String savingsProductName; + @ApiModelProperty(example = "[]") + public List groups; + } + + @ApiModel(value = "PostClientsRequest") + public final static class PostClientsRequest { + private PostClientsRequest() { + } + + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "Client of group") + public String fullname; + @ApiModelProperty(example = "1") + public Integer groupId; + @ApiModelProperty(example = "dd MMMM yyyy") + public String dateFormat; + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "true") + public Boolean active; + @ApiModelProperty(example = "04 March 2009") + public String activationDate; + } + + @ApiModel(value = "PostClientsResponse") + public final static class PostClientsResponse { + private PostClientsResponse() { + } + + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "1") + public Integer groupId; + @ApiModelProperty(example = "2") + public Integer clientId; + @ApiModelProperty(example = "2") + public Integer resourceId; + } + + @ApiModel(value = "PutClientsClientIdRequest") + public final static class PutClientsClientIdRequest { + private PutClientsClientIdRequest() { + } + + @ApiModelProperty(example = "786444UUUYYH7") + public String externalId; + } + + @ApiModel(value = "PutClientsClientIdResponse") + public final static class PutClientsClientIdResponse { + private PutClientsClientIdResponse() { + } + + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "1") + public Integer resourceId; + public PutClientsClientIdRequest changes; + } + + @ApiModel(value = "DeleteClientsClientIdRequest") + public final static class DeleteClientsClientIdRequest { + private DeleteClientsClientIdRequest() { + } + } + + @ApiModel(value = "DeleteClientsClientIdResponse") + public final static class DeleteClientsClientIdResponse { + private DeleteClientsClientIdResponse() { + } + + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "3") + public Integer clientId; + @ApiModelProperty(example = "3") + public Integer resourceId; + } + + @ApiModel(value = "PostClientsClientIdRequest") + public final static class PostClientsClientIdRequest { + private PostClientsClientIdRequest() { + } + + @ApiModelProperty(example = "We cannot accept transfers of clients having loans with less than 1 repayment left") + public String note; + } + + @ApiModel(value = "PostClientsClientIdResponse") + public final static class PostClientsClientIdResponse { + private PostClientsClientIdResponse() { + } + + @ApiModelProperty(example = "2") + public Integer clientId; + @ApiModelProperty(example = "2") + public Integer resourceId; + } + + @ApiModel(value = "GetClientsClientIdAccountsResponse") + public final static class GetClientsClientIdAccountsResponse { + private GetClientsClientIdAccountsResponse() { + } + + final class GetClientsLoanAccounts { + private GetClientsLoanAccounts() { + } + + final class GetClientsLoanAccountsStatus { + private GetClientsLoanAccountsStatus() { + } + + @ApiModelProperty(example = "300") + public Integer id; + @ApiModelProperty(example = "loanStatusType.active") + public String code; + @ApiModelProperty(example = "Active") + public String value; + @ApiModelProperty(example = "false") + public Boolean pendingApproval; + @ApiModelProperty(example = "false") + public Boolean waitingForDisbursal; + @ApiModelProperty(example = "true") + public Boolean active; + @ApiModelProperty(example = "false") + public Boolean closedObligationsMet; + @ApiModelProperty(example = "false") + public Boolean closedWrittenOff; + @ApiModelProperty(example = "false") + public Boolean closedRescheduled; + @ApiModelProperty(example = "false") + public Boolean closed; + @ApiModelProperty(example = "false") + public Boolean overpaid; + } + + final class GetClientsLoanAccountsType { + private GetClientsLoanAccountsType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "loanType.individual") + public String code; + @ApiModelProperty(example = "Individual") + public String value; + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "000000001") + public Long accountNo; + @ApiModelProperty(example = "456") + public Integer externalId; + @ApiModelProperty(example = "1") + public Integer productId; + @ApiModelProperty(example = "TestOne") + public String productName; + public GetClientsLoanAccountsStatus status; + public GetClientsLoanAccountsType loanType; + @ApiModelProperty(example = "1") + public Integer loanCycle; + } + + final class GetClientsSavingsAccounts { + private GetClientsSavingsAccounts() { + } + + final class GetClientsSavingsAccountsCurrency { + private GetClientsSavingsAccountsCurrency() { + } + + @ApiModelProperty(example = "USD") + public String code; + @ApiModelProperty(example = "US Dollar") + public String name; + @ApiModelProperty(example = "2") + public Integer decimalPlaces; + @ApiModelProperty(example = "$") + public String displaySymbol; + @ApiModelProperty(example = "currency.USD") + public String nameCode; + @ApiModelProperty(example = "US Dollar ($)") + public String displayLabel; + } + + final class GetClientsSavingsAccountsStatus { + private GetClientsSavingsAccountsStatus() { + } + + @ApiModelProperty(example = "100") + public Integer id; + @ApiModelProperty(example = "savingsAccountStatusType.submitted.and.pending.approval") + public String code; + @ApiModelProperty(example = "Submitted and pending approval") + public String value; + @ApiModelProperty(example = "true") + public Boolean submittedAndPendingApproval; + @ApiModelProperty(example = "false") + public Boolean approved; + @ApiModelProperty(example = "false") + public Boolean rejected; + @ApiModelProperty(example = "false") + public Boolean withdrawnByApplicant; + @ApiModelProperty(example = "false") + public Boolean active; + @ApiModelProperty(example = "false") + public Boolean closed; + } + + @ApiModelProperty(example = "7") + public Integer id; + @ApiModelProperty(example = "000000007") + public Long accountNo; + @ApiModelProperty(example = "2") + public Integer productId; + @ApiModelProperty(example = "Other product") + public String productName; + public GetClientsSavingsAccountsStatus status; + public GetClientsSavingsAccountsCurrency currency; + } + + public Set loanAccounts; + public Set savingsAccounts; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/collateral/api/CollateralsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/collateral/api/CollateralsApiResource.java index 569a2ceaa..9266dc191 100755 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/collateral/api/CollateralsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/collateral/api/CollateralsApiResource.java @@ -18,24 +18,7 @@ */ package org.apache.fineract.portfolio.collateral.api; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriInfo; - +import io.swagger.annotations.*; import org.apache.fineract.commands.domain.CommandWrapper; import org.apache.fineract.commands.service.CommandWrapperBuilder; import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService; @@ -52,9 +35,16 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; +import java.util.*; + @Path("/loans/{loanId}/collaterals") @Component @Scope("singleton") +@Api(value = "Loan Collateral", description = "In lending agreements, collateral is a borrower's pledge of specific property to a lender, to secure repayment of a loan. The collateral serves as protection for a lender against a borrower's default - that is, any borrower failing to pay the principal and interest under the terms of a loan obligation. If a borrower does default on a loan (due to insolvency or other event), that borrower forfeits (gives up) the property pledged as collateral - and the lender then becomes the owner of the collateral") public class CollateralsApiResource { private static final Set RESPONSE_DATA_PARAMETERS = new HashSet<>(Arrays.asList("id", "type", "value", "description", @@ -87,6 +77,8 @@ public class CollateralsApiResource { @Path("template") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) + @ApiOperation(value = "Retrieve Collateral Details Template", httpMethod = "GET", notes = "This is a convenience resource. It can be useful when building maintenance user interface screens for client applications. The template data returned consists of any or all of:\n" + "\n" + "Field Defaults\n" + "Allowed Value Lists\n" + "Example Request:\n" + "\n" + "loans/1/collaterals/template") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = CollateralsApiResourceSwagger.GetLoansLoanIdCollateralsTemplateResponse.class)}) public String newCollateralTemplate(@Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermission); @@ -102,7 +94,9 @@ public class CollateralsApiResource { @GET @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveCollateralDetails(@Context final UriInfo uriInfo, @PathParam("loanId") final Long loanId) { + @ApiOperation(value = "List Loan Collaterals", httpMethod = "GET", notes = "Example Requests:\n" + "\n" + "loans/1/collaterals\n" + "\n" + "\n" + "loans/1/collaterals?fields=value,description") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = CollateralsApiResourceSwagger.GetLoansLoanIdCollateralsResponse.class, responseContainer = "List")}) + public String retrieveCollateralDetails(@Context final UriInfo uriInfo, @PathParam("loanId") @ApiParam(value = "loanId") final Long loanId) { this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermission); final List CollateralDatas = this.collateralReadPlatformService.retrieveCollateralsForValidLoan(loanId); @@ -116,8 +110,10 @@ public class CollateralsApiResource { @Path("{collateralId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveCollateralDetails(@Context final UriInfo uriInfo, @PathParam("loanId") final Long loanId, - @PathParam("collateralId") final Long CollateralId) { + @ApiOperation(value = "Retrieve a Collateral", httpMethod = "GET", notes = "Example Requests:\n" + "\n" + "/loans/1/collaterals/1\n" + "\n" + "\n" + "/loans/1/collaterals/1?fields=value,description") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = CollateralsApiResourceSwagger.GetLoansLoanIdCollateralsResponse.class)}) + public String retrieveCollateralDetails(@Context final UriInfo uriInfo, @PathParam("loanId") @ApiParam(value = "loanId")final Long loanId, + @PathParam("collateralId") @ApiParam(value = "collateralId") final Long CollateralId) { this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermission); CollateralData CollateralData = this.collateralReadPlatformService.retrieveCollateral(loanId, CollateralId); @@ -135,7 +131,10 @@ public class CollateralsApiResource { @POST @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String createCollateral(@PathParam("loanId") final Long loanId, final String apiRequestBodyAsJson) { + @ApiOperation(value = "Create a Collateral", httpMethod = "POST", notes = "Note: Currently, Collaterals may be added only before a Loan is approved") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = CollateralsApiResourceSwagger.PostLoansLoanIdCollateralsRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = CollateralsApiResourceSwagger.PostLoansLoanIdCollateralsResponse.class)}) + public String createCollateral(@PathParam("loanId") @ApiParam(value = "loanId") final Long loanId, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder().createCollateral(loanId).withJson(apiRequestBodyAsJson).build(); @@ -148,8 +147,11 @@ public class CollateralsApiResource { @Path("{collateralId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String updateCollateral(@PathParam("loanId") final Long loanId, @PathParam("collateralId") final Long collateralId, - final String jsonRequestBody) { + @ApiOperation(value = "Update a Collateral", httpMethod = "PUT") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = CollateralsApiResourceSwagger.PutLoansLoandIdCollateralsCollateralIdRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = CollateralsApiResourceSwagger.PutLoansLoanIdCollateralsCollateralIdResponse.class)}) + public String updateCollateral(@PathParam("loanId") @ApiParam(value = "loanId") final Long loanId, @PathParam("collateralId") @ApiParam(value = "collateralId") final Long collateralId, + @ApiParam(hidden = true) final String jsonRequestBody) { final CommandWrapper commandRequest = new CommandWrapperBuilder().updateCollateral(loanId, collateralId).withJson(jsonRequestBody) .build(); @@ -162,7 +164,9 @@ public class CollateralsApiResource { @Path("{collateralId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String deleteCollateral(@PathParam("loanId") final Long loanId, @PathParam("collateralId") final Long collateralId) { + @ApiOperation(value = "Remove a Collateral", httpMethod = "DELETE", notes = "Note: A collateral can only be removed from Loans that are not yet approved.") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = CollateralsApiResourceSwagger.DeleteLoansLoanIdCollateralsCollateralIdResponse.class)}) + public String deleteCollateral(@PathParam("loanId") @ApiParam(value = "loanId") final Long loanId, @PathParam("collateralId") @ApiParam(value = "collateralId")final Long collateralId) { final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteCollateral(loanId, collateralId).build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/collateral/api/CollateralsApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/collateral/api/CollateralsApiResourceSwagger.java new file mode 100644 index 000000000..0eb00f88e --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/collateral/api/CollateralsApiResourceSwagger.java @@ -0,0 +1,147 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.collateral.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Set; + +/** + * Created by Chirag Gupta on 12/01/17. + */ +final class CollateralsApiResourceSwagger { + private CollateralsApiResourceSwagger() { + } + + @ApiModel(value = "GetLoansLoanIdCollateralsResponse") + public static final class GetLoansLoanIdCollateralsResponse { + private GetLoansLoanIdCollateralsResponse() { + } + + final class GetCollateralTypeResponse { + private GetCollateralTypeResponse() { + } + + @ApiModelProperty(example = "8") + public Integer id; + @ApiModelProperty(example = "Gold") + public String name; + } + + final class GetCollateralCurrencyResponse { + private GetCollateralCurrencyResponse() { + } + + @ApiModelProperty(example = "USD") + public String code; + @ApiModelProperty(example = "US Dollar") + public String name; + @ApiModelProperty(example = "2") + public Integer decimalPlaces; + @ApiModelProperty(example = "$") + public String displaySymbol; + @ApiModelProperty(example = "currency.USD") + public String nameCode; + @ApiModelProperty(example = "US Dollar ($)") + public String displayLabel; + } + + @ApiModelProperty(example = "12") + public Integer id; + public GetCollateralTypeResponse type; + @ApiModelProperty(example = "50000") + public Long value; + @ApiModelProperty(example = "24 Carat Gold chain weighing 12 grams") + public String description; + public GetCollateralCurrencyResponse currency; + } + + @ApiModel(value = "PostLoansLoanIdCollateralsRequest") + public static final class PostLoansLoanIdCollateralsRequest { + private PostLoansLoanIdCollateralsRequest() { + } + + @ApiModelProperty(example = "9") + public Integer collateralTypeId; + } + + @ApiModel(value = "PostLoansLoanIdCollateralsResponse") + public static final class PostLoansLoanIdCollateralsResponse { + private PostLoansLoanIdCollateralsResponse() { + } + + @ApiModelProperty(example = "1") + public Integer loanId; + @ApiModelProperty(example = "12") + public Integer resourceId; + } + + @ApiModel(value = "PutLoansLoandIdCollateralsCollateralIdRequest") + public static final class PutLoansLoandIdCollateralsCollateralIdRequest { + private PutLoansLoandIdCollateralsCollateralIdRequest() { + } + + @ApiModelProperty(example = "22 Carat Gold chain weighing 12 grams") + public String description; + } + + @ApiModel(value = "PutLoansLoanIdCollateralsCollateralIdResponse") + public static final class PutLoansLoanIdCollateralsCollateralIdResponse { + private PutLoansLoanIdCollateralsCollateralIdResponse() { + } + + @ApiModelProperty(example = "1") + public Integer loanId; + @ApiModelProperty(example = "12") + public Integer resourceId; + public PutLoansLoandIdCollateralsCollateralIdRequest changes; + } + + @ApiModel(value = "GetLoansLoanIdCollateralsTemplateResponse") + public static final class GetLoansLoanIdCollateralsTemplateResponse { + private GetLoansLoanIdCollateralsTemplateResponse() { + } + + final class GetCollateralsTemplateAllowedTypes { + private GetCollateralsTemplateAllowedTypes() { + } + + @ApiModelProperty(example = "9") + public Integer id; + @ApiModelProperty(example = "Silver") + public String name; + @ApiModelProperty(example = "0") + public Integer position; + } + + public Set allowedCollateralTypes; + } + + @ApiModel(value = "DeleteLoansLoanIdCollateralsCollateralIdResponse") + public static final class DeleteLoansLoanIdCollateralsCollateralIdResponse { + private DeleteLoansLoanIdCollateralsCollateralIdResponse() { + } + + @ApiModelProperty(example = "1") + public Integer loanId; + @ApiModelProperty(example = "12") + public Integer resourceId; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/collectionsheet/api/CollectionSheetApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/collectionsheet/api/CollectionSheetApiResourceSwagger.java new file mode 100644 index 000000000..a04cce6ba --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/collectionsheet/api/CollectionSheetApiResourceSwagger.java @@ -0,0 +1,90 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.collectionsheet.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.List; + +/** + * Created by Chirag Gupta on 12/17/17. + */ +final class CollectionSheetApiResourceSwagger { + private CollectionSheetApiResourceSwagger() { + } + + @ApiModel(value = "PostCollectionSheetRequest") + public final static class PostCollectionSheetRequest { + private PostCollectionSheetRequest() { + } + + final class PostCollectionSheetBulkRepaymentTransactions { + private PostCollectionSheetBulkRepaymentTransactions() { + } + + @ApiModelProperty(example = "10") + public Integer loanId; + @ApiModelProperty(example = "1221.36") + public Double transactionAmount; + @ApiModelProperty(example = "19") + public Integer paymentTypeId; + @ApiModelProperty(example = "1245356") + public Long receiptNumber; + } + + @ApiModelProperty(example = "dd MMMM yyyy") + public String dateFormat; + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "04 May 2014") + public String transactionDate; + @ApiModelProperty(example = "04 May 2014") + public String actualDisbursementDate; + public List bulkDisbursementTransactions; + public PostCollectionSheetBulkRepaymentTransactions bulkRepaymentTransactions; + public List bulkSavingsDueTransactions; + } + + @ApiModel(value = "PostCollectionSheetResponse") + public final static class PostCollectionSheetResponse { + private PostCollectionSheetResponse() { + } + + final class PostCollectionSheetChanges { + private PostCollectionSheetChanges() { + } + + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "dd MMMM yyyy") + public String dateFormat; + @ApiModelProperty(example = "[15]") + public List loanTransactions; + @ApiModelProperty(example = "[]") + public List SavingsTransactions; + } + + @ApiModelProperty(example = "10") + public Integer groupId; + @ApiModelProperty(example = "10") + public Integer resourceId; + public PostCollectionSheetChanges changes; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/collectionsheet/api/CollectionSheetApiResourse.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/collectionsheet/api/CollectionSheetApiResourse.java index 3de8b57da..16f3a7d41 100755 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/collectionsheet/api/CollectionSheetApiResourse.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/collectionsheet/api/CollectionSheetApiResourse.java @@ -18,15 +18,8 @@ */ package org.apache.fineract.portfolio.collectionsheet.api; -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriInfo; - +import com.google.gson.JsonElement; +import io.swagger.annotations.*; import org.apache.commons.lang.StringUtils; import org.apache.fineract.commands.domain.CommandWrapper; import org.apache.fineract.commands.service.CommandWrapperBuilder; @@ -45,11 +38,15 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; -import com.google.gson.JsonElement; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; @Path("/collectionsheet") @Component @Scope("singleton") +@Api(value = "Collection Sheet", description = "") public class CollectionSheetApiResourse { private final CollectionSheetReadPlatformService collectionSheetReadPlatformService; @@ -75,8 +72,11 @@ public class CollectionSheetApiResourse { @POST @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String generateCollectionSheet(@QueryParam("command") final String commandParam, final String apiRequestBodyAsJson, - @Context final UriInfo uriInfo) { + @ApiOperation(value = "Generate Individual Collection Sheet | Save Collection Sheet", httpMethod = "POST", notes = "Generate Individual Collection Sheet:\n\n" + "This Api retrieves repayment details of all individual loans under a office as on a specified meeting date.\n\n" + "Save Collection Sheet:\n\n" + "This Api allows the loan officer to perform bulk repayments of individual loans and deposit of mandatory savings on a given meeting date.") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = CollectionSheetApiResourceSwagger.PostCollectionSheetRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = CollectionSheetApiResourceSwagger.PostCollectionSheetResponse.class)}) + public String generateCollectionSheet(@QueryParam("command") @ApiParam(value = "command") final String commandParam, @ApiParam(hidden = true) final String apiRequestBodyAsJson, + @Context final UriInfo uriInfo) { final CommandWrapperBuilder builder = new CommandWrapperBuilder().withJson(apiRequestBodyAsJson); CommandProcessingResult result = null; diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/floatingrates/api/FloatingRatesApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/floatingrates/api/FloatingRatesApiResource.java index d94c1161e..c9bdae783 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/floatingrates/api/FloatingRatesApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/floatingrates/api/FloatingRatesApiResource.java @@ -18,22 +18,7 @@ */ package org.apache.fineract.portfolio.floatingrates.api; -import java.util.Arrays; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriInfo; - +import io.swagger.annotations.*; import org.apache.fineract.commands.domain.CommandWrapper; import org.apache.fineract.commands.service.CommandWrapperBuilder; import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService; @@ -48,9 +33,19 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + @Path("/floatingrates") @Component @Scope("singleton") +@Api(value = "Floating Rates", description = "It lets you create, list, retrieve and upload the floating rates") public class FloatingRatesApiResource { private static final String RESOURCE_NAME = "FLOATINGRATE"; @@ -84,7 +79,10 @@ public class FloatingRatesApiResource { @POST @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String createFloatingRate(final String apiRequestBodyAsJson) { + @ApiOperation(value = "Create a new Floating Rate", httpMethod = "POST", notes = "Creates a new Floating Rate\n" + "Mandatory Fields: name\n" + "Optional Fields: isBaseLendingRate, isActive, ratePeriods") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = FloatingRatesApiResourceSwagger.PostFloatingRatesRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = FloatingRatesApiResourceSwagger.PostFloatingRatesResponse.class)}) + public String createFloatingRate(@ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder() .createFloatingRate().withJson(apiRequestBodyAsJson).build(); @@ -96,6 +94,8 @@ public class FloatingRatesApiResource { @GET @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) + @ApiOperation(value = "List Floating Rates", httpMethod = "GET", notes = "Lists Floating Rates") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = FloatingRatesApiResourceSwagger.GetFloatingRatesResponse.class, responseContainer = "List")}) public String retrieveAll(@Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission( RESOURCE_NAME); @@ -111,8 +111,10 @@ public class FloatingRatesApiResource { @Path("{floatingRateId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) + @ApiOperation(value = "Retrieve Floating Rate", httpMethod = "GET", notes = "Retrieves Floating Rate") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = FloatingRatesApiResourceSwagger.GetFloatingRatesFloatingRateIdResponse.class)}) public String retrieveOne( - @PathParam("floatingRateId") final Long floatingRateId, + @PathParam("floatingRateId") @ApiParam(value = "floatingRateId") final Long floatingRateId, @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission( RESOURCE_NAME); @@ -128,9 +130,12 @@ public class FloatingRatesApiResource { @Path("{floatingRateId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) + @ApiOperation(value = "Update Floating Rate", httpMethod = "PUT", notes = "Updates new Floating Rate. Rate Periods in the past cannot be modified. All the future rateperiods would be replaced with the new ratePeriods data sent.") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = FloatingRatesApiResourceSwagger.PutFloatingRatesFloatingRateIdRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = FloatingRatesApiResourceSwagger.PutFloatingRatesFloatingRateIdResponse.class)}) public String updateFloatingRate( - @PathParam("floatingRateId") final Long floatingRateId, - final String apiRequestBodyAsJson) { + @PathParam("floatingRateId") @ApiParam(value = "floatingRateId") final Long floatingRateId, + @ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder() .updateFloatingRate(floatingRateId) .withJson(apiRequestBodyAsJson).build(); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/floatingrates/api/FloatingRatesApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/floatingrates/api/FloatingRatesApiResourceSwagger.java new file mode 100644 index 000000000..258a91312 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/floatingrates/api/FloatingRatesApiResourceSwagger.java @@ -0,0 +1,171 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.floatingrates.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Set; + +/** + * Created by Chirag Gupta on 12/17/17. + */ +final class FloatingRatesApiResourceSwagger { + private FloatingRatesApiResourceSwagger() { + } + + @ApiModel(value = "PostFloatingRatesRequest") + public final static class PostFloatingRatesRequest { + private PostFloatingRatesRequest() { + } + + final class PostFloatingRatesRatePeriods { + private PostFloatingRatesRatePeriods() { + } + + @ApiModelProperty(example = "19 November 2015") + public String fromDate; + @ApiModelProperty(example = "10") + public Double interestRate; + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "dd MMMM yyyy") + public String dateFormat; + } + + @ApiModelProperty(example = "Floating Rate 1") + public String name; + @ApiModelProperty(example = "true") + public Boolean isBaseLendingRate; + @ApiModelProperty(example = "true") + public Boolean isActive; + public Set ratePeriods; + } + + @ApiModel(value = "PostFloatingRatesResponse") + public final static class PostFloatingRatesResponse { + private PostFloatingRatesResponse() { + } + + @ApiModelProperty(example = "1") + public Integer resourceId; + } + + @ApiModel(value = "GetFloatingRatesResponse") + public final static class GetFloatingRatesResponse { + private GetFloatingRatesResponse() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "Floating Rate 1") + public String name; + @ApiModelProperty(example = "true") + public Boolean isBaseLendingRate; + @ApiModelProperty(example = "true") + public Boolean isActive; + @ApiModelProperty(example = "mifos") + public String createdBy; + @ApiModelProperty(example = "Nov 18, 2015") + public String createdOn; + @ApiModelProperty(example = "mifos") + public String modifiedBy; + @ApiModelProperty(example = "Nov 18, 2015") + public String modifiedOn; + } + + @ApiModel(value = "GetFloatingRatesFloatingRateIdResponse") + public final static class GetFloatingRatesFloatingRateIdResponse { + private GetFloatingRatesFloatingRateIdResponse() { + } + + final class GetFloatingRatesRatePeriods { + private GetFloatingRatesRatePeriods() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "Dec 15, 2015") + public String fromDate; + @ApiModelProperty(example = "11") + public Double interestRate; + @ApiModelProperty(example = "false") + public Boolean isDifferentialToBaseLendingRate; + @ApiModelProperty(example = "true") + public Boolean isActive; + @ApiModelProperty(example = "mifos") + public String createdBy; + @ApiModelProperty(example = "Nov 18, 2015") + public String createdOn; + @ApiModelProperty(example = "mifos") + public String modifiedBy; + @ApiModelProperty(example = "Nov 18, 2015") + public String modifiedOn; + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "Floating Rate 1") + public String name; + @ApiModelProperty(example = "true") + public Boolean isBaseLendingRate; + @ApiModelProperty(example = "true") + public Boolean isActive; + @ApiModelProperty(example = "mifos") + public String createdBy; + @ApiModelProperty(example = "Nov 18, 2015") + public String createdOn; + @ApiModelProperty(example = "mifos") + public String modifiedBy; + @ApiModelProperty(example = "Nov 18, 2015") + public String modifiedOn; + public Set ratePeriods; + } + + @ApiModel(value = "PutFloatingRatesFloatingRateIdRequest") + public final static class PutFloatingRatesFloatingRateIdRequest { + private PutFloatingRatesFloatingRateIdRequest() { + } + + @ApiModelProperty(example = "Floating Rate 1") + public String name; + @ApiModelProperty(example = "true") + public Boolean isBaseLendingRate; + @ApiModelProperty(example = "true") + public Boolean isActive; + public Set ratePeriods; + } + + @ApiModel(value = "PutFloatingRatesFloatingRateIdResponse") + public final static class PutFloatingRatesFloatingRateIdResponse { + private PutFloatingRatesFloatingRateIdResponse() { + } + + final class PutFloatingRatesChanges { + private PutFloatingRatesChanges() { + } + + public Set ratePeriods; + } + + @ApiModelProperty(example = "1") + public Integer resourceId; + public PutFloatingRatesChanges changes; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/fund/api/FundsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/fund/api/FundsApiResource.java index f2967f8c6..4e0ae4cb9 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/fund/api/FundsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/fund/api/FundsApiResource.java @@ -18,22 +18,7 @@ */ package org.apache.fineract.portfolio.fund.api; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriInfo; - +import io.swagger.annotations.*; import org.apache.fineract.commands.domain.CommandWrapper; import org.apache.fineract.commands.service.CommandWrapperBuilder; import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService; @@ -49,9 +34,19 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + @Path("/funds") @Component @Scope("singleton") +@Api(value = "Funds", description = "") public class FundsApiResource { /** @@ -81,6 +76,8 @@ public class FundsApiResource { @GET @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) + @ApiOperation(value = "Retrieve Funds", httpMethod = "GET", notes = "Returns the list of funds.\n" + "\n" + "Example Requests:\n" + "\n" + "funds") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = FundsApiResourceSwagger.GetFundsResponse.class, responseContainer = "List")}) public String retrieveFunds(@Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions); @@ -94,7 +91,10 @@ public class FundsApiResource { @POST @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String createFund(final String apiRequestBodyAsJson) { + @ApiOperation(value = "Create a Fund", httpMethod = "POST", notes = "Creates a Fund") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = FundsApiResourceSwagger.PostFundsRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = FundsApiResourceSwagger.PostFundsResponse.class)}) + public String createFund(@ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder().createFund().withJson(apiRequestBodyAsJson).build(); @@ -107,7 +107,9 @@ public class FundsApiResource { @Path("{fundId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retreiveFund(@PathParam("fundId") final Long fundId, @Context final UriInfo uriInfo) { + @ApiOperation(value = "Retrieve a Fund", httpMethod = "GET", notes = "Returns the details of a Fund.\n" + "\n" + "Example Requests:\n" + "\n" + "funds/1") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = FundsApiResourceSwagger.GetFundsResponse.class)}) + public String retreiveFund(@PathParam("fundId") @ApiParam(value = "fundId") final Long fundId, @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions); @@ -121,7 +123,10 @@ public class FundsApiResource { @Path("{fundId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String updateFund(@PathParam("fundId") final Long fundId, final String apiRequestBodyAsJson) { + @ApiOperation(value = "Update a Fund", httpMethod = "PUT", notes = "Updates the details of a fund.") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = FundsApiResourceSwagger.PutFundsFundIdRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = FundsApiResourceSwagger.PutFundsFundIdResponse.class)}) + public String updateFund(@PathParam("fundId") @ApiParam(value = "fundId") final Long fundId, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder().updateFund(fundId).withJson(apiRequestBodyAsJson).build(); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/fund/api/FundsApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/fund/api/FundsApiResourceSwagger.java new file mode 100644 index 000000000..f15a6863c --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/fund/api/FundsApiResourceSwagger.java @@ -0,0 +1,78 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.fund.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +/** + * Created by Chirag Gupta on 12/08/17. + */ +final class FundsApiResourceSwagger { + private FundsApiResourceSwagger() { + } + + @ApiModel(value = "GetFundsResponse") + public static final class GetFundsResponse { + private GetFundsResponse() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "EU Agri Fund") + public String name; + } + + @ApiModel(value = "PostFundsRequest") + public static final class PostFundsRequest { + private PostFundsRequest() { + } + + @ApiModelProperty(example = "EU Agri Fund") + public String name; + } + + @ApiModel(value = "PostFundsResponse") + public static final class PostFundsResponse { + private PostFundsResponse() { + } + + @ApiModelProperty(example = "1") + public Integer resourceId; + } + + @ApiModel(value = "PutFundsFundIdRequest") + public static final class PutFundsFundIdRequest { + private PutFundsFundIdRequest() { + } + + @ApiModelProperty(example = "EU Agri Fund (2010-2020)") + public String name; + } + + @ApiModel(value = "PutFundsFundIdResponse") + public static final class PutFundsFundIdResponse { + private PutFundsFundIdResponse() { + } + + @ApiModelProperty(example = "1") + public Integer resourceId; + public PutFundsFundIdRequest changes; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/api/CentersApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/api/CentersApiResource.java index 0195e99cd..b9633a917 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/api/CentersApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/api/CentersApiResource.java @@ -18,22 +18,8 @@ */ package org.apache.fineract.portfolio.group.api; -import java.util.*; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriInfo; - +import com.google.gson.JsonElement; +import io.swagger.annotations.*; import org.apache.commons.lang.StringUtils; import org.apache.fineract.accounting.journalentry.api.DateParam; import org.apache.fineract.commands.domain.CommandWrapper; @@ -73,11 +59,16 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; -import com.google.gson.JsonElement; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; +import java.util.*; @Path("/centers") @Component @Scope("singleton") +@Api(value = "Centers", description = "Centers along with Groups are used to provided a distinctive banking distribution channel used in microfinance. Its common in areas such as Southern Asia to use Centers and Group as administrative units in grameen style lending. Typically groups will contain one to five people and centers themselves will be made of anywhere between 2-10 groups.") public class CentersApiResource { private final PlatformSecurityContext context; @@ -123,9 +114,11 @@ public class CentersApiResource { @Path("template") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveTemplate(@Context final UriInfo uriInfo, @QueryParam("command") final String commandParam, - @QueryParam("officeId") final Long officeId, - @DefaultValue("false") @QueryParam("staffInSelectedOfficeOnly") final boolean staffInSelectedOfficeOnly) { + @ApiOperation(value = "Retrieve a Center Template", httpMethod = "GET", notes = "Retrieves a Center Template\n\n" + "Example Requests:\n\n" + "\n\n" + "centers/template\n\n" + "\n\n" + "centers/template?officeId=2") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = CentersApiResourceSwagger.GetCentersTemplateResponse.class)}) + public String retrieveTemplate(@Context final UriInfo uriInfo, @QueryParam("command") @ApiParam(value = "command") final String commandParam, + @QueryParam("officeId") @ApiParam(value = "officeId") final Long officeId, + @DefaultValue("false") @QueryParam("staffInSelectedOfficeOnly") @ApiParam(value = "staffInSelectedOfficeOnly") final boolean staffInSelectedOfficeOnly) { this.context.authenticatedUser().validateHasReadPermission(GroupingTypesApiConstants.CENTER_RESOURCE_NAME); @@ -148,14 +141,16 @@ public class CentersApiResource { @GET @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveAll(@Context final UriInfo uriInfo, @QueryParam("sqlSearch") final String sqlSearch, - @QueryParam("officeId") final Long officeId, @QueryParam("staffId") final Long staffId, - @QueryParam("externalId") final String externalId, @QueryParam("name") final String name, - @QueryParam("underHierarchy") final String hierarchy, @QueryParam("paged") final Boolean paged, - @QueryParam("offset") final Integer offset, @QueryParam("limit") final Integer limit, - @QueryParam("orderBy") final String orderBy, @QueryParam("sortOrder") final String sortOrder, - @QueryParam("meetingDate") final DateParam meetingDateParam, @QueryParam("dateFormat") final String dateFormat, - @QueryParam("locale") final String locale) { + @ApiOperation(value = "List Centers", httpMethod = "GET", notes = "The default implementation supports pagination and sorting with the default pagination size set to 200 records. The parameter limit with value -1 will return all entries.\n\n" + "Example Requests:\n\n" + "\n\n" + "centers\n\n" + "\n\n" + "centers?fields=name,officeName,joinedDate\n\n" + "\n\n" + "centers?offset=10&limit=50\n\n" + "\n\n" + "centers?orderBy=name&sortOrder=DESC") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = CentersApiResourceSwagger.GetCentersResponse.class)}) + public String retrieveAll(@Context final UriInfo uriInfo, @QueryParam("sqlSearch") @ApiParam(value = "sqlSearch") final String sqlSearch, + @QueryParam("officeId") @ApiParam(value = "officeId") final Long officeId, @QueryParam("staffId") @ApiParam(value = "staffId") final Long staffId, + @QueryParam("externalId") @ApiParam(value = "externalId") final String externalId, @QueryParam("name") @ApiParam(value = "name") final String name, + @QueryParam("underHierarchy") @ApiParam(value = "underHierarchy") final String hierarchy, @QueryParam("paged") @ApiParam(value = "paged") final Boolean paged, + @QueryParam("offset") @ApiParam(value = "offset") final Integer offset, @QueryParam("limit") @ApiParam(value = "limit") final Integer limit, + @QueryParam("orderBy") @ApiParam(value = "orderBy") final String orderBy, @QueryParam("sortOrder") @ApiParam(value = "sortOrder") final String sortOrder, + @QueryParam("meetingDate") @ApiParam(value = "meetingDate") final DateParam meetingDateParam, @QueryParam("dateFormat") @ApiParam(value = "dateFormat") final String dateFormat, + @QueryParam("locale") @ApiParam(value = "locale") final String locale) { this.context.authenticatedUser().validateHasReadPermission(GroupingTypesApiConstants.CENTER_RESOURCE_NAME); final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); @@ -183,8 +178,10 @@ public class CentersApiResource { @Path("{centerId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveOne(@Context final UriInfo uriInfo, @PathParam("centerId") final Long centerId, - @DefaultValue("false") @QueryParam("staffInSelectedOfficeOnly") final boolean staffInSelectedOfficeOnly) { + @ApiOperation(value = "Retrieve a Center", httpMethod = "GET", notes = "Retrieves a Center\n\n" + "Example Requests:\n\n" + "\n\n" + "centers/1\n\n" + "\n\n" + "centers/1?associations=groupMembers") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = CentersApiResourceSwagger.GetCentersCenterIdResponse.class)}) + public String retrieveOne(@Context final UriInfo uriInfo, @PathParam("centerId") @ApiParam(value = "centerId") final Long centerId, + @DefaultValue("false") @QueryParam("staffInSelectedOfficeOnly") @ApiParam(value = "staffInSelectedOfficeOnly") final boolean staffInSelectedOfficeOnly) { this.context.authenticatedUser().validateHasReadPermission(GroupingTypesApiConstants.CENTER_RESOURCE_NAME); final Set associationParameters = ApiParameterHelper.extractAssociationsForResponseIfProvided(uriInfo.getQueryParameters()); @@ -232,7 +229,10 @@ public class CentersApiResource { @POST @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String create(final String apiRequestBodyAsJson) { + @ApiOperation(value = "Create a Center", httpMethod = "POST", notes = "Creates a Center\n\n" + "Mandatory Fields: name, officeId, active, activationDate (if active=true)\n\n" + "Optional Fields: externalId, staffId, groupMembers") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = CentersApiResourceSwagger.PostCentersRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = CentersApiResourceSwagger.PostCentersResponse.class)}) + public String create(@ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder() // .createCenter() // @@ -247,7 +247,10 @@ public class CentersApiResource { @Path("{centerId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String update(@PathParam("centerId") final Long centerId, final String apiRequestBodyAsJson) { + @ApiOperation(value = "Update a Center", httpMethod = "PUT", notes = "Updates a Center") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = CentersApiResourceSwagger.PutCentersCenterIdRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = CentersApiResourceSwagger.PutCentersCenterIdResponse.class)}) + public String update(@PathParam("centerId") @ApiParam(value = "centerId") final Long centerId, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder() // .updateCenter(centerId) // @@ -261,7 +264,9 @@ public class CentersApiResource { @Path("{centerId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String delete(@PathParam("centerId") final Long centerId) { + @ApiOperation(value = "Delete a Center", httpMethod = "DELETE", notes = "A Center can be deleted if it is in pending state and has no association - groups, loans or savings") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = CentersApiResourceSwagger.DeleteCentersCenterIdResponse.class)}) + public String delete(@PathParam("centerId") @ApiParam(value = "centerId") final Long centerId) { final CommandWrapper commandRequest = new CommandWrapperBuilder() // .deleteCenter(centerId) // @@ -274,8 +279,11 @@ public class CentersApiResource { @Path("{centerId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String activate(@PathParam("centerId") final Long centerId, @QueryParam("command") final String commandParam, - final String apiRequestBodyAsJson, @Context final UriInfo uriInfo) { + @ApiOperation(value = "Activate a Center | Generate Collection Sheet | Save Collection Sheet | Close a Center | Associate Groups | Disassociate Groups", httpMethod = "POST", notes = "Activate a Center:\n\n" + "Centers can be created in a Pending state. This API exists to enable center activation. If the center happens to be already active, this API will result in an error.\n\n" + "Close a Center:\n\n" + "Centers can be closed if they don't have any non-closed groups or saving accounts. If the Center has any active groups or savings accounts, this API will result in an error.\n\n" + "Associate Groups:\n\n" + "This API allows associating existing groups to a center. The groups are listed from the office to which the center is associated. If group(s) is already associated with a center, this API will result in an error.\n\n" + "Disassociate Groups:\n\n" + "This API allows to disassociate groups from a center.\n\n" + "Generate Collection Sheet:\n\n" + "This Api retrieves repayment details of all jlg loans under a center as on a specified meeting date.\n\n" + "Save Collection Sheet:\n\n" + "This Api allows the loan officer to perform bulk repayments of JLG loans for a center on a given meeting date.\n\n" + "Showing Request/Response for Close a Center") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = CentersApiResourceSwagger.PostCentersCenterIdRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = CentersApiResourceSwagger.PostCentersCenterIdResponse.class)}) + public String activate(@PathParam("centerId") @ApiParam(value = "centerId") final Long centerId, @QueryParam("command") @ApiParam(value = "command") final String commandParam, + @ApiParam(hidden = true) final String apiRequestBodyAsJson, @Context final UriInfo uriInfo) { final CommandWrapperBuilder builder = new CommandWrapperBuilder().withJson(apiRequestBodyAsJson); @@ -322,7 +330,9 @@ public class CentersApiResource { @Path("{centerId}/accounts") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveGroupAccount(@PathParam("centerId") final Long centerId, @Context final UriInfo uriInfo) { + @ApiOperation(value = "Retrieve Center accounts overview", httpMethod = "GET", notes = "An example of how a savings summary for a Center can be provided. This is requested in a specific use case of the reference application.\n\n" + "It is quite reasonable to add resources like this to simplify User Interface development.\n\n" + "\n\n" + "Example Requests:\n\n" + "\n\n" + "centers/9/accounts") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = CentersApiResourceSwagger.GetCentersCenterIdAccountsResponse.class)}) + public String retrieveGroupAccount(@PathParam("centerId") @ApiParam(value = "centerId") final Long centerId, @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(GroupingTypesApiConstants.CENTER_RESOURCE_NAME); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/api/CentersApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/api/CentersApiResourceSwagger.java new file mode 100644 index 000000000..7a510c626 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/api/CentersApiResourceSwagger.java @@ -0,0 +1,343 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.group.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.time.LocalDate; +import java.util.Set; + +/** + * Created by Chirag Gupta on 12/18/17. + */ +final class CentersApiResourceSwagger { + private CentersApiResourceSwagger() { + } + + @ApiModel(value = "GetCentersTemplateResponse") + public final static class GetCentersTemplateResponse { + private GetCentersTemplateResponse() { + } + + final class GetCentersOfficeOptions { + private GetCentersOfficeOptions() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "Head Office") + public String name; + @ApiModelProperty(example = "Head Office") + public String nameDecorated; + } + + final class GetCentersStaffOptions { + private GetCentersStaffOptions() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "D, Mary") + public String displayName; + } + + + @ApiModelProperty(example = "false") + public Boolean active; + @ApiModelProperty(example = "[2013, 4, 18]") + public LocalDate activationDate; + @ApiModelProperty(example = "2") + public Integer officeId; + public Set officeOptions; + public Set staffOptions; + } + + @ApiModel(value = "GetCentersResponse") + public final static class GetCentersResponse { + private GetCentersResponse() { + } + + final class GetCentersPageItems { + private GetCentersPageItems() { + } + + final class GetCentersStatus { + private GetCentersStatus() { + } + + @ApiModelProperty(example = "100") + public Integer id; + @ApiModelProperty(example = "groupingStatusType.pending") + public String code; + @ApiModelProperty(example = "Pending") + public String value; + } + + @ApiModelProperty(example = "2") + public Integer id; + public GetCentersStatus status; + @ApiModelProperty(example = "false") + public Boolean active; + @ApiModelProperty(example = "Center 1") + public String name; + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "Head Office") + public String officeName; + @ApiModelProperty(example = ".2.") + public String hierarchy; + } + + @ApiModelProperty(example = "2") + public Integer totalFilteredRecords; + public Set pageItems; + } + + @ApiModel(value = "GetCentersCenterIdResponse") + public final static class GetCentersCenterIdResponse { + private GetCentersCenterIdResponse() { + } + + @ApiModelProperty(example = "8") + public Integer id; + public GetCentersResponse.GetCentersPageItems.GetCentersStatus status; + @ApiModelProperty(example = "false") + public Boolean active; + @ApiModelProperty(example = "First Center (No groups)") + public String name; + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "Head Office") + public String officeName; + @ApiModelProperty(example = ".8.") + public String hierarchy; + } + + @ApiModel(value = "PostCentersRequest") + public final static class PostCentersRequest { + private PostCentersRequest() { + } + + @ApiModelProperty(example = "First Center (No groups)") + public String name; + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "false") + public Boolean active; + } + + @ApiModel(value = "PostCentersResponse") + public final static class PostCentersResponse { + private PostCentersResponse() { + } + + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "8") + public Integer groupId; + @ApiModelProperty(example = "8") + public Integer resourceId; + } + + @ApiModel(value = "PutCentersCenterIdRequest") + public final static class PutCentersCenterIdRequest { + private PutCentersCenterIdRequest() { + } + + @ApiModelProperty(example = "First Center (No groups)") + public String name; + } + + @ApiModel(value = "PutCentersCenterIdResponse") + public final static class PutCentersCenterIdResponse { + private PutCentersCenterIdResponse() { + } + + final class PutCentersChanges { + private PutCentersChanges() { + } + + @ApiModelProperty(example = "First Center (No groups) - modified") + public String name; + } + + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "8") + public Integer groupId; + @ApiModelProperty(example = "8") + public Integer resourceId; + public PutCentersChanges changes; + } + + @ApiModel(value = "DeleteCentersCenterIdResponse") + public final static class DeleteCentersCenterIdResponse { + private DeleteCentersCenterIdResponse() { + } + + final class DeleteCentersChanges { + private DeleteCentersChanges() { + } + } + + @ApiModelProperty(example = "1") + public Integer resourceId; + public DeleteCentersChanges changes; + } + + @ApiModel(value = "PostCentersCenterIdRequest") + public final static class PostCentersCenterIdRequest { + private PostCentersCenterIdRequest() { + } + + @ApiModelProperty(example = "32") + public Integer closureReasonId; + @ApiModelProperty(example = "05 May 2014") + public String closureDate; + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "dd MMMM yyyy") + public String dateFormat; + } + + @ApiModel(value = "PostCentersCenterIdResponse") + public final static class PostCentersCenterIdResponse { + private PostCentersCenterIdResponse() { + } + + @ApiModelProperty(example = "1") + public Integer resourceId; + } + + @ApiModel(value = "GetCentersCenterIdAccountsResponse") + public final static class GetCentersCenterIdAccountsResponse { + private GetCentersCenterIdAccountsResponse() { + } + + final class GetCentersSavingsAccounts { + private GetCentersSavingsAccounts() { + } + + final class GetCentersCenterIdStatus { + private GetCentersCenterIdStatus() { + } + + @ApiModelProperty(example = "100") + public Integer id; + @ApiModelProperty(example = "savingsAccountStatusType.submitted.and.pending.approval") + public String code; + @ApiModelProperty(example = "Submitted and pending approval") + public String value; + @ApiModelProperty(example = "true") + public Boolean submittedAndPendingApproval; + @ApiModelProperty(example = "false") + public Boolean approved; + @ApiModelProperty(example = "false") + public Boolean rejected; + @ApiModelProperty(example = "false") + public Boolean withdrawnByApplicant; + @ApiModelProperty(example = "false") + public Boolean active; + @ApiModelProperty(example = "false") + public Boolean closed; + @ApiModelProperty(example = "false") + public Boolean prematureClosed; + @ApiModelProperty(example = "false") + public Boolean transferInProgress; + @ApiModelProperty(example = "false") + public Boolean transferOnHold; + } + + final class GetCentersCenterIdCurrency { + private GetCentersCenterIdCurrency() { + } + + @ApiModelProperty(example = "USD") + public String code; + @ApiModelProperty(example = "US Dollar") + public String name; + @ApiModelProperty(example = "2") + public Integer decimalPlaces; + @ApiModelProperty(example = "0") + public Integer inMultiplesOf; + @ApiModelProperty(example = "$") + public String displaySymbol; + @ApiModelProperty(example = "currency.USD") + public String nameCode; + @ApiModelProperty(example = "US Dollar ($)") + public String displayLabel; + } + + final class GetCentersAccountType { + private GetCentersAccountType() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "accountType.group") + public String code; + @ApiModelProperty(example = "Group") + public String value; + } + + final class GetCentersTimeline { + private GetCentersTimeline() { + } + + @ApiModelProperty(example = "[2014, 5, 1]") + public LocalDate submittedOnDate; + @ApiModelProperty(example = "mifos") + public String submittedByUsername; + @ApiModelProperty(example = "App") + public String submittedByFirstname; + @ApiModelProperty(example = "Administrator") + public String submittedByLastname; + } + + final class GetCentersDepositType { + private GetCentersDepositType() { + } + + @ApiModelProperty(example = "100") + public Integer id; + @ApiModelProperty(example = "depositAccountType.savingsDeposit") + public String code; + @ApiModelProperty(example = "Savings") + public String value; + } + + @ApiModelProperty(example = "16") + public Integer id; + @ApiModelProperty(example = "000000016") + public Long accountNo; + @ApiModelProperty(example = "1") + public Integer productId; + @ApiModelProperty(example = "Voluntary savings") + public String productName; + public GetCentersCenterIdStatus status; + public GetCentersCenterIdCurrency currency; + public GetCentersAccountType accountType; + public GetCentersTimeline timeline; + public GetCentersDepositType depositType; + } + + public Set savingsAccounts; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/api/GroupsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/api/GroupsApiResource.java index 96dc132a9..2d5059a37 100755 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/api/GroupsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/api/GroupsApiResource.java @@ -18,26 +18,8 @@ */ package org.apache.fineract.portfolio.group.api; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriInfo; - +import com.google.gson.JsonElement; +import io.swagger.annotations.*; import org.apache.commons.lang.StringUtils; import org.apache.fineract.commands.domain.CommandWrapper; import org.apache.fineract.commands.service.CommandWrapperBuilder; @@ -81,11 +63,16 @@ import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; -import com.google.gson.JsonElement; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; +import java.util.*; @Path("/groups") @Component @Scope("singleton") +@Api(value = "Groups", description = "Groups are used to provide a distinctive banking distribution channel used in microfinances throughout the world. The Group is an administrative unit. It can contain as few as 5 people or as many as 40 depending on how its used.\n\n" + "\n\n" + "Different styles of group lending - Joint-Liability Group, Grameen Model (Center-Group), Self-Help Groups, Village/Communal Banks)") public class GroupsApiResource { private final PlatformSecurityContext context; @@ -141,10 +128,12 @@ public class GroupsApiResource { @Path("template") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveTemplate(@Context final UriInfo uriInfo, @QueryParam("officeId") final Long officeId, - @QueryParam("center") final boolean isCenterGroup, @QueryParam("centerId") final Long centerId, - @QueryParam("command") final String commandParam, - @DefaultValue("false") @QueryParam("staffInSelectedOfficeOnly") final boolean staffInSelectedOfficeOnly) { + @ApiOperation(value = "Retrieve Group Template", httpMethod = "GET", notes = "This is a convenience resource. It can be useful when building maintenance user interface screens for client applications. The template data returned consists of any or all of:\n\n" + "\n\n" + "Field Defaults\n\n" + "Allowed Value Lists\n\n" + "Example Requests:\n\n" + "\n\n" + "groups/template\n\n" + "\n\n" + "groups/template?officeId=2\n\n" + "\n\n" + "groups/template?centerId=1\n\n" + "\n\n" + "groups/template?centerId=1&staffInSelectedOfficeOnly=true") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = GroupsApiResourceSwagger.GetGroupsTemplateResponse.class)}) + public String retrieveTemplate(@Context final UriInfo uriInfo, @QueryParam("officeId") @ApiParam(value = "officeId") final Long officeId, + @QueryParam("center") @ApiParam(value = "center") final boolean isCenterGroup, @QueryParam("centerId") @ApiParam(value = "centerId") final Long centerId, + @QueryParam("command") @ApiParam(value = "command") final String commandParam, + @DefaultValue("false") @QueryParam("staffInSelectedOfficeOnly") @ApiParam(value = "staffInSelectedOfficeOnly") final boolean staffInSelectedOfficeOnly) { this.context.authenticatedUser().validateHasReadPermission(GroupingTypesApiConstants.GROUP_RESOURCE_NAME); @@ -177,13 +166,15 @@ public class GroupsApiResource { @GET @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveAll(@Context final UriInfo uriInfo, @QueryParam("sqlSearch") final String sqlSearch, - @QueryParam("officeId") final Long officeId, @QueryParam("staffId") final Long staffId, - @QueryParam("externalId") final String externalId, @QueryParam("name") final String name, - @QueryParam("underHierarchy") final String hierarchy, @QueryParam("paged") final Boolean paged, - @QueryParam("offset") final Integer offset, @QueryParam("limit") final Integer limit, - @QueryParam("orderBy") final String orderBy, @QueryParam("sortOrder") final String sortOrder, - @QueryParam("orphansOnly") final Boolean orphansOnly) { + @ApiOperation(value = "List Groups", httpMethod = "GET", notes = "The default implementation of listing Groups returns 200 entries with support for pagination and sorting. Using the parameter limit with value -1 returns all entries.\n\n" + "Example Requests:\n\n" + "\n\n" + "groups\n\n" + "\n\n" + "groups?fields=name,officeName,joinedDate\n\n" + "\n\n" + "groups?offset=10&limit=50\n\n" + "\n\n" + "groups?orderBy=name&sortOrder=DESC") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = GroupsApiResourceSwagger.GetGroupsResponse.class)}) + public String retrieveAll(@Context final UriInfo uriInfo, @QueryParam("sqlSearch") @ApiParam(value = "sqlSearch") final String sqlSearch, + @QueryParam("officeId") @ApiParam(value = "officeId") final Long officeId, @QueryParam("staffId") @ApiParam(value = "staffId") final Long staffId, + @QueryParam("externalId") @ApiParam(value = "externalId") final String externalId, @QueryParam("name") @ApiParam(value = "name") final String name, + @QueryParam("underHierarchy") @ApiParam(value = "underHierarchy") final String hierarchy, @QueryParam("paged") @ApiParam(value = "paged") final Boolean paged, + @QueryParam("offset")@ApiParam(value = "offset") final Integer offset, @QueryParam("limit") @ApiParam(value = "limit") final Integer limit, + @QueryParam("orderBy") @ApiParam(value = "orderBy") final String orderBy, @QueryParam("sortOrder") @ApiParam(value = "sortOrder") final String sortOrder, + @QueryParam("orphansOnly") @ApiParam(value = "orphansOnly") final Boolean orphansOnly) { this.context.authenticatedUser().validateHasReadPermission(GroupingTypesApiConstants.GROUP_RESOURCE_NAME); final PaginationParameters parameters = PaginationParameters.instance(paged, offset, limit, orderBy, sortOrder); @@ -204,9 +195,11 @@ public class GroupsApiResource { @Path("{groupId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveOne(@Context final UriInfo uriInfo, @PathParam("groupId") final Long groupId, - @DefaultValue("false") @QueryParam("staffInSelectedOfficeOnly") final boolean staffInSelectedOfficeOnly, - @QueryParam("roleId") final Long roleId) { + @ApiOperation(value = "Retrieve a Group", httpMethod = "GET", notes = "Retrieve group information.\n\n" + "Example Requests:\n\n" + "\n\n" + "groups/1\n\n" + "\n\n" + "groups/1?associations=clientMembers") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = GroupsApiResourceSwagger.GetGroupsGroupIdResponse.class)}) + public String retrieveOne(@Context final UriInfo uriInfo, @PathParam("groupId") @ApiParam(value = "groupId") final Long groupId, + @DefaultValue("false") @QueryParam("staffInSelectedOfficeOnly") @ApiParam(value = "staffInSelectedOfficeOnly") final boolean staffInSelectedOfficeOnly, + @QueryParam("roleId") @ApiParam(value = "roleId") final Long roleId) { this.context.authenticatedUser().validateHasReadPermission(GroupingTypesApiConstants.GROUP_RESOURCE_NAME); final Set associationParameters = ApiParameterHelper.extractAssociationsForResponseIfProvided(uriInfo.getQueryParameters()); @@ -301,7 +294,10 @@ public class GroupsApiResource { @POST @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String create(final String apiRequestBodyAsJson) { + @ApiOperation(value = "Create a Group", httpMethod = "POST", notes = "Creates a Group\n\n" + "Mandatory Fields: name, officeId, active, activationDate (if active=true)\n\n" + "Optional Fields: externalId, staffId, clientMembers") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = GroupsApiResourceSwagger.PostGroupsRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = GroupsApiResourceSwagger.PostGroupsResponse.class)}) + public String create(@ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder() // .createGroup() // @@ -315,7 +311,10 @@ public class GroupsApiResource { @Path("{groupId}/command/unassign_staff") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String unassignLoanOfficer(@PathParam("groupId") final Long groupId, final String apiRequestBodyAsJson) { + @ApiOperation(value = "Unassign a Staff", httpMethod = "POST", notes = "Allows you to unassign the Staff.\n\n" + "Mandatory Fields: staffId") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = GroupsApiResourceSwagger.PostGroupsGroupIdCommandUnassignStaffRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = GroupsApiResourceSwagger.PostGroupsGroupIdCommandUnassignStaffResponse.class )}) + public String unassignLoanOfficer(@PathParam("groupId") @ApiParam(value = "groupId") final Long groupId,@ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder() // .unassignGroupStaff(groupId) // @@ -330,7 +329,10 @@ public class GroupsApiResource { @Path("{groupId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String update(@PathParam("groupId") final Long groupId, final String apiRequestBodyAsJson) { + @ApiOperation(value = "Update a Group", httpMethod = "PUT", notes = "Updates a Group") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = GroupsApiResourceSwagger.PutGroupsGroupIdRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = GroupsApiResourceSwagger.PutGroupsGroupIdResponse.class)}) + public String update(@PathParam("groupId")@ApiParam(value = "groupId") final Long groupId, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder() // .updateGroup(groupId) // @@ -344,7 +346,9 @@ public class GroupsApiResource { @Path("{groupId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String delete(@PathParam("groupId") final Long groupId) { + @ApiOperation(value = "Delete a Group", httpMethod = "DELETE", notes = "A group can be deleted if it is in pending state and has no associations - clients, loans or savings") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = GroupsApiResourceSwagger.DeleteGroupsGroupIdResponse.class)}) + public String delete(@PathParam("groupId") @ApiParam(value = "groupId") final Long groupId) { final CommandWrapper commandRequest = new CommandWrapperBuilder() // .deleteGroup(groupId) // @@ -357,8 +361,11 @@ public class GroupsApiResource { @Path("{groupId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String activateOrGenerateCollectionSheet(@PathParam("groupId") final Long groupId, - @QueryParam("command") final String commandParam, @QueryParam("roleId") final Long roleId, final String apiRequestBodyAsJson, + @ApiOperation(value = "Activate a Group | Associate Clients | Disassociate Clients | Transfer Clients across groups | Generate Collection Sheet | Save Collection Sheet | Unassign a Staff | Assign a Staff | Close a Group | Unassign a Role | Update a Role", httpMethod = "POST", notes = "Activate a Group:\n\n" + "Groups can be created in a Pending state. This API exists to enable group activation.\n\n" + "\n\n" + "If the group happens to be already active this API will result in an error.\n\n" + "Mandatory Fields: activationDate\n\n" + "Associate Clients:\n\n" + "This API allows to associate existing clients to a group.\n\n" + "\n\n" + "The clients are listed from the office to which the group is associated.\n\n" + "\n\n" + "If client(s) is already associated with group then API will result in an error.\n\n" + "Mandatory Fields: clientMembers\n\n" + "Disassociate Clients:\n\n" + "This API allows to disassociate clients from a group.\n\n" + "\n\n" + "Disassociating a client with active joint liability group loans results in an error.\n\n" + "Mandatory Fields: clientMembers\n\n" + "Transfer Clients across groups:\n\n" + "This API allows to transfer clients from one group to another\n\n" + "Mandatory Fields: destinationGroupId and clients\n\n" + "Optional Fields: inheritDestinationGroupLoanOfficer (defaults to true) and transferActiveLoans (defaults to true)\n\n" + "Generate Collection Sheet:\n\n" + "This API retrieves repayment details of all jlg loans of all members of a group on a specified meeting date.\n\n" + "Mandatory Fields: calendarId and transactionDate\n\n" + "Save Collection Sheet:\n\n" + "This api allows the loan officer to perform bulk repayments of JLG loans for a group on its meeting date.\n\n" + "Mandatory Fields: calendarId, transactionDate, actualDisbursementDate\n\n" + "Optional Fields: clientsAttendance, bulkRepaymentTransaction, bulkDisbursementTransactions\n\n" + "Unassign a Staff:\n\n" + "Allows you to unassign the Staff.\n\n" + "Mandatory Fields: staffId\n\n" + "Assign a Staff:\n\n" + "Allows you to assign Staff to an existing Group.\n\n" + "\n\n" + "The selected Staff should be belong to the same office (or an office higher up in the hierarchy) as this group" + "Mandatory Fields: staffId\n\n" + "Optional Fields: inheritStaffForClientAccounts (Optional: Boolean if true all members of the group (i.e all clients with active loans and savings ) will inherit the staffId)\n\n" + "Close a Group:\n\n" + "This API exists to close a group. Groups can be closed if they don't have any non-closed clients/loans/savingsAccounts.\n\n" + "\n\n" + "If the group has any active clients/loans/savingsAccount, this API will result in an error." + "Assign a Role:\n\n" + "Allows you to assign a Role to an existing member of a group.\n\n" + "\n\n" + "We can define the different roles applicable to group members by adding code values to the pre-defined system code GROUPROLE. Example:Group leader etc.\n\n" + "Mandatory Fields: clientId, role\n\n" + "Unassign a Role:\n\n" + "Allows you to unassign Roles associated tp Group members.\n\n" + "Update a Role:\n\n" + "Allows you to update the member Role.\n\n" + "Mandatory Fields: role\n\n" + "Showing request/response for Transfer Clients across groups") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = GroupsApiResourceSwagger.PostGroupsGroupIdRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = GroupsApiResourceSwagger.PostGroupsGroupIdResponse.class)}) + public String activateOrGenerateCollectionSheet(@PathParam("groupId") @ApiParam(value = "groupId") final Long groupId, + @QueryParam("command") @ApiParam(value = "command") final String commandParam, @QueryParam("roleId") @ApiParam(value = "roleId") final Long roleId, @ApiParam(hidden = true) final String apiRequestBodyAsJson, @Context final UriInfo uriInfo) { final CommandWrapperBuilder builder = new CommandWrapperBuilder().withJson(apiRequestBodyAsJson); @@ -429,7 +436,9 @@ public class GroupsApiResource { @Path("{groupId}/accounts") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveAccounts(@PathParam("groupId") final Long groupId, @Context final UriInfo uriInfo) { + @ApiOperation(value = "Retrieve Group accounts overview", httpMethod = "GET", notes = "Retrieves details of all Loan and Savings accounts associated with this group.\n\n" + "\n\n" + "Example Requests:\n\n" + "\n\n" + "groups/1/accounts\n\n" + "\n\n" + "\n\n" + "groups/1/accounts?fields=loanAccounts,savingsAccounts,memberLoanAccounts,\n\n" + "memberSavingsAccounts") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = GroupsApiResourceSwagger.GetGroupsGroupIdAccountsResponse.class)}) + public String retrieveAccounts(@PathParam("groupId") @ApiParam(value = "groupId") final Long groupId, @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission("GROUP"); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/api/GroupsApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/api/GroupsApiResourceSwagger.java new file mode 100644 index 000000000..23d0911ac --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/group/api/GroupsApiResourceSwagger.java @@ -0,0 +1,529 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.group.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.time.LocalDate; +import java.util.Set; + +/** + * Created by Chirag Gupta on 12/10/17. + */ +final class GroupsApiResourceSwagger { + private GroupsApiResourceSwagger() { + } + + @ApiModel(value = "GetGroupsTemplateResponse") + public final static class GetGroupsTemplateResponse { + private GetGroupsTemplateResponse() { + } + + final class GetGroupsTemplateOfficeOptions { + private GetGroupsTemplateOfficeOptions() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "Head Office") + public String name; + @ApiModelProperty(example = "Head Office") + public String nameDecorated; + } + + final class GetGroupsTemplateStaffOptions { + private GetGroupsTemplateStaffOptions() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "C, Mike") + public String displayName; + } + + final class GetGroupsTemplateClientOptions { + private GetGroupsTemplateClientOptions() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "Petra Yton") + public String displayName; + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "Head Office") + public String officeName; + } + + final class GetGroupsTemplateDatatables { + private GetGroupsTemplateDatatables() { + } + + final class GetGroupsTemplateColumnHeaderData { + private GetGroupsTemplateColumnHeaderData() { + } + + final class GetGroupsTemplateColumnValues { + private GetGroupsTemplateColumnValues() { + } + } + + @ApiModelProperty(example = "group_id") + public String columnName; + @ApiModelProperty(example = "bigint") + public String columnType; + @ApiModelProperty(example = "0") + public Integer columnLength; + @ApiModelProperty(example = "INTEGER") + public String columnDisplayType; + @ApiModelProperty(example = "false") + public Boolean isColumnNullable; + @ApiModelProperty(example = "true") + public Boolean isColumnPrimaryKey; + public Set columnValues; + } + + @ApiModelProperty(example = "m_group") + public String applicationTableName; + @ApiModelProperty(example = "Group Activation Data") + public String registeredTableName; + public Set columnHeaderData; + } + + @ApiModelProperty(example = "1") + public Integer officeId; + public Set officeOptions; + public Set staffOptions; + public Set clientOptions; + public Set datatables; + } + + @ApiModel(value = "GetGroupsResponse") + public static final class GetGroupsResponse { + private GetGroupsResponse() { + } + + final class GetGroupsPageItems { + private GetGroupsPageItems() { + } + + final class GetGroupsStatus { + private GetGroupsStatus() { + } + + @ApiModelProperty(example = "100") + public Integer id; + @ApiModelProperty(example = "clientStatusType.pending") + public String code; + @ApiModelProperty(example = "Pending") + public String value; + } + + @ApiModelProperty(example = "4") + public Integer id; + @ApiModelProperty(example = "AnotherGroup") + public String name; + public GetGroupsStatus status; + @ApiModelProperty(example = "false") + public Boolean active; + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "Head Office") + public String officeName; + @ApiModelProperty(example = ".4.") + public String hierarchy; + } + + @ApiModelProperty(example = "2") + public Integer totalFilteredRecords; + public Set pageItems; + } + + @ApiModel(value = "GetGroupsGroupIdResponse") + public final static class GetGroupsGroupIdResponse { + private GetGroupsGroupIdResponse() { + } + + final class GetGroupsGroupIdTimeline { + private GetGroupsGroupIdTimeline() { + } + + @ApiModelProperty(example = "[2013, 11, 14]") + public LocalDate activatedOnDate; + @ApiModelProperty(example = "mifos") + public String activatedByUsername; + @ApiModelProperty(example = "App") + public String activatedByFirstname; + @ApiModelProperty(example = "Administrator") + public String activatedByLastname; + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "First Group") + public String name; + @ApiModelProperty(example = "000-1A") + public String externalId; + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "Head Office") + public String officeName; + @ApiModelProperty(example = ".1.") + public String hierarchy; + public GetGroupsGroupIdTimeline timeline; + } + + @ApiModel(value = "PostGroupsRequest") + public final static class PostGroupsRequest { + private PostGroupsRequest() { + } + + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "Pending Group") + public String name; + @ApiModelProperty(example = "false") + public Boolean active; + } + + @ApiModel(value = "PostGroupsResponse") + public final static class PostGroupsResponse { + private PostGroupsResponse() { + } + + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "2") + public Integer groupId; + @ApiModelProperty(example = "2") + public Integer resourceId; + } + + @ApiModel(value = "DeleteGroupsGroupIdResponse") + public final static class DeleteGroupsGroupIdResponse { + private DeleteGroupsGroupIdResponse() { + } + + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "2") + public Integer groupId; + @ApiModelProperty(example = "2") + public Integer resourceId; + } + + @ApiModel(value = "PostGroupsGroupIdCommandUnassignStaffRequest") + public final static class PostGroupsGroupIdCommandUnassignStaffRequest { + private PostGroupsGroupIdCommandUnassignStaffRequest() { + } + + @ApiModelProperty(example = "1") + public Integer staffId; + } + + @ApiModel(value = "PostGroupsGroupIdCommandUnassignStaffResponse") + public final static class PostGroupsGroupIdCommandUnassignStaffResponse { + private PostGroupsGroupIdCommandUnassignStaffResponse() { + } + + final class PostGroupsGroupIdCommandUnassignStaffChanges { + private PostGroupsGroupIdCommandUnassignStaffChanges() { + } + } + + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "1") + public Integer groupId; + @ApiModelProperty(example = "1") + public Integer resourceId; + public PostGroupsGroupIdCommandUnassignStaffChanges changes; + } + + @ApiModel(value = "PutGroupsGroupIdRequest") + public final static class PutGroupsGroupIdRequest { + private PutGroupsGroupIdRequest() { + } + + @ApiModelProperty(example = "First Group (changed)") + public String name; + } + + @ApiModel(value = "PutGroupsGroupIdResponse") + public final static class PutGroupsGroupIdResponse { + private PutGroupsGroupIdResponse() { + } + + final class PutGroupsGroupIdChanges { + private PutGroupsGroupIdChanges() { + } + + @ApiModelProperty(example = "First Group (changed)") + public String name; + } + + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "1") + public Integer groupId; + @ApiModelProperty(example = "1") + public Integer resourceId; + public PutGroupsGroupIdChanges changes; + } + + @ApiModel(value = "GetGroupsGroupIdAccountsResponse") + public final static class GetGroupsGroupIdAccountsResponse { + private GetGroupsGroupIdAccountsResponse() { + } + + final class GetGroupsGroupIdAccountsLoanAccounts { + private GetGroupsGroupIdAccountsLoanAccounts() { + } + + final class GetGroupsGroupIdAccountsStatus { + private GetGroupsGroupIdAccountsStatus() { + } + + @ApiModelProperty(example = "100") + public Integer id; + @ApiModelProperty(example = "loanStatusType.submitted.and.pending.approval") + public String code; + @ApiModelProperty(example = "Submitted and pending approval") + public String value; + @ApiModelProperty(example = "true") + public Boolean pendingApproval; + @ApiModelProperty(example = "false") + public Boolean waitingForDisbursal; + @ApiModelProperty(example = "false") + public Boolean active; + @ApiModelProperty(example = "false") + public Boolean closedObligationsMet; + @ApiModelProperty(example = "false") + public Boolean closedWrittenOff; + @ApiModelProperty(example = "false") + public Boolean closedRescheduled; + @ApiModelProperty(example = "false") + public Boolean closed; + @ApiModelProperty(example = "false") + public Boolean overpaid; + } + + final class GetGroupsGroupIdAccountsLoanType { + private GetGroupsGroupIdAccountsLoanType() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "accountType.group") + public String code; + @ApiModelProperty(example = "Group") + public String value; + } + + @ApiModelProperty(example = "3") + public Integer id; + @ApiModelProperty(example = "000000003") + public Long accountNo; + @ApiModelProperty(example = "3") + public Integer productId; + @ApiModelProperty(example = "daily product") + public String productName; + public GetGroupsGroupIdAccountsStatus status; + public GetGroupsGroupIdAccountsLoanType loanType; + } + + final class GetGroupsGroupIdAccountsSavingAccounts { + private GetGroupsGroupIdAccountsSavingAccounts() { + } + + final class GetGroupsGroupIdAccountsSavingStatus { + private GetGroupsGroupIdAccountsSavingStatus() { + } + + @ApiModelProperty(example = "100") + public Integer id; + @ApiModelProperty(example = "savingsAccountStatusType.submitted.and.pending.approval") + public String code; + @ApiModelProperty(example = "Submitted and pending approval") + public String value; + @ApiModelProperty(example = "true") + public Boolean submittedAndPendingApproval; + @ApiModelProperty(example = "false") + public Boolean approved; + @ApiModelProperty(example = "false") + public Boolean rejected; + @ApiModelProperty(example = "false") + public Boolean withdrawnByApplicant; + @ApiModelProperty(example = "false") + public Boolean active; + @ApiModelProperty(example = "false") + public Boolean closed; + } + + final class GetGroupsGroupIdAccountsSavingCurrency { + private GetGroupsGroupIdAccountsSavingCurrency() { + } + + @ApiModelProperty(example = "USD") + public String code; + @ApiModelProperty(example = "US Dollar") + public String name; + @ApiModelProperty(example = "2") + public Integer decimalPlaces; + @ApiModelProperty(example = "$") + public String displaySymbol; + @ApiModelProperty(example = "currency.USD") + public String nameCode; + @ApiModelProperty(example = "US Dollar ($)") + public String displayLabel; + } + + final class GetGroupsGroupIdAccountsSavingAccountType { + private GetGroupsGroupIdAccountsSavingAccountType() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "accountType.group") + public String code; + @ApiModelProperty(example = "Group") + public String value; + } + + @ApiModelProperty(example = "9") + public Integer id; + @ApiModelProperty(example = "000000009") + public Long accountNo; + @ApiModelProperty(example = "1") + public Integer productId; + @ApiModelProperty(example = "p_sav") + public String productName; + public GetGroupsGroupIdAccountsSavingStatus status; + public GetGroupsGroupIdAccountsSavingCurrency currency; + public GetGroupsGroupIdAccountsSavingAccountType accountType; + } + + final class GetGroupsGroupIdAccountsMemberLoanAccounts { + private GetGroupsGroupIdAccountsMemberLoanAccounts() { + } + + final class GetGroupsGroupIdAccountsMemberLoanStatus { + private GetGroupsGroupIdAccountsMemberLoanStatus() { + } + + @ApiModelProperty(example = "200") + public Integer id; + @ApiModelProperty(example = "loanStatusType.approved") + public String code; + @ApiModelProperty(example = "Approved") + public String value; + @ApiModelProperty(example = "false") + public Boolean pendingApproval; + @ApiModelProperty(example = "true") + public Boolean waitingForDisbursal; + @ApiModelProperty(example = "false") + public Boolean active; + @ApiModelProperty(example = "false") + public Boolean closedObligationsMet; + @ApiModelProperty(example = "false") + public Boolean closedWrittenOff; + @ApiModelProperty(example = "false") + public Boolean closedRescheduled; + @ApiModelProperty(example = "false") + public Boolean closed; + @ApiModelProperty(example = "false") + public Boolean overpaid; + } + + final class GetGroupsGroupIdAccountsMemberLoanType { + private GetGroupsGroupIdAccountsMemberLoanType() { + } + + @ApiModelProperty(example = "3") + public Integer id; + @ApiModelProperty(example = "accountType.jlg") + public String code; + @ApiModelProperty(example = "JLG") + public String value; + } + + @ApiModelProperty(example = "4") + public Integer id; + @ApiModelProperty(example = "000000004") + public Long accountNo; + @ApiModelProperty(example = "1") + public Integer productId; + @ApiModelProperty(example = "testLoan") + public String productName; + public GetGroupsGroupIdAccountsMemberLoanStatus status; + public GetGroupsGroupIdAccountsMemberLoanType loanType; + } + + final class GetGroupsGroupIdAccountsMemberSavingsAccounts { + private GetGroupsGroupIdAccountsMemberSavingsAccounts() { + } + + + @ApiModelProperty(example = "3") + public Integer id; + @ApiModelProperty(example = "000000003") + public Long accountNo; + @ApiModelProperty(example = "1") + public Integer productId; + @ApiModelProperty(example = "p_sav") + public String productName; + public GetGroupsGroupIdAccountsSavingAccounts.GetGroupsGroupIdAccountsSavingStatus status; + public GetGroupsGroupIdAccountsSavingAccounts.GetGroupsGroupIdAccountsSavingCurrency currency; + public GetGroupsGroupIdAccountsMemberLoanAccounts.GetGroupsGroupIdAccountsMemberLoanType accountType; + } + + public Set loanAccounts; + public Set savingsAccounts; + public Set memberLoanAccounts; + public Set memberSavingsAccounts; + } + + @ApiModel(value = "PostGroupsGroupIdRequest") + public final static class PostGroupsGroupIdRequest { + private PostGroupsGroupIdRequest() { + } + + final class PostGroupsGroupIdClients { + private PostGroupsGroupIdClients() { + } + + @ApiModelProperty(example = "1") + public Integer id; + } + + @ApiModelProperty(example = "2") + public Integer destinationGroupId; + public Set clients; + } + + @ApiModel(value = "PostGroupsGroupIdResponse") + public final static class PostGroupsGroupIdResponse { + private PostGroupsGroupIdResponse() { + } + + @ApiModelProperty(example = "1") + public Integer resourceId; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/api/InterestRateChartSlabsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/api/InterestRateChartSlabsApiResource.java index d62878dfc..364be3d2a 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/api/InterestRateChartSlabsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/api/InterestRateChartSlabsApiResource.java @@ -18,36 +18,7 @@ */ package org.apache.fineract.portfolio.interestratechart.api; -import static org.apache.fineract.portfolio.interestratechart.InterestRateChartSlabApiConstants.INTERESTRATE_CHART_SLAB_RESOURCE_NAME; - - -import static org.apache.fineract.portfolio.interestratechart.InterestRateChartSlabApiConstants.amountRangeFromParamName; -import static org.apache.fineract.portfolio.interestratechart.InterestRateChartSlabApiConstants.amountRangeToParamName; -import static org.apache.fineract.portfolio.interestratechart.InterestRateChartSlabApiConstants.annualInterestRateParamName; -import static org.apache.fineract.portfolio.interestratechart.InterestRateChartSlabApiConstants.currencyCodeParamName; -import static org.apache.fineract.portfolio.interestratechart.InterestRateChartSlabApiConstants.descriptionParamName; -import static org.apache.fineract.portfolio.interestratechart.InterestRateChartSlabApiConstants.fromPeriodParamName; -import static org.apache.fineract.portfolio.interestratechart.InterestRateChartSlabApiConstants.incentivesParamName; -import static org.apache.fineract.portfolio.interestratechart.InterestRateChartSlabApiConstants.periodTypeParamName; -import static org.apache.fineract.portfolio.interestratechart.InterestRateChartSlabApiConstants.toPeriodParamName; - -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriInfo; - +import io.swagger.annotations.*; import org.apache.fineract.commands.domain.CommandWrapper; import org.apache.fineract.commands.service.CommandWrapperBuilder; import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService; @@ -63,9 +34,21 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import static org.apache.fineract.portfolio.interestratechart.InterestRateChartSlabApiConstants.*; + @Path("/interestratecharts/{chartId}/chartslabs") @Component @Scope("singleton") +@Api(value = "Interest Rate Slab (A.K.A interest bands)", description = "The slabs a.k.a interest bands are associated with Interest Rate Chart. These bands allow to define different interest rates for different deposit term periods.") public class InterestRateChartSlabsApiResource { private final InterestRateChartSlabReadPlatformService interestRateChartSlabReadPlatformService; @@ -105,7 +88,9 @@ public class InterestRateChartSlabsApiResource { @GET @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveAll(@PathParam("chartId") final Long chartId, @Context final UriInfo uriInfo) { + @ApiOperation(value = "Retrieve all Slabs", httpMethod = "GET", notes = "Retrieve list of slabs associated with a chart\n" + "\n" + "Example Requests:\n" + "\n" + "interestratecharts/1/chartslabs") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = InterestRateChartSlabsApiResourceSwagger.GetInterestRateChartsChartIdChartSlabsResponse.class, responseContainer = "List")}) + public String retrieveAll(@PathParam("chartId") @ApiParam(value = "chartId") final Long chartId, @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(INTERESTRATE_CHART_SLAB_RESOURCE_NAME); Collection chartSlabs = this.interestRateChartSlabReadPlatformService.retrieveAll(chartId); @@ -118,7 +103,9 @@ public class InterestRateChartSlabsApiResource { @Path("{chartSlabId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveOne(@PathParam("chartId") final Long chartId, @PathParam("chartSlabId") final Long chartSlabId, + @ApiOperation(value = "Retrieve a Slab", httpMethod = "GET", notes = "Retrieve a slab associated with an Interest rate chart\n" + "\n" + "Example Requests:\n" + "\n" + "interestratecharts/1/chartslabs/1\n") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = InterestRateChartSlabsApiResourceSwagger.GetInterestRateChartsChartIdChartSlabsResponse.class)}) + public String retrieveOne(@PathParam("chartId") @ApiParam(value = "chartId") final Long chartId, @PathParam("chartSlabId") @ApiParam(value = "chartSlabId") final Long chartSlabId, @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(INTERESTRATE_CHART_SLAB_RESOURCE_NAME); @@ -135,7 +122,10 @@ public class InterestRateChartSlabsApiResource { @POST @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String create(@PathParam("chartId") final Long chartId, final String apiRequestBodyAsJson) { + @ApiOperation(value = "Create a Slab", httpMethod = "POST", notes = "Creates a new interest rate slab for an interest rate chart.\n" + "Mandatory Fields\n" + "periodType, fromPeriod, annualInterestRate\n" + "Optional Fields\n" + "toPeriod and description\n" +"Example Requests:\n" + "\n" + "interestratecharts/1/chartslabs") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = InterestRateChartSlabsApiResourceSwagger.PostInterestRateChartsChartIdChartSlabsRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = InterestRateChartSlabsApiResourceSwagger.PostInterestRateChartsChartIdChartSlabsResponse.class)}) + public String create(@PathParam("chartId") @ApiParam(value = "chartId") final Long chartId, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder().createInterestRateChartSlab(chartId) .withJson(apiRequestBodyAsJson).build(); @@ -149,8 +139,11 @@ public class InterestRateChartSlabsApiResource { @Path("{chartSlabId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String update(@PathParam("chartId") final Long chartId, @PathParam("chartSlabId") final Long chartSlabId, - final String apiRequestBodyAsJson) { + @ApiOperation(value = "Update a Slab", httpMethod = "PUT", notes = "It updates the Slab from chart") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = InterestRateChartSlabsApiResourceSwagger.PutInterestRateChartsChartIdChartSlabsChartSlabIdRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = InterestRateChartSlabsApiResourceSwagger.PutInterestRateChartsChartIdChartSlabsChartSlabIdResponse.class)}) + public String update(@PathParam("chartId") @ApiParam(value = "chartId") final Long chartId, @PathParam("chartSlabId") @ApiParam(value = "chartSlabId") final Long chartSlabId, + @ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder().updateInterestRateChartSlab(chartId, chartSlabId) .withJson(apiRequestBodyAsJson).build(); @@ -164,7 +157,9 @@ public class InterestRateChartSlabsApiResource { @Path("{chartSlabId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String delete(@PathParam("chartId") final Long chartId, @PathParam("chartSlabId") final Long chartSlabId) { + @ApiOperation(value = "Delete a Slab", httpMethod = "DELETE", notes = "Delete a Slab from a chart") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = InterestRateChartSlabsApiResourceSwagger.DeleteInterestRateChartsChartIdChartSlabsResponse.class)}) + public String delete(@PathParam("chartId") @ApiParam(value = "chartId") final Long chartId, @PathParam("chartSlabId") @ApiParam(value = "chartSlabId") final Long chartSlabId) { final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteInterestRateChartSlab(chartId, chartSlabId).build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); return this.toApiJsonSerializer.serialize(result); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/api/InterestRateChartSlabsApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/api/InterestRateChartSlabsApiResourceSwagger.java new file mode 100644 index 000000000..2d18cbf7b --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/api/InterestRateChartSlabsApiResourceSwagger.java @@ -0,0 +1,195 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.interestratechart.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Set; + +/** + * Created by Chirag Gupta on 08/12/17. + */ +final class InterestRateChartSlabsApiResourceSwagger { + private InterestRateChartSlabsApiResourceSwagger() { + } + + @ApiModel(value = "GetInterestRateChartsChartIdChartSlabsResponse") + public final static class GetInterestRateChartsChartIdChartSlabsResponse { + private GetInterestRateChartsChartIdChartSlabsResponse() { + } + + final class GetInterestRateChartsChartIdChartSlabsIncentives { + private GetInterestRateChartsChartIdChartSlabsIncentives() { + } + + final class GetInterestRateChartsChartIdChartSlabsEntityType { + private GetInterestRateChartsChartIdChartSlabsEntityType() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "InterestIncentiveEntityType.customer") + public Integer code; + @ApiModelProperty(example = "Customer") + public Integer value; + } + + final class GetInterestRateChartsChartIdChartSlabsAttributeName { + private GetInterestRateChartsChartIdChartSlabsAttributeName() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "InterestIncentiveAttributeName.gender") + public Integer code; + @ApiModelProperty(example = "Gender") + public Integer value; + } + + final class GetInterestRateChartsChartIdChartSlabsConditionType { + private GetInterestRateChartsChartIdChartSlabsConditionType() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "incentiveConditionType.equal") + public Integer code; + @ApiModelProperty(example = "equal") + public Integer value; + } + + final class GetInterestRateChartsChartIdChartSlabsIncentiveType { + private GetInterestRateChartsChartIdChartSlabsIncentiveType() { + } + + @ApiModelProperty(example = "3") + public Integer id; + @ApiModelProperty(example = "InterestIncentiveType.incentive") + public Integer code; + @ApiModelProperty(example = "Incentive") + public Integer value; + } + + @ApiModelProperty(example = "1") + public Integer id; + public GetInterestRateChartsChartIdChartSlabsEntityType entityType; + public GetInterestRateChartsChartIdChartSlabsAttributeName attributeName; + public GetInterestRateChartsChartIdChartSlabsConditionType conditionType; + @ApiModelProperty(example = "11") + public Integer attributeValue; + @ApiModelProperty(example = "FEMALE") + public String attributeValueDesc; + public GetInterestRateChartsChartIdChartSlabsIncentiveType incentiveType; + @ApiModelProperty(example = "-1.000000") + public Float amount; + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "5% interest from 1 day till 180 days of deposit") + public String description; + public InterestRateChartsApiResourceSwagger.GetInterestRateChartsTemplateResponse.GetInterestRateChartsTemplatePeriodTypes periodTypes; + @ApiModelProperty(example = "1") + public Integer fromPeriod; + @ApiModelProperty(example = "180") + public Integer toPeriod; + @ApiModelProperty(example = "5") + public Double annualInterestRate; + public InterestRateChartsApiResourceSwagger.GetInterestRateChartsResponse.GetInterestRateChartsCurrency currency; + public Set incentives; + } + + @ApiModel(value = "PostInterestRateChartsChartIdChartSlabsRequest") + public static final class PostInterestRateChartsChartIdChartSlabsRequest { + private PostInterestRateChartsChartIdChartSlabsRequest() { + } + + final class PostInterestRateChartsChartIdChartSlabsIncentives { + private PostInterestRateChartsChartIdChartSlabsIncentives() { + } + + @ApiModelProperty(example = "2") + public Integer entityType; + @ApiModelProperty(example = "2") + public Integer attributeName; + @ApiModelProperty(example = "2") + public Integer conditionType; + @ApiModelProperty(example = "11") + public Integer attributeValue; + @ApiModelProperty(example = "2") + public Integer incentiveType; + @ApiModelProperty(example = "-1") + public Float amount; + } + + @ApiModelProperty(example = "0") + public Integer periodType; + @ApiModelProperty(example = "1") + public Integer fromPeriod; + @ApiModelProperty(example = "180") + public Integer toPeriod; + @ApiModelProperty(example = "5") + public Double annualInterestRate; + @ApiModelProperty(example = "5% interest from 1 day till 180 days of deposit") + public String description; + @ApiModelProperty(example = "en") + public String locale; + public Set incentives; + } + + @ApiModel(value = "PostInterestRateChartsChartIdChartSlabsResponse") + public final static class PostInterestRateChartsChartIdChartSlabsResponse { + private PostInterestRateChartsChartIdChartSlabsResponse() { + } + + @ApiModelProperty(example = "1") + public Integer resourceId; + } + + @ApiModel(value = "PutInterestRateChartsChartIdChartSlabsChartSlabIdRequest") + public static final class PutInterestRateChartsChartIdChartSlabsChartSlabIdRequest { + private PutInterestRateChartsChartIdChartSlabsChartSlabIdRequest() { + } + + @ApiModelProperty(example = "6") + public Double annualInterestRate; + @ApiModelProperty(example = "Interest rate changed to 6%") + public String description; + } + + @ApiModel(value = "PutInterestRateChartsChartIdChartSlabsChartSlabIdResponse") + public static final class PutInterestRateChartsChartIdChartSlabsChartSlabIdResponse { + private PutInterestRateChartsChartIdChartSlabsChartSlabIdResponse() { + } + + @ApiModelProperty(example = "1") + public Integer resourceId; + public PutInterestRateChartsChartIdChartSlabsChartSlabIdRequest changes; + } + + @ApiModel(value = "DeleteInterestRateChartsChartIdChartSlabsResponse") + public final static class DeleteInterestRateChartsChartIdChartSlabsResponse { + private DeleteInterestRateChartsChartIdChartSlabsResponse() { + } + + @ApiModelProperty(example = "1") + public Integer resourceId; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/api/InterestRateChartsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/api/InterestRateChartsApiResource.java index cf54a3aa3..ae19c3b11 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/api/InterestRateChartsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/api/InterestRateChartsApiResource.java @@ -18,24 +18,7 @@ */ package org.apache.fineract.portfolio.interestratechart.api; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriInfo; - +import io.swagger.annotations.*; import org.apache.fineract.commands.domain.CommandWrapper; import org.apache.fineract.commands.service.CommandWrapperBuilder; import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService; @@ -52,17 +35,21 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; -import static org.apache.fineract.portfolio.interestratechart.InterestRateChartApiConstants.chartSlabs; -import static org.apache.fineract.portfolio.interestratechart.InterestRateChartApiConstants.descriptionParamName; -import static org.apache.fineract.portfolio.interestratechart.InterestRateChartApiConstants.endDateParamName; -import static org.apache.fineract.portfolio.interestratechart.InterestRateChartApiConstants.fromDateParamName; -import static org.apache.fineract.portfolio.interestratechart.InterestRateChartApiConstants.idParamName; -import static org.apache.fineract.portfolio.interestratechart.InterestRateChartApiConstants.isPrimaryGroupingByAmountParamName; -import static org.apache.fineract.portfolio.interestratechart.InterestRateChartApiConstants.nameParamName; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import static org.apache.fineract.portfolio.interestratechart.InterestRateChartApiConstants.*; @Path("/interestratecharts") @Component @Scope("singleton") +@Api(value = "Interest Rate Chart", description = "This defines an interest rate scheme that can be associated to a term deposit product. This will have a slab (band or range) of deposit periods and the associated interest rates applicable along with incentives for each band.") public class InterestRateChartsApiResource { private final InterestRateChartReadPlatformService chartReadPlatformService; @@ -92,6 +79,8 @@ public class InterestRateChartsApiResource { @Path("template") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) + @ApiOperation(value = "Retrieve Chart Details Template", httpMethod = "GET", notes = "This is a convenience resource. It can be useful when building maintenance user interface screens for creating a chart. The template data returned consists of any or all of:\n" + "\n" + "Field Defaults\n" + "Allowed Value Lists\n" + "Example Request:\n" + "\n" + "interestratecharts/template") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = InterestRateChartsApiResourceSwagger.GetInterestRateChartsTemplateResponse.class)}) public String template(@Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(InterestRateChartApiConstants.INTERESTRATE_CHART_RESOURCE_NAME); @@ -104,7 +93,9 @@ public class InterestRateChartsApiResource { @GET @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveAll(@Context final UriInfo uriInfo, @QueryParam("productId") final Long productId) { + @ApiOperation(value = "Retrieve all Charts", httpMethod = "GET", notes = "Retrieve list of charts associated with a term deposit product(FD or RD).\n" + "Example Requests:\n" + "\n" + "interestratecharts?productId=1") + @ApiResponses({@ApiResponse(code = 200, message = "OK", responseContainer = "List", response = InterestRateChartsApiResourceSwagger.GetInterestRateChartsResponse.class)}) + public String retrieveAll(@Context final UriInfo uriInfo, @QueryParam("productId") @ApiParam(value = "productId") final Long productId) { this.context.authenticatedUser().validateHasReadPermission(InterestRateChartApiConstants.INTERESTRATE_CHART_RESOURCE_NAME); @@ -118,10 +109,12 @@ public class InterestRateChartsApiResource { @Path("{chartId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveOne(@PathParam("chartId") final Long chartId, @Context final UriInfo uriInfo) { + @ApiOperation(value = "Retrieve a Chart", httpMethod = "GET", notes = "It retrieves the Interest Rate Chart\n" + "Example Requests:\n" + "\n" + "interestratecharts/1") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = InterestRateChartsApiResourceSwagger.GetInterestRateChartsResponse.class)}) + public String retrieveOne(@PathParam("chartId") @ApiParam(value = "chartId") final Long chartId, @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(InterestRateChartApiConstants.INTERESTRATE_CHART_RESOURCE_NAME); - + InterestRateChartData chartData = null; final Set associationParameters = ApiParameterHelper.extractAssociationsForResponseIfProvided(uriInfo.getQueryParameters()); if (!associationParameters.isEmpty() && associationParameters.contains(InterestRateChartApiConstants.chartSlabs)) { @@ -129,7 +122,7 @@ public class InterestRateChartsApiResource { }else { chartData = this.chartReadPlatformService.retrieveOne(chartId); } - + final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); if (settings.isTemplate()) { chartData = this.chartReadPlatformService.retrieveWithTemplate(chartData); @@ -141,7 +134,10 @@ public class InterestRateChartsApiResource { @POST @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String create(final String apiRequestBodyAsJson) { + @ApiOperation(value = "Create a Chart", httpMethod = "POST", notes = "Creates a new chart which can be attached to a term deposit products (FD or RD).") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = InterestRateChartsApiResourceSwagger.PostInterestRateChartsRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = InterestRateChartsApiResourceSwagger.PostInterestRateChartsResponse.class)}) + public String create(@ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder().createInterestRateChart().withJson(apiRequestBodyAsJson).build(); @@ -154,7 +150,10 @@ public class InterestRateChartsApiResource { @Path("{chartId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String update(@PathParam("chartId") final Long chartId, final String apiRequestBodyAsJson) { + @ApiOperation(value = "Update a Chart", notes = "It updates the Chart.", httpMethod = "PUT") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = InterestRateChartsApiResourceSwagger.PutInterestRateChartsChartIdRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = InterestRateChartsApiResourceSwagger.PutInterestRateChartsChartIdResponse.class)}) + public String update(@PathParam("chartId") @ApiParam(value = "chartId") final Long chartId, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder().updateInterestRateChart(chartId) .withJson(apiRequestBodyAsJson).build(); @@ -168,7 +167,9 @@ public class InterestRateChartsApiResource { @Path("{chartId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String delete(@PathParam("chartId") final Long chartId) { + @ApiOperation(value = "Delete a Chart", notes = "It deletes the chart", httpMethod = "DELETE") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = InterestRateChartsApiResourceSwagger.DeleteInterestRateChartsChartIdResponse.class)}) + public String delete(@PathParam("chartId") @ApiParam(value = "chartId") final Long chartId) { final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteInterestRateChart(chartId).build(); final CommandProcessingResult result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest); return this.toApiJsonSerializer.serialize(result); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/api/InterestRateChartsApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/api/InterestRateChartsApiResourceSwagger.java new file mode 100644 index 000000000..9da338d16 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/interestratechart/api/InterestRateChartsApiResourceSwagger.java @@ -0,0 +1,157 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.interestratechart.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.time.LocalDate; +import java.util.Set; + +/** + * Created by Chirag Gupta on 12/04/17. + */ +final class InterestRateChartsApiResourceSwagger { + private InterestRateChartsApiResourceSwagger() { + } + + @ApiModel(value = "GetInterestRateChartsTemplateResponse") + public final static class GetInterestRateChartsTemplateResponse { + private GetInterestRateChartsTemplateResponse() { + } + + final class GetInterestRateChartsTemplatePeriodTypes { + private GetInterestRateChartsTemplatePeriodTypes() { + } + + @ApiModelProperty(example = "0") + public Integer id; + @ApiModelProperty(example = "interestChartPeriodType.days") + public String code; + @ApiModelProperty(example = "Days") + public String value; + } + + public Set periodTypes; + } + + @ApiModel(value = "GetInterestRateChartsResponse") + public static final class GetInterestRateChartsResponse { + private GetInterestRateChartsResponse() { + } + + final class GetInterestRateChartsChartSlabs { + private GetInterestRateChartsChartSlabs() { + } + + @ApiModelProperty(example = "1") + public Integer id; + public GetInterestRateChartsTemplateResponse.GetInterestRateChartsTemplatePeriodTypes periodTypes; + @ApiModelProperty(example = "1") + public Integer fromPeriod; + @ApiModelProperty(example = "6") + public Integer annualInterestRate; + public GetInterestRateChartsCurrency currency; + } + + final class GetInterestRateChartsCurrency { + private GetInterestRateChartsCurrency() { + } + + @ApiModelProperty(example = "USD") + public String code; + @ApiModelProperty(example = "US Dollar") + public String name; + @ApiModelProperty(example = "2") + public Integer decimalPlaces; + @ApiModelProperty(example = "$") + public String displaySymbol; + @ApiModelProperty(example = "currency.USD") + public String nameCode; + @ApiModelProperty(example = "US Dollar ($)") + public String displayLabel; + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "[2014, 1, 1]") + public LocalDate fromDate; + @ApiModelProperty(example = "1") + public Integer savingsProductId; + @ApiModelProperty(example = "Fixed Deposit Product 001") + public String savingsProductName; + public Set chartSlabs; + } + + @ApiModel(value = "PostInterestRateChartsRequest") + public static final class PostInterestRateChartsRequest { + private PostInterestRateChartsRequest() { + } + + @ApiModelProperty(example = "Chart - 2014") + public String name; + @ApiModelProperty(example = "This chart is applicable for year 2014") + public String description; + @ApiModelProperty(example = "Document") + public String type; + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "dd MMMM yyyy") + public String dateFormat; + @ApiModelProperty(example = "01 Jan 2014") + public String fromDate; + } + + @ApiModel(value = "PostInterestRateChartsResponse") + public static final class PostInterestRateChartsResponse { + private PostInterestRateChartsResponse() { + } + + @ApiModelProperty(example = "1") + public Integer resourceId; + } + + @ApiModel(value = "PutInterestRateChartsChartIdRequest") + public static final class PutInterestRateChartsChartIdRequest { + private PutInterestRateChartsChartIdRequest() { + } + @ApiModelProperty(example = "Interest rate chart for 2014") + public String name; + @ApiModelProperty(example = "Interest rate chart for 2014") + public String description; + } + + @ApiModel(value = "PutInterestRateChartsChartIdResponse") + public static final class PutInterestRateChartsChartIdResponse { + private PutInterestRateChartsChartIdResponse() { + } + + @ApiModelProperty(example = "1") + public Integer resourceId; + } + + @ApiModel(value = "DeleteInterestRateChartsChartIdResponse") + public static final class DeleteInterestRateChartsChartIdResponse { + private DeleteInterestRateChartsChartIdResponse() { + } + + @ApiModelProperty(example = "1") + public Integer resourceId; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoanChargesApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoanChargesApiResource.java index b5ebd3d07..dce33108a 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoanChargesApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoanChargesApiResource.java @@ -18,24 +18,7 @@ */ package org.apache.fineract.portfolio.loanaccount.api; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriInfo; - +import io.swagger.annotations.*; import org.apache.commons.lang.StringUtils; import org.apache.fineract.commands.domain.CommandWrapper; import org.apache.fineract.commands.service.CommandWrapperBuilder; @@ -56,9 +39,19 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + @Path("/loans/{loanId}/charges") @Component @Scope("singleton") +@Api(value = "Loan Charges", description = "Its typical for MFIs to add extra costs for their loan products. They can be either Fees or Penalties.\n" + "\n" + "Loan Charges are instances of Charges and represent either fees and penalties for loan products. Refer Charges for documentation of the various properties of a charge, Only additional properties ( specific to the context of a Charge being associated with a Loan) are described here") public class LoanChargesApiResource { private final Set RESPONSE_DATA_PARAMETERS = new HashSet<>( @@ -96,7 +89,9 @@ public class LoanChargesApiResource { @GET @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveAllLoanCharges(@PathParam("loanId") final Long loanId, @Context final UriInfo uriInfo) { + @ApiOperation(value = "List Loan Charges", httpMethod = "GET", notes = "It lists all the Loan Charges specific to a Loan \n\n" + "Example Requests:\n" + "\n" + "loans/1/charges\n" + "\n" + "\n" + "loans/1/charges?fields=name,amountOrPercentage") + @ApiResponses({@ApiResponse(code = 200, message = "OK", responseContainer = "List", response = LoanChargesApiResourceSwagger.GetLoansLoanIdChargesChargeIdResponse.class)}) + public String retrieveAllLoanCharges(@PathParam("loanId") @ApiParam(value = "loanId") final Long loanId, @Context final UriInfo uriInfo){ this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions); @@ -108,9 +103,11 @@ public class LoanChargesApiResource { @GET @Path("template") - @Consumes({ MediaType.APPLICATION_JSON }) - @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveTemplate(@PathParam("loanId") final Long loanId, @Context final UriInfo uriInfo) { + @Consumes({MediaType.APPLICATION_JSON}) + @Produces({MediaType.APPLICATION_JSON}) + @ApiOperation(value = "Retrieve Loan Charges Template", httpMethod = "GET", notes = "This is a convenience resource. It can be useful when building maintenance user interface screens for client applications. The template data returned consists of any or all of:\n" + "\n" + "Field Defaults\n" + "Allowed Value Lists\n" + "Example Request:\n" + "\n" + "loans/1/charges/template\n" + "\n") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = LoanChargesApiResourceSwagger.GetLoansLoanIdChargesTemplateResponse.class)}) + public String retrieveTemplate(@PathParam("loanId") @ApiParam(value = "loanId") final Long loanId, @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions); @@ -124,10 +121,12 @@ public class LoanChargesApiResource { @GET @Path("{chargeId}") - @Consumes({ MediaType.APPLICATION_JSON }) - @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveLoanCharge(@PathParam("loanId") final Long loanId, @PathParam("chargeId") final Long loanChargeId, - @Context final UriInfo uriInfo) { + @Consumes({MediaType.APPLICATION_JSON}) + @Produces({MediaType.APPLICATION_JSON}) + @ApiOperation(value = "Retrieve a Loan Charge", httpMethod = "GET", notes = "Retrieves Loan Charge according to the Loan ID and Charge ID" + "Example Requests:\n" + "\n" + "/loans/1/charges/1\n" + "\n" + "\n" + "/loans/1/charges/1?fields=name,amountOrPercentage") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = LoanChargesApiResourceSwagger.GetLoansLoanIdChargesChargeIdResponse.class)}) + public String retrieveLoanCharge(@PathParam("loanId") @ApiParam(value = "loanId") final Long loanId, @PathParam("chargeId") @ApiParam(value = "chargeId") final Long loanChargeId, + @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions); @@ -143,10 +142,13 @@ public class LoanChargesApiResource { } @POST - @Consumes({ MediaType.APPLICATION_JSON }) - @Produces({ MediaType.APPLICATION_JSON }) - public String executeLoanCharge(@PathParam("loanId") final Long loanId, @QueryParam("command") final String commandParam, - final String apiRequestBodyAsJson) { + @Consumes({MediaType.APPLICATION_JSON}) + @Produces({MediaType.APPLICATION_JSON}) + @ApiOperation(value = "Create a Loan Charge", httpMethod = "POST", notes = "It Creates a Loan Charge") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = LoanChargesApiResourceSwagger.PostLoansLoanIdChargesRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = LoanChargesApiResourceSwagger.PostLoansLoanIdChargesResponse.class)}) + public String executeLoanCharge(@PathParam("loanId") @ApiParam(value = "loanId") final Long loanId, @QueryParam("command") @ApiParam(value = "command") final String commandParam, + @ApiParam(hidden = true) final String apiRequestBodyAsJson) { CommandProcessingResult result = null; if (is(commandParam, "pay")) { @@ -164,10 +166,13 @@ public class LoanChargesApiResource { @PUT @Path("{chargeId}") - @Consumes({ MediaType.APPLICATION_JSON }) - @Produces({ MediaType.APPLICATION_JSON }) - public String updateLoanCharge(@PathParam("loanId") final Long loanId, @PathParam("chargeId") final Long loanChargeId, - final String apiRequestBodyAsJson) { + @Consumes({MediaType.APPLICATION_JSON}) + @Produces({MediaType.APPLICATION_JSON}) + @ApiOperation(value = "Update a Loan Charge", httpMethod = "PUT", notes = "Currently Loan Charges may be updated only if the Loan is not yet approved") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = LoanChargesApiResourceSwagger.PutLoansLoanIdChargesChargeIdRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = LoanChargesApiResourceSwagger.PutLoansLoanIdChargesChargeIdResponse.class)}) + public String updateLoanCharge(@PathParam("loanId") @ApiParam(value = "loanId") final Long loanId, @PathParam("chargeId") @ApiParam(value = "chargeId") final Long loanChargeId, + @ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder().updateLoanCharge(loanId, loanChargeId) .withJson(apiRequestBodyAsJson).build(); @@ -179,10 +184,13 @@ public class LoanChargesApiResource { @POST @Path("{chargeId}") - @Consumes({ MediaType.APPLICATION_JSON }) - @Produces({ MediaType.APPLICATION_JSON }) - public String executeLoanCharge(@PathParam("loanId") final Long loanId, @PathParam("chargeId") final Long loanChargeId, - @QueryParam("command") final String commandParam, final String apiRequestBodyAsJson) { + @Consumes({MediaType.APPLICATION_JSON}) + @Produces({MediaType.APPLICATION_JSON}) + @ApiOperation(value = "Pay Loan Charge", httpMethod = "POST", notes = "Loan Charge will be paid if the loan is linked with a savings account") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = LoanChargesApiResourceSwagger.PostLoansLoanIdChargesChargeIdRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = LoanChargesApiResourceSwagger.PostLoansLoanIdChargesChargeIdResponse.class)}) + public String executeLoanCharge(@PathParam("loanId") @ApiParam(value = "loanId") final Long loanId, @PathParam("chargeId") @ApiParam(value = "chargeId") final Long loanChargeId, + @QueryParam("command") @ApiParam(value = "command") final String commandParam, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapperBuilder builder = new CommandWrapperBuilder().withJson(apiRequestBodyAsJson); CommandProcessingResult result = null; @@ -201,9 +209,11 @@ public class LoanChargesApiResource { @DELETE @Path("{chargeId}") - @Consumes({ MediaType.APPLICATION_JSON }) - @Produces({ MediaType.APPLICATION_JSON }) - public String deleteLoanCharge(@PathParam("loanId") final Long loanId, @PathParam("chargeId") final Long loanChargeId) { + @Consumes({MediaType.APPLICATION_JSON}) + @Produces({MediaType.APPLICATION_JSON}) + @ApiOperation(value = "Delete a Loan Charge", httpMethod = "DELETE", notes = "Note: Currently, A Loan Charge may only be removed from Loans that are not yet approved.") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = LoanChargesApiResourceSwagger.DeleteLoansLoanIdChargesChargeIdResponse.class)}) + public String deleteLoanCharge(@PathParam("loanId") @ApiParam(value = "loanId") final Long loanId, @PathParam("chargeId") @ApiParam(value = "chargeId") final Long loanChargeId) { final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteLoanCharge(loanId, loanChargeId).build(); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoanChargesApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoanChargesApiResourceSwagger.java new file mode 100644 index 000000000..e839359d0 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoanChargesApiResourceSwagger.java @@ -0,0 +1,277 @@ + +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.loanaccount.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Set; + +/** + * Created by Chirag Gupta on 12/02/17. + */ +final class LoanChargesApiResourceSwagger { + private LoanChargesApiResourceSwagger() { + } + + @ApiModel(value = "GetLoansLoanIdChargesChargeIdResponse") + public static final class GetLoansLoanIdChargesChargeIdResponse { + private GetLoansLoanIdChargesChargeIdResponse() { + } + + final class GetLoanChargeTimeType { + private GetLoanChargeTimeType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "chargeTimeType.disbursement") + public String code; + @ApiModelProperty(example = "Disbursement") + public String value; + } + + final class GetLoanChargeCalculationType { + private GetLoanChargeCalculationType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "chargeCalculationType.flat") + public String code; + @ApiModelProperty(example = "Flat") + public String value; + } + + final class GetLoanChargeCurrency { + private GetLoanChargeCurrency() { + } + + @ApiModelProperty(example = "USD") + public String code; + @ApiModelProperty(example = "US Dollar") + public String name; + @ApiModelProperty(example = "2") + public Integer decimalPlaces; + @ApiModelProperty(example = "$") + public String displaySymbol; + @ApiModelProperty(example = "currency.USD") + public String nameCode; + @ApiModelProperty(example = "US Dollar ($)") + public String displayLabel; + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "1") + public Integer chargeId; + @ApiModelProperty(example = "Loan Processing fee") + public String name; + public GetLoanChargeTimeType chargeTimeType; + public GetLoanChargeCalculationType chargeCalculationType; + @ApiModelProperty(example = "0") + public Double percentage; + @ApiModelProperty(example = "0") + public Double amountPercentageAppliedTo; + public GetLoanChargeCurrency currency; + @ApiModelProperty(example = "100") + public Float amount; + @ApiModelProperty(example = "0") + public Float amountPaid; + @ApiModelProperty(example = "0") + public Float amountWaived; + @ApiModelProperty(example = "0") + public Float amountWrittenOff; + @ApiModelProperty(example = "100") + public Float amountOutstanding; + @ApiModelProperty(example = "100") + public Float amountOrPercentage; + @ApiModelProperty(example = "false") + public Boolean penalty; + } + + @ApiModel(value = "GetLoansLoanIdChargesTemplateResponse") + public static final class GetLoansLoanIdChargesTemplateResponse { + private GetLoansLoanIdChargesTemplateResponse() { + } + + final class GetLoanChargeTemplateChargeOptions { + private GetLoanChargeTemplateChargeOptions() { + } + + final class GetLoanChargeTemplateChargeTimeType { + private GetLoanChargeTemplateChargeTimeType() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "chargeTimeType.specifiedDueDate") + public String code; + @ApiModelProperty(example = "Specified due date") + public String value; + } + + final class GetLoanChargeTemplateChargeAppliesTo { + private GetLoanChargeTemplateChargeAppliesTo() { + } + + @ApiModelProperty(example = "1 ") + public Integer id; + @ApiModelProperty(example = "chargeAppliesTo.loan") + public String code; + @ApiModelProperty(example = "Loan") + public String value; + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "Collection fee") + public String name; + @ApiModelProperty(example = "true") + public Boolean active; + @ApiModelProperty(example = "false") + public Boolean penalty; + public GetLoansLoanIdChargesChargeIdResponse.GetLoanChargeCurrency currency; + @ApiModelProperty(example = "100") + public Float amount; + public GetLoanChargeTemplateChargeTimeType chargeTimeType; + public GetLoanChargeTemplateChargeAppliesTo chargeAppliesTo; + public GetLoansLoanIdChargesChargeIdResponse.GetLoanChargeCalculationType chargeCalculationType; + } + + @ApiModelProperty(example = "0") + public Float amountPaid; + @ApiModelProperty(example = "0") + public Float amountWaived; + @ApiModelProperty(example = "0") + public Float amountWrittenOff; + public Set chargeOptions; + @ApiModelProperty(example = "false") + public Boolean penalty; + } + + @ApiModel(value = " PostLoansLoanIdChargesRequest") + public static final class PostLoansLoanIdChargesRequest { + private PostLoansLoanIdChargesRequest() { + } + + @ApiModelProperty(example = "2") + public Integer chargeId; + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "100") + public Float amount; + @ApiModelProperty(example = "dd MMMM yyyy") + public String dateFormat; + @ApiModelProperty(example = "29 April 2013") + public String dueDate; + } + + @ApiModel(value = " PostLoansLoanIdChargesResponse") + public static final class PostLoansLoanIdChargesResponse { + private PostLoansLoanIdChargesResponse() { + } + + @ApiModelProperty(example = "1") + public Long officeId; + @ApiModelProperty(example = "1") + public Long clientId; + @ApiModelProperty(example = "1") + public Long loanId; + @ApiModelProperty(example = "31") + public Integer resourceId; + } + + @ApiModel(value = " PutLoansLoanIdChargesChargeIdRequest") + public static final class PutLoansLoanIdChargesChargeIdRequest { + private PutLoansLoanIdChargesChargeIdRequest() { + } + + @ApiModelProperty(example = "dd MMMM yyyy") + public String dateFormat; + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "60") + public Float amount; + @ApiModelProperty(example = "27 March 2013") + public String dueDate; + } + + @ApiModel(value = "PutLoansLoanIdChargesChargeIdResponse") + public static final class PutLoansLoanIdChargesChargeIdResponse { + private PutLoansLoanIdChargesChargeIdResponse() { + } + + @ApiModelProperty(example = "1") + public Long officeId; + @ApiModelProperty(example = "1") + public Long clientId; + @ApiModelProperty(example = "1") + public Long loanId; + @ApiModelProperty(example = "6") + public Integer resourceId; + public PutLoansLoanIdChargesChargeIdRequest changes; + } + + @ApiModel(value = "PostLoansLoanIdChargesChargeIdRequest") + public static final class PostLoansLoanIdChargesChargeIdRequest { + private PostLoansLoanIdChargesChargeIdRequest() { + } + + @ApiModelProperty(example = "dd MMMM yyyy") + public String dateFormat; + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "19 September 2013") + public String transactionDate; + } + + @ApiModel(value = "PostLoansLoanIdChargesChargeIdResponse") + public static final class PostLoansLoanIdChargesChargeIdResponse { + private PostLoansLoanIdChargesChargeIdResponse() { + } + + @ApiModelProperty(example = "1") + public Long officeId; + @ApiModelProperty(example = "1") + public Long clientId; + @ApiModelProperty(example = "6") + public Long loanId; + @ApiModelProperty(example = "1") + public Long savingsId; + @ApiModelProperty(example = "12") + public Integer resourceId; + } + + @ApiModel(value = "DeleteLoansLoanIdChargesChargeIdResponse") + public static final class DeleteLoansLoanIdChargesChargeIdResponse { + private DeleteLoansLoanIdChargesChargeIdResponse() { + } + + @ApiModelProperty(example = "1") + public Long officeId; + @ApiModelProperty(example = "1") + public Long clientId; + @ApiModelProperty(example = "1") + public Long loanId; + @ApiModelProperty(example = "2") + public Integer resourceId; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoanScheduleApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoanScheduleApiResource.java index 3d107f1c6..207381265 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoanScheduleApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoanScheduleApiResource.java @@ -18,18 +18,7 @@ */ package org.apache.fineract.portfolio.loanaccount.api; -import java.util.HashSet; - -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriInfo; - +import io.swagger.annotations.*; import org.apache.commons.lang.StringUtils; import org.apache.fineract.commands.domain.CommandWrapper; import org.apache.fineract.commands.service.CommandWrapperBuilder; @@ -45,9 +34,16 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; +import java.util.HashSet; + @Path("/loans/{loanId}/schedule") @Component @Scope("singleton") +@Api(value = "Loan Rescheduling", description = "Loan Term Variations provides the ability to change due dates, amounts and number of instalments before loan approval.") public class LoanScheduleApiResource { private final String resourceNameForPermissions = "LOAN"; @@ -73,8 +69,11 @@ public class LoanScheduleApiResource { @POST @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String calculateLoanScheduleOrSubmitVariableSchedule(@PathParam("loanId") final Long loanId, - @QueryParam("command") final String commandParam, @Context final UriInfo uriInfo, final String apiRequestBodyAsJson) { + @ApiOperation(value = "Calculate loan repayment schedule based on Loan term variations | Updates loan repayment schedule based on Loan term variations | Updates loan repayment schedule by removing Loan term variations", httpMethod = "POST", notes = "Calculate loan repayment schedule based on Loan term variations:\n\n" + "Mandatory Fields: exceptions,locale,dateFormat\n\n" + "Updates loan repayment schedule based on Loan term variations:\n\n" + "Mandatory Fields: exceptions,locale,dateFormat\n\n" + "Updates loan repayment schedule by removing Loan term variations:\n\n" + "It updates the loan repayment schedule by removing Loan term variations\n\n" + "Showing request/response for 'Updates loan repayment schedule by removing Loan term variations'") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = LoanScheduleApiResourceSwagger.PostLoansLoanIdScheduleRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = LoanScheduleApiResourceSwagger.PostLoansLoanIdScheduleResponse.class)}) + public String calculateLoanScheduleOrSubmitVariableSchedule(@PathParam("loanId") @ApiParam(value = "loanId") final Long loanId, + @QueryParam("command") @ApiParam(value = "command") final String commandParam, @Context final UriInfo uriInfo, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { CommandWrapper commandRequest = null; if (is(commandParam, "calculateLoanSchedule")) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoanScheduleApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoanScheduleApiResourceSwagger.java new file mode 100644 index 000000000..fbd10b753 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoanScheduleApiResourceSwagger.java @@ -0,0 +1,56 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.loanaccount.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.List; + +/** + * Created by Chirag Gupta on 12/30/17. + */ +final class LoanScheduleApiResourceSwagger { + private LoanScheduleApiResourceSwagger() { + } + + @ApiModel(value = "PostLoansLoanIdScheduleRequest") + public final static class PostLoansLoanIdScheduleRequest { + private PostLoansLoanIdScheduleRequest() { + } + } + + @ApiModel(value = "PostLoansLoanIdScheduleResponse") + public final static class PostLoansLoanIdScheduleResponse { + private PostLoansLoanIdScheduleResponse() { + } + + final class PostLoanChanges { + private PostLoanChanges() { + } + + @ApiModelProperty(example = "[21, 22]") + public List removedEntityIds; + } + + @ApiModelProperty(example = "1") + public Integer loanId; + public PostLoanChanges changes; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoanTransactionsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoanTransactionsApiResource.java index e4b30362b..6e45fd463 100755 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoanTransactionsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoanTransactionsApiResource.java @@ -18,22 +18,7 @@ */ package org.apache.fineract.portfolio.loanaccount.api; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriInfo; - +import io.swagger.annotations.*; import org.apache.commons.lang.StringUtils; import org.apache.fineract.accounting.journalentry.api.DateParam; import org.apache.fineract.commands.domain.CommandWrapper; @@ -55,9 +40,19 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + @Path("/loans/{loanId}/transactions") @Component @Scope("singleton") +@Api(value = "Loan Transactions", description = "Capabilities include loan repayment's, interest waivers and the ability to 'adjust' an existing transaction. An 'adjustment' of a transaction is really a 'reversal' of existing transaction followed by creation of a new transaction with the provided details.") public class LoanTransactionsApiResource { private final Set RESPONSE_DATA_PARAMETERS = new HashSet<>(Arrays.asList("id", "type", "date", "currency", "amount", @@ -94,9 +89,11 @@ public class LoanTransactionsApiResource { @Path("template") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveTransactionTemplate(@PathParam("loanId") final Long loanId, @QueryParam("command") final String commandParam, - @Context final UriInfo uriInfo, @QueryParam("dateFormat") final String dateFormat, - @QueryParam("transactionDate") final DateParam transactionDateParam, @QueryParam("locale") final String locale) { + @ApiOperation(value = "Retrieve Loan Transaction Template", httpMethod = "GET", notes = "This is a convenience resource. It can be useful when building maintenance user interface screens for client applications. The template data returned consists of any or all of:\n" + "\n" + "Field Defaults\n" + "Allowed Value Lists\n\n" + "Example Request:\n" + "\n" + "loans/1/transactions/template?command=repayment") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = LoanTransactionsApiResourceSwagger.GetLoansLoanIdTransactionsTemplateResponse.class)}) + public String retrieveTransactionTemplate(@PathParam("loanId") @ApiParam(value = "loanId") final Long loanId, @QueryParam("command") @ApiParam(value = "command") final String commandParam, + @Context final UriInfo uriInfo, @QueryParam("dateFormat") @ApiParam(value = "dateFormat") final String dateFormat, + @QueryParam("transactionDate") @ApiParam(value = "transactionDate") final DateParam transactionDateParam, @QueryParam("locale") @ApiParam(value = "locale") final String locale) { this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions); @@ -149,7 +146,9 @@ public class LoanTransactionsApiResource { @Path("{transactionId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveTransaction(@PathParam("loanId") final Long loanId, @PathParam("transactionId") final Long transactionId, + @ApiOperation(value = "Retrieve a Transaction Details", httpMethod = "GET", notes = "Retrieves a Transaction Details\n\n" + "Example Request:\n" + "\n" + "loans/5/transactions/3") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = LoanTransactionsApiResourceSwagger.GetLoansLoanIdTransactionsTransactionIdResponse.class)}) + public String retrieveTransaction(@PathParam("loanId") @ApiParam(value = "loanId") final Long loanId, @PathParam("transactionId") @ApiParam(value = "transactionId") final Long transactionId, @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions); @@ -167,8 +166,11 @@ public class LoanTransactionsApiResource { @POST @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String executeLoanTransaction(@PathParam("loanId") final Long loanId, @QueryParam("command") final String commandParam, - final String apiRequestBodyAsJson) { + @ApiOperation(value = "Make a Repayment | Make a Refund of an Active Loan by Cash | Foreclosure of an Active Loan | Waive Interest | Write-off Loan | Make Recovery Payment | Undo Loan Write-off Transaction", httpMethod = "POST", notes = "Make Recovery Payment:\n\n" + "This API allows collecting recovery payments for written-off loans") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = LoanTransactionsApiResourceSwagger.PostLoansLoanIdTransactionsRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = LoanTransactionsApiResourceSwagger.PostLoansLoanIdTransactionsResponse.class)}) + public String executeLoanTransaction(@PathParam("loanId") @ApiParam(value = "loanId") final Long loanId, @QueryParam("command") @ApiParam(value = "command") final String commandParam, + @ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapperBuilder builder = new CommandWrapperBuilder().withJson(apiRequestBodyAsJson); @@ -211,8 +213,11 @@ public class LoanTransactionsApiResource { @Path("{transactionId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String adjustLoanTransaction(@PathParam("loanId") final Long loanId, @PathParam("transactionId") final Long transactionId, - final String apiRequestBodyAsJson) { + @ApiOperation(value = "Adjust a Transaction", httpMethod = "POST", notes = "Note: there is no need to specify command={transactionType} parameter.\n\n" + "Mandatory Fields: transactionDate, transactionAmount") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = LoanTransactionsApiResourceSwagger.PostLoansLoanIdTransactionsTransactionIdRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = LoanTransactionsApiResourceSwagger.PostLoansLoanIdTransactionsTransactionIdResponse.class)}) + public String adjustLoanTransaction(@PathParam("loanId") @ApiParam(value = "loanId") final Long loanId, @PathParam("transactionId") @ApiParam(value = "transactionId") final Long transactionId, + @ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapperBuilder builder = new CommandWrapperBuilder().withJson(apiRequestBodyAsJson); final CommandWrapper commandRequest = builder.adjustTransaction(loanId, transactionId).build(); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoanTransactionsApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoanTransactionsApiResourceSwagger.java new file mode 100644 index 000000000..aaef19ed5 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoanTransactionsApiResourceSwagger.java @@ -0,0 +1,191 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.loanaccount.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.time.LocalDate; + +/** + * Created by Chirag Gupta on 12/30/17. + */ +final class LoanTransactionsApiResourceSwagger { + private LoanTransactionsApiResourceSwagger() { + } + + @ApiModel(value = "GetLoansLoanIdTransactionsTemplateResponse") + public final static class GetLoansLoanIdTransactionsTemplateResponse { + private GetLoansLoanIdTransactionsTemplateResponse() { + } + + final class GetLoansTransactionType { + private GetLoansTransactionType() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "loanTransactionType.repayment") + public String code; + @ApiModelProperty(example = "Repayment") + public String value; + } + + final class GetLoansTotal { + private GetLoansTotal() { + } + + @ApiModelProperty(example = "XOF") + public String currencyCode; + @ApiModelProperty(example = "0") + public Integer digitsAfterDecimal; + @ApiModelProperty(example = "0") + public Integer inMultiplesOf; + @ApiModelProperty(example = "471") + public Float amount; + @ApiModelProperty(example = "CFA Franc BCEAO") + public String defaultName; + @ApiModelProperty(example = "currency.XOF") + public String nameCode; + @ApiModelProperty(example = "CFA") + public String displaySymbol; + @ApiModelProperty(example = "false") + public Boolean zero; + @ApiModelProperty(example = "true") + public Boolean greaterThanZero; + @ApiModelProperty(example = "471 CFA") + public String displaySymbolValue; + } + + public GetLoansTransactionType transactionType; + @ApiModelProperty(example = "[2009, 8, 1]") + public LocalDate date; + public GetLoansTotal total; + } + + @ApiModel(value = "GetLoansLoanIdTransactionsTransactionIdResponse") + public final static class GetLoansLoanIdTransactionsTransactionIdResponse { + private GetLoansLoanIdTransactionsTransactionIdResponse() { + } + + final class GetLoansType { + private GetLoansType() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "loanTransactionType.repayment") + public String code; + @ApiModelProperty(example = "Repayment") + public String value; + @ApiModelProperty(example = "false") + public Boolean disbursement; + @ApiModelProperty(example = "false") + public Boolean repaymentAtDisbursement; + @ApiModelProperty(example = "true") + public Boolean repayment; + @ApiModelProperty(example = "false") + public Boolean contra; + @ApiModelProperty(example = "false") + public Boolean waiveInterest; + @ApiModelProperty(example = "false") + public Boolean waiveCharges; + @ApiModelProperty(example = "false") + public Boolean writeOff; + @ApiModelProperty(example = "false") + public Boolean recoveryRepayment; + } + + final class GetLoansCurrency { + private GetLoansCurrency() { + } + + @ApiModelProperty(example = "USD") + public String code; + @ApiModelProperty(example = "US Dollar") + public String name; + @ApiModelProperty(example = "2") + public Integer decimalPlaces; + @ApiModelProperty(example = "$") + public String displaySymbol; + @ApiModelProperty(example = "currency.USD") + public String nameCode; + @ApiModelProperty(example = "US Dollar ($)") + public String displayLabel; + } + + @ApiModelProperty(example = "3") + public Integer id; + public GetLoansType type; + @ApiModelProperty(example = "[2012, 5, 14]") + public LocalDate date; + @ApiModelProperty(example = "false") + public Boolean manuallyReversed; + public GetLoansCurrency currency; + @ApiModelProperty(example = "559.88") + public Double amount; + @ApiModelProperty(example = "559.88") + public Double interestPortion; + } + + @ApiModel(value = "PostLoansLoanIdTransactionsRequest") + public final static class PostLoansLoanIdTransactionsRequest { + private PostLoansLoanIdTransactionsRequest() { + } + } + + @ApiModel(value = "PostLoansLoanIdTransactionsResponse") + public final static class PostLoansLoanIdTransactionsResponse { + private PostLoansLoanIdTransactionsResponse() { + } + + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "22") + public Integer resourceId; + } + + @ApiModel(value = "PostLoansLoanIdTransactionsTransactionIdRequest") + public final static class PostLoansLoanIdTransactionsTransactionIdRequest { + private PostLoansLoanIdTransactionsTransactionIdRequest() { + } + + @ApiModelProperty(example = "en_GB") + public String locale; + @ApiModelProperty(example = "dd MMMM yyyy") + public String dateFormat; + @ApiModelProperty(example = "25 May 2012") + public String transactionDate; + @ApiModelProperty(example = "50,000.00") + public Double transactionAmount; + @ApiModelProperty(example = "An optional note about why your adjusting or changing the transaction.") + public String note; + } + + @ApiModel(value = "PostLoansLoanIdTransactionsTransactionIdResponse") + public final static class PostLoansLoanIdTransactionsTransactionIdResponse { + private PostLoansLoanIdTransactionsTransactionIdResponse() { + } + + @ApiModelProperty(example = "16") + public Integer resourceId; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoansApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoansApiResource.java index e3c51c761..50accfaec 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoansApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoansApiResource.java @@ -18,24 +18,8 @@ */ package org.apache.fineract.portfolio.loanaccount.api; -import static org.apache.fineract.portfolio.loanproduct.service.LoanEnumerations.interestType; - -import java.util.*; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriInfo; - +import com.google.gson.JsonElement; +import io.swagger.annotations.*; import org.apache.commons.lang.StringUtils; import org.apache.fineract.commands.domain.CommandWrapper; import org.apache.fineract.commands.service.CommandWrapperBuilder; @@ -81,14 +65,7 @@ import org.apache.fineract.portfolio.fund.data.FundData; import org.apache.fineract.portfolio.fund.service.FundReadPlatformService; import org.apache.fineract.portfolio.group.data.GroupGeneralData; import org.apache.fineract.portfolio.group.service.GroupReadPlatformService; -import org.apache.fineract.portfolio.loanaccount.data.DisbursementData; -import org.apache.fineract.portfolio.loanaccount.data.LoanAccountData; -import org.apache.fineract.portfolio.loanaccount.data.LoanApprovalData; -import org.apache.fineract.portfolio.loanaccount.data.LoanChargeData; -import org.apache.fineract.portfolio.loanaccount.data.LoanTermVariationsData; -import org.apache.fineract.portfolio.loanaccount.data.LoanTransactionData; -import org.apache.fineract.portfolio.loanaccount.data.PaidInAdvanceData; -import org.apache.fineract.portfolio.loanaccount.data.RepaymentScheduleRelatedLoanData; +import org.apache.fineract.portfolio.loanaccount.data.*; import org.apache.fineract.portfolio.loanaccount.domain.LoanTermVariationType; import org.apache.fineract.portfolio.loanaccount.exception.LoanTemplateTypeRequiredException; import org.apache.fineract.portfolio.loanaccount.exception.NotSupportedLoanTemplateTypeException; @@ -116,11 +93,18 @@ import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; -import com.google.gson.JsonElement; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; +import java.util.*; + +import static org.apache.fineract.portfolio.loanproduct.service.LoanEnumerations.interestType; @Path("/loans") @Component @Scope("singleton") +@Api(value = "Loans", description = "The API concept of loans models the loan application process and the loan contract/monitoring process.") public class LoansApiResource { private final Set LOAN_DATA_PARAMETERS = new HashSet<>(Arrays.asList("id", "accountNo", "status", "externalId", "clientId", @@ -228,8 +212,8 @@ public class LoansApiResource { @Path("{loanId}/template") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveApprovalTemplate(@PathParam("loanId") final Long loanId, @QueryParam("templateType") final String templateType, - @Context final UriInfo uriInfo) { + public String retrieveApprovalTemplate(@PathParam("loanId") @ApiParam(value = "loanId") final Long loanId, @QueryParam("templateType") @ApiParam(value = "templateType") final String templateType, + @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions); @@ -251,10 +235,12 @@ public class LoansApiResource { @Path("template") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String template(@QueryParam("clientId") final Long clientId, @QueryParam("groupId") final Long groupId, - @QueryParam("productId") final Long productId, @QueryParam("templateType") final String templateType, - @DefaultValue("false") @QueryParam("staffInSelectedOfficeOnly") final boolean staffInSelectedOfficeOnly, - @DefaultValue("false") @QueryParam("activeOnly") final boolean onlyActive, @Context final UriInfo uriInfo) { + @ApiOperation(value = "Retrieve Loan Details Template", httpMethod = "GET", notes = "This is a convenience resource. It can be useful when building maintenance user interface screens for client applications. The template data returned consists of any or all of:\n" + "\n" + "Field Defaults\n" + "Allowed Value Lists\n" + "Example Requests:\n" + "\n" + "loans/template?templateType=individual&clientId=1\n" + "\n" + "\n" + "loans/template?templateType=individual&clientId=1&productId=1") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = LoansApiResourceSwagger.GetLoansTemplateResponse.class)}) + public String template(@QueryParam("clientId") @ApiParam(value = "clientId") final Long clientId, @QueryParam("groupId") @ApiParam(value = "groupId") final Long groupId, + @QueryParam("productId")@ApiParam(value = "productId") final Long productId, @QueryParam("templateType") @ApiParam(value = "templateType") final String templateType, + @DefaultValue("false") @QueryParam("staffInSelectedOfficeOnly") @ApiParam(value = "staffInSelectedOfficeOnly") final boolean staffInSelectedOfficeOnly, + @DefaultValue("false") @QueryParam("activeOnly") @ApiParam(value = "activeOnly") final boolean onlyActive, @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions); @@ -375,8 +361,10 @@ public class LoansApiResource { @Path("{loanId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveLoan(@PathParam("loanId") final Long loanId, - @DefaultValue("false") @QueryParam("staffInSelectedOfficeOnly") final boolean staffInSelectedOfficeOnly, + @ApiOperation(value = "Retrieve a Loan", httpMethod = "GET", notes = "Note: template=true parameter doesn't apply to this resource." + "Example Requests:\n" + "\n" + "loans/1\n" + "\n" + "\n" + "loans/1?fields=id,principal,annualInterestRate\n" + "\n" + "\n" + "loans/1?associations=all\n" + "\n" + "loans/1?associations=all&exclude=guarantors\n" + "\n" + "\n" + "loans/1?fields=id,principal,annualInterestRate&associations=repaymentSchedule,transactions") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = LoansApiResourceSwagger.GetLoansLoanIdResponse.class)}) + public String retrieveLoan(@PathParam("loanId") @ApiParam(value = "loanId") final Long loanId, + @DefaultValue("false") @QueryParam("staffInSelectedOfficeOnly") @ApiParam(value = "staffInSelectedOfficeOnly") final boolean staffInSelectedOfficeOnly, @Context final UriInfo uriInfo) { long start = System.currentTimeMillis() ; this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions); @@ -627,13 +615,15 @@ public class LoansApiResource { @GET @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) + @ApiOperation(value = "List Loans", httpMethod = "GET", notes = "The list capability of loans can support pagination and sorting.\n" + "Example Requests:\n" + "\n" + "loans\n" + "\n" + "loans?fields=accountNo\n" + "\n" + "loans?offset=10&limit=50\n" + "\n" + "loans?orderBy=accountNo&sortOrder=DESC") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = LoansApiResourceSwagger.GetLoansResponse.class)}) public String retrieveAll(@Context final UriInfo uriInfo, - @QueryParam("sqlSearch") final String sqlSearch, - @QueryParam("externalId") final String externalId, + @QueryParam("sqlSearch") @ApiParam(value = "sqlSearch") final String sqlSearch, + @QueryParam("externalId") @ApiParam(value = "externalId") final String externalId, // @QueryParam("underHierarchy") final String hierarchy, - @QueryParam("offset") final Integer offset, @QueryParam("limit") final Integer limit, - @QueryParam("orderBy") final String orderBy, @QueryParam("sortOrder") final String sortOrder, - @QueryParam("accountNo") final String accountNo) { + @QueryParam("offset") @ApiParam(value = "offset") final Integer offset, @QueryParam("limit") @ApiParam(value = "limit") final Integer limit, + @QueryParam("orderBy") @ApiParam(value = "orderBy") final String orderBy, @QueryParam("sortOrder") @ApiParam(value = "sortOrder")final String sortOrder, + @QueryParam("accountNo") @ApiParam(value = "accountNo") final String accountNo) { this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions); @@ -649,8 +639,11 @@ public class LoansApiResource { @POST @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String calculateLoanScheduleOrSubmitLoanApplication(@QueryParam("command") final String commandParam, - @Context final UriInfo uriInfo, final String apiRequestBodyAsJson) { + @ApiOperation(value = "Calculate loan repayment schedule | Submit a new Loan Application", httpMethod = "POST", notes = "It calculates the loan repayment Schedule\n" + "Submits a new loan application\n" + "Mandatory Fields: clientId, productId, principal, loanTermFrequency, loanTermFrequencyType, loanType, numberOfRepayments, repaymentEvery, repaymentFrequencyType, interestRatePerPeriod, amortizationType, interestType, interestCalculationPeriodType, transactionProcessingStrategyId, expectedDisbursementDate, submittedOnDate, loanType\n" + "Optional Fields: graceOnPrincipalPayment, graceOnInterestPayment, graceOnInterestCharged, linkAccountId, allowPartialPeriodInterestCalcualtion, fixedEmiAmount, maxOutstandingLoanBalance, disbursementData, graceOnArrearsAgeing, createStandingInstructionAtDisbursement (requires linkedAccountId if set to true)\n" + "Additional Mandatory Fields if interest recalculation is enabled for product and Rest frequency not same as repayment period: recalculationRestFrequencyDate\n" + "Additional Mandatory Fields if interest recalculation with interest/fee compounding is enabled for product and compounding frequency not same as repayment period: recalculationCompoundingFrequencyDate\n" + "Additional Mandatory Field if Entity-Datatable Check is enabled for the entity of type loan: datatables") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = LoansApiResourceSwagger.PostLoansRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = LoansApiResourceSwagger.PostLoansResponse.class)}) + public String calculateLoanScheduleOrSubmitLoanApplication(@QueryParam("command") @ApiParam(value = "command") final String commandParam, + @Context final UriInfo uriInfo, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { if (is(commandParam, "calculateLoanSchedule")) { @@ -674,7 +667,10 @@ public class LoansApiResource { @Path("{loanId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String modifyLoanApplication(@PathParam("loanId") final Long loanId, final String apiRequestBodyAsJson) { + @ApiOperation(value = "Modify a loan application", httpMethod = "PUT", notes = "Loan application can only be modified when in 'Submitted and pending approval' state. Once the application is approved, the details cannot be changed using this method.") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = LoansApiResourceSwagger.PutLoansLoanIdRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = LoansApiResourceSwagger.PutLoansLoanIdResponse.class)}) + public String modifyLoanApplication(@PathParam("loanId") @ApiParam(value = "loanId") final Long loanId, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder().updateLoanApplication(loanId).withJson(apiRequestBodyAsJson) .build(); @@ -688,7 +684,9 @@ public class LoansApiResource { @Path("{loanId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String deleteLoanApplication(@PathParam("loanId") final Long loanId) { + @ApiOperation(value = "Delete a Loan Application", httpMethod = "DELETE", notes = "Note: Only loans in \"Submitted and awaiting approval\" status can be deleted.") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = LoansApiResourceSwagger.DeleteLoansLoanIdResponse.class)}) + public String deleteLoanApplication(@PathParam("loanId") @ApiParam(value = "loanId") final Long loanId) { final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteLoanApplication(loanId).build(); @@ -701,8 +699,11 @@ public class LoansApiResource { @Path("{loanId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String stateTransitions(@PathParam("loanId") final Long loanId, @QueryParam("command") final String commandParam, - final String apiRequestBodyAsJson) { + @ApiOperation(value = "Approve Loan Application | Recover Loan Guarantee | Undo Loan Application Approval | Assign a Loan Officer | Unassign a Loan Officer | Reject Loan Application | Applicant Withdraws from Loan Application | Disburse Loan Disburse Loan To Savings Account | Undo Loan Disbursal", httpMethod = "POST", notes = "Approve Loan Application:\n" + "Mandatory Fields: approvedOnDate\n" + "Optional Fields: approvedLoanAmount and expectedDisbursementDate\n" + "Approves the loan application\n\n" + "Recover Loan Guarantee:\n" + "Recovers the loan guarantee\n\n" + "Undo Loan Application Approval:\n" + "Undoes the Loan Application Approval\n\n" + "Assign a Loan Officer:\n" + "Allows you to assign Loan Officer for existing Loan.\n\n" + "Unassign a Loan Officer:\n" + "Allows you to unassign the Loan Officer.\n\n" + "Reject Loan Application:\n" + "Mandatory Fields: rejectedOnDate\n" + "Allows you to reject the loan application\n\n" + "Applicant Withdraws from Loan Application:\n" + "Mandatory Fields: withdrawnOnDate\n" + "Allows the applicant to withdraw the loan application\n\n" + "Disburse Loan:\n" + "Mandatory Fields: actualDisbursementDate\n" + "Optional Fields: transactionAmount and fixedEmiAmount\n" + "Disburses the Loan\n\n" + "Disburse Loan To Savings Account:\n" + "Mandatory Fields: actualDisbursementDate\n" + "Optional Fields: transactionAmount and fixedEmiAmount\n" + "Disburses the loan to Saving Account\n\n" + "Undo Loan Disbursal:\n" + "Undoes the Loan Disbursal\n" + "Showing request and response for Assign a Loan Officer") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = LoansApiResourceSwagger.PostLoansLoanIdRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = LoansApiResourceSwagger.PostLoansLoanIdResponse.class)}) + public String stateTransitions(@PathParam("loanId") @ApiParam(value = "loanId") final Long loanId, @QueryParam("command") @ApiParam(value = "command") final String commandParam, + @ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapperBuilder builder = new CommandWrapperBuilder().withJson(apiRequestBodyAsJson); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoansApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoansApiResourceSwagger.java new file mode 100644 index 000000000..df7c602c4 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoansApiResourceSwagger.java @@ -0,0 +1,692 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.loanaccount.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.time.LocalDate; +import java.util.Set; + +/** + * Created by Chirag Gupta on 12/09/17. + */ +final class LoansApiResourceSwagger { + private LoansApiResourceSwagger() { + } + + @ApiModel(value = "GetLoansTemplateResponse") + public final static class GetLoansTemplateResponse { + private GetLoansTemplateResponse() { + } + + final class GetLoansTemplateTimeline { + private GetLoansTemplateTimeline() { + } + + @ApiModelProperty(example = "[2013, 3, 8]") + public LocalDate expectedDisbursementDate; + } + + final class GetLoansTemplateProductOptions { + private GetLoansTemplateProductOptions() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "Kampala Product (with cash accounting)") + public String name; + } + + @ApiModelProperty(example = "1") + public Long clientId; + @ApiModelProperty(example = "Kampala first Client") + public String clientName; + @ApiModelProperty(example = "2") + public Integer clientOfficeId; + public GetLoansTemplateTimeline timeline; + public Set productOptions; + } + + @ApiModel(value = "GetLoansLoanIdResponse") + public final static class GetLoansLoanIdResponse { + private GetLoansLoanIdResponse() { + } + + final class GetLoansLoanIdStatus { + private GetLoansLoanIdStatus() { + } + + @ApiModelProperty(example = "300") + public Integer id; + @ApiModelProperty(example = "loanStatusType.active") + public String code; + @ApiModelProperty(example = "Active") + public String value; + @ApiModelProperty(example = "false") + public Boolean pendingApproval; + @ApiModelProperty(example = "false") + public Boolean waitingForDisbursal; + @ApiModelProperty(example = "true") + public Boolean active; + @ApiModelProperty(example = "false") + public Boolean closedObligationsMet; + @ApiModelProperty(example = "false") + public Boolean closedWrittenOff; + @ApiModelProperty(example = "false") + public Boolean closedRescheduled; + @ApiModelProperty(example = "false") + public Boolean closed; + @ApiModelProperty(example = "false") + public Boolean overpaid; + } + + final class GetLoansLoanIdLoanType { + private GetLoansLoanIdLoanType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "loanType.individual") + public String code; + @ApiModelProperty(example = "Individual") + public String value; + } + + final class GetLoansLoanIdCurrency { + private GetLoansLoanIdCurrency() { + } + + @ApiModelProperty(example = "UGX") + public String code; + @ApiModelProperty(example = "Uganda Shilling") + public String name; + @ApiModelProperty(example = "2") + public Integer decimalPlaces; + @ApiModelProperty(example = "USh") + public String displaySymbol; + @ApiModelProperty(example = "currency.UGX") + public String nameCode; + @ApiModelProperty(example = "Uganda Shilling (USh)") + public String displayLabel; + } + + final class GetLoansLoanIdTermPeriodFrequencyType { + private GetLoansLoanIdTermPeriodFrequencyType() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "termFrequency.periodFrequencyType.months") + public String code; + @ApiModelProperty(example = "Months") + public String value; + } + + final class GetLoansLoanIdRepaymentFrequencyType { + private GetLoansLoanIdRepaymentFrequencyType() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "repaymentFrequency.periodFrequencyType.months") + public String code; + @ApiModelProperty(example = "Months") + public String value; + } + + final class GetLoansLoanIdInterestRateFrequencyType { + private GetLoansLoanIdInterestRateFrequencyType() { + } + + @ApiModelProperty(example = "3") + public Integer id; + @ApiModelProperty(example = "interestRateFrequency.periodFrequencyType.years") + public String code; + @ApiModelProperty(example = "Per year") + public String value; + } + + final class GetLoansLoanIdAmortizationType { + private GetLoansLoanIdAmortizationType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "amortizationType.equal.installments") + public String code; + @ApiModelProperty(example = "Equal installments") + public String value; + } + + final class GetLoansLoanIdInterestType { + private GetLoansLoanIdInterestType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "interestType.flat") + public String code; + @ApiModelProperty(example = "Flat") + public String value; + } + + final class GetLoansLoanIdInterestCalculationPeriodType { + private GetLoansLoanIdInterestCalculationPeriodType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "interestCalculationPeriodType.same.as.repayment.period") + public String code; + @ApiModelProperty(example = "Same as repayment period") + public String value; + } + + final class GetLoansLoanIdTimeline { + private GetLoansLoanIdTimeline() { + } + + @ApiModelProperty(example = "[2012, 4, 3]") + public LocalDate submittedOnDate; + @ApiModelProperty(example = "admin") + public String submittedByUsername; + @ApiModelProperty(example = "App") + public String submittedByFirstname; + @ApiModelProperty(example = "Administrator") + public String submittedByLastname; + @ApiModelProperty(example = "[2012, 4, 3]") + public LocalDate approvedOnDate; + @ApiModelProperty(example = "admin") + public String approvedByUsername; + @ApiModelProperty(example = "App") + public String approvedByFirstname; + @ApiModelProperty(example = "Administrator") + public String approvedByLastname; + @ApiModelProperty(example = "[2012, 4, 10]") + public LocalDate expectedDisbursementDate; + @ApiModelProperty(example = "[2012, 4, 10]") + public LocalDate actualDisbursementDate; + @ApiModelProperty(example = "admin") + public String disbursedByUsername; + @ApiModelProperty(example = "App") + public String disbursedByFirstname; + @ApiModelProperty(example = "Administrator") + public String disbursedByLastname; + @ApiModelProperty(example = "[2012, 4, 10]") + public LocalDate expectedMaturityDate; + } + + final class GetLoansLoanIdSummary { + private GetLoansLoanIdSummary() { + } + + final class GetLoansLoanIdEmiVariations { + private GetLoansLoanIdEmiVariations() { + } + } + + final class GetLoansLoanIdLinkedAccount { + private GetLoansLoanIdLinkedAccount() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "000000001") + public Long accountNo; + } + + final class GetLoansLoanIdDisbursementDetails { + private GetLoansLoanIdDisbursementDetails() { + } + + @ApiModelProperty(example = "71") + public Integer id; + @ApiModelProperty(example = "[2013, 11, 1]") + public LocalDate expectedDisbursementDate; + @ApiModelProperty(example = "22000.000000") + public Float principal; + @ApiModelProperty(example = "22000.000000") + public Float approvedPrincipal; + } + + final class GetLoansLoanIdOverdueCharges { + private GetLoansLoanIdOverdueCharges() { + } + + final class GetLoansLoanIdChargeTimeType { + private GetLoansLoanIdChargeTimeType() { + } + + @ApiModelProperty(example = "9") + public Integer id; + @ApiModelProperty(example = "chargeTimeType.overdueInstallment") + public String code; + @ApiModelProperty(example = "overdue fees") + public String value; + } + + final class GetLoansLoanIdChargeCalculationType { + private GetLoansLoanIdChargeCalculationType() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "chargeCalculationType.percent.of.amount") + public String code; + @ApiModelProperty(example = "% Amount") + public String value; + } + + final class GetLoansLoanIdChargePaymentMode { + private GetLoansLoanIdChargePaymentMode() { + } + + @ApiModelProperty(example = "0") + public Integer id; + @ApiModelProperty(example = "chargepaymentmode.regular") + public String code; + @ApiModelProperty(example = "Regular") + public String value; + } + + final class GetLoansLoanIdFeeFrequency { + private GetLoansLoanIdFeeFrequency() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "feeFrequencyperiodFrequencyType.weeks") + public String code; + @ApiModelProperty(example = "Weeks") + public String value; + } + + @ApiModelProperty(example = "20") + public Integer id; + @ApiModelProperty(example = "overdraft penality") + public String name; + @ApiModelProperty(example = "true") + public Boolean active; + @ApiModelProperty(example = "true") + public Boolean penalty; + public LoanChargesApiResourceSwagger.GetLoansLoanIdChargesChargeIdResponse.GetLoanChargeCurrency currency; + @ApiModelProperty(example = "3.000000") + public Float amount; + public GetLoansLoanIdChargeTimeType chargeTimeType; + public LoanChargesApiResourceSwagger.GetLoansLoanIdChargesTemplateResponse.GetLoanChargeTemplateChargeOptions.GetLoanChargeTemplateChargeAppliesTo chargeAppliesTo; + public GetLoansLoanIdChargeCalculationType chargeCalculationType; + public GetLoansLoanIdChargePaymentMode chargePaymentMode; + @ApiModelProperty(example = "2") + public Integer feeInterval; + public GetLoansLoanIdFeeFrequency feeFrequency; + } + + public GetLoansLoanIdCurrency currency; + @ApiModelProperty(example = "1000000") + public Long principalDisbursed; + @ApiModelProperty(example = "0") + public Long principalPaid; + @ApiModelProperty(example = "0") + public Long principalWrittenOff; + @ApiModelProperty(example = "1000000") + public Long principalOutstanding; + @ApiModelProperty(example = "833333.3") + public Double principalOverdue; + @ApiModelProperty(example = "240000") + public Long interestCharged; + @ApiModelProperty(example = "0") + public Long interestPaid; + @ApiModelProperty(example = "0") + public Long interestWaived; + @ApiModelProperty(example = "0") + public Long interestWrittenOff; + @ApiModelProperty(example = "240000") + public Long interestOutstanding; + @ApiModelProperty(example = "200000") + public Long interestOverdue; + @ApiModelProperty(example = "18000") + public Long feeChargesCharged; + @ApiModelProperty(example = "0") + public Long feeChargesDueAtDisbursementCharged; + @ApiModelProperty(example = "0") + public Long feeChargesPaid; + @ApiModelProperty(example = "0") + public Long feeChargesWaived; + @ApiModelProperty(example = "0") + public Long feeChargesWrittenOff; + @ApiModelProperty(example = "18000") + public Long feeChargesOutstanding; + @ApiModelProperty(example = "15000") + public Long feeChargesOverdue; + @ApiModelProperty(example = "0") + public Long penaltyChargesCharged; + @ApiModelProperty(example = "0") + public Long penaltyChargesPaid; + @ApiModelProperty(example = "0") + public Long penaltyChargesWaived; + @ApiModelProperty(example = "0") + public Long penaltyChargesWrittenOff; + @ApiModelProperty(example = "0") + public Long penaltyChargesOutstanding; + @ApiModelProperty(example = "0") + public Long penaltyChargesOverdue; + @ApiModelProperty(example = "1258000") + public Long totalExpectedRepayment; + @ApiModelProperty(example = "0") + public Long totalRepayment; + @ApiModelProperty(example = "258000") + public Long totalExpectedCostOfLoan; + @ApiModelProperty(example = "0") + public Long totalCostOfLoan; + @ApiModelProperty(example = "0") + public Long totalWaived; + @ApiModelProperty(example = "0") + public Long totalWrittenOff; + @ApiModelProperty(example = "1258000") + public Long totalOutstanding; + @ApiModelProperty(example = "1048333.3") + public Double totalOverdue; + @ApiModelProperty(example = "[2012, 5, 10]") + public LocalDate overdueSinceDate; + public GetLoansLoanIdLinkedAccount linkedAccount; + public Set disbursementDetails; + @ApiModelProperty(example = "1100.000000") + public Float fixedEmiAmount; + @ApiModelProperty(example = "35000") + public Long maxOutstandingLoanBalance; + @ApiModelProperty(example = "false") + public Boolean canDisburse; + public Set emiAmountVariations; + @ApiModelProperty(example = "true") + public Boolean inArrears; + @ApiModelProperty(example = "false") + public Boolean isNPA; + public Set overdueCharges; + } + + @ApiModelProperty(example = "1") + public Long id; + @ApiModelProperty(example = "000000001") + public Long accountNo; + public GetLoansLoanIdStatus status; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "Kampala first Client") + public String clientName; + @ApiModelProperty(example = "2") + public Integer clientOfficeId; + @ApiModelProperty(example = "1") + public Integer loanProductId; + @ApiModelProperty(example = "Kampala Product (with cash accounting)") + public String loanProductName; + @ApiModelProperty(example = "Typical Kampala loan product with cash accounting enabled for testing.") + public String loanProductDescription; + @ApiModelProperty(example = "22") + public Integer loanPurposeId; + @ApiModelProperty(example = "option.HousingImprovement") + public String loanPurposeName; + @ApiModelProperty(example = "2") + public Integer loanOfficerId; + @ApiModelProperty(example = "LoanOfficer, Kampala") + public String loanOfficerName; + public GetLoansLoanIdLoanType loanType; + public GetLoansLoanIdCurrency currency; + @ApiModelProperty(example = "1000000") + public Long principal; + @ApiModelProperty(example = "12") + public Integer termFrequency; + public GetLoansLoanIdTermPeriodFrequencyType termPeriodFrequencyType; + @ApiModelProperty(example = "12") + public Integer numberOfRepayments; + @ApiModelProperty(example = "1") + public Integer repaymentEvery; + public GetLoansLoanIdRepaymentFrequencyType repaymentFrequencyType; + @ApiModelProperty(example = "24") + public Integer interestRatePerPeriod; + public GetLoansLoanIdInterestRateFrequencyType interestRateFrequencyType; + @ApiModelProperty(example = "24") + public Integer annualInterestRate; + public GetLoansLoanIdAmortizationType amortizationType; + public GetLoansLoanIdInterestType interestType; + public GetLoansLoanIdInterestCalculationPeriodType interestCalculationPeriodType; + @ApiModelProperty(example = "2") + public Integer transactionProcessingStrategyId; + public GetLoansLoanIdTimeline timeline; + public GetLoansLoanIdSummary summary; + } + + @ApiModel(value = "GetLoansResponse") + public final static class GetLoansResponse { + private GetLoansResponse() { + } + + @ApiModelProperty(example = "1") + public Integer totalFilteredRecords; + public Set pageItems; + } + + @ApiModel(value = "PostLoansRequest") + public static final class PostLoansRequest { + private PostLoansRequest() { + } + + @ApiModelProperty(example = "dd MMMM yyyy") + public String dateFormat; + @ApiModelProperty(example = "en_GB") + public String locale; + @ApiModelProperty(example = "1") + public Integer productId; + @ApiModelProperty(example = "100,000.00") + public Double principal; + @ApiModelProperty(example = "12") + public Integer loanTermFrequency; + @ApiModelProperty(example = "2") + public Integer loanTermFrequencyType; + @ApiModelProperty(example = "12") + public Integer numberOfRepayments; + @ApiModelProperty(example = "1") + public Integer repaymentEvery; + @ApiModelProperty(example = "2") + public Integer repaymentFrequencyType; + @ApiModelProperty(example = "2") + public Integer interestRatePerPeriod; + @ApiModelProperty(example = "1") + public Integer amortizationType; + @ApiModelProperty(example = "0") + public Integer interestType; + @ApiModelProperty(example = "1") + public Integer interestCalculationPeriodType; + @ApiModelProperty(example = "20 September 2011") + public String expectedDisbursementDate; + @ApiModelProperty(example = "2") + public Integer transactionProcessingStrategyId; + } + + @ApiModel(value = "PostLoansResponse") + public static final class PostLoansResponse { + private PostLoansResponse() { + } + + final class PostLoansRepaymentSchedulePeriods { + private PostLoansRepaymentSchedulePeriods() { + } + + @ApiModelProperty(example = "0") + public Integer period; + @ApiModelProperty(example = "[2011, 9, 20]") + public LocalDate dueDate; + @ApiModelProperty(example = "100000") + public Long principalDisbursed; + @ApiModelProperty(example = "100000") + public Long principalLoanBalanceOutstanding; + @ApiModelProperty(example = "0") + public Long feeChargesDue; + @ApiModelProperty(example = "0") + public Long feeChargesOutstanding; + @ApiModelProperty(example = "0") + public Long totalOriginalDueForPeriod; + @ApiModelProperty(example = "0") + public Long totalDueForPeriod; + @ApiModelProperty(example = "0") + public Long totalOutstandingForPeriod; + @ApiModelProperty(example = "0") + public Long totalOverdue; + @ApiModelProperty(example = "0") + public Long totalActualCostOfLoanForPeriod; + } + + public GetLoansLoanIdResponse.GetLoansLoanIdCurrency currency; + @ApiModelProperty(example = "366") + public Integer loanTermInDays; + @ApiModelProperty(example = "100000") + public Long totalPrincipalDisbursed; + @ApiModelProperty(example = "100000") + public Long totalPrincipalExpected; + @ApiModelProperty(example = "0") + public Long totalPrincipalPaid; + @ApiModelProperty(example = "13471.52") + public Double totalInterestCharged; + @ApiModelProperty(example = "0") + public Long totalFeeChargesCharged; + @ApiModelProperty(example = "0") + public Long totalPenaltyChargesCharged; + @ApiModelProperty(example = "0") + public Long totalWaived; + @ApiModelProperty(example = "0") + public Long totalWrittenOff; + @ApiModelProperty(example = "113471.52") + public Double totalRepaymentExpected; + @ApiModelProperty(example = "0") + public Long totalRepayment; + @ApiModelProperty(example = "0") + public Long totalOutstanding; + public Set periods; + } + + @ApiModel(value = "PutLoansLoanIdRequest") + public final static class PutLoansLoanIdRequest { + private PutLoansLoanIdRequest() { + } + + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "dd MMMM yyyy") + public String dateFormat; + @ApiModelProperty(example = "1") + public Integer productId; + @ApiModelProperty(example = "5000") + public Long principal; + @ApiModelProperty(example = "10") + public Integer loanTermFrequency; + @ApiModelProperty(example = "0") + public Integer loanTermFrequencyType; + @ApiModelProperty(example = "10") + public Integer numberOfRepayments; + @ApiModelProperty(example = "1") + public Integer repaymentEvery; + @ApiModelProperty(example = "0") + public Integer repaymentFrequencyType; + @ApiModelProperty(example = "2") + public Integer interestRatePerPeriod; + @ApiModelProperty(example = "0") + public Integer interestType; + @ApiModelProperty(example = "0") + public Integer interestCalculationPeriodType; + @ApiModelProperty(example = "1") + public Integer amortizationType; + @ApiModelProperty(example = "04 March 2014") + public String expectedDisbursementDate; + @ApiModelProperty(example = "1") + public Integer transactionProcessingStrategyId; + } + + @ApiModel(value = "PutLoansLoanIdResponse") + public final static class PutLoansLoanIdResponse { + private PutLoansLoanIdResponse() { + } + + final class PutLoansLoanIdChanges { + private PutLoansLoanIdChanges() { + } + + @ApiModelProperty(example = "5000") + public Long principal; + @ApiModelProperty(example = "en") + public String locale; + } + + @ApiModelProperty(example = "2") + public Integer officeId; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "1") + public Integer loanId; + @ApiModelProperty(example = "1") + public Integer resourceId; + public PutLoansLoanIdChanges changes; + } + + @ApiModel(value = "DeleteLoansLoanIdResponse") + public static final class DeleteLoansLoanIdResponse { + private DeleteLoansLoanIdResponse() { + } + + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "1") + public Integer loanId; + @ApiModelProperty(example = "1") + public Integer resourceId; + } + + @ApiModel(value = "PostLoansLoanIdRequest") + public final static class PostLoansLoanIdRequest { + private PostLoansLoanIdRequest() { + } + + @ApiModelProperty(example = "2") + public Integer toLoanOfficerId; + @ApiModelProperty(example = "02 September 2014") + public String assignmentDate; + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "dd MMMM yyyy") + public String dateFormat; + @ApiModelProperty(example = "") + public Integer fromLoanOfficerId; + } + + @ApiModel(value = "PostLoansLoanIdResponse") + public static final class PostLoansLoanIdResponse { + private PostLoansLoanIdResponse() { + } + + @ApiModelProperty(example = "2") + public Integer officeId; + @ApiModelProperty(example = "6") + public Integer clientId; + @ApiModelProperty(example = "3") + public Integer loanId; + @ApiModelProperty(example = "3") + public Integer resourceId; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/api/LoanProductsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/api/LoanProductsApiResource.java index 5a56c5a18..9c68524f7 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/api/LoanProductsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/api/LoanProductsApiResource.java @@ -18,25 +18,7 @@ */ package org.apache.fineract.portfolio.loanproduct.api; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriInfo; - +import io.swagger.annotations.*; import org.apache.fineract.accounting.common.AccountingDropdownReadPlatformService; import org.apache.fineract.accounting.glaccount.data.GLAccountData; import org.apache.fineract.accounting.producttoaccountmapping.data.ChargeToGLAccountMapper; @@ -74,9 +56,16 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; +import java.util.*; + @Path("/loanproducts") @Component @Scope("singleton") +@Api(value = "Loan Products", description = "A Loan product is a template that is used when creating a loan. Much of the template definition can be overridden during loan creation.") public class LoanProductsApiResource { private final Set LOAN_PRODUCT_DATA_PARAMETERS = new HashSet<>(Arrays.asList("id", "name", "shortName", "description", @@ -150,7 +139,10 @@ public class LoanProductsApiResource { @POST @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String createLoanProduct(final String apiRequestBodyAsJson) { + @ApiOperation(value = "Create a Loan Product", httpMethod = "POST", notes = "Depending of the Accounting Rule (accountingRule) selected, additional fields with details of the appropriate Ledger Account identifiers would need to be passed in.\n" + "\n" + "Refer MifosX Accounting Specs Draft for more details regarding the significance of the selected accounting rule\n\n" + "Mandatory Fields: name, shortName, currencyCode, digitsAfterDecimal, inMultiplesOf, principal, numberOfRepayments, repaymentEvery, repaymentFrequencyType, interestRatePerPeriod, interestRateFrequencyType, amortizationType, interestType, interestCalculationPeriodType, transactionProcessingStrategyId, accountingRule, isInterestRecalculationEnabled, daysInYearType, daysInMonthType\n\n" + "Optional Fields: inArrearsTolerance, graceOnPrincipalPayment, graceOnInterestPayment, graceOnInterestCharged, graceOnArrearsAgeing, charges, paymentChannelToFundSourceMappings, feeToIncomeAccountMappings, penaltyToIncomeAccountMappings, includeInBorrowerCycle, useBorrowerCycle,principalVariationsForBorrowerCycle, numberOfRepaymentVariationsForBorrowerCycle, interestRateVariationsForBorrowerCycle, multiDisburseLoan,maxTrancheCount, outstandingLoanBalance,overdueDaysForNPA,holdGuaranteeFunds, principalThresholdForLastInstalment, accountMovesOutOfNPAOnlyOnArrearsCompletion, canDefineInstallmentAmount, installmentAmountInMultiplesOf, allowAttributeOverrides, allowPartialPeriodInterestCalcualtion\n\n" + "Additional Mandatory Fields for Cash(2) based accounting: fundSourceAccountId, loanPortfolioAccountId, interestOnLoanAccountId, incomeFromFeeAccountId, incomeFromPenaltyAccountId, writeOffAccountId, transfersInSuspenseAccountId, overpaymentLiabilityAccountId\n\n" + "Additional Mandatory Fields for periodic (3) and upfront (4)accrual accounting: fundSourceAccountId, loanPortfolioAccountId, interestOnLoanAccountId, incomeFromFeeAccountId, incomeFromPenaltyAccountId, writeOffAccountId, receivableInterestAccountId, receivableFeeAccountId, receivablePenaltyAccountId, transfersInSuspenseAccountId, overpaymentLiabilityAccountId\n\n" + "Additional Mandatory Fields if interest recalculation is enabled(true): interestRecalculationCompoundingMethod, rescheduleStrategyMethod, recalculationRestFrequencyType\n\n" + "Additional Optional Fields if interest recalculation is enabled(true): isArrearsBasedOnOriginalSchedule, preClosureInterestCalculationStrategy\n\n" + "Additional Optional Fields if interest recalculation is enabled(true) and recalculationRestFrequencyType is not same as repayment period: recalculationRestFrequencyInterval, recalculationRestFrequencyDate\n\n" + "Additional Optional Fields if interest recalculation is enabled(true) and interestRecalculationCompoundingMethod is enabled: recalculationCompoundingFrequencyType\n\n" + "Additional Optional Fields if interest recalculation is enabled(true) and interestRecalculationCompoundingMethod is enabled and recalculationCompoundingFrequencyType is not same as repayment period: recalculationCompoundingFrequencyInterval, recalculationCompoundingFrequencyDate\n\n" + "Additional Mandatory Fields if Hold Guarantee funds is enabled(true): mandatoryGuarantee\n\n" + "Additional Optional Fields if Hold Guarantee funds is enabled(true): minimumGuaranteeFromOwnFunds,minimumGuaranteeFromGuarantor") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = LoanProductsApiResourceSwagger.PostLoanProductsRequest.class)}) + @ApiResponses({@ApiResponse(code = 200,message = "OK", response = LoanProductsApiResourceSwagger.PostLoanProductsResponse.class)}) + public String createLoanProduct(@ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder().createLoanProduct().withJson(apiRequestBodyAsJson).build(); @@ -162,6 +154,8 @@ public class LoanProductsApiResource { @GET @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) + @ApiOperation(value = "List Loan Products", httpMethod = "GET", notes = "Lists Loan Products\n\n" + "Example Requests:\n" + "\n" + "loanproducts\n" + "\n" + "\n" + "loanproducts?fields=name,description,interestRateFrequencyType,amortizationType") + @ApiResponses({@ApiResponse(code = 200, message = "OK", responseContainer = "List", response = LoanProductsApiResourceSwagger.GetLoanProductsResponse.class)}) public String retrieveAllLoanProducts(@Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions); @@ -185,7 +179,9 @@ public class LoanProductsApiResource { @Path("template") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveTemplate(@Context final UriInfo uriInfo, @QueryParam("isProductMixTemplate") final boolean isProductMixTemplate) { + @ApiOperation(value = "Retrieve Loan Product Details Template", httpMethod = "GET", notes = "This is a convenience resource. It can be useful when building maintenance user interface screens for client applications. The template data returned consists of any or all of:\n" + "\n" + "Field Defaults\n" + "Allowed Value Lists\n" + "Example Request:\n" + "\n" + "loanproducts/template") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = LoanProductsApiResourceSwagger.GetLoanProductsTemplateResponse.class)}) + public String retrieveTemplate(@Context final UriInfo uriInfo, @QueryParam("isProductMixTemplate") @ApiParam(value = "isProductMixTemplate") final boolean isProductMixTemplate) { this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions); final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); @@ -208,7 +204,9 @@ public class LoanProductsApiResource { @Path("{productId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveLoanProductDetails(@PathParam("productId") final Long productId, @Context final UriInfo uriInfo) { + @ApiOperation(value = "Retrieve a Loan Product", httpMethod = "GET", notes = "Retrieves a Loan Product\n\n" + "Example Requests:\n" + "\n" + "loanproducts/1\n" + "\n" + "\n" + "loanproducts/1?template=true\n" + "\n" + "\n" + "loanproducts/1?fields=name,description,numberOfRepayments") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = LoanProductsApiResourceSwagger.GetLoanProductsProductIdResponse.class)}) + public String retrieveLoanProductDetails(@PathParam("productId") @ApiParam(value = "productId") final Long productId, @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions); @@ -243,7 +241,10 @@ public class LoanProductsApiResource { @Path("{productId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String updateLoanProduct(@PathParam("productId") final Long productId, final String apiRequestBodyAsJson) { + @ApiOperation(value = "Update a Loan Product", httpMethod = "PUT", notes = "Updates a Loan Product") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = LoanProductsApiResourceSwagger.PutLoanProductsProductIdRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = LoanProductsApiResourceSwagger.PutLoanProductsProductIdResponse.class)}) + public String updateLoanProduct(@PathParam("productId") @ApiParam(value = "productId") final Long productId, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder().updateLoanProduct(productId).withJson(apiRequestBodyAsJson) .build(); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/api/LoanProductsApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/api/LoanProductsApiResourceSwagger.java new file mode 100644 index 000000000..cd09968ba --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/api/LoanProductsApiResourceSwagger.java @@ -0,0 +1,1109 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.loanproduct.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.time.LocalDate; +import java.util.List; +import java.util.Set; + +/** + * Created by Chirag Gupta on 12/27/17. + */ +final class LoanProductsApiResourceSwagger { + private LoanProductsApiResourceSwagger() { + } + + @ApiModel(value = "PostLoanProductsRequest") + public final static class PostLoanProductsRequest { + private PostLoanProductsRequest() { + } + + @ApiModelProperty(example = "LP Accrual Accounting") + public String name; + @ApiModelProperty(example = "LPAA") + public String shortName; + @ApiModelProperty(example = "USD") + public String currencyCode; + @ApiModelProperty(example = "en_GB") + public String locale; + @ApiModelProperty(example = "2") + public Integer digitsAfterDecimal; + @ApiModelProperty(example = "0") + public Integer inMultiplesOf; + @ApiModelProperty(example = "100,000.00") + public Double principal; + @ApiModelProperty(example = "12") + public Integer numberOfRepayments; + @ApiModelProperty(example = "1") + public Integer repaymentEvery; + @ApiModelProperty(example = "2") + public Integer repaymentFrequencyType; + @ApiModelProperty(example = "1") + public Integer transactionProcessingStrategyId; + @ApiModelProperty(example = "1.75") + public Double interestRatePerPeriod; + @ApiModelProperty(example = "2") + public Integer interestRateFrequencyType; + @ApiModelProperty(example = "1") + public Integer amortizationType; + @ApiModelProperty(example = "0") + public Integer interestType; + @ApiModelProperty(example = "1") + public Integer interestCalculationPeriodType; + @ApiModelProperty(example = "1") + public Integer daysInMonthType; + @ApiModelProperty(example = "1") + public Integer daysInYearType; + @ApiModelProperty(example = "false") + public Boolean isInterestRecalculationEnabled; + @ApiModelProperty(example = "3") + public Integer accountingRule; + @ApiModelProperty(example = "4") + public Integer fundSourceAccountId; + @ApiModelProperty(example = "8") + public Integer loanPortfolioAccountId; + @ApiModelProperty(example = "9") + public Integer receivableInterestAccountId; + @ApiModelProperty(example = "11") + public Integer receivableFeeAccountId; + @ApiModelProperty(example = "10") + public Integer receivablePenaltyAccountId; + @ApiModelProperty(example = "34") + public Integer interestOnLoanAccountId; + @ApiModelProperty(example = "37") + public Integer incomeFromFeeAccountId; + @ApiModelProperty(example = "35") + public Integer incomeFromPenaltyAccountId; + @ApiModelProperty(example = "2") + public Integer overpaymentLiabilityAccountId; + @ApiModelProperty(example = "41") + public Integer writeOffAccountId; + } + + @ApiModel(value = "PostLoanProductsResponse") + public final static class PostLoanProductsResponse { + private PostLoanProductsResponse() { + } + + @ApiModelProperty(example = "3") + public Integer resourceId; + } + + @ApiModel(value = "GetLoanProductsResponse") + public final static class GetLoanProductsResponse { + private GetLoanProductsResponse() { + } + + final class GetLoanProductsCurrency { + private GetLoanProductsCurrency() { + } + + @ApiModelProperty(example = "USD") + public String code; + @ApiModelProperty(example = "US Dollar") + public String name; + @ApiModelProperty(example = "2") + public Integer decimalPlaces; + @ApiModelProperty(example = "0") + public Integer inMultiplesOf; + @ApiModelProperty(example = "$") + public String displaySymbol; + @ApiModelProperty(example = "currency.USD") + public String nameCode; + @ApiModelProperty(example = "US Dollar ($)") + public String displayLabel; + } + + final class GetLoanProductsRepaymentFrequencyType { + private GetLoanProductsRepaymentFrequencyType() { + } + + @ApiModelProperty(example = "0") + public Integer id; + @ApiModelProperty(example = "repaymentFrequency.periodFrequencyType.days") + public String code; + @ApiModelProperty(example = "Days") + public String value; + } + + final class GetLoanProductsInterestRateFrequencyType { + private GetLoanProductsInterestRateFrequencyType() { + } + + @ApiModelProperty(example = "3") + public Integer id; + @ApiModelProperty(example = "interestRateFrequency.periodFrequencyType.years") + public String code; + @ApiModelProperty(example = "Per year") + public String value; + } + + final class GetLoanProductsAmortizationType { + private GetLoanProductsAmortizationType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "amortizationType.equal.installments") + public String code; + @ApiModelProperty(example = "Equal installments") + public String value; + } + + final class GetLoanProductsInterestType { + private GetLoanProductsInterestType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "interestType.flat") + public String code; + @ApiModelProperty(example = "Flat") + public String value; + } + + final class GetLoansProductsInterestCalculationPeriodType { + private GetLoansProductsInterestCalculationPeriodType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "interestCalculationPeriodType.same.as.repayment.period") + public String code; + @ApiModelProperty(example = "Same as repayment period") + public String value; + } + + final class GetLoansProductsDaysInMonthType { + private GetLoansProductsDaysInMonthType() { + } + + @ApiModelProperty(example = "30") + public Integer id; + @ApiModelProperty(example = "DaysInMonthType.days360") + public String code; + @ApiModelProperty(example = "30 Days") + public String value; + } + + final class GetLoansProductsDaysInYearType { + private GetLoansProductsDaysInYearType() { + } + + @ApiModelProperty(example = "360") + public Integer id; + @ApiModelProperty(example = "DaysInYearType.days360") + public String code; + @ApiModelProperty(example = "360 Days") + public String value; + } + + final class GetLoanProductsInterestRecalculationData { + private GetLoanProductsInterestRecalculationData() { + } + + final class GetLoanProductsInterestRecalculationCompoundingType { + private GetLoanProductsInterestRecalculationCompoundingType() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "interestRecalculationCompoundingMethod.fee") + public String code; + @ApiModelProperty(example = "Fee") + public String value; + } + + final class GetLoanProductsInterestRecalculationCompoundingFrequencyType { + private GetLoanProductsInterestRecalculationCompoundingFrequencyType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "interestRecalculationFrequencyType.same.as.repayment.period") + public String code; + @ApiModelProperty(example = "Same as repayment period") + public String value; + } + + final class GetLoanProductsRescheduleStrategyType { + private GetLoanProductsRescheduleStrategyType() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "loanRescheduleStrategyMethod.reduce.number.of.installments") + public String code; + @ApiModelProperty(example = "Reduce number of installments") + public String value; + } + + final class GetLoanProductsPreClosureInterestCalculationStrategy { + private GetLoanProductsPreClosureInterestCalculationStrategy() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "loanPreClosureInterestCalculationStrategy.tillPreClosureDate") + public String code; + @ApiModelProperty(example = "Till preclose Date") + public String value; + } + + @ApiModelProperty(example = "3") + public Integer id; + @ApiModelProperty(example = "1") + public Integer productId; + public GetLoanProductsInterestRecalculationCompoundingType interestRecalculationCompoundingType; + public GetLoanProductsInterestRecalculationCompoundingFrequencyType interestRecalculationCompoundingFrequencyType; + public GetLoanProductsRescheduleStrategyType rescheduleStrategyType; + public GetLoanProductsInterestRecalculationCompoundingFrequencyType recalculationRestFrequencyType; + public GetLoanProductsPreClosureInterestCalculationStrategy preClosureInterestCalculationStrategy; + @ApiModelProperty(example = "true") + public Boolean isArrearsBasedOnOriginalSchedule; + } + + final class GetLoanProductsAccountingRule { + private GetLoanProductsAccountingRule() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "accountingRuleType.cash") + public String code; + @ApiModelProperty(example = "CASH BASED") + public String value; + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "personal loan product") + public String name; + @ApiModelProperty(example = "pe1") + public String shortName; + @ApiModelProperty(example = "false") + public Boolean includeInBorrowerCycle; + @ApiModelProperty(example = "false") + public Boolean useBorrowerCycle; + @ApiModelProperty(example = "[2013, 9, 2]") + public LocalDate startDate; + @ApiModelProperty(example = "[2014, 2, 7]") + public LocalDate endDate; + @ApiModelProperty(example = "loanProduct.active") + public String status; + public GetLoanProductsCurrency currency; + @ApiModelProperty(example = "10000.000000") + public Float principal; + @ApiModelProperty(example = "5000.000000") + public Float minPrincipal; + @ApiModelProperty(example = "15000.000000") + public Float maxPrincipal; + @ApiModelProperty(example = "10") + public Integer numberOfRepayments; + @ApiModelProperty(example = "5") + public Integer minNumberOfRepayments; + @ApiModelProperty(example = "15") + public Integer maxNumberOfRepayments; + @ApiModelProperty(example = "7") + public Integer repaymentEvery; + public GetLoanProductsRepaymentFrequencyType repaymentFrequencyType; + @ApiModelProperty(example = "15.000000") + public Float interestRatePerPeriod; + public GetLoanProductsInterestRateFrequencyType interestRateFrequencyType; + @ApiModelProperty(example = "15.000000") + public Float annualInterestRate; + public GetLoanProductsAmortizationType amortizationType; + public GetLoanProductsInterestType interestType; + public GetLoansProductsInterestCalculationPeriodType interestCalculationPeriodType; + @ApiModelProperty(example = "1") + public Integer transactionProcessingStrategyId; + @ApiModelProperty(example = "Mifos style") + public String transactionProcessingStrategyName; + @ApiModelProperty(example = "[]") + public List principalVariationsForBorrowerCycle; + @ApiModelProperty(example = "[]") + public List interestRateVariationsForBorrowerCycle; + @ApiModelProperty(example = "[]") + public List numberOfRepaymentVariationsForBorrowerCycle; + public GetLoansProductsDaysInMonthType daysInMonthType; + public GetLoansProductsDaysInYearType daysInYearType; + @ApiModelProperty(example = "true") + public Boolean isInterestRecalculationEnabled; + public GetLoanProductsInterestRecalculationData interestRecalculationData; + public GetLoanProductsAccountingRule accountingRule; + @ApiModelProperty(example = "0") + public Integer principalThresholdForLastInstalment; + } + + @ApiModel(value = "GetLoanProductsTemplateResponse") + public final static class GetLoanProductsTemplateResponse { + private GetLoanProductsTemplateResponse() { + } + + final class GetLoanProductsTemplateCurrency { + private GetLoanProductsTemplateCurrency() { + } + + @ApiModelProperty(example = "") + public String code; + @ApiModelProperty(example = "") + public String name; + @ApiModelProperty(example = "0") + public Integer decimalPlaces; + @ApiModelProperty(example = "0") + public Integer inMultiplesOf; + @ApiModelProperty(example = "") + public String displaySymbol; + @ApiModelProperty(example = "") + public String nameCode; + @ApiModelProperty(example = "[]") + public String displayLabel; + } + + final class GetLoanProductsRepaymentTemplateFrequencyType { + private GetLoanProductsRepaymentTemplateFrequencyType() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "repaymentFrequency.periodFrequencyType.months") + public String code; + @ApiModelProperty(example = "Months") + public String value; + } + + final class GetLoanProductsInterestRateTemplateFrequencyType { + private GetLoanProductsInterestRateTemplateFrequencyType() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "interestRateFrequency.periodFrequencyType.months") + public String code; + @ApiModelProperty(example = "Per month") + public String value; + } + + final class GetLoanProductsInterestTemplateType { + private GetLoanProductsInterestTemplateType() { + } + + @ApiModelProperty(example = "0") + public Integer id; + @ApiModelProperty(example = "interestType.declining.balance") + public String code; + @ApiModelProperty(example = "Declining Balance") + public String value; + } + + final class GetLoanProductsAccountingRule { + private GetLoanProductsAccountingRule() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "accountingRuleType.none") + public String code; + @ApiModelProperty(example = "NONE") + public String value; + } + + final class GetLoansProductsDaysInMonthTemplateType { + private GetLoansProductsDaysInMonthTemplateType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "DaysInMonthType.actual") + public String code; + @ApiModelProperty(example = "Actual") + public String value; + } + + final class GetLoanProductsDaysInYearTemplateType { + private GetLoanProductsDaysInYearTemplateType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "DaysInYearType.actual") + public String code; + @ApiModelProperty(example = "Actual") + public String value; + } + + final class GetLoanProductsInterestRecalculationTemplateData { + private GetLoanProductsInterestRecalculationTemplateData() { + } + + final class GetLoanProductsInterestRecalculationCompoundingType { + private GetLoanProductsInterestRecalculationCompoundingType() { + } + + @ApiModelProperty(example = "0") + public Integer id; + @ApiModelProperty(example = "interestRecalculationCompoundingMethod.none") + public String code; + @ApiModelProperty(example = "None") + public String value; + } + + final class GetLoanProductsRescheduleStrategyType { + private GetLoanProductsRescheduleStrategyType() { + } + + @ApiModelProperty(example = "3") + public Integer id; + @ApiModelProperty(example = "loanRescheduleStrategyMethod.reduce.emi.amount") + public String code; + @ApiModelProperty(example = "Reduce EMI amount") + public String value; + } + + public GetLoanProductsInterestRecalculationCompoundingType interestRecalculationCompoundingType; + public GetLoanProductsRescheduleStrategyType rescheduleStrategyType; + public GetLoanProductsResponse.GetLoanProductsInterestRecalculationData.GetLoanProductsPreClosureInterestCalculationStrategy preClosureInterestCalculationStrategy; + } + + final class GetLoanProductsPaymentTypeOptions { + private GetLoanProductsPaymentTypeOptions() { + } + + @ApiModelProperty(example = "10") + public Integer id; + @ApiModelProperty(example = "check") + public String name; + @ApiModelProperty(example = "1") + public Integer position; + } + + final class GetLoanProductsCurrencyOptions { + private GetLoanProductsCurrencyOptions() { + } + + @ApiModelProperty(example = "USD") + public String code; + @ApiModelProperty(example = "US Dollar") + public String name; + @ApiModelProperty(example = "2") + public Integer decimalPlaces; + @ApiModelProperty(example = "$") + public String displaySymbol; + @ApiModelProperty(example = "currency.USD") + public String nameCode; + @ApiModelProperty(example = "US Dollar ($)") + public String displayLabel; + } + + final class GetLoanProductsTransactionProcessingStrategyOptions { + private GetLoanProductsTransactionProcessingStrategyOptions() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "mifos-standard-strategy") + public String code; + @ApiModelProperty(example = "Penalties, Fees, Interest, Principal order") + public String name; + } + + final class GetLoanProductsChargeOptions { + private GetLoanProductsChargeOptions() { + } + + final class GetLoanChargeTimeType { + private GetLoanChargeTimeType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "chargeTimeType.disbursement") + public String code; + @ApiModelProperty(example = "Disbursement") + public String value; + } + + final class GetLoanProductsChargeAppliesTo { + private GetLoanProductsChargeAppliesTo() { + } + + @ApiModelProperty(example = "1 ") + public Integer id; + @ApiModelProperty(example = "chargeAppliesTo.loan") + public String code; + @ApiModelProperty(example = "Loan") + public String value; + } + + final class GetLoanChargeCalculationType { + private GetLoanChargeCalculationType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "chargeCalculationType.flat") + public String code; + @ApiModelProperty(example = "Flat") + public String value; + } + + final class GetLoansChargePaymentMode { + private GetLoansChargePaymentMode() { + } + + @ApiModelProperty(example = "0") + public Integer id; + @ApiModelProperty(example = "chargepaymentmode.regular") + public String code; + @ApiModelProperty(example = "Regular") + public String value; + } + + @ApiModelProperty(example = "5") + public Integer id; + @ApiModelProperty(example = "des charges") + public String name; + @ApiModelProperty(example = "true") + public Boolean active; + @ApiModelProperty(example = "false") + public Boolean penalty; + public GetLoanProductsCurrencyOptions currency; + @ApiModelProperty(example = "100") + public Long amount; + public GetLoanChargeTimeType chargeTimeType; + public GetLoanProductsChargeAppliesTo chargeAppliesTo; + public GetLoanChargeCalculationType chargeCalculationType; + public GetLoansChargePaymentMode chargePaymentMode; + } + + final class GetLoanProductsAccountingMappingOptions { + private GetLoanProductsAccountingMappingOptions() { + } + + final class GetLoanProductsLiabilityAccountOptions { + private GetLoanProductsLiabilityAccountOptions() { + } + + final class GetLoanProductsLiabilityType { + private GetLoanProductsLiabilityType() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "accountType.liability") + public String code; + @ApiModelProperty(example = "LIABILITY") + public String value; + } + + final class GetLoanProductsLiabilityUsage { + private GetLoanProductsLiabilityUsage() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "accountUsage.detail") + public String code; + @ApiModelProperty(example = "DETAIL") + public String value; + } + + final class GetLoanProductsLiabilityTagId { + private GetLoanProductsLiabilityTagId() { + } + + @ApiModelProperty(example = "0") + public Integer id; + } + + @ApiModelProperty(example = "11") + public Integer id; + @ApiModelProperty(example = "over payment") + public String name; + @ApiModelProperty(example = "13") + public Integer glCode; + @ApiModelProperty(example = "false") + public Boolean disabled; + @ApiModelProperty(example = "true") + public Boolean manualEntriesAllowed; + public GetLoanProductsLiabilityType type; + public GetLoanProductsLiabilityUsage usage; + @ApiModelProperty(example = "over payment") + public String nameDecorated; + public GetLoanProductsLiabilityTagId tagId; + @ApiModelProperty(example = "0") + public Integer organizationRunningBalance; + } + + final class GetLoanProductsAssetAccountOptions { + private GetLoanProductsAssetAccountOptions() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "Loan portfolio") + public String name; + @ApiModelProperty(example = "02") + public Integer glCode; + @ApiModelProperty(example = "false") + public Boolean disabled; + @ApiModelProperty(example = "true") + public Boolean manualEntriesAllowed; + public GetLoanProductsLiabilityAccountOptions.GetLoanProductsLiabilityType type; + public GetLoanProductsLiabilityAccountOptions.GetLoanProductsLiabilityUsage usage; + @ApiModelProperty(example = "Loan portfolio") + public String nameDecorated; + public GetLoanProductsLiabilityAccountOptions.GetLoanProductsLiabilityTagId tagId; + @ApiModelProperty(example = "60000") + public Integer organizationRunningBalance; + } + + final class GetLoanProductsExpenseAccountOptions { + private GetLoanProductsExpenseAccountOptions() { + } + + final class GetLoanProductsExpenseType { + private GetLoanProductsExpenseType() { + } + + @ApiModelProperty(example = "5") + public Integer id; + @ApiModelProperty(example = "accountType.expense") + public String code; + @ApiModelProperty(example = "EXPENSE") + public String value; + } + + @ApiModelProperty(example = "10") + public Integer id; + @ApiModelProperty(example = "loans written off 2") + public String name; + @ApiModelProperty(example = "12") + public Integer glCode; + @ApiModelProperty(example = "false") + public Boolean disabled; + @ApiModelProperty(example = "true") + public Boolean manualEntriesAllowed; + public GetLoanProductsExpenseType type; + public GetLoanProductsLiabilityAccountOptions.GetLoanProductsLiabilityUsage usage; + @ApiModelProperty(example = "loans written off 2") + public String nameDecorated; + public GetLoanProductsLiabilityAccountOptions.GetLoanProductsLiabilityTagId tagId; + @ApiModelProperty(example = "0") + public Integer organizationRunningBalance; + } + + final class GetLoanProductsIncomeAccountOptions { + private GetLoanProductsIncomeAccountOptions() { + } + + final class GetLoanProductsIncomeType { + private GetLoanProductsIncomeType() { + } + + @ApiModelProperty(example = "4") + public Integer id; + @ApiModelProperty(example = "accountType.income") + public String code; + @ApiModelProperty(example = "INCOME") + public String value; + } + + @ApiModelProperty(example = "4") + public Integer id; + @ApiModelProperty(example = "income from interest") + public String name; + @ApiModelProperty(example = "04") + public Integer glCode; + @ApiModelProperty(example = "false") + public Boolean disabled; + @ApiModelProperty(example = "true") + public Boolean manualEntriesAllowed; + public GetLoanProductsIncomeType type; + public GetLoanProductsLiabilityAccountOptions.GetLoanProductsLiabilityUsage usage; + @ApiModelProperty(example = "income from interest") + public String nameDecorated; + public GetLoanProductsLiabilityAccountOptions.GetLoanProductsLiabilityTagId tagId; + @ApiModelProperty(example = "19") + public Integer organizationRunningBalance; + } + + public Set liabilityAccountOptions; + public Set assetAccountOptions; + public Set expenseAccountOptions; + public Set incomeAccountOptions; + } + + final class GetLoanProductsValueConditionTypeOptions { + private GetLoanProductsValueConditionTypeOptions() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "mifos-standard-strategyLoanProductValueConditionType.equal") + public String code; + @ApiModelProperty(example = "equals") + public String value; + } + + @ApiModelProperty(example = "false") + public Boolean includeInBorrowerCycle; + @ApiModelProperty(example = "false") + public Boolean useBorrowerCycle; + public GetLoanProductsTemplateCurrency currency; + public GetLoanProductsRepaymentTemplateFrequencyType repaymentFrequencyType; + public GetLoanProductsInterestRateTemplateFrequencyType interestRateFrequencyType; + public GetLoanProductsResponse.GetLoanProductsAmortizationType amortizationType; + public GetLoanProductsInterestTemplateType interestType; + public GetLoanProductsResponse.GetLoansProductsInterestCalculationPeriodType interestCalculationPeriodType; + @ApiModelProperty(example = "[]") + public List principalVariationsForBorrowerCycle; + @ApiModelProperty(example = "[]") + public List interestRateVariationsForBorrowerCycle; + @ApiModelProperty(example = "[]") + public List numberOfRepaymentVariationsForBorrowerCycle; + public GetLoanProductsAccountingRule accountingRule; + public GetLoansProductsDaysInMonthTemplateType daysInMonthType; + public GetLoanProductsDaysInYearTemplateType daysInYearType; + @ApiModelProperty(example = "false") + public Boolean isInterestRecalculationEnabled; + public GetLoanProductsInterestRecalculationTemplateData interestRecalculationData; + public Set paymentTypeOptions; + public Set currencyOptions; + public Set repaymentFrequencyTypeOptions; + public Set preClosureInterestCalculationStrategyOptions; + public Set interestRateFrequencyTypeOptions; + public Set amortizationTypeOptions; + public Set interestTypeOptions; + public Set interestCalculationPeriodTypeOptions; + public Set transactionProcessingStrategyOptions; + public Set chargeOptions; + public Set accountingRuleOptions; + public GetLoanProductsAccountingMappingOptions accountingMappingOptions; + public Set valueConditionTypeOptions; + public Set daysInMonthTypeOptions; + public Set daysInYearTypeOptions; + public Set interestRecalculationCompoundingTypeOptions; + public Set rescheduleStrategyTypeOptions; + public Set interestRecalculationFrequencyTypeOptions; + } + + @ApiModel(value = "GetLoanProductsProductIdResponse") + public final static class GetLoanProductsProductIdResponse { + private GetLoanProductsProductIdResponse() { + } + + final class GetLoanProductsInterestRateFrequencyType { + private GetLoanProductsInterestRateFrequencyType() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "interestRateFrequency.periodFrequencyType.months") + public String code; + @ApiModelProperty(example = "Per month") + public String value; + } + + final class GetLoanProductsPrincipalVariationsForBorrowerCycle { + private GetLoanProductsPrincipalVariationsForBorrowerCycle() { + } + + final class GetLoanProductsParamType { + private GetLoanProductsParamType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "LoanProductParamType.principal") + public String code; + @ApiModelProperty(example = "principal") + public String value; + } + + final class GetLoanProductsValueConditionType { + private GetLoanProductsValueConditionType() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "LoanProductValueConditionType.equal") + public String code; + @ApiModelProperty(example = "equals") + public String value; + } + + @ApiModelProperty(example = "21") + public Integer id; + @ApiModelProperty(example = "1") + public Integer borrowerCycleNumber; + public GetLoanProductsParamType paramType; + public GetLoanProductsValueConditionType valueConditionType; + @ApiModelProperty(example = "2000.000000") + public Float minValue; + @ApiModelProperty(example = "20000.000000") + public Float maxValue; + @ApiModelProperty(example = "15000.000000") + public Float defaultValue; + } + + final class GetLoanAccountingMappings { + private GetLoanAccountingMappings() { + } + + final class GetLoanFundSourceAccount { + private GetLoanFundSourceAccount() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "fund source") + public String name; + @ApiModelProperty(example = "01") + public Integer glCode; + } + + final class GetLoanPortfolioAccount { + private GetLoanPortfolioAccount() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "Loan portfolio") + public String name; + @ApiModelProperty(example = "02") + public Integer glCode; + } + + final class GetLoanTransfersInSuspenseAccount { + private GetLoanTransfersInSuspenseAccount() { + } + + @ApiModelProperty(example = "3") + public Integer id; + @ApiModelProperty(example = "transfers") + public String name; + @ApiModelProperty(example = "03") + public Integer glCode; + } + + final class GetLoanInterestOnLoanAccount { + private GetLoanInterestOnLoanAccount() { + } + + @ApiModelProperty(example = "4") + public Integer id; + @ApiModelProperty(example = "income from interest") + public String name; + @ApiModelProperty(example = "04") + public Integer glCode; + } + + final class GetLoanIncomeFromFeeAccount { + private GetLoanIncomeFromFeeAccount() { + } + + @ApiModelProperty(example = "8") + public Integer id; + @ApiModelProperty(example = "income from fees 2") + public String name; + @ApiModelProperty(example = "10") + public Integer glCode; + } + + final class GetLoanIncomeFromPenaltyAccount { + private GetLoanIncomeFromPenaltyAccount() { + } + + @ApiModelProperty(example = "9") + public Integer id; + @ApiModelProperty(example = "income from penalities 2") + public String name; + @ApiModelProperty(example = "11") + public Integer glCode; + } + + final class GetLoanWriteOffAccount { + private GetLoanWriteOffAccount() { + } + + @ApiModelProperty(example = "10") + public Integer id; + @ApiModelProperty(example = "loans written off 2") + public String name; + @ApiModelProperty(example = "12") + public Integer glCode; + } + + final class GetLoanOverpaymentLiabilityAccount { + private GetLoanOverpaymentLiabilityAccount() { + } + + @ApiModelProperty(example = "11") + public Integer id; + @ApiModelProperty(example = "over payment") + public String name; + @ApiModelProperty(example = "13") + public Integer glCode; + } + + public GetLoanFundSourceAccount fundSourceAccount; + public GetLoanPortfolioAccount loanPortfolioAccount; + public GetLoanTransfersInSuspenseAccount transfersInSuspenseAccount; + public GetLoanInterestOnLoanAccount interestOnLoanAccount; + public GetLoanIncomeFromFeeAccount incomeFromFeeAccount; + public GetLoanIncomeFromPenaltyAccount incomeFromPenaltyAccount; + public GetLoanWriteOffAccount writeOffAccount; + public GetLoanOverpaymentLiabilityAccount overpaymentLiabilityAccount; + } + + final class GetLoanPaymentChannelToFundSourceMappings { + private GetLoanPaymentChannelToFundSourceMappings() { + } + + final class GetLoanPaymentType { + private GetLoanPaymentType() { + } + + @ApiModelProperty(example = "10") + public Integer id; + @ApiModelProperty(example = "check") + public String name; + } + + public GetLoanPaymentType paymentType; + public GetLoanAccountingMappings.GetLoanFundSourceAccount fundSourceAccount; + } + + final class GetLoanFeeToIncomeAccountMappings { + private GetLoanFeeToIncomeAccountMappings() { + } + + final class GetLoanCharge { + private GetLoanCharge() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "flat install") + public String name; + @ApiModelProperty(example = "false") + public Boolean active; + @ApiModelProperty(example = "false") + public Boolean penalty; + } + + public GetLoanCharge charge; + public GetLoanAccountingMappings.GetLoanIncomeFromFeeAccount incomeAccount; + } + + @ApiModelProperty(example = "11") + public Integer id; + @ApiModelProperty(example = "advanced accounting") + public String name; + @ApiModelProperty(example = "ad11") + public String shortName; + @ApiModelProperty(example = "true") + public Boolean includeInBorrowerCycle; + @ApiModelProperty(example = "true") + public Boolean useBorrowerCycle; + @ApiModelProperty(example = "loanProduct.active") + public String status; + public GetLoanProductsResponse.GetLoanProductsCurrency currency; + @ApiModelProperty(example = "10000.000000") + public Float principal; + @ApiModelProperty(example = "2000.000000") + public Float minPrincipal; + @ApiModelProperty(example = "15000.000000") + public Float maxPrincipal; + @ApiModelProperty(example = "7") + public Integer numberOfRepayments; + @ApiModelProperty(example = "7") + public Integer repaymentEvery; + public GetLoanProductsResponse.GetLoanProductsRepaymentFrequencyType repaymentFrequencyType; + @ApiModelProperty(example = "5.000000") + public Float interestRatePerPeriod; + public GetLoanProductsInterestRateFrequencyType interestRateFrequencyType; + @ApiModelProperty(example = "60.000000") + public Float annualInterestRate; + public GetLoanProductsResponse.GetLoanProductsAmortizationType amortizationType; + public GetLoanProductsTemplateResponse.GetLoanProductsInterestTemplateType interestType; + public GetLoanProductsResponse.GetLoansProductsInterestCalculationPeriodType interestCalculationPeriodType; + @ApiModelProperty(example = "1") + public Integer transactionProcessingStrategyId; + @ApiModelProperty(example = "Mifos style") + public String transactionProcessingStrategyName; + @ApiModelProperty(example = "[]") + public List charges; + public Set productsPrincipalVariationsForBorrowerCycle; + @ApiModelProperty(example = "[]") + public List interestRateVariationsForBorrowerCycle; + @ApiModelProperty(example = "[]") + public List numberOfRepaymentVariationsForBorrowerCycle; + public GetLoanProductsResponse.GetLoanProductsAccountingRule accountingRule; + public GetLoanAccountingMappings accountingMappings; + public Set paymentChannelToFundSourceMappings; + public Set feeToIncomeAccountMappings; + @ApiModelProperty(example = "true") + public Boolean multiDisburseLoan; + @ApiModelProperty(example = "3") + public Integer maxTrancheCount; + @ApiModelProperty(example = "36000.000000") + public Float outstandingLoanBalance; + @ApiModelProperty(example = "2") + public Integer overdueDaysForNPA; + @ApiModelProperty(example = "50") + public Integer principalThresholdForLastInstalment; + } + + @ApiModel(value = "PutLoanProductsProductIdRequest") + public final static class PutLoanProductsProductIdRequest { + private PutLoanProductsProductIdRequest() { + } + + @ApiModelProperty(example = "en_GB") + public String locale; + @ApiModelProperty(example = "70,000.00") + public Double principal; + } + + @ApiModel(value = "PutLoanProductsProductIdResponse") + public final static class PutLoanProductsProductIdResponse { + private PutLoanProductsProductIdResponse() { + } + + final class PutLoanChanges { + private PutLoanChanges() { + } + + @ApiModelProperty(example = "70,000.00") + public Double principal; + @ApiModelProperty(example = "en_GB") + public String locale; + } + + @ApiModelProperty(example = "1") + public Integer resourceId; + public PutLoanChanges changes; + } +} + diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/note/api/NotesApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/note/api/NotesApiResource.java index 217968921..f1b4a8128 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/note/api/NotesApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/note/api/NotesApiResource.java @@ -18,23 +18,7 @@ */ package org.apache.fineract.portfolio.note.api; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriInfo; - +import io.swagger.annotations.*; import org.apache.fineract.commands.domain.CommandWrapper; import org.apache.fineract.commands.service.CommandWrapperBuilder; import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService; @@ -51,9 +35,19 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + @Path("/{resourceType}/{resourceId}/notes") @Component @Scope("singleton") +@Api(value = "Notes", description = "Notes API allows to enter notes for supported resources.") public class NotesApiResource { private final Set NOTE_DATA_PARAMETERS = new HashSet<>(Arrays.asList("id", "clientId", "groupId", "loanId", @@ -80,8 +74,10 @@ public class NotesApiResource { @GET @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveNotesByResource(@PathParam("resourceType") final String resourceType, - @PathParam("resourceId") final Long resourceId, @Context final UriInfo uriInfo) { + @ApiOperation(value = "Retrieve a Resource's Notes", httpMethod = "GET", notes = "Retrieves a Resource's Notes\n\n" + "Note: Notes are returned in descending createOn order.\n" + "\n" + "Example Requests:\n" + "\n" + "clients/2/notes\n" + "\n" + "\n" + "groups/2/notes?fields=note,createdOn,createdByUsername") + @ApiResponses({@ApiResponse(code = 200, message = "OK", responseContainer = "List", response = NotesApiResourceSwagger.GetResourceTypeResourceIdNotesResponse.class)}) + public String retrieveNotesByResource(@PathParam("resourceType") @ApiParam(value = "resourceType") final String resourceType, + @PathParam("resourceId") @ApiParam(value = "resourceId") final Long resourceId, @Context final UriInfo uriInfo) { final NoteType noteType = NoteType.fromApiUrl(resourceType); @@ -101,8 +97,10 @@ public class NotesApiResource { @Path("{noteId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveNote(@PathParam("resourceType") final String resourceType, @PathParam("resourceId") final Long resourceId, - @PathParam("noteId") final Long noteId, @Context final UriInfo uriInfo) { + @ApiOperation(value = "Retrieve a Resource Note", httpMethod = "GET", notes = "Retrieves a Resource Note\n\n" + "Example Requests:\n" + "\n" + "clients/1/notes/76\n" + "\n" + "\n" + "groups/1/notes/20\n" + "\n" + "\n" + "clients/1/notes/76?fields=note,createdOn,createdByUsername\n" + "\n" + "\n" + "groups/1/notes/20?fields=note,createdOn,createdByUsername") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = NotesApiResourceSwagger.GetResourceTypeResourceIdNotesNoteIdResponse.class)}) + public String retrieveNote(@PathParam("resourceType") @ApiParam(value = "resourceType")final String resourceType, @PathParam("resourceId") @ApiParam(value = "resourceId")final Long resourceId, + @PathParam("noteId") @ApiParam(value = "noteId") final Long noteId, @Context final UriInfo uriInfo) { final NoteType noteType = NoteType.fromApiUrl(resourceType); @@ -121,8 +119,11 @@ public class NotesApiResource { @POST @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String addNewNote(@PathParam("resourceType") final String resourceType, @PathParam("resourceId") final Long resourceId, - final String apiRequestBodyAsJson) { + @ApiOperation(value = "Add a Resource Note", httpMethod = "POST", notes = "Adds a new note to a supported resource.\n\n" + "Example Requests:\n" + "\n" + "clients/1/notes\n" + "\n" + "\n" + "groups/1/notes") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = NotesApiResourceSwagger.PostResourceTypeResourceIdNotesRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = NotesApiResourceSwagger.PostResourceTypeResourceIdNotesResponse.class)}) + public String addNewNote(@PathParam("resourceType") @ApiParam(value = "resourceType")final String resourceType, @PathParam("resourceId") @ApiParam(value = "resourceId")final Long resourceId, + @ApiParam(hidden = true) final String apiRequestBodyAsJson) { final NoteType noteType = NoteType.fromApiUrl(resourceType); @@ -141,8 +142,11 @@ public class NotesApiResource { @Path("{noteId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String updateNote(@PathParam("resourceType") final String resourceType, @PathParam("resourceId") final Long resourceId, - @PathParam("noteId") final Long noteId, final String apiRequestBodyAsJson) { + @ApiOperation(value = "Update a Resource Note", httpMethod = "PUT", notes = "Updates a Resource Note") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = NotesApiResourceSwagger.PutResourceTypeResourceIdNotesNoteIdRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = NotesApiResourceSwagger.PutResourceTypeResourceIdNotesNoteIdResponse.class)}) + public String updateNote(@PathParam("resourceType") @ApiParam(value = "resourceType") final String resourceType, @PathParam("resourceId") @ApiParam(value = "resourceId") final Long resourceId, + @PathParam("noteId") @ApiParam(value = "noteId") final Long noteId, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { final NoteType noteType = NoteType.fromApiUrl(resourceType); @@ -162,8 +166,10 @@ public class NotesApiResource { @Path("{noteId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String deleteNote(@PathParam("resourceType") final String resourceType, @PathParam("resourceId") final Long resourceId, - @PathParam("noteId") final Long noteId) { + @ApiOperation(value = "Delete a Resource Note", httpMethod = "DELETE", notes = "Deletes a Resource Note") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = NotesApiResourceSwagger.DeleteResourceTypeResourceIdNotesNoteIdResponse.class)}) + public String deleteNote(@PathParam("resourceType") @ApiParam(value = "resourceType")final String resourceType, @PathParam("resourceId") @ApiParam(value = "resourceId")final Long resourceId, + @PathParam("noteId") @ApiParam(value = "noteId")final Long noteId) { final NoteType noteType = NoteType.fromApiUrl(resourceType); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/note/api/NotesApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/note/api/NotesApiResourceSwagger.java new file mode 100644 index 000000000..ddc880f67 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/note/api/NotesApiResourceSwagger.java @@ -0,0 +1,157 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.note.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import org.joda.time.DateTime; + +/** + * Created by Chirag Gupta on 12/29/17. + */ +final class NotesApiResourceSwagger { + private NotesApiResourceSwagger() { + } + + @ApiModel(value = "GetResourceTypeResourceIdNotesResponse") + public final static class GetResourceTypeResourceIdNotesResponse { + private GetResourceTypeResourceIdNotesResponse() { + } + + final class GetNotesNoteType { + private GetNotesNoteType() { + } + + @ApiModelProperty(example = "100") + public Integer id; + @ApiModelProperty(example = "noteType.client") + public String code; + @ApiModelProperty(example = "Client note") + public String value; + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "1") + public Integer clientId; + public GetNotesNoteType noteType; + @ApiModelProperty(example = "First note edited") + public String note; + @ApiModelProperty(example = "1") + public Integer createdById; + @ApiModelProperty(example = "mifos") + public String createdByUsername; + @ApiModelProperty(example = "1342498505000") + public DateTime createdOn; + @ApiModelProperty(example = "1") + public Integer updatedById; + @ApiModelProperty(example = "mifos") + public String updatedByUsername; + @ApiModelProperty(example = "1342498517000") + public DateTime updatedOn; + } + + @ApiModel(value = "GetResourceTypeResourceIdNotesNoteIdResponse") + public final static class GetResourceTypeResourceIdNotesNoteIdResponse { + private GetResourceTypeResourceIdNotesNoteIdResponse() { + } + + @ApiModelProperty(example = "76") + public Integer id; + @ApiModelProperty(example = "1") + public Integer clientId; + public GetResourceTypeResourceIdNotesResponse.GetNotesNoteType noteType; + @ApiModelProperty(example = "a note about the client") + public String note; + @ApiModelProperty(example = "1") + public Integer createdById; + @ApiModelProperty(example = "mifos") + public String createdByUsername; + @ApiModelProperty(example = "1359463135000") + public DateTime createdOn; + @ApiModelProperty(example = "1") + public Integer updatedById; + @ApiModelProperty(example = "mifos") + public String updatedByUsername; + @ApiModelProperty(example = "1359463135000") + public DateTime updatedOn; + } + + @ApiModel(value = "PostResourceTypeResourceIdNotesRequest") + public final static class PostResourceTypeResourceIdNotesRequest { + private PostResourceTypeResourceIdNotesRequest() { + } + + @ApiModelProperty(example = "a note about the client") + public String note; + } + + @ApiModel(value = "PostResourceTypeResourceIdNotesResponse") + public final static class PostResourceTypeResourceIdNotesResponse { + private PostResourceTypeResourceIdNotesResponse() { + } + + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "76") + public Integer resourceId; + } + + @ApiModel(value = "PutResourceTypeResourceIdNotesNoteIdRequest") + public final static class PutResourceTypeResourceIdNotesNoteIdRequest { + private PutResourceTypeResourceIdNotesNoteIdRequest() { + } + + @ApiModelProperty(example = "a note about the client") + public String note; + } + + @ApiModel(value = "PutResourceTypeResourceIdNotesNoteIdResponse") + public final static class PutResourceTypeResourceIdNotesNoteIdResponse { + private PutResourceTypeResourceIdNotesNoteIdResponse() { + } + + final class PutNotesChanges { + private PutNotesChanges() { + } + + @ApiModelProperty(example = "a note about the client") + public String note; + } + + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "76") + public Integer resourceId; + public PutNotesChanges changes; + } + + @ApiModel(value = "DeleteResourceTypeResourceIdNotesNoteIdResponse") + public final static class DeleteResourceTypeResourceIdNotesNoteIdResponse { + private DeleteResourceTypeResourceIdNotesNoteIdResponse() { + } + + @ApiModelProperty(example = "76") + public Integer resourceId; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/paymenttype/api/PaymentTypeApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/paymenttype/api/PaymentTypeApiResource.java index ccdcd705b..af5e76446 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/paymenttype/api/PaymentTypeApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/paymenttype/api/PaymentTypeApiResource.java @@ -18,20 +18,7 @@ */ package org.apache.fineract.portfolio.paymenttype.api; -import java.util.Collection; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriInfo; - +import io.swagger.annotations.*; import org.apache.fineract.commands.domain.CommandWrapper; import org.apache.fineract.commands.service.CommandWrapperBuilder; import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService; @@ -46,8 +33,15 @@ import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadPlatform import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; +import java.util.Collection; + @Path("/paymenttypes") @Component +@Api(value = "Payment Type", description = "This defines the payment type") public class PaymentTypeApiResource { private final PlatformSecurityContext securityContext; @@ -77,6 +71,8 @@ public class PaymentTypeApiResource { @GET @Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON }) @Produces(MediaType.APPLICATION_JSON) + @ApiOperation(value = "Retrieve all Payment Types", httpMethod = "GET", notes = "Retrieve list of payment types") + @ApiResponses({@ApiResponse(code = 200, message = "OK", responseContainer = "List", response = PaymentTypeApiResourceSwagger.GetPaymentTypesResponse.class)}) public String getAllPaymentTypes(@Context final UriInfo uriInfo) { this.securityContext.authenticatedUser().validateHasReadPermission(PaymentTypeApiResourceConstants.resourceNameForPermissions); final Collection paymentTypes = this.readPlatformService.retrieveAllPaymentTypes(); @@ -88,7 +84,9 @@ public class PaymentTypeApiResource { @Path("{paymentTypeId}") @Consumes({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON }) @Produces(MediaType.APPLICATION_JSON) - public String retrieveOnePaymentType(@PathParam("paymentTypeId") final Long paymentTypeId, @Context final UriInfo uriInfo) { + @ApiOperation(value = "Retrieve a Payment Type", httpMethod = "GET", notes = "Retrieves a payment type") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = PaymentTypeApiResourceSwagger.GetPaymentTypesPaymentTypeIdResponse.class)}) + public String retrieveOnePaymentType(@PathParam("paymentTypeId") @ApiParam(value = "paymentTypeId") final Long paymentTypeId, @Context final UriInfo uriInfo) { this.securityContext.authenticatedUser().validateHasReadPermission(PaymentTypeApiResourceConstants.resourceNameForPermissions); this.paymentTypeRepositoryWrapper.findOneWithNotFoundDetection(paymentTypeId); final PaymentTypeData paymentTypes = this.readPlatformService.retrieveOne(paymentTypeId); @@ -99,7 +97,10 @@ public class PaymentTypeApiResource { @POST @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String createPaymentType(final String apiRequestBodyAsJson) { + @ApiOperation(value = "Create a Payment Type", httpMethod = "POST", notes = "Creates a new Payment type\n\n" + "Mandatory Fields: name\n\n" + "Optional Fields: Description, isCashPayment,Position") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = PaymentTypeApiResourceSwagger.PostPaymentTypesRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = PaymentTypeApiResourceSwagger.PostPaymentTypesResponse.class)}) + public String createPaymentType(@ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder().createPaymentType().withJson(apiRequestBodyAsJson).build(); @@ -112,7 +113,10 @@ public class PaymentTypeApiResource { @Path("{paymentTypeId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String updatePaymentType(@PathParam("paymentTypeId") final Long paymentTypeId, final String apiRequestBodyAsJson) { + @ApiOperation(value = "Update a Payment Type", httpMethod = "PUT", notes = "Updates a Payment Type") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = PaymentTypeApiResourceSwagger.PutPaymentTypesPaymentTypeIdRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = PaymentTypeApiResourceSwagger.PutPaymentTypesPaymentTypeIdResponse.class)}) + public String updatePaymentType(@PathParam("paymentTypeId") @ApiParam(value = "paymentTypeId") final Long paymentTypeId, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder().updatePaymentType(paymentTypeId).withJson(apiRequestBodyAsJson) .build(); @@ -126,7 +130,9 @@ public class PaymentTypeApiResource { @Path("{paymentTypeId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String deleteCode(@PathParam("paymentTypeId") final Long paymentTypeId) { + @ApiOperation(value = "Delete a Payment Type", httpMethod = "DELETE", notes = "Deletes payment type") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = PaymentTypeApiResourceSwagger.DeletePaymentTypesPaymentTypeIdResponse.class)}) + public String deleteCode(@PathParam("paymentTypeId") @ApiParam(value = "paymentTypeId") final Long paymentTypeId) { final CommandWrapper commandRequest = new CommandWrapperBuilder().deletePaymentType(paymentTypeId).build(); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/paymenttype/api/PaymentTypeApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/paymenttype/api/PaymentTypeApiResourceSwagger.java new file mode 100644 index 000000000..71ba65345 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/paymenttype/api/PaymentTypeApiResourceSwagger.java @@ -0,0 +1,121 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.paymenttype.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +/** + * Created by Chirag Gupta on 01/01/18. + */ +final class PaymentTypeApiResourceSwagger { + private PaymentTypeApiResourceSwagger() { + } + + @ApiModel(value = "GetPaymentTypesResponse") + public final static class GetPaymentTypesResponse { + private GetPaymentTypesResponse() { + } + + @ApiModelProperty(example = "24") + public Integer id; + @ApiModelProperty(example = "PTC") + public String name; + @ApiModelProperty(example = "Cash") + public String description; + @ApiModelProperty(example = "true") + public Boolean isCashPayment; + @ApiModelProperty(example = "0") + public Integer position; + } + + @ApiModel(value = "GetPaymentTypesPaymentTypeIdResponse") + public final static class GetPaymentTypesPaymentTypeIdResponse { + private GetPaymentTypesPaymentTypeIdResponse() { + } + + @ApiModelProperty(example = "13") + public Integer id; + @ApiModelProperty(example = "cash") + public String name; + @ApiModelProperty(example = "cash Payment") + public String description; + @ApiModelProperty(example = "true") + public Boolean isCashPayment; + @ApiModelProperty(example = "1") + public Integer position; + } + + @ApiModel(value = "PostPaymentTypesRequest") + public final static class PostPaymentTypesRequest { + private PostPaymentTypesRequest() { + } + + @ApiModelProperty(example = "cash") + public String name; + @ApiModelProperty(example = "cash payment type") + public String description; + @ApiModelProperty(example = "true") + public Boolean isCashPayment; + @ApiModelProperty(example = "1") + public Integer position; + } + + @ApiModel(value = "PostPaymentTypesResponse") + public final static class PostPaymentTypesResponse { + private PostPaymentTypesResponse() { + } + + @ApiModelProperty(example = "1") + public Integer resourceId; + } + + @ApiModel(value = "PutPaymentTypesPaymentTypeIdRequest") + public final static class PutPaymentTypesPaymentTypeIdRequest { + private PutPaymentTypesPaymentTypeIdRequest() { + } + + @ApiModelProperty(example = "mPay") + public String name; + @ApiModelProperty(example = "not a cash payment type") + public String description; + @ApiModelProperty(example = "false") + public Boolean isCashPayment; + @ApiModelProperty(example = "3") + public Integer position; + } + + @ApiModel(value = "PutPaymentTypesPaymentTypeIdResponse") + public final static class PutPaymentTypesPaymentTypeIdResponse { + private PutPaymentTypesPaymentTypeIdResponse() { + } + + @ApiModelProperty(example = "13") + public Integer resourceId; + } + + @ApiModel(value = "DeletePaymentTypesPaymentTypeIdResponse") + public final static class DeletePaymentTypesPaymentTypeIdResponse { + private DeletePaymentTypesPaymentTypeIdResponse() { + } + + @ApiModelProperty(example = "13") + public Integer resourceId; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/products/api/ProductsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/products/api/ProductsApiResource.java index a94a1467b..62804507e 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/products/api/ProductsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/products/api/ProductsApiResource.java @@ -18,18 +18,7 @@ */ package org.apache.fineract.portfolio.products.api; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriInfo; - +import io.swagger.annotations.*; import org.apache.fineract.commands.domain.CommandWrapper; import org.apache.fineract.commands.service.CommandWrapperBuilder; import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService; @@ -49,9 +38,15 @@ import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; + @Path("/products/{type}") @Component @Scope("singleton") +@Api(value = "Products", description = "") public class ProductsApiResource { private final ApplicationContext applicationContext; @@ -75,7 +70,7 @@ public class ProductsApiResource { @Path("template") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveTemplate(@PathParam("type") final String productType, @Context final UriInfo uriInfo) { + public String retrieveTemplate(@PathParam("type") @ApiParam(value = "type") final String productType, @Context final UriInfo uriInfo) { String serviceName = productType + ProductsApiConstants.READPLATFORM_NAME; try { ProductReadPlatformService service = (ProductReadPlatformService) this.applicationContext.getBean(serviceName); @@ -91,7 +86,9 @@ public class ProductsApiResource { @Path("{productId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveProduct(@PathParam("productId") final Long productId, @PathParam("type") final String productType, + @ApiOperation(value = "Retrieve a Share Product", httpMethod = "GET", notes = "Retrieves a Share Product\n\n" + "Example Requests:\n" + "\n" + "products/share/1\n" + "\n" + "\n" + "products/share/1?template=true") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ProductsApiResourceSwagger.GetProductsTypeProductIdResponse.class)}) + public String retrieveProduct(@PathParam("productId") @ApiParam(value = "productId") final Long productId, @PathParam("type") @ApiParam(value = "type") final String productType, @Context final UriInfo uriInfo) { try { String serviceName = productType + ProductsApiConstants.READPLATFORM_NAME; @@ -107,7 +104,9 @@ public class ProductsApiResource { @GET @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveAllProducts(@PathParam("type") final String productType, @QueryParam("offset") final Integer offset, @QueryParam("limit") final Integer limit, + @ApiOperation(value = "List Share Products", httpMethod = "GET", notes = "Lists Share Products\n\n" + "Mandatory Fields: limit, offset\n\n" + "Example Requests:\n" + "\n" + "shareproducts") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ProductsApiResourceSwagger.GetProductsTypeResponse.class)}) + public String retrieveAllProducts(@PathParam("type") @ApiParam(value = "type") final String productType, @QueryParam("offset") @ApiParam(value = "offset") final Integer offset, @QueryParam("limit") @ApiParam(value = "limit") final Integer limit, @Context final UriInfo uriInfo) { try { String serviceName = productType + ProductsApiConstants.READPLATFORM_NAME; @@ -123,7 +122,10 @@ public class ProductsApiResource { @POST @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String createProduct(@PathParam("type") final String productType, final String apiRequestBodyAsJson) { + @ApiOperation(value = "Create a Share Product", httpMethod = "POST", notes = "Creates a Share Product\n\n" + "Mandatory Fields: name, shortName, description, currencyCode, digitsAfterDecimal,inMultiplesOf, locale, totalShares, unitPrice, nominalShares,allowDividendCalculationForInactiveClients,accountingRule\n\n" + "Mandatory Fields for Cash based accounting (accountingRule = 2): shareReferenceId, shareSuspenseId, shareEquityId, incomeFromFeeAccountId\n\n" + "Optional Fields: sharesIssued, minimumShares, maximumShares, minimumActivePeriodForDividends, minimumactiveperiodFrequencyType, lockinPeriodFrequency, lockinPeriodFrequencyType, marketPricePeriods, chargesSelected") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = ProductsApiResourceSwagger.PostProductsTypeRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ProductsApiResourceSwagger.PostProductsTypeResponse.class)}) + public String createProduct(@PathParam("type") @ApiParam(value = "type") final String productType, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { CommandWrapper commandWrapper = null; this.platformSecurityContext.authenticatedUser(); commandWrapper = new CommandWrapperBuilder().createProduct(productType).withJson(apiRequestBodyAsJson).build(); @@ -135,8 +137,8 @@ public class ProductsApiResource { @Path("{productId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String handleCommands(@PathParam("type") final String productType, @PathParam("productId") final Long productId, - @QueryParam("command") final String commandParam, @SuppressWarnings("unused") @Context final UriInfo uriInfo, final String apiRequestBodyAsJson) { + public String handleCommands(@PathParam("type") @ApiParam(value = "type") final String productType, @PathParam("productId") @ApiParam(value = "productId") final Long productId, + @QueryParam("command") @ApiParam(value = "command") final String commandParam, @SuppressWarnings("unused") @Context final UriInfo uriInfo, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { CommandWrapper commandWrapper = new CommandWrapperBuilder().createProductCommand(productType, commandParam, productId) .withJson(apiRequestBodyAsJson).build(); final CommandProcessingResult commandProcessingResult = this.commandsSourceWritePlatformService.logCommandSource(commandWrapper); @@ -147,8 +149,11 @@ public class ProductsApiResource { @Path("{productId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String updateProduct(@PathParam("type") final String productType, @PathParam("productId") final Long productId, - final String apiRequestBodyAsJson) { + @ApiOperation(value = "Update a Share Product", httpMethod = "PUT", notes = "Updates a Share Product") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = ProductsApiResourceSwagger.PutProductsTypeProductIdRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ProductsApiResourceSwagger.PutProductsTypeProductIdResponse.class)}) + public String updateProduct(@PathParam("type") @ApiParam(value = "type")final String productType, @PathParam("productId") @ApiParam(value = "productId")final Long productId, + @ApiParam(hidden = true) final String apiRequestBodyAsJson) { this.platformSecurityContext.authenticatedUser(); final CommandWrapper commandRequest = new CommandWrapperBuilder().updateProduct(productType, productId) .withJson(apiRequestBodyAsJson).build(); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/products/api/ProductsApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/products/api/ProductsApiResourceSwagger.java new file mode 100644 index 000000000..6d833a3a4 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/products/api/ProductsApiResourceSwagger.java @@ -0,0 +1,597 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.products.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Set; + +/** + * Created by Chirag Gupta on 01/01/18. + */ +final class ProductsApiResourceSwagger { + private ProductsApiResourceSwagger() { + } + + @ApiModel(value = "GetProductsTypeProductIdResponse") + public final static class GetProductsTypeProductIdResponse { + private GetProductsTypeProductIdResponse() { + } + + final class GetProductsCurrency { + private GetProductsCurrency() { + } + + @ApiModelProperty(example = "USD") + public String code; + @ApiModelProperty(example = "US Dollar") + public String name; + @ApiModelProperty(example = "2") + public Integer decimalPlaces; + @ApiModelProperty(example = "100") + public Integer inMultiplesOf; + @ApiModelProperty(example = "$") + public String displaySymbol; + @ApiModelProperty(example = "currency.USD") + public String nameCode; + @ApiModelProperty(example = "US Dollar ($)") + public String displayLabel; + } + + final class GetProductsMarketPrice { + private GetProductsMarketPrice() { + } + + @ApiModelProperty(example = "4") + public Integer id; + @ApiModelProperty(example = "Feb 1, 2016") + public String fromDate; + @ApiModelProperty(example = "1") + public Integer shareValue; + } + + final class GetProductsCharges { + private GetProductsCharges() { + } + + final class GetChargesCurrency { + private GetChargesCurrency() { + } + + @ApiModelProperty(example = "USD") + public String code; + @ApiModelProperty(example = "US Dollar") + public String name; + @ApiModelProperty(example = "2") + public Integer decimalPlaces; + @ApiModelProperty(example = "$") + public String displaySymbol; + @ApiModelProperty(example = "currency.USD") + public String nameCode; + @ApiModelProperty(example = "US Dollar ($)") + public String displayLabel; + } + + final class GetChargeTimeType { + private GetChargeTimeType() { + } + + @ApiModelProperty(example = "13") + public Integer id; + @ApiModelProperty(example = "chargeTimeType.activation") + public String code; + @ApiModelProperty(example = "Share Account Activate") + public String value; + } + + final class GetChargeAppliesTo { + private GetChargeAppliesTo() { + } + + @ApiModelProperty(example = "4") + public Integer id; + @ApiModelProperty(example = "chargeAppliesTo.shares") + public String code; + @ApiModelProperty(example = "Shares") + public String value; + } + + final class GetChargeCalculationType { + private GetChargeCalculationType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "chargeCalculationType.flat") + public String code; + @ApiModelProperty(example = "Flat") + public String value; + } + + final class GetChargePaymentMode { + private GetChargePaymentMode() { + } + + @ApiModelProperty(example = "0") + public Integer id; + @ApiModelProperty(example = "chargepaymentmode.regular") + public String code; + @ApiModelProperty(example = "Regular") + public String value; + } + + @ApiModelProperty(example = "20") + public Integer id; + @ApiModelProperty(example = "Share Account Activation Flat") + public String name; + @ApiModelProperty(example = "true") + public Boolean active; + @ApiModelProperty(example = "false") + public Boolean penalty; + public GetChargesCurrency currency; + @ApiModelProperty(example = "1") + public Integer amount; + public GetChargeTimeType chargeTimeType; + public GetChargeAppliesTo chargeAppliesTo; + public GetChargeCalculationType chargeCalculationType; + public GetChargePaymentMode chargePaymentMode; + } + + final class GetLockPeriodTypeEnum { + private GetLockPeriodTypeEnum() { + } + + @ApiModelProperty(example = "0") + public Integer id; + @ApiModelProperty(example = "Days") + public String value; + } + + final class GetProductsAccountingRule { + private GetProductsAccountingRule() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "accountingRuleType.cash") + public String code; + @ApiModelProperty(example = "CASH BASED") + public String value; + } + + final class GetProductsAccountingMappings { + private GetProductsAccountingMappings() { + } + + final class GetShareReferenceId { + private GetShareReferenceId() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "ACCOUNT_NAME_1FJBQ") + public String name; + @ApiModelProperty(example = "ASSET_ED1461237837829") + public String glCode; + } + + final class GetIncomeFromFeeAccountId { + private GetIncomeFromFeeAccountId() { + } + + @ApiModelProperty(example = "14") + public Integer id; + @ApiModelProperty(example = "ACCOUNT_NAME_1FJBQ") + public String name; + @ApiModelProperty(example = "INCOME_OY1461237869836") + public String glCode; + } + + final class GetShareEquityId { + private GetShareEquityId() { + } + + @ApiModelProperty(example = "66") + public Integer id; + @ApiModelProperty(example = "Equity Account") + public String name; + @ApiModelProperty(example = "EQUITY1") + public String glCode; + } + + final class GetShareSuspenseId { + private GetShareSuspenseId() { + } + + @ApiModelProperty(example = "8") + public Integer id; + @ApiModelProperty(example = "ACCOUNT_NAME_1FJBQ") + public String name; + @ApiModelProperty(example = "LIABILITY_MA1461237860198") + public String glCode; + } + + public GetShareReferenceId shareReferenceId; + public GetIncomeFromFeeAccountId incomeFromFeeAccountId; + public GetShareEquityId shareEquityId; + public GetShareSuspenseId shareSuspenseId; + } + + final class GetProductsMinimumActivePeriodFrequencyTypeOptions { + private GetProductsMinimumActivePeriodFrequencyTypeOptions() { + } + + @ApiModelProperty(example = "0") + public Integer id; + @ApiModelProperty(example = "savings.lockin.sharePeriodFrequencyType.days") + public String code; + @ApiModelProperty(example = "Days") + public String value; + } + + final class GetProductsAccountingMappingOptions { + private GetProductsAccountingMappingOptions() { + } + + final class GetProductsLiabilityAccountOptions { + private GetProductsLiabilityAccountOptions() { + } + + final class GetProductsLiabilityType { + private GetProductsLiabilityType() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "accountType.liability") + public String code; + @ApiModelProperty(example = "LIABILITY") + public String value; + } + + final class GetProductsLiabilityUsage { + private GetProductsLiabilityUsage() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "accountUsage.detail") + public String code; + @ApiModelProperty(example = "DETAIL") + public String value; + } + + final class GetProductsTagId { + private GetProductsTagId() { + } + + @ApiModelProperty(example = "0") + public Integer id; + @ApiModelProperty(example = "false") + public Boolean isActive; + } + + @ApiModelProperty(example = "4") + public Integer id; + @ApiModelProperty(example = "ACCOUNT_NAME_1FJBQ") + public String name; + @ApiModelProperty(example = "LIABILITY_2T1461237838897") + public String glCode; + @ApiModelProperty(example = "false") + public Boolean disabled; + @ApiModelProperty(example = "true") + public Boolean manualEntriesAllowed; + public GetProductsLiabilityType type; + public GetProductsLiabilityUsage usage; + @ApiModelProperty(example = "DEFAULT_DESCRIPTION") + public String description; + @ApiModelProperty(example = "ACCOUNT_NAME_1FJBQ") + public String nameDecorated; + public GetProductsTagId tagId; + } + + final class GetProductsAssetAccountOptions { + private GetProductsAssetAccountOptions() { + } + + final class GetAssetType { + private GetAssetType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "accountType.asset") + public String code; + @ApiModelProperty(example = "ASSET") + public String value; + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "ACCOUNT_NAME_1FJBQ") + public String name; + @ApiModelProperty(example = "ASSET_ED1461237837829") + public String glCode; + @ApiModelProperty(example = "false") + public Boolean disabled; + @ApiModelProperty(example = "true") + public Boolean manualEntriesAllowed; + public GetAssetType type; + public GetProductsLiabilityAccountOptions.GetProductsLiabilityUsage usage; + @ApiModelProperty(example = "DEFAULT_DESCRIPTION") + public String description; + @ApiModelProperty(example = "ACCOUNT_NAME_1FJBQ") + public String nameDecorated; + public GetProductsLiabilityAccountOptions.GetProductsTagId tagId; + } + + final class GetProductsIncomeAccountOptions { + private GetProductsIncomeAccountOptions() { + } + + final class GetIncomeType { + private GetIncomeType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "accountType.income") + public String code; + @ApiModelProperty(example = "INCOME") + public String value; + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "ACCOUNT_NAME_1FJBQ") + public String name; + @ApiModelProperty(example = "INCOME_9O1461237838422") + public String glCode; + @ApiModelProperty(example = "false") + public Boolean disabled; + @ApiModelProperty(example = "true") + public Boolean manualEntriesAllowed; + public GetIncomeType type; + public GetProductsLiabilityAccountOptions.GetProductsLiabilityUsage usage; + @ApiModelProperty(example = "DEFAULT_DESCRIPTION") + public String description; + @ApiModelProperty(example = "ACCOUNT_NAME_1FJBQ") + public String nameDecorated; + public GetProductsLiabilityAccountOptions.GetProductsTagId tagId; + } + + final class GetProductsEquityAccountOptions { + private GetProductsEquityAccountOptions() { + } + + final class GetEquityType { + private GetEquityType() { + } + + @ApiModelProperty(example = "3") + public Integer id; + @ApiModelProperty(example = "accountType.equity") + public String code; + @ApiModelProperty(example = "EQUITY") + public String value; + } + + @ApiModelProperty(example = "66") + public Integer id; + @ApiModelProperty(example = "Equity Account") + public String name; + @ApiModelProperty(example = "EQUITY1") + public String glCode; + @ApiModelProperty(example = "false") + public Boolean disabled; + @ApiModelProperty(example = "true") + public Boolean manualEntriesAllowed; + public GetEquityType type; + public GetProductsLiabilityAccountOptions.GetProductsLiabilityUsage usage; + @ApiModelProperty(example = "Equity Account") + public String nameDecorated; + public GetProductsLiabilityAccountOptions.GetProductsTagId tagId; + } + + public Set liabilityAccountOptions; + public Set assetAccountOptions; + public Set incomeAccountOptions; + public Set equityAccountOptions; + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "Share Product") + public String name; + @ApiModelProperty(example = "SP") + public String shortName; + @ApiModelProperty(example = "SP") + public String description; + public GetProductsCurrency currency; + @ApiModelProperty(example = "100") + public Integer totalShares; + @ApiModelProperty(example = "50") + public Integer totalSharesIssued; + @ApiModelProperty(example = "1") + public Integer unitPrice; + @ApiModelProperty(example = "50") + public Integer shareCapital; + @ApiModelProperty(example = "1") + public Integer minimumShares; + @ApiModelProperty(example = "10") + public Integer nominalShares; + @ApiModelProperty(example = "50") + public Integer maximumShares; + public Set marketPrice; + public Set charges; + @ApiModelProperty(example = "true") + public Boolean allowDividendCalculationForInactiveClients; + @ApiModelProperty(example = "1") + public Integer lockinPeriod; + public GetLockPeriodTypeEnum lockPeriodTypeEnum; + @ApiModelProperty(example = "1") + public Integer minimumActivePeriod; + public GetLockPeriodTypeEnum minimumActivePeriodForDividendsTypeEnum; + public GetProductsAccountingRule accountingRule; + public GetProductsAccountingMappings accountingMappings; + public Set currencyOptions; + public Set chargeOptions; + public Set minimumActivePeriodFrequencyTypeOptions; + public Set lockinPeriodFrequencyTypeOptions; + public GetProductsAccountingMappingOptions accountingMappingOptions; + } + + @ApiModel(value = "GetProductsTypeResponse") + public static final class GetProductsTypeResponse { + private GetProductsTypeResponse() { + } + + final class GetProductsPageItems { + private GetProductsPageItems() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "Share Product") + public String name; + @ApiModelProperty(example = "Share Product Description") + public String shortName; + @ApiModelProperty(example = "100") + public Integer totalShares; + } + + @ApiModelProperty(example = "1") + public Integer totalFilteredRecords; + public Set pageItems; + } + + @ApiModel(value = "PostProductsTypeRequest") + public final static class PostProductsTypeRequest { + private PostProductsTypeRequest() { + } + + final class PostProductsMarketPricePeriods { + private PostProductsMarketPricePeriods() { + } + + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "dd MMMM yyyy") + public String dateFormat; + @ApiModelProperty(example = "04 May 2016") + public String fromDate; + @ApiModelProperty(example = "2") + public Integer shareValue; + } + + final class PostProductsChargesSelected { + private PostProductsChargesSelected() { + } + + @ApiModelProperty(example = "20") + public Integer id; + } + + @ApiModelProperty(example = "Share Product") + public String name; + @ApiModelProperty(example = "SP") + public String shortName; + @ApiModelProperty(example = "Description") + public String description; + @ApiModelProperty(example = "USD") + public String currencyCode; + @ApiModelProperty(example = "2") + public Integer digitsAfterDecimal; + @ApiModelProperty(example = "1") + public Integer inMultiplesOf; + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "1000") + public Integer totalShares; + @ApiModelProperty(example = "1000") + public Integer sharesIssued; + @ApiModelProperty(example = "1") + public Integer unitPrice; + @ApiModelProperty(example = "10") + public Integer minimumShares; + @ApiModelProperty(example = "20") + public Integer nominalShares; + @ApiModelProperty(example = "30") + public Integer maximumShares; + @ApiModelProperty(example = "1") + public Integer minimumActivePeriodForDividends; + @ApiModelProperty(example = "0") + public Integer minimumactiveperiodFrequencyType; + @ApiModelProperty(example = "1") + public Integer lockinPeriodFrequency; + @ApiModelProperty(example = "1") + public Integer lockinPeriodFrequencyType; + @ApiModelProperty(example = "true") + public Boolean allowDividendCalculationForInactiveClients; + public Set marketPricePeriods; + public Set chargesSelected; + @ApiModelProperty(example = "1") + public Integer accountingRule; + } + + @ApiModel(value = "PostProductsTypeResponse") + public final static class PostProductsTypeResponse { + private PostProductsTypeResponse() { + } + + @ApiModelProperty(example = "1") + public Integer resourceId; + } + + @ApiModel(value = "PutProductsTypeProductIdRequest") + public final static class PutProductsTypeProductIdRequest { + private PutProductsTypeProductIdRequest() { + } + + @ApiModelProperty(example = "Share Product Description.") + public String description; + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "5.0") + public Double unitPrice; + } + + @ApiModel(value = "PutProductsTypeProductIdResponse") + public final static class PutProductsTypeProductIdResponse { + private PutProductsTypeProductIdResponse() { + } + + final class PutProductsChanges { + private PutProductsChanges() { + } + + @ApiModelProperty(example = "Share Product Description.") + public String description; + @ApiModelProperty(example = "5.0") + public Double unitPrice; + @ApiModelProperty(example = "en") + public String locale; + } + + @ApiModelProperty(example = "1") + public Integer resourceId; + public PutProductsChanges changes; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/FixedDepositAccountsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/FixedDepositAccountsApiResource.java index 49cba4fe5..48eeb6b42 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/FixedDepositAccountsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/FixedDepositAccountsApiResource.java @@ -18,26 +18,8 @@ */ package org.apache.fineract.portfolio.savings.api; -import java.math.BigDecimal; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriInfo; - +import com.google.gson.JsonElement; +import io.swagger.annotations.*; import org.apache.commons.lang.StringUtils; import org.apache.fineract.commands.domain.CommandWrapper; import org.apache.fineract.commands.service.CommandWrapperBuilder; @@ -70,11 +52,20 @@ import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; -import com.google.gson.JsonElement; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; +import java.math.BigDecimal; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; @Path("/fixeddepositaccounts") @Component @Scope("singleton") +@Api(value = "Fixed Deposit Account", description = "Fixed Deposit accounts are instances of a praticular fixed deposit product created. An application process around the creation of accounts is also supported.") public class FixedDepositAccountsApiResource { private final DepositAccountReadPlatformService depositAccountReadPlatformService; @@ -110,10 +101,12 @@ public class FixedDepositAccountsApiResource { @Path("template") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String template(@QueryParam("clientId") final Long clientId, @QueryParam("groupId") final Long groupId, - @QueryParam("productId") final Long productId, - @DefaultValue("false") @QueryParam("staffInSelectedOfficeOnly") final boolean staffInSelectedOfficeOnly, - @Context final UriInfo uriInfo) { + @ApiOperation(value = "Retrieve Fixed Deposit Account Template", httpMethod = "GET", notes = "This is a convenience resource. It can be useful when building maintenance user interface screens for fixed deposit applications. The template data returned consists of any or all of:\n\n" + "\n\n" + "Field Defaults\n\n" + "Allowed Value Lists" + "Example Requests:\n\n" + "\n\n" + "fixeddepositaccounts/template?clientId=1") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = FixedDepositAccountsApiResourceSwagger.GetFixedDepositAccountsTemplateResponse.class)}) + public String template(@QueryParam("clientId") @ApiParam(value = "clientId") final Long clientId, @QueryParam("groupId") @ApiParam(value = "groupId") final Long groupId, + @QueryParam("productId")@ApiParam(value = "productId") final Long productId, + @DefaultValue("false") @QueryParam("staffInSelectedOfficeOnly") @ApiParam(value = "staffInSelectedOfficeOnly") final boolean staffInSelectedOfficeOnly, + @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(DepositsApiConstants.FIXED_DEPOSIT_ACCOUNT_RESOURCE_NAME); @@ -127,9 +120,11 @@ public class FixedDepositAccountsApiResource { @GET @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveAll(@Context final UriInfo uriInfo, @QueryParam("paged") final Boolean paged, - @QueryParam("offset") final Integer offset, @QueryParam("limit") final Integer limit, - @QueryParam("orderBy") final String orderBy, @QueryParam("sortOrder") final String sortOrder) { + @ApiOperation(value = "List Fixed deposit applications/accounts", httpMethod = "GET", notes = "Lists Fixed Deposit Accounts\n\n" + "Example Requests:\n\n" + "\n\n" + "fixeddepositaccounts\n\n" + "\n\n" + "fixeddepositaccounts?fields=name") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = FixedDepositAccountsApiResourceSwagger.GetFixedDepositAccountsResponse.class, responseContainer = "List")}) + public String retrieveAll(@Context final UriInfo uriInfo, @QueryParam("paged") @ApiParam(value = "paged") final Boolean paged, + @QueryParam("offset") @ApiParam(value = "offset") final Integer offset, @QueryParam("limit") @ApiParam(value = "limit") final Integer limit, + @QueryParam("orderBy") @ApiParam(value = "orderBy") final String orderBy, @QueryParam("sortOrder") @ApiParam(value = "sortOrder") final String sortOrder) { this.context.authenticatedUser().validateHasReadPermission(DepositsApiConstants.FIXED_DEPOSIT_ACCOUNT_RESOURCE_NAME); final PaginationParameters paginationParameters = PaginationParameters.instance(paged, offset, limit, orderBy, sortOrder); @@ -151,7 +146,10 @@ public class FixedDepositAccountsApiResource { @POST @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String submitApplication(final String apiRequestBodyAsJson) { + @ApiOperation(value = "Submit new fixed deposit application", httpMethod = "POST", notes = "Submits a new fixed deposit application"+"Mandatory Fields: clientId or groupId, productId, submittedOnDate, depositAmount, depositPeriod, depositPeriodFrequencyId\n\n" + "Optional Fields: accountNo, externalId, fieldOfficerId,linkAccountId(if provided initial deposit amount will be collected from this account),transferInterestToSavings(By enabling this flag all interest postings will be transferred to linked saving account )") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = FixedDepositAccountsApiResourceSwagger.PostFixedDepositAccountsRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = FixedDepositAccountsApiResourceSwagger.PostFixedDepositAccountsResponse.class)}) + public String submitApplication(@ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder().createFixedDepositAccount().withJson(apiRequestBodyAsJson) .build(); @@ -165,9 +163,11 @@ public class FixedDepositAccountsApiResource { @Path("{accountId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveOne(@PathParam("accountId") final Long accountId, - @DefaultValue("false") @QueryParam("staffInSelectedOfficeOnly") final boolean staffInSelectedOfficeOnly, - @DefaultValue("all") @QueryParam("chargeStatus") final String chargeStatus, @Context final UriInfo uriInfo) { + @ApiOperation(value = "Retrieve a fixed deposit application/account", httpMethod = "GET", notes = "Retrieves a fixed deposit application/account\n\n" + "Example Requests :\n\n" + "\n\n" + "fixeddepositaccounts/1" + "\n\n" + "fixeddepositaccounts/1?associations=all" ) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = FixedDepositAccountsApiResourceSwagger.GetFixedDepositAccountsAccountIdResponse.class)}) + public String retrieveOne(@PathParam("accountId") @ApiParam(value = "accountId") final Long accountId, + @DefaultValue("false") @QueryParam("staffInSelectedOfficeOnly") @ApiParam(value = "staffInSelectedOfficeOnly") final boolean staffInSelectedOfficeOnly, + @DefaultValue("all") @QueryParam("chargeStatus")@ApiParam(value = "chargeStatus") final String chargeStatus, @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(DepositsApiConstants.FIXED_DEPOSIT_ACCOUNT_RESOURCE_NAME); @@ -254,7 +254,10 @@ public class FixedDepositAccountsApiResource { @Path("{accountId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String update(@PathParam("accountId") final Long accountId, final String apiRequestBodyAsJson) { + @ApiOperation(value = "Modify a fixed deposit application", httpMethod = "PUT", notes = "Fixed deposit application can only be modified when in 'Submitted and pending approval' state. Once the application is approved, the details cannot be changed using this method. Specific api endpoints will be created to allow change of interest detail such as rate, compounding period, posting period etc") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = FixedDepositAccountsApiResourceSwagger.PutFixedDepositAccountsAccountIdRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = FixedDepositAccountsApiResourceSwagger.PutFixedDepositAccountsAccountIdResponse.class)}) + public String update(@PathParam("accountId") @ApiParam(value = "accountId") final Long accountId, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder().updateFixedDepositAccount(accountId) .withJson(apiRequestBodyAsJson).build(); @@ -268,8 +271,11 @@ public class FixedDepositAccountsApiResource { @Path("{accountId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String handleCommands(@PathParam("accountId") final Long accountId, @QueryParam("command") final String commandParam, - @Context final UriInfo uriInfo, final String apiRequestBodyAsJson) { + @ApiOperation(value = "Approve fixed deposit application | Undo approval fixed deposit application | Reject fixed deposit application | Withdraw fixed deposit application | Activate a fixed deposit account | Close a fixed deposit account | Premature Close a fixed deposit account | Calculate Premature amount on Fixed deposit account | Calculate Interest on Fixed Deposit Account | Post Interest on Fixed Deposit Account", httpMethod = "POST", notes = "Approve fixed deposit application:\n\n" + "Approves fixed deposit application so long as its in 'Submitted and pending approval' state.\n\n" + "Undo approval fixed deposit application:\n\n" + "Will move 'approved' fixed deposit application back to 'Submitted and pending approval' state.\n\n" + "Reject fixed deposit application:\n\n" + "Rejects fixed deposit application so long as its in 'Submitted and pending approval' state.\n\n" + "Withdraw fixed deposit application:\n\n" + "Used when an applicant withdraws from the fixed deposit application. It must be in 'Submitted and pending approval' state.\n\n" + "Close a fixed deposit account:\n\n" + "Results in a Matured fixed deposit account being converted into a 'closed' fixed deposit account.\n\n" + "Premature Close a fixed deposit account:\n\n" + "Results in an Active fixed deposit account being converted into a 'Premature Closed' fixed deposit account with options to withdraw prematured amount. (premature amount is calculated using interest rate chart applicable along with penal interest if any.)\n\n" + "Calculate Premature amount on Fixed deposit account:\n\n" + "Calculate premature amount on fixed deposit account till premature close date. Premature amount is calculated based on interest chart and penal interest applicable.\n\n" + "Calculate Interest on Fixed Deposit Account:\n\n" + "Calculates interest earned on a fixed deposit account based on todays date. It does not attempt to post or credit the interest on the account. That is responsibility of the Post Interest API that will likely be called by overnight process.\n\n" + "Post Interest on Fixed Deposit Account:\n\n" + "Calculates and Posts interest earned on a fixed deposit account based on today's date and whether an interest posting or crediting event is due.\n\n" + "Showing request/response for Calculate Interest on Fixed Deposit Account") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = FixedDepositAccountsApiResourceSwagger.PostFixedDepositAccountsAccountIdRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = FixedDepositAccountsApiResourceSwagger.PostFixedDepositAccountsAccountIdResponse.class)}) + public String handleCommands(@PathParam("accountId") @ApiParam(value = "accountId") final Long accountId, @QueryParam("command") @ApiParam(value = "command") final String commandParam, + @Context final UriInfo uriInfo, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { String jsonApiRequest = apiRequestBodyAsJson; if (StringUtils.isBlank(jsonApiRequest)) { @@ -331,7 +337,9 @@ public class FixedDepositAccountsApiResource { @Path("{accountId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String delete(@PathParam("accountId") final Long accountId) { + @ApiOperation(value = "Delete a fixed deposit application", httpMethod = "DELETE", notes = "At present we support hard delete of fixed deposit application so long as its in 'Submitted and pending approval' state. One the application is moves past this state, it is not possible to do a 'hard' delete of the application or the account. An API endpoint will be added to close/de-activate the fixed deposit account.") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = FixedDepositAccountsApiResourceSwagger.DeleteFixedDepositAccountsAccountIdResponse.class)}) + public String delete(@PathParam("accountId") @ApiParam(value = "accountId") final Long accountId) { final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteFixedDepositAccount(accountId).build(); @@ -344,7 +352,7 @@ public class FixedDepositAccountsApiResource { @Path("{accountId}/template") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String accountClosureTemplate(@PathParam("accountId") final Long accountId, @QueryParam("command") final String commandParam, + public String accountClosureTemplate(@PathParam("accountId") @ApiParam(value = "accountId") final Long accountId, @QueryParam("command") @ApiParam(value = "command") final String commandParam, @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(DepositsApiConstants.FIXED_DEPOSIT_ACCOUNT_RESOURCE_NAME); @@ -356,4 +364,4 @@ public class FixedDepositAccountsApiResource { final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters()); return this.toApiJsonSerializer.serialize(settings, account, DepositsApiConstants.FIXED_DEPOSIT_ACCOUNT_RESPONSE_DATA_PARAMETERS); } -} \ No newline at end of file +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/FixedDepositAccountsApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/FixedDepositAccountsApiResourceSwagger.java new file mode 100644 index 000000000..41567ca82 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/FixedDepositAccountsApiResourceSwagger.java @@ -0,0 +1,523 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.savings.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.time.LocalDate; +import java.util.Set; + +/** + * Created by Chirag Gupta on 12/15/17. + */ +final class FixedDepositAccountsApiResourceSwagger { + private FixedDepositAccountsApiResourceSwagger() { + } + + @ApiModel(value = "GetFixedDepositAccountsTemplateResponse") + public final static class GetFixedDepositAccountsTemplateResponse { + private GetFixedDepositAccountsTemplateResponse() { + } + + final class GetFixedDepositAccountsProductOptions { + private GetFixedDepositAccountsProductOptions() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "Passbook Savings") + public String name; + } + + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "small business") + public String clientName; + public Set productOptions; + } + + @ApiModel(value = "GetFixedDepositAccountsResponse") + public final static class GetFixedDepositAccountsResponse { + private GetFixedDepositAccountsResponse() { + } + + final class GetFixedDepositAccountsStatus { + private GetFixedDepositAccountsStatus() { + } + + @ApiModelProperty(example = "100") + public Integer id; + @ApiModelProperty(example = "savingsAccountStatusType.submitted.and.pending.approval") + public String code; + @ApiModelProperty(example = "Submitted and pending approval") + public String value; + @ApiModelProperty(example = "true") + public Boolean submittedAndPendingApproval; + @ApiModelProperty(example = "false") + public Boolean approved; + @ApiModelProperty(example = "false") + public Boolean rejected; + @ApiModelProperty(example = "false") + public Boolean withdrawnByApplicant; + @ApiModelProperty(example = "false") + public Boolean active; + @ApiModelProperty(example = "false") + public Boolean closed; + @ApiModelProperty(example = "false") + public Boolean prematureClosed; + @ApiModelProperty(example = "false") + public Boolean transferInProgress; + @ApiModelProperty(example = "false") + public Boolean transferOnHold; + } + + final class GetFixedDepositAccountsTimeline { + private GetFixedDepositAccountsTimeline() { + } + + @ApiModelProperty(example = "[2014, 3, 1]") + public LocalDate submittedOnDate; + @ApiModelProperty(example = "mifos") + public String submittedByUsername; + @ApiModelProperty(example = "App") + public String submittedByFirstname; + @ApiModelProperty(example = "Administrator") + public String submittedByLastname; + } + + final class GetFixedDepositAccountsCurrency { + private GetFixedDepositAccountsCurrency() { + } + + @ApiModelProperty(example = "USD") + public String code; + @ApiModelProperty(example = "US Dollar") + public String name; + @ApiModelProperty(example = "2") + public Integer decimalPlaces; + @ApiModelProperty(example = "1") + public Integer inMultiplesOf; + @ApiModelProperty(example = "$") + public String displaySymbol; + @ApiModelProperty(example = "currency.USD") + public String nameCode; + @ApiModelProperty(example = "US Dollar ($)") + public String displayLabel; + } + + final class GetFixedDepositAccountsInterestCompoundingPeriodType { + private GetFixedDepositAccountsInterestCompoundingPeriodType() { + } + + @ApiModelProperty(example = "4") + public Integer id; + @ApiModelProperty(example = "savings.interest.period.savingsCompoundingInterestPeriodType.monthly") + public String code; + @ApiModelProperty(example = "Monthly") + public String value; + } + + final class GetFixedDepositAccountsInterestPostingPeriodType { + private GetFixedDepositAccountsInterestPostingPeriodType() { + } + + @ApiModelProperty(example = "4") + public Integer id; + @ApiModelProperty(example = "savings.interest.posting.period.savingsPostingInterestPeriodType.monthly") + public String code; + @ApiModelProperty(example = "Monthly") + public String value; + } + + final class GetFixedDepositAccountsInterestCalculationType { + private GetFixedDepositAccountsInterestCalculationType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "savingsInterestCalculationType.dailybalance") + public String code; + @ApiModelProperty(example = "Daily Balance") + public String value; + } + + final class GetFixedDepositAccountsInterestCalculationDaysInYearType { + private GetFixedDepositAccountsInterestCalculationDaysInYearType() { + } + + @ApiModelProperty(example = "365") + public Integer id; + @ApiModelProperty(example = "savingsInterestCalculationDaysInYearType.days365") + public String code; + @ApiModelProperty(example = "365 Days") + public String value; + } + + final class GetFixedDepositAccountsSummary { + private GetFixedDepositAccountsSummary() { + } + + public GetFixedDepositAccountsCurrency currency; + @ApiModelProperty(example = "0") + public Float accountBalance; + } + + final class GetFixedDepositAccountsMinDepositTermType { + private GetFixedDepositAccountsMinDepositTermType() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "deposit.term.savingsPeriodFrequencyType.months") + public String code; + @ApiModelProperty(example = "Months") + public String value; + } + + final class GetFixedDepositAccountsMaxDepositTermType { + private GetFixedDepositAccountsMaxDepositTermType() { + } + + @ApiModelProperty(example = "3") + public Integer id; + @ApiModelProperty(example = "deposit.term.savingsPeriodFrequencyType.years") + public String code; + @ApiModelProperty(example = "Years") + public String value; + } + + final class GetFixedDepositAccountsDepositPeriodFrequency { + private GetFixedDepositAccountsDepositPeriodFrequency() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "deposit.period.savingsPeriodFrequencyType.months") + public String code; + @ApiModelProperty(example = "Months") + public String value; + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "000000001") + public Long accountNo; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "Sangamesh N") + public String clientName; + @ApiModelProperty(example = "3") + public Integer savingsProductId; + @ApiModelProperty(example = "FD01") + public String savingsProductName; + @ApiModelProperty(example = "0") + public Integer fieldOfficerId; + public GetFixedDepositAccountsStatus status; + public GetFixedDepositAccountsTimeline timeline; + public GetFixedDepositAccountsCurrency currency; + public GetFixedDepositAccountsInterestCompoundingPeriodType interestCompoundingPeriodType; + public GetFixedDepositAccountsInterestPostingPeriodType interestPostingPeriodType; + public GetFixedDepositAccountsInterestCalculationType interestCalculationType; + public GetFixedDepositAccountsInterestCalculationDaysInYearType interestCalculationDaysInYearType; + public GetFixedDepositAccountsSummary summary; + @ApiModelProperty(example = "false") + public Boolean interestFreePeriodApplicable; + @ApiModelProperty(example = "false") + public Boolean preClosurePenalApplicable; + @ApiModelProperty(example = "3") + public Integer minDepositTerm; + @ApiModelProperty(example = "4") + public Integer maxDepositTerm; + public GetFixedDepositAccountsMinDepositTermType minDepositTermType; + public GetFixedDepositAccountsMaxDepositTermType maxDepositTermType; + @ApiModelProperty(example = "5000") + public Float depositAmount; + @ApiModelProperty(example = "5140.25") + public Float maturityAmount; + @ApiModelProperty(example = "[2014, 9, 1]") + public LocalDate maturityDate; + @ApiModelProperty(example = "6") + public Integer depositPeriod; + public GetFixedDepositAccountsDepositPeriodFrequency depositPeriodFrequency; + } + + @ApiModel(value = "PostFixedDepositAccountsRequest") + public final static class PostFixedDepositAccountsRequest { + private PostFixedDepositAccountsRequest() { + } + + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "1") + public Integer productId; + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "dd MMMM yyyy") + public String dateFormat; + @ApiModelProperty(example = "01 March 2014") + public String submittedOnDate; + @ApiModelProperty(example = "5000") + public Float depositAmount; + @ApiModelProperty(example = "6") + public Integer depositPeriod; + @ApiModelProperty(example = "2") + public Integer depositPeriodFrequencyId; + } + + @ApiModel(value = "PostFixedDepositAccountsResponse") + public final static class PostFixedDepositAccountsResponse { + private PostFixedDepositAccountsResponse() { + } + + @ApiModelProperty(example = "2") + public Integer officeId; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "1") + public Integer savingsId; + @ApiModelProperty(example = "1") + public Integer resourceId; + } + + @ApiModel(value = "GetFixedDepositAccountsAccountIdResponse") + public final static class GetFixedDepositAccountsAccountIdResponse { + private GetFixedDepositAccountsAccountIdResponse() { + } + + final class GetFixedDepositAccountsAccountChart { + private GetFixedDepositAccountsAccountChart() { + } + + final class GetFixedDepositAccountsChartSlabs { + private GetFixedDepositAccountsChartSlabs() { + } + + final class GetFixedDepositAccountsPeriodType { + private GetFixedDepositAccountsPeriodType() { + } + + @ApiModelProperty(example = "0") + public Integer id; + @ApiModelProperty(example = "interestChartPeriodType.days") + public String code; + @ApiModelProperty(example = "Days") + public String value; + } + + final class GetFixedDepositAccountsAccountChartCurrency { + private GetFixedDepositAccountsAccountChartCurrency() { + } + + @ApiModelProperty(example = "USD") + public String code; + @ApiModelProperty(example = "US Dollar") + public String name; + @ApiModelProperty(example = "2") + public Integer decimalPlaces; + @ApiModelProperty(example = "$") + public String displaySymbol; + @ApiModelProperty(example = "currency.USD") + public String nameCode; + @ApiModelProperty(example = "US Dollar ($)") + public String displayLabel; + } + + @ApiModelProperty(example = "13") + public Integer id; + public GetFixedDepositAccountsPeriodType periodType; + @ApiModelProperty(example = "181") + public Integer fromPeriod; + @ApiModelProperty(example = "365") + public Integer toPeriod; + @ApiModelProperty(example = "5.5") + public Double annualInterestRate; + public GetFixedDepositAccountsAccountChartCurrency currency; + } + + final class GetFixedDepositAccountsPeriodTypes { + private GetFixedDepositAccountsPeriodTypes() { + } + + @ApiModelProperty(example = "0") + public Integer id; + @ApiModelProperty(example = "interestChartPeriodType.days") + public String code; + @ApiModelProperty(example = "Days") + public String value; + } + + @ApiModelProperty(example = "4") + public Integer id; + @ApiModelProperty(example = "[2013, 10, 2]") + public LocalDate fromDate; + @ApiModelProperty(example = "5") + public Integer accountId; + @ApiModelProperty(example = "FD000023") + public Long accountNumber; + public Set chartSlabs; + public Set periodTypes; + } + + final class GetFixedDepositAccountsAccountIdCurrency { + private GetFixedDepositAccountsAccountIdCurrency() { + } + + @ApiModelProperty(example = "USD") + public String code; + @ApiModelProperty(example = "US Dollar") + public String name; + @ApiModelProperty(example = "2") + public Integer decimalPlaces; + @ApiModelProperty(example = "1") + public Integer inMultiplesOf; + @ApiModelProperty(example = "$") + public String displaySymbol; + @ApiModelProperty(example = "currency.USD") + public String nameCode; + @ApiModelProperty(example = "US Dollar ($)") + public String displayLabel; + } + + final class GetFixedDepositAccountsAccountIdSummary { + private GetFixedDepositAccountsAccountIdSummary() { + } + + public GetFixedDepositAccountsAccountIdCurrency currency; + @ApiModelProperty(example = "0") + public Float accountBalance; + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "FD000023") + public Long accountNo; + @ApiModelProperty(example = "FD-23") + public String externalId; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "Sangamesh N") + public String clientName; + @ApiModelProperty(example = "3") + public Integer savingsProductId; + @ApiModelProperty(example = "FD01") + public String savingsProductName; + @ApiModelProperty(example = "0") + public Integer fieldOfficerId; + public GetFixedDepositAccountsResponse.GetFixedDepositAccountsStatus status; + public GetFixedDepositAccountsResponse.GetFixedDepositAccountsTimeline timeline; + public GetFixedDepositAccountsAccountIdCurrency currency; + public GetFixedDepositAccountsResponse.GetFixedDepositAccountsInterestCompoundingPeriodType interestCompoundingPeriodType; + public GetFixedDepositAccountsResponse.GetFixedDepositAccountsInterestPostingPeriodType interestPostingPeriodType; + public GetFixedDepositAccountsResponse.GetFixedDepositAccountsInterestCalculationType interestCalculationType; + public GetFixedDepositAccountsResponse.GetFixedDepositAccountsInterestCalculationDaysInYearType interestCalculationDaysInYearType; + @ApiModelProperty(example = "false") + public Boolean interestFreePeriodApplicable; + @ApiModelProperty(example = "false") + public Boolean preClosurePenalApplicable; + @ApiModelProperty(example = "3") + public Integer minDepositTerm; + @ApiModelProperty(example = "4") + public Integer maxDepositTerm; + public GetFixedDepositAccountsResponse.GetFixedDepositAccountsMinDepositTermType minDepositTermType; + public GetFixedDepositAccountsResponse.GetFixedDepositAccountsMaxDepositTermType maxDepositTermType; + @ApiModelProperty(example = "5000") + public Float depositAmount; + @ApiModelProperty(example = "5140.25") + public Float maturityAmount; + @ApiModelProperty(example = "[2014, 9, 1]") + public LocalDate maturityDate; + @ApiModelProperty(example = "6") + public Integer depositPeriod; + public GetFixedDepositAccountsResponse.GetFixedDepositAccountsDepositPeriodFrequency depositPeriodFrequency; + public GetFixedDepositAccountsAccountIdSummary summary; + public GetFixedDepositAccountsAccountChart accountChart; + } + + @ApiModel(value = "PutFixedDepositAccountsAccountIdRequest") + public final static class PutFixedDepositAccountsAccountIdRequest { + private PutFixedDepositAccountsAccountIdRequest() { + } + + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "6000") + public Float depositAmount; + } + + @ApiModel(value = "PutFixedDepositAccountsAccountIdResponse") + public final static class PutFixedDepositAccountsAccountIdResponse { + private PutFixedDepositAccountsAccountIdResponse() { + } + + final class PutFixedDepositAccountsChanges { + private PutFixedDepositAccountsChanges() { + } + + @ApiModelProperty(example = "6000") + public Float depositAmount; + @ApiModelProperty(example = "en") + public String locale; + } + + @ApiModelProperty(example = "2") + public Integer officeId; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "1") + public Integer savingsId; + @ApiModelProperty(example = "1") + public Integer resourceId; + public PutFixedDepositAccountsChanges changes; + } + + @ApiModel(value = "PostFixedDepositAccountsAccountIdRequest") + public final static class PostFixedDepositAccountsAccountIdRequest { + private PostFixedDepositAccountsAccountIdRequest() { + } + } + + @ApiModel(value = "PostFixedDepositAccountsAccountIdResponse") + public final static class PostFixedDepositAccountsAccountIdResponse { + private PostFixedDepositAccountsAccountIdResponse() { + } + + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "1") + public Integer savingsId; + @ApiModelProperty(example = "1") + public Integer resourceId; + } + + @ApiModel(value = "DeleteFixedDepositAccountsAccountIdResponse") + public final static class DeleteFixedDepositAccountsAccountIdResponse { + private DeleteFixedDepositAccountsAccountIdResponse() { + } + + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "1") + public Integer resourceId; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/FixedDepositProductsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/FixedDepositProductsApiResource.java index 0648a13bc..cfd89e1d3 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/FixedDepositProductsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/FixedDepositProductsApiResource.java @@ -18,23 +18,7 @@ */ package org.apache.fineract.portfolio.savings.api; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriInfo; - +import io.swagger.annotations.*; import org.apache.fineract.accounting.common.AccountingDropdownReadPlatformService; import org.apache.fineract.accounting.common.AccountingEnumerations; import org.apache.fineract.accounting.common.AccountingRuleType; @@ -60,12 +44,7 @@ import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartDat import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartReadPlatformService; import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeData; import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadPlatformService; -import org.apache.fineract.portfolio.savings.DepositAccountType; -import org.apache.fineract.portfolio.savings.DepositsApiConstants; -import org.apache.fineract.portfolio.savings.SavingsCompoundingInterestPeriodType; -import org.apache.fineract.portfolio.savings.SavingsInterestCalculationDaysInYearType; -import org.apache.fineract.portfolio.savings.SavingsInterestCalculationType; -import org.apache.fineract.portfolio.savings.SavingsPostingInterestPeriodType; +import org.apache.fineract.portfolio.savings.*; import org.apache.fineract.portfolio.savings.data.FixedDepositProductData; import org.apache.fineract.portfolio.savings.service.DepositProductReadPlatformService; import org.apache.fineract.portfolio.savings.service.DepositsDropdownReadPlatformService; @@ -78,9 +57,19 @@ import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; + @Path("/fixeddepositproducts") @Component @Scope("singleton") +@Api(value = "Fixed Deposit Product", description = "This is one of the advanced term deposit product offered by MFI's. The Fixed Deposit Products (aka FD) product offerings are modeled using this API.\n" + "\n" + "The FD products are deposit accounts which are held for a fixed term – like 1 year, 2 years etc.\n" + "\n" + "When creating fixed deposit accounts, the details from the fixed deposit product are used to auto fill details of the fixed deposit account application process.") public class FixedDepositProductsApiResource { private final DepositProductReadPlatformService depositProductReadPlatformService; @@ -135,7 +124,10 @@ public class FixedDepositProductsApiResource { @POST @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String create(final String apiRequestBodyAsJson) { + @ApiOperation(value = "Create a Fixed Deposit Product", httpMethod = "POST", notes = "Creates a Fixed Deposit Product\n\n" + "Mandatory Fields: name, shortName, description, currencyCode, digitsAfterDecimal,inMultiplesOf, interestCompoundingPeriodType, interestCalculationType, interestCalculationDaysInYearType, minDepositTerm, minDepositTermTypeId, accountingRule\n\n" + "Optional Fields: lockinPeriodFrequency, lockinPeriodFrequencyType, maxDepositTerm, maxDepositTermTypeId, inMultiplesOfDepositTerm, inMultiplesOfDepositTermTypeId, preClosurePenalApplicable, preClosurePenalInterest, preClosurePenalInterestOnTypeId, feeToIncomeAccountMappings, penaltyToIncomeAccountMappings, charges, charts, , withHoldTax, taxGroupId\n\n" + "\n" + "Mandatory Fields for Cash based accounting (accountingRule = 2): savingsReferenceAccountId, savingsControlAccountId, interestOnSavingsAccountId, incomeFromFeeAccountId, transfersInSuspenseAccountId, incomeFromPenaltyAccountId") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = FixedDepositProductsApiResourceSwagger.PostFixedDepositProductsRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = FixedDepositProductsApiResourceSwagger.PostFixedDepositProductsResponse.class)}) + public String create(@ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder().createFixedDepositProduct().withJson(apiRequestBodyAsJson) .build(); @@ -149,7 +141,10 @@ public class FixedDepositProductsApiResource { @Path("{productId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String update(@PathParam("productId") final Long productId, final String apiRequestBodyAsJson) { + @ApiOperation(value = "Update a Fixed Deposit Product", httpMethod = "PUT", notes = "Updates a Fixed Deposit Product") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = FixedDepositProductsApiResourceSwagger.PutFixedDepositProductsProductIdRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = FixedDepositProductsApiResourceSwagger.PutFixedDepositProductsProductIdResponse.class)}) + public String update(@PathParam("productId") @ApiParam(value = "productId") final Long productId, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder().updateFixedDepositProduct(productId) .withJson(apiRequestBodyAsJson).build(); @@ -163,6 +158,8 @@ public class FixedDepositProductsApiResource { @GET @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) + @ApiOperation(value = "List Fixed Deposit Products", httpMethod = "GET", notes = "Lists Fixed Deposit Products\n\n" + "Example Requests:\n" + "\n" +"fixeddepositproducts\n" + "\n" + "\n" + "fixeddepositproducts?fields=name") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = FixedDepositProductsApiResourceSwagger.GetFixedDepositProductsResponse.class, responseContainer = "List")}) public String retrieveAll(@Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(DepositsApiConstants.FIXED_DEPOSIT_PRODUCT_RESOURCE_NAME); @@ -179,7 +176,9 @@ public class FixedDepositProductsApiResource { @Path("{productId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveOne(@PathParam("productId") final Long productId, @Context final UriInfo uriInfo) { + @ApiOperation(value = "Retrieve a Fixed Deposit Product", httpMethod = "GET", notes = "Retrieves a Fixed Deposit Product\n\n" + "Example Requests:\n" + "\n" + "fixeddepositproducts/1\n" + "\n" + "\n" + "fixeddepositproducts/1?template=true\n" + "\n" + "\n" + "fixeddepositproducts/1?fields=name,description") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = FixedDepositProductsApiResourceSwagger.GetFixedDepositProductsProductIdResponse.class)}) + public String retrieveOne(@PathParam("productId") @ApiParam(value = "productId") final Long productId, @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(DepositsApiConstants.FIXED_DEPOSIT_PRODUCT_RESOURCE_NAME); @@ -319,7 +318,9 @@ public class FixedDepositProductsApiResource { @Path("{productId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String delete(@PathParam("productId") final Long productId) { + @ApiOperation(value = "Delete a Fixed Deposit Product", httpMethod = "DELETE", notes = "Deletes a Fixed Deposit Product") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = FixedDepositProductsApiResourceSwagger.DeleteFixedDepositProductsProductIdResponse.class)}) + public String delete(@PathParam("productId") @ApiParam(value = "productId") final Long productId) { final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteFixedDepositProduct(productId).build(); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/FixedDepositProductsApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/FixedDepositProductsApiResourceSwagger.java new file mode 100644 index 000000000..3b01f7343 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/FixedDepositProductsApiResourceSwagger.java @@ -0,0 +1,583 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.savings.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.time.LocalDate; +import java.util.Set; + +/** + * Created by Chirag Gupta on 12/23/17. + */ +final class FixedDepositProductsApiResourceSwagger { + private FixedDepositProductsApiResourceSwagger() { + } + + @ApiModel(value = "PostFixedDepositProductsRequest") + public final static class PostFixedDepositProductsRequest { + private PostFixedDepositProductsRequest() { + } + + final class PostFixedDepositProductsCharts { + private PostFixedDepositProductsCharts() { + } + + final class PostFixedDepositProductsChartSlabs { + private PostFixedDepositProductsChartSlabs() { + } + + @ApiModelProperty(example = "from 0 to 90 days") + public String description; + @ApiModelProperty(example = "1") + public Integer periodType; + @ApiModelProperty(example = "0") + public Integer fromPeriod; + @ApiModelProperty(example = "90") + public Integer toPeriod; + @ApiModelProperty(example = "4.5") + public Double annualInterestRate; + } + + @ApiModelProperty(example = "01 Jan 2014") + public String fromDate; + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "dd MMMM yyyy") + public String dateFormat; + public Set chartSlabs; + } + + @ApiModelProperty(example = "Fixed deposit product") + public String name; + @ApiModelProperty(example = "FD01") + public String shortName; + @ApiModelProperty(example = "Daily compounding using Daily Balance, 5% per year, 365 days in year") + public String description; + @ApiModelProperty(example = "USD") + public String currencyCode; + @ApiModelProperty(example = "2") + public Integer digitsAfterDecimal; + @ApiModelProperty(example = "0") + public Integer inMultiplesOf; + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "1") + public Integer interestCompoundingPeriodType; + @ApiModelProperty(example = "4") + public Integer interestPostingPeriodType; + @ApiModelProperty(example = "1") + public Integer interestCalculationType; + @ApiModelProperty(example = "365") + public Integer interestCalculationDaysInYearType; + @ApiModelProperty(example = "1") + public Integer accountingRule; + @ApiModelProperty(example = "true") + public Boolean preClosurePenalApplicable; + @ApiModelProperty(example = "1.75") + public Double preClosurePenalInterest; + @ApiModelProperty(example = "1") + public Integer preClosurePenalInterestOnTypeId; + @ApiModelProperty(example = "1") + public Integer minDepositTerm; + @ApiModelProperty(example = "1") + public Integer minDepositTermTypeId; + @ApiModelProperty(example = "5") + public Integer maxDepositTerm; + @ApiModelProperty(example = "3") + public Integer maxDepositTermTypeId; + public Set charts; + } + + @ApiModel(value = "PostFixedDepositProductsResponse") + public final static class PostFixedDepositProductsResponse { + private PostFixedDepositProductsResponse() { + } + + @ApiModelProperty(example = "1") + public Integer resourceId; + } + + @ApiModel(value = "PutFixedDepositProductsProductIdRequest") + public final static class PutFixedDepositProductsProductIdRequest { + private PutFixedDepositProductsProductIdRequest() { + } + + @ApiModelProperty(example = "Fixed deposit product new offerings") + public String description; + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "5") + public Integer minDepositTerm; + @ApiModelProperty(example = "1") + public Integer minDepositTermTypeId; + } + + @ApiModel(value = "PutFixedDepositProductsProductIdResponse") + public final static class PutFixedDepositProductsProductIdResponse { + private PutFixedDepositProductsProductIdResponse() { + } + + final class PutFixedDepositProductsChanges { + private PutFixedDepositProductsChanges() { + } + + @ApiModelProperty(example = "Fixed deposit product new offerings") + public String description; + @ApiModelProperty(example = "5") + public Integer minDepositTerm; + } + + @ApiModelProperty(example = "1") + public Integer resourceId; + public PutFixedDepositProductsChanges changes; + } + + @ApiModel(value = "GetFixedDepositProductsResponse") + public final static class GetFixedDepositProductsResponse { + private GetFixedDepositProductsResponse() { + } + + final class GetFixedDepositProductsCurrency { + private GetFixedDepositProductsCurrency() { + } + + @ApiModelProperty(example = "USD") + public String code; + @ApiModelProperty(example = "US Dollar") + public String name; + @ApiModelProperty(example = "2") + public Integer decimalPlaces; + @ApiModelProperty(example = "1") + public Integer inMultiplesOf; + @ApiModelProperty(example = "$") + public String displaySymbol; + @ApiModelProperty(example = "currency.USD") + public String nameCode; + @ApiModelProperty(example = "US Dollar ($)") + public String displayLabel; + } + + final class GetFixedDepositProductsMinDepositTermType { + private GetFixedDepositProductsMinDepositTermType() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "deposit.term.savingsPeriodFrequencyType.months") + public String code; + @ApiModelProperty(example = "Months") + public String value; + } + + final class GetFixedDepositProductsMaxDepositTermType { + private GetFixedDepositProductsMaxDepositTermType() { + } + + @ApiModelProperty(example = "3") + public Integer id; + @ApiModelProperty(example = "deposit.term.savingsPeriodFrequencyType.years") + public String code; + @ApiModelProperty(example = "Years") + public String value; + } + + final class GetFixedDepositProductsInterestCompoundingPeriodType { + private GetFixedDepositProductsInterestCompoundingPeriodType() { + } + + @ApiModelProperty(example = "4") + public Integer id; + @ApiModelProperty(example = "savings.interest.period.savingsCompoundingInterestPeriodType.monthly") + public String code; + @ApiModelProperty(example = "Monthly") + public String value; + } + + final class GetFixedDepositProductsInterestPostingPeriodType { + private GetFixedDepositProductsInterestPostingPeriodType() { + } + + @ApiModelProperty(example = "4") + public Integer id; + @ApiModelProperty(example = "savings.interest.posting.period.savingsPostingInterestPeriodType.monthly") + public String code; + @ApiModelProperty(example = "Monthly") + public String value; + } + + final class GetFixedDepositProductsInterestCalculationType { + private GetFixedDepositProductsInterestCalculationType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "savingsInterestCalculationType.dailybalance") + public String code; + @ApiModelProperty(example = "Daily Balance") + public String value; + } + + final class GetFixedDepositProductsInterestCalculationDaysInYearType { + private GetFixedDepositProductsInterestCalculationDaysInYearType() { + } + + @ApiModelProperty(example = "365") + public Integer id; + @ApiModelProperty(example = "savingsInterestCalculationDaysInYearType.days365") + public String code; + @ApiModelProperty(example = "365 Days") + public String value; + } + + final class GetFixedDepositProductsAccountingRule { + private GetFixedDepositProductsAccountingRule() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "accountingRuleType.none") + public String code; + @ApiModelProperty(example = "NONE") + public String value; + } + + @ApiModelProperty(example = "3") + public Integer id; + @ApiModelProperty(example = "FD01") + public String name; + @ApiModelProperty(example = "FD01") + public String shortName; + @ApiModelProperty(example = "FD01") + public String description; + public GetFixedDepositProductsCurrency currency; + @ApiModelProperty(example = "false") + public Boolean preClosurePenalApplicable; + @ApiModelProperty(example = "3") + public Integer minDepositTerm; + @ApiModelProperty(example = "4") + public Integer maxDepositTerm; + public GetFixedDepositProductsMinDepositTermType minDepositTermType; + public GetFixedDepositProductsMaxDepositTermType maxDepositTermType; + @ApiModelProperty(example = "0") + public Double nominalAnnualInterestRate; + public GetFixedDepositProductsInterestCompoundingPeriodType interestCompoundingPeriodType; + public GetFixedDepositProductsInterestPostingPeriodType interestPostingPeriodType; + public GetFixedDepositProductsInterestCalculationType interestCalculationType; + public GetFixedDepositProductsInterestCalculationDaysInYearType interestCalculationDaysInYearType; + public GetFixedDepositProductsAccountingRule accountingRule; + } + + @ApiModel(value = "GetFixedDepositProductsProductIdResponse") + public final static class GetFixedDepositProductsProductIdResponse { + private GetFixedDepositProductsProductIdResponse() { + } + + final class GetFixedDepositProductsProductIdCurrency { + private GetFixedDepositProductsProductIdCurrency() { + } + + @ApiModelProperty(example = "USD") + public String code; + @ApiModelProperty(example = "US Dollar") + public String name; + @ApiModelProperty(example = "2") + public Integer decimalPlaces; + @ApiModelProperty(example = "$") + public String displaySymbol; + @ApiModelProperty(example = "currency.USD") + public String nameCode; + @ApiModelProperty(example = "US Dollar ($)") + public String displayLabel; + } + + final class GetFixedDepositProductsProductIdInterestCompoundingPeriodType { + private GetFixedDepositProductsProductIdInterestCompoundingPeriodType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "savings.interest.period.savingsCompoundingInterestPeriodType.daily") + public String code; + @ApiModelProperty(example = "Daily") + public String value; + } + + final class GetFixedDepositProductsProductIdAccountingMappings { + private GetFixedDepositProductsProductIdAccountingMappings() { + } + + final class GetFixedDepositProductsProductIdSavingsReferenceAccount { + private GetFixedDepositProductsProductIdSavingsReferenceAccount() { + } + + @ApiModelProperty(example = "12") + public Integer id; + @ApiModelProperty(example = "savings ref") + public String name; + @ApiModelProperty(example = "20") + public Integer glCode; + } + + final class GetFixedDepositProductsProductIdIncomeFromFeeAccount { + private GetFixedDepositProductsProductIdIncomeFromFeeAccount() { + } + + @ApiModelProperty(example = "16") + public Integer id; + @ApiModelProperty(example = "income from savings fee") + public String name; + @ApiModelProperty(example = "24") + public Integer glCode; + } + + final class GetFixedDepositProductsProductIdIncomeFromPenaltyAccount { + private GetFixedDepositProductsProductIdIncomeFromPenaltyAccount() { + } + + @ApiModelProperty(example = "17") + public Integer id; + @ApiModelProperty(example = "income from sav penalties") + public String name; + @ApiModelProperty(example = "25") + public Integer glCode; + } + + final class GetFixedDepositProductsProductIdInterestOnSavingsAccount { + private GetFixedDepositProductsProductIdInterestOnSavingsAccount() { + } + + @ApiModelProperty(example = "15") + public Integer id; + @ApiModelProperty(example = "interest on savings") + public String name; + @ApiModelProperty(example = "23") + public Integer glCode; + } + + final class GetFixedDepositProductsProductIdSavingsControlAccount { + private GetFixedDepositProductsProductIdSavingsControlAccount() { + } + + @ApiModelProperty(example = "13") + public Integer id; + @ApiModelProperty(example = "savings ref tool kit") + public String name; + @ApiModelProperty(example = "21") + public Integer glCode; + } + + final class GetFixedDepositProductsProductIdTransfersInSuspenseAccount { + private GetFixedDepositProductsProductIdTransfersInSuspenseAccount() { + } + + @ApiModelProperty(example = "14") + public Integer id; + @ApiModelProperty(example = "saving transfers") + public String name; + @ApiModelProperty(example = "22") + public Integer glCode; + } + + public GetFixedDepositProductsProductIdSavingsReferenceAccount savingsReferenceAccount; + public GetFixedDepositProductsProductIdIncomeFromFeeAccount incomeFromFeeAccount; + public GetFixedDepositProductsProductIdIncomeFromPenaltyAccount incomeFromPenaltyAccount; + public GetFixedDepositProductsProductIdInterestOnSavingsAccount interestOnSavingsAccount; + public GetFixedDepositProductsProductIdSavingsControlAccount savingsControlAccount; + public GetFixedDepositProductsProductIdTransfersInSuspenseAccount transfersInSuspenseAccount; + } + + final class GetFixedDepositProductsProductIdFeeToIncomeAccountMappings { + private GetFixedDepositProductsProductIdFeeToIncomeAccountMappings() { + } + + final class GetFixedDepositProductsProductIdFeeToIncomeAccountMappingsCharge { + private GetFixedDepositProductsProductIdFeeToIncomeAccountMappingsCharge() { + } + + @ApiModelProperty(example = "11") + public Integer id; + @ApiModelProperty(example = "sav charge") + public String name; + @ApiModelProperty(example = "false") + public Boolean active; + @ApiModelProperty(example = "false") + public Boolean penalty; + } + + final class GetFixedDepositProductsProductIdFeeToIncomeAccountMappingsIncomeAccount { + private GetFixedDepositProductsProductIdFeeToIncomeAccountMappingsIncomeAccount() { + } + + @ApiModelProperty(example = "16") + public Integer id; + @ApiModelProperty(example = "income from savings fee") + public String name; + @ApiModelProperty(example = "24") + public Integer glCode; + } + + public GetFixedDepositProductsProductIdFeeToIncomeAccountMappingsCharge charge; + public GetFixedDepositProductsProductIdFeeToIncomeAccountMappingsIncomeAccount incomeAccount; + } + + final class GetFixedDepositProductsProductIdPenaltyToIncomeAccountMappings { + private GetFixedDepositProductsProductIdPenaltyToIncomeAccountMappings() { + } + + final class GetFixedDepositProductsProductIdPenaltyToIncomeAccountMappingsCharge { + private GetFixedDepositProductsProductIdPenaltyToIncomeAccountMappingsCharge() { + } + + @ApiModelProperty(example = "12") + public Integer id; + @ApiModelProperty(example = "sav 2") + public String name; + @ApiModelProperty(example = "false") + public Boolean active; + @ApiModelProperty(example = "true") + public Boolean penalty; + } + + public GetFixedDepositProductsProductIdPenaltyToIncomeAccountMappingsCharge charge; + public GetFixedDepositProductsProductIdAccountingMappings.GetFixedDepositProductsProductIdIncomeFromPenaltyAccount incomeAccount; + } + + final class GetFixedDepositProductsProductIdPreClosurePenalInterestOnType { + private GetFixedDepositProductsProductIdPreClosurePenalInterestOnType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "preClosurePenalInterestOnType.wholeTerm") + public String code; + @ApiModelProperty(example = "Whole term") + public String value; + } + + final class GetFixedDepositProductsProductIdMinDepositTermType { + private GetFixedDepositProductsProductIdMinDepositTermType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "deposit.term.savingsPeriodFrequencyType.weeks") + public String code; + @ApiModelProperty(example = "Weeks") + public String value; + } + + final class GetFixedDepositProductsProductIdMaxDepositTermType { + private GetFixedDepositProductsProductIdMaxDepositTermType() { + } + + @ApiModelProperty(example = "3") + public Integer id; + @ApiModelProperty(example = "deposit.term.savingsPeriodFrequencyType.years") + public String code; + @ApiModelProperty(example = "Years") + public String value; + } + + final class GetFixedDepositProductsProductIdActiveChart { + private GetFixedDepositProductsProductIdActiveChart() { + } + + final class GetFixedDepositProductsProductIdChartSlabs { + private GetFixedDepositProductsProductIdChartSlabs() { + } + + final class GetFixedDepositProductsProductIdPeriodType { + private GetFixedDepositProductsProductIdPeriodType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "interestChartPeriodType.weeks") + public String code; + @ApiModelProperty(example = "Weeks") + public String value; + } + + @ApiModelProperty(example = "18") + public Integer id; + @ApiModelProperty(example = "from 0 to 90 days") + public String description; + public GetFixedDepositProductsProductIdPeriodType periodType; + @ApiModelProperty(example = "0") + public Integer fromPeriod; + @ApiModelProperty(example = "90") + public Integer toPeriod; + @ApiModelProperty(example = "4.5") + public Double annualInterestRate; + public GetFixedDepositProductsProductIdCurrency currency; + } + + @ApiModelProperty(example = "8") + public Integer id; + @ApiModelProperty(example = "[2014, 1, 1]") + public LocalDate fromDate; + @ApiModelProperty(example = "8") + public Integer savingsProductId; + @ApiModelProperty(example = "Fixed deposit product") + public String savingsProductName; + public Set chartSlabs; + public Set periodTypes; + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "Fixed deposit product") + public String name; + @ApiModelProperty(example = "FD01") + public String shortName; + @ApiModelProperty(example = "Daily compounding using Daily Balance, 5% per year, 365 days in year") + public String description; + public GetFixedDepositProductsProductIdCurrency currency; + public GetFixedDepositProductsProductIdInterestCompoundingPeriodType interestCompoundingPeriodType; + public GetFixedDepositProductsResponse.GetFixedDepositProductsInterestPostingPeriodType interestPostingPeriodType; + public GetFixedDepositProductsResponse.GetFixedDepositProductsInterestCalculationType interestCalculationType; + public GetFixedDepositProductsResponse.GetFixedDepositProductsInterestCalculationDaysInYearType interestCalculationDaysInYearType; + public GetFixedDepositProductsProductIdAccountingMappings accountingMappings; + public Set feeToIncomeAccountMappings; + public Set penaltyToIncomeAccountMappings; + @ApiModelProperty(example = "true") + public Boolean preClosurePenalApplicable; + @ApiModelProperty(example = "1.75") + public Double preClosurePenalInterest; + public GetFixedDepositProductsProductIdPreClosurePenalInterestOnType preClosurePenalInterestOnType; + @ApiModelProperty(example = "1") + public Integer minDepositTerm; + public GetFixedDepositProductsProductIdMinDepositTermType minDepositTermType; + @ApiModelProperty(example = "5") + public Integer maxDepositTerm; + public GetFixedDepositProductsProductIdMaxDepositTermType maxDepositTermType; + public GetFixedDepositProductsProductIdActiveChart activeChart; + } + + @ApiModel(value = "DeleteFixedDepositProductsProductIdResponse") + public final static class DeleteFixedDepositProductsProductIdResponse { + private DeleteFixedDepositProductsProductIdResponse() { + } + + @ApiModelProperty(example = "1") + public Integer resourceId; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/RecurringDepositAccountTransactionsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/RecurringDepositAccountTransactionsApiResource.java index 089dc2b9f..91f3e5b4e 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/RecurringDepositAccountTransactionsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/RecurringDepositAccountTransactionsApiResource.java @@ -18,22 +18,7 @@ */ package org.apache.fineract.portfolio.savings.api; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriInfo; - +import io.swagger.annotations.*; import org.apache.commons.lang.StringUtils; import org.apache.fineract.commands.domain.CommandWrapper; import org.apache.fineract.commands.service.CommandWrapperBuilder; @@ -48,7 +33,6 @@ import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeData; import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadPlatformService; import org.apache.fineract.portfolio.savings.DepositAccountType; import org.apache.fineract.portfolio.savings.DepositsApiConstants; -import org.apache.fineract.portfolio.savings.SavingsApiConstants; import org.apache.fineract.portfolio.savings.data.SavingsAccountTransactionData; import org.apache.fineract.portfolio.savings.service.DepositAccountReadPlatformService; import org.apache.fineract.portfolio.savings.service.SavingsAccountReadPlatformService; @@ -56,9 +40,19 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + @Path("/recurringdepositaccounts/{recurringDepositAccountId}/transactions") @Component @Scope("singleton") +@Api(value = "Recurring Deposit Account Transactions", description = "Transactions possible on a recurring deposit account.") public class RecurringDepositAccountTransactionsApiResource { private final PlatformSecurityContext context; @@ -100,8 +94,10 @@ public class RecurringDepositAccountTransactionsApiResource { @Path("template") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveTemplate(@PathParam("recurringDepositAccountId") final Long recurringDepositAccountId, - @QueryParam("command") final String commandParam, @Context final UriInfo uriInfo) { + @ApiOperation(value = "Retrieve Recurring Deposit Account Transaction Template", httpMethod = "GET", notes = "This is a convenience resource. It can be useful when building maintenance user interface screens for client applications. The template data returned consists of any or all of:\n" + "\n" + "Field Defaults\n" + "Allowed Value Lists\n" + "Example Requests:\n" + "\n" + "recurringdepositaccounts/1/transactions/template?command=deposit\n" + "\n" + "recurringdepositaccounts/1/transactions/template?command=withdrawal") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = RecurringDepositAccountTransactionsApiResourceSwagger.GetRecurringDepositAccountsRecurringDepositAccountIdTransactionsTemplateResponse.class)}) + public String retrieveTemplate(@PathParam("recurringDepositAccountId") @ApiParam(value = "recurringDepositAccountId") final Long recurringDepositAccountId, + @QueryParam("command") @ApiParam(value = "command") final String commandParam, @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(DepositsApiConstants.RECURRING_DEPOSIT_ACCOUNT_RESOURCE_NAME); @@ -138,8 +134,10 @@ public class RecurringDepositAccountTransactionsApiResource { @Path("{transactionId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveOne(@PathParam("recurringDepositAccountId") final Long recurringDepositAccountId, - @PathParam("transactionId") final Long transactionId, @Context final UriInfo uriInfo) { + @ApiOperation(value = "Retrieve Recurring Deposit Account Transaction", httpMethod = "GET", notes = "Retrieves Recurring Deposit Account Transaction\n\n" + "Example Requests:\n" + "\n" + "recurringdepositaccounts/1/transactions/1") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = RecurringDepositAccountTransactionsApiResourceSwagger.GetRecurringDepositAccountsRecurringDepositAccountIdTransactionsTransactionIdResponse.class)}) + public String retrieveOne(@PathParam("recurringDepositAccountId") @ApiParam(value = "recurringDepositAccountId") final Long recurringDepositAccountId, + @PathParam("transactionId") @ApiParam(value = "transactionId") final Long transactionId, @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(DepositsApiConstants.RECURRING_DEPOSIT_ACCOUNT_RESOURCE_NAME); SavingsAccountTransactionData transactionData = this.savingsAccountReadPlatformService.retrieveSavingsTransaction( @@ -157,8 +155,11 @@ public class RecurringDepositAccountTransactionsApiResource { @POST @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String transaction(@PathParam("recurringDepositAccountId") final Long recurringDepositAccountId, - @QueryParam("command") final String commandParam, final String apiRequestBodyAsJson) { + @ApiOperation(value = "Deposit Transaction | Withdrawal Transaction", httpMethod = "POST", notes = "Deposit Transaction:\n\n" + "Used for a deposit transaction\n\n" + "Withdrawal Transaction:\n\n" + "Used for a Withdrawal Transaction\n\n" + "Showing request/response for Deposit Transaction") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = RecurringDepositAccountTransactionsApiResourceSwagger.PostRecurringDepositAccountsRecurringDepositAccountIdTransactionsRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = RecurringDepositAccountTransactionsApiResourceSwagger.PostRecurringDepositAccountsRecurringDepositAccountIdTransactionsResponse.class)}) + public String transaction(@PathParam("recurringDepositAccountId") @ApiParam(value = "recurringDepositAccountId") final Long recurringDepositAccountId, + @QueryParam("command") @ApiParam(value = "command") final String commandParam, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapperBuilder builder = new CommandWrapperBuilder().withJson(apiRequestBodyAsJson); @@ -184,9 +185,12 @@ public class RecurringDepositAccountTransactionsApiResource { @Path("{transactionId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String handleTransactionCommands(@PathParam("recurringDepositAccountId") final Long recurringDepositAccountId, - @PathParam("transactionId") final Long transactionId, @QueryParam("command") final String commandParam, - final String apiRequestBodyAsJson) { + @ApiOperation(value = "Adjust Transaction | Undo transaction", httpMethod = "POST", notes = "Adjust Transaction:\n\n" + "This command modifies the given transaction.\n\n" + "Undo transaction:\n\n" + "This command reverses the given transaction.\n\n" + "Showing request/response for 'Adjust Transaction'") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = RecurringDepositAccountTransactionsApiResourceSwagger.PostRecurringDepositAccountsRecurringDepositAccountIdTransactionsRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = RecurringDepositAccountTransactionsApiResourceSwagger.PostRecurringDepositAccountsRecurringDepositAccountIdTransactionsTransactionIdResponse.class)}) + public String handleTransactionCommands(@PathParam("recurringDepositAccountId") @ApiParam(value = "recurringDepositAccountId") final Long recurringDepositAccountId, + @PathParam("transactionId") @ApiParam(value = "transactionId") final Long transactionId, @QueryParam("command") @ApiParam(value = "command") final String commandParam, + @ApiParam(hidden = true) final String apiRequestBodyAsJson) { String jsonApiRequest = apiRequestBodyAsJson; if (StringUtils.isBlank(jsonApiRequest)) { diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/RecurringDepositAccountTransactionsApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/RecurringDepositAccountTransactionsApiResourceSwagger.java new file mode 100644 index 000000000..9efa97f6f --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/RecurringDepositAccountTransactionsApiResourceSwagger.java @@ -0,0 +1,279 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.savings.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.math.BigDecimal; +import java.time.LocalDate; +import java.util.List; + +/** + * Created by Chirag Gupta on 12/31/17. + */ +final class RecurringDepositAccountTransactionsApiResourceSwagger { + private RecurringDepositAccountTransactionsApiResourceSwagger() { + } + + @ApiModel(value = "GetRecurringDepositAccountsRecurringDepositAccountIdTransactionsTemplateResponse") + public final static class GetRecurringDepositAccountsRecurringDepositAccountIdTransactionsTemplateResponse { + private GetRecurringDepositAccountsRecurringDepositAccountIdTransactionsTemplateResponse() { + } + + final class GetRecurringTransactionType { + private GetRecurringTransactionType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "savingsAccountTransactionType.deposit") + public String code; + @ApiModelProperty(example = "Deposit") + public String value; + @ApiModelProperty(example = "true") + public Boolean deposit; + @ApiModelProperty(example = "false") + public Boolean withdrawal; + @ApiModelProperty(example = "false") + public Boolean interestPosting; + @ApiModelProperty(example = "false") + public Boolean feeDeduction; + @ApiModelProperty(example = "false") + public Boolean initiateTransfer; + @ApiModelProperty(example = "false") + public Boolean approveTransfer; + @ApiModelProperty(example = "false") + public Boolean withdrawTransfer; + @ApiModelProperty(example = "false") + public Boolean rejectTransfer; + @ApiModelProperty(example = "false") + public Boolean overdraftInterest; + @ApiModelProperty(example = "false") + public Boolean writtenoff; + @ApiModelProperty(example = "true") + public Boolean overdraftFee; + } + + final class GetRecurringCurrency { + private GetRecurringCurrency() { + } + + @ApiModelProperty(example = "USD") + public String code; + @ApiModelProperty(example = "US Dollar") + public String name; + @ApiModelProperty(example = "4") + public Integer decimalPlaces; + @ApiModelProperty(example = "100") + public Integer inMultiplesOf; + @ApiModelProperty(example = "$") + public String displaySymbol; + @ApiModelProperty(example = "currency.USD") + public String nameCode; + @ApiModelProperty(example = "US Dollar ($)") + public String displayLabel; + } + + @ApiModelProperty(example = "1") + public Integer id; + public GetRecurringTransactionType transactionType; + @ApiModelProperty(example = "1") + public Integer accountId; + @ApiModelProperty(example = "000000001") + public String accountNo; + @ApiModelProperty(example = "[2014, 6, 25]") + public LocalDate date; + public GetRecurringCurrency currency; + @ApiModelProperty(example = "100000.000000") + public BigDecimal amount; + @ApiModelProperty(example = "false") + public Boolean reversed; + @ApiModelProperty(example = "[]") + public List paymentTypeOptions; + } + + @ApiModel(value = "GetRecurringDepositAccountsRecurringDepositAccountIdTransactionsTransactionIdResponse") + public final static class GetRecurringDepositAccountsRecurringDepositAccountIdTransactionsTransactionIdResponse { + private GetRecurringDepositAccountsRecurringDepositAccountIdTransactionsTransactionIdResponse() { + } + + final class GetRecurringTransactionsCurrency { + private GetRecurringTransactionsCurrency() { + } + + @ApiModelProperty(example = "USD") + public String code; + @ApiModelProperty(example = "US Dollar") + public String name; + @ApiModelProperty(example = "2") + public Integer decimalPlaces; + @ApiModelProperty(example = "0") + public Integer inMultiplesOf; + @ApiModelProperty(example = "$") + public String displaySymbol; + @ApiModelProperty(example = "currency.USD") + public String nameCode; + @ApiModelProperty(example = "US Dollar ($)") + public String displayLabel; + } + + final class GetRecurringTransactionsTransactionType { + private GetRecurringTransactionsTransactionType() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "savingsAccountTransactionType.withdrawal") + public String code; + @ApiModelProperty(example = "Withdrawal") + public String value; + @ApiModelProperty(example = "false") + public Boolean deposit; + @ApiModelProperty(example = "true") + public Boolean withdrawal; + @ApiModelProperty(example = "false") + public Boolean interestPosting; + @ApiModelProperty(example = "false") + public Boolean feeDeduction; + } + + final class GetRecurringPaymentDetailData { + private GetRecurringPaymentDetailData() { + } + + final class GetRecurringPaymentType { + private GetRecurringPaymentType() { + } + + @ApiModelProperty(example = "11") + public Integer id; + @ApiModelProperty(example = "cash") + public String name; + } + + @ApiModelProperty(example = "62") + public Integer id; + public GetRecurringPaymentType paymentType; + @ApiModelProperty(example = "") + public Integer accountNumber; + @ApiModelProperty(example = "") + public Integer checkNumber; + @ApiModelProperty(example = "") + public Integer routingCode; + @ApiModelProperty(example = "") + public Integer receiptNumber; + @ApiModelProperty(example = "") + public Integer bankNumber; + } + + @ApiModelProperty(example = "1") + public Integer id; + public GetRecurringTransactionsTransactionType transactionType; + @ApiModelProperty(example = "1") + public Integer accountId; + @ApiModelProperty(example = "000000001") + public String accountNo; + @ApiModelProperty(example = "[2013, 8, 7]") + public LocalDate date; + public GetRecurringTransactionsCurrency currency; + public GetRecurringPaymentDetailData paymentDetailData; + @ApiModelProperty(example = "5000") + public Float amount; + @ApiModelProperty(example = "0") + public Integer runningBalance; + @ApiModelProperty(example = "true") + public Boolean reversed; + } + + @ApiModel(value = "PostRecurringDepositAccountsRecurringDepositAccountIdTransactionsRequest") + public final static class PostRecurringDepositAccountsRecurringDepositAccountIdTransactionsRequest { + private PostRecurringDepositAccountsRecurringDepositAccountIdTransactionsRequest() { + } + + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "dd MMMM yyyy") + public String dateFormat; + @ApiModelProperty(example = "27 May 2013") + public String transactionDate; + @ApiModelProperty(example = "500") + public Double transactionAmount; + @ApiModelProperty(example = "14") + public Integer paymentTypeId; + @ApiModelProperty(example = "acc123") + public String accountNumber; + @ApiModelProperty(example = "che123") + public String checkNumber; + @ApiModelProperty(example = "rou123") + public String routingCode; + @ApiModelProperty(example = "rec123") + public String receiptNumber; + @ApiModelProperty(example = "ban123") + public String bankNumber; + } + + @ApiModel(value = "PostRecurringDepositAccountsRecurringDepositAccountIdTransactionsResponse") + public final static class PostRecurringDepositAccountsRecurringDepositAccountIdTransactionsResponse { + private PostRecurringDepositAccountsRecurringDepositAccountIdTransactionsResponse() { + } + + final class PostRecurringChanges { + private PostRecurringChanges() { + } + + @ApiModelProperty(example = "acc123") + public String accountNumber; + @ApiModelProperty(example = "che123") + public String checkNumber; + @ApiModelProperty(example = "rou123") + public String routingCode; + @ApiModelProperty(example = "rec123") + public String receiptNumber; + @ApiModelProperty(example = "ban123") + public String bankNumber; + } + + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "2") + public Integer clientId; + @ApiModelProperty(example = "1") + public Integer savingsId; + @ApiModelProperty(example = "47") + public Integer resourceId; + public PostRecurringChanges changes; + } + + @ApiModel(value = "PostRecurringDepositAccountsRecurringDepositAccountIdTransactionsTransactionIdResponse") + public final static class PostRecurringDepositAccountsRecurringDepositAccountIdTransactionsTransactionIdResponse { + private PostRecurringDepositAccountsRecurringDepositAccountIdTransactionsTransactionIdResponse() { + } + + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "2") + public Integer clientId; + @ApiModelProperty(example = "1") + public Integer savingsId; + @ApiModelProperty(example = "48") + public Integer resourceId; + public PostRecurringDepositAccountsRecurringDepositAccountIdTransactionsResponse.PostRecurringChanges changes; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/RecurringDepositAccountsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/RecurringDepositAccountsApiResource.java index bedfadc6e..575f10c6e 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/RecurringDepositAccountsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/RecurringDepositAccountsApiResource.java @@ -18,25 +18,8 @@ */ package org.apache.fineract.portfolio.savings.api; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriInfo; - +import com.google.gson.JsonElement; +import io.swagger.annotations.*; import org.apache.commons.lang.StringUtils; import org.apache.fineract.commands.domain.CommandWrapper; import org.apache.fineract.commands.service.CommandWrapperBuilder; @@ -67,11 +50,19 @@ import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; -import com.google.gson.JsonElement; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; @Path("/recurringdepositaccounts") @Component @Scope("singleton") +@Api(value = "Recurring Deposit Account", description = "Recurring Deposit accounts are instances of a praticular recurring deposit product created. An application process around the creation of accounts is also supported.") public class RecurringDepositAccountsApiResource { private final DepositAccountReadPlatformService depositAccountReadPlatformService; @@ -104,10 +95,12 @@ public class RecurringDepositAccountsApiResource { @Path("template") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String template(@QueryParam("clientId") final Long clientId, @QueryParam("groupId") final Long groupId, - @QueryParam("productId") final Long productId, - @DefaultValue("false") @QueryParam("staffInSelectedOfficeOnly") final boolean staffInSelectedOfficeOnly, - @Context final UriInfo uriInfo) { + @ApiOperation(value = "Retrieve recurring Deposit Account Template", httpMethod = "GET", notes = "This is a convenience resource. It can be useful when building maintenance user interface screens for recurring deposit applications. The template data returned consists of any or all of:\n" + "\n" + "Field Defaults\n" + "Allowed Value Lists\n\n" + "Example Requests:\n" + "\n" + "recurringdepositaccounts/template?clientId=1\n" + "\n" + "\n" + "recurringdepositaccounts/template?clientId=1&productId=1") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = RecurringDepositAccountsApiResourceSwagger.GetRecurringDepositAccountsTemplateResponse.class)}) + public String template(@QueryParam("clientId") @ApiParam(value = "clientId") final Long clientId, @QueryParam("groupId") @ApiParam(value = "groupId") final Long groupId, + @QueryParam("productId") @ApiParam(value = "productId") final Long productId, + @DefaultValue("false") @QueryParam("staffInSelectedOfficeOnly") @ApiParam(value = "staffInSelectedOfficeOnly") final boolean staffInSelectedOfficeOnly, + @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(DepositsApiConstants.RECURRING_DEPOSIT_ACCOUNT_RESOURCE_NAME); @@ -122,9 +115,11 @@ public class RecurringDepositAccountsApiResource { @GET @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveAll(@Context final UriInfo uriInfo, @QueryParam("paged") final Boolean paged, - @QueryParam("offset") final Integer offset, @QueryParam("limit") final Integer limit, - @QueryParam("orderBy") final String orderBy, @QueryParam("sortOrder") final String sortOrder) { + @ApiOperation(value = "List Recurring deposit applications/accounts", httpMethod = "GET", notes = "Lists Recurring deposit applications/accounts\n\n" + "Example Requests:\n" + "\n" + "recurringdepositaccounts\n" + "\n" + "\n" + "recurringdepositaccounts?fields=name") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = RecurringDepositAccountsApiResourceSwagger.GetRecurringDepositAccountsResponse.class, responseContainer = "List")}) + public String retrieveAll(@Context final UriInfo uriInfo, @QueryParam("paged") @ApiParam(value = "paged") final Boolean paged, + @QueryParam("offset") @ApiParam(value = "offset") final Integer offset, @QueryParam("limit") @ApiParam(value = "limit") final Integer limit, + @QueryParam("orderBy") @ApiParam(value = "orderBy") final String orderBy, @QueryParam("sortOrder") @ApiParam(value = "sortOrder") final String sortOrder) { this.context.authenticatedUser().validateHasReadPermission(DepositsApiConstants.RECURRING_DEPOSIT_ACCOUNT_RESOURCE_NAME); final PaginationParameters paginationParameters = PaginationParameters.instance(paged, offset, limit, orderBy, sortOrder); @@ -147,7 +142,10 @@ public class RecurringDepositAccountsApiResource { @POST @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String submitApplication(final String apiRequestBodyAsJson) { + @ApiOperation(value = "Submit new recurring deposit application", httpMethod = "POST", notes = "Submits new recurring deposit application\n\n" + "Mandatory Fields: clientId or groupId, productId, submittedOnDate, depositAmount, depositPeriod, depositPeriodFrequencyId\n\n" + "Optional Fields: accountNo, externalId, fieldOfficerId,linkAccountId(if provided initial deposit amount will be collected from this account),transferInterestToSavings(By enabling this flag all interest postings will be transferred to linked saving account )\n\n" + "Inherited from Product (if not provided): interestCompoundingPeriodType, interestCalculationType, interestCalculationDaysInYearType, lockinPeriodFrequency, lockinPeriodFrequencyType, preClosurePenalApplicable, preClosurePenalInterest, preClosurePenalInterestOnTypeId, charts, withHoldTax") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = RecurringDepositAccountsApiResourceSwagger.PostRecurringDepositAccountsRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = RecurringDepositAccountsApiResourceSwagger.PostRecurringDepositAccountsResponse.class)}) + public String submitApplication(@ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder().createRecurringDepositAccount().withJson(apiRequestBodyAsJson) .build(); @@ -161,9 +159,11 @@ public class RecurringDepositAccountsApiResource { @Path("{accountId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveOne(@PathParam("accountId") final Long accountId, - @DefaultValue("false") @QueryParam("staffInSelectedOfficeOnly") final boolean staffInSelectedOfficeOnly, - @DefaultValue("all") @QueryParam("chargeStatus") final String chargeStatus, @Context final UriInfo uriInfo) { + @ApiOperation(value = "Retrieve a recurring deposit application/account", httpMethod = "GET", notes = "Retrieves a recurring deposit application/account\n\n" + "Example Requests :\n" + "\n" + "recurringdepositaccounts/1\n" + "\n" + "\n" + "recurringdepositaccounts/1?associations=all") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = RecurringDepositAccountsApiResourceSwagger.GetRecurringDepositAccountsAccountIdResponse.class)}) + public String retrieveOne(@PathParam("accountId") @ApiParam(value = "accountId") final Long accountId, + @DefaultValue("false") @QueryParam("staffInSelectedOfficeOnly") @ApiParam(value = "staffInSelectedOfficeOnly") final boolean staffInSelectedOfficeOnly, + @DefaultValue("all") @QueryParam("chargeStatus") @ApiParam(value = "chargeStatus") final String chargeStatus, @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(DepositsApiConstants.RECURRING_DEPOSIT_ACCOUNT_RESOURCE_NAME); @@ -232,7 +232,10 @@ public class RecurringDepositAccountsApiResource { @Path("{accountId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String update(@PathParam("accountId") final Long accountId, final String apiRequestBodyAsJson) { + @ApiOperation(value = "Modify a recurring deposit application", httpMethod = "PUT", notes = "Recurring deposit application can only be modified when in 'Submitted and pending approval' state. Once the application is approved, the details cannot be changed using this method. Specific api endpoints will be created to allow change of interest detail such as rate, compounding period, posting period etc") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = RecurringDepositAccountsApiResourceSwagger.PutRecurringDepositAccountsAccountIdRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = RecurringDepositAccountsApiResourceSwagger.PutRecurringDepositAccountsAccountIdResponse.class)}) + public String update(@PathParam("accountId") @ApiParam(value = "accountId") final Long accountId, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder().updateRecurringDepositAccount(accountId) .withJson(apiRequestBodyAsJson).build(); @@ -246,8 +249,11 @@ public class RecurringDepositAccountsApiResource { @Path("{accountId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String handleCommands(@PathParam("accountId") final Long accountId, @QueryParam("command") final String commandParam, - @Context final UriInfo uriInfo, final String apiRequestBodyAsJson) { + @ApiOperation(value = "Approve recurring deposit application | Undo approval recurring deposit application | Reject recurring deposit application | Withdraw recurring deposit application | Activate a recurring deposit account | Update the recommended deposit amount for a recurring deposit account | Close a recurring deposit account | Premature Close a recurring deposit account | Calculate Premature amount on Recurring deposit account | Calculate Interest on recurring Deposit Account | Post Interest on recurring Deposit Account", httpMethod = "POST", notes = "Approve recurring deposit application:\n\n" + "Approves recurring deposit application so long as its in 'Submitted and pending approval' state.\n\n" + "Undo approval recurring deposit application:\n\n" + "Will move 'approved' recurring deposit application back to 'Submitted and pending approval' state.\n\n" + "Reject recurring deposit application\n\n" + "Rejects recurring deposit application so long as its in 'Submitted and pending approval' state.\n\n" + "Withdraw recurring deposit application:\n\n" + "Used when an applicant withdraws from the recurring deposit application. It must be in 'Submitted and pending approval' state.\n\n" + "Activate a recurring deposit account:\n\n" + "Results in an approved recurring deposit application being converted into an 'active' recurring deposit account.\n\n" + "Update the recommended deposit amount for a recurring deposit account:\n\n" + "Updates the recommended deposit amount for a RD account as on the effective date.\n\n" + "Close a recurring deposit account\n\n" + "Results in a Matured recurring deposit account being converted into a 'closed' recurring deposit account.\n" + "\n" + "On account close allowed actions are." + "Premature Close a recurring deposit account:\n\n" + "Results in an Active recurring deposit account being converted into a 'Premature Closed' recurring deposit account with options to withdraw prematured amount. (premature amount is calculated using interest rate chart applicable along with penal interest if any.)\n" + "\n" + "On account premature closure allowed actions are.\n\n" + "Calculate Premature amount on Recurring deposit account:\n\n" + "Calculate premature amount on recurring deposit till premature close date. Premature amount is calculated based on interest chart and penal interest applicable if any.\n\n" + "Calculate Interest on recurring Deposit Account:\n\n" + "Calculates interest earned on a recurring deposit account based on todays date. It does not attempt to post or credit the interest on the account. That is responsibility of the Post Interest API that will likely be called by overnight process.\n\n" + "Post Interest on recurring Deposit Account:\n\n" + "Calculates and Posts interest earned on a recurring deposit account based on todays date and whether an interest posting or crediting event is due.\n\n" + "Showing request/response for 'Post Interest on recurring Deposit Account'") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = RecurringDepositAccountsApiResourceSwagger.PostRecurringDepositAccountsAccountIdRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = RecurringDepositAccountsApiResourceSwagger.PostRecurringDepositAccountsAccountIdResponse.class)}) + public String handleCommands(@PathParam("accountId") @ApiParam(value = "accountId") final Long accountId, @QueryParam("command") @ApiParam(value = "command") final String commandParam, + @Context final UriInfo uriInfo, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { String jsonApiRequest = apiRequestBodyAsJson; if (StringUtils.isBlank(jsonApiRequest)) { @@ -313,7 +319,9 @@ public class RecurringDepositAccountsApiResource { @Path("{accountId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String delete(@PathParam("accountId") final Long accountId) { + @ApiOperation(value = "Delete a recurring deposit application", httpMethod = "DELETE", notes = "At present we support hard delete of recurring deposit application so long as its in 'Submitted and pending approval' state. One the application is moves past this state, it is not possible to do a 'hard' delete of the application or the account. An API endpoint will be added to close/de-activate the recurring deposit account.") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = RecurringDepositAccountsApiResourceSwagger.DeleteRecurringDepositAccountsResponse.class)}) + public String delete(@PathParam("accountId") @ApiParam(value = "accountId") final Long accountId) { final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteRecurringDepositAccount(accountId).build(); @@ -326,7 +334,7 @@ public class RecurringDepositAccountsApiResource { @Path("{accountId}/template") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String accountClosureTemplate(@PathParam("accountId") final Long accountId, @QueryParam("command") final String commandParam, + public String accountClosureTemplate(@PathParam("accountId") @ApiParam(value = "accountId") final Long accountId, @QueryParam("command") @ApiParam(value = "command") final String commandParam, @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(DepositsApiConstants.RECURRING_DEPOSIT_ACCOUNT_RESOURCE_NAME); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/RecurringDepositAccountsApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/RecurringDepositAccountsApiResourceSwagger.java new file mode 100644 index 000000000..3e7bdda48 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/RecurringDepositAccountsApiResourceSwagger.java @@ -0,0 +1,516 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.savings.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.time.LocalDate; +import java.util.Set; + +/** + * Created by Chirag Gupta on 12/26/17. + */ +final class RecurringDepositAccountsApiResourceSwagger { + private RecurringDepositAccountsApiResourceSwagger() { + } + + @ApiModel(value = "GetRecurringDepositAccountsTemplateResponse") + public final static class GetRecurringDepositAccountsTemplateResponse { + private GetRecurringDepositAccountsTemplateResponse() { + } + + final class GetRecurringProductOptions { + private GetRecurringProductOptions() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "Passbook Savings") + public String name; + } + + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "small business") + public String clientName; + public Set productOptions; + } + + @ApiModel(value = "GetRecurringDepositAccountsResponse") + public final static class GetRecurringDepositAccountsResponse { + private GetRecurringDepositAccountsResponse() { + } + + final class GetRecurringDepositAccountsStatus { + private GetRecurringDepositAccountsStatus() { + } + + @ApiModelProperty(example = "100") + public Integer id; + @ApiModelProperty(example = "savingsAccountStatusType.submitted.and.pending.approval") + public String code; + @ApiModelProperty(example = "Submitted and pending approval") + public String value; + @ApiModelProperty(example = "true") + public Boolean submittedAndPendingApproval; + @ApiModelProperty(example = "false") + public Boolean approved; + @ApiModelProperty(example = "false") + public Boolean rejected; + @ApiModelProperty(example = "false") + public Boolean withdrawnByApplicant; + @ApiModelProperty(example = "false") + public Boolean active; + @ApiModelProperty(example = "false") + public Boolean closed; + @ApiModelProperty(example = "false") + public Boolean prematureClosed; + @ApiModelProperty(example = "false") + public Boolean transferInProgress; + @ApiModelProperty(example = "false") + public Boolean transferOnHold; + } + + final class GetRecurringDepositAccountsTimeline { + private GetRecurringDepositAccountsTimeline() { + } + + @ApiModelProperty(example = "[2014, 3, 1]") + public LocalDate submittedOnDate; + @ApiModelProperty(example = "mifos") + public String submittedByUsername; + @ApiModelProperty(example = "App") + public String submittedByFirstname; + @ApiModelProperty(example = "Administrator") + public String submittedByLastname; + } + + final class GetRecurringDepositAccountsCurrency { + private GetRecurringDepositAccountsCurrency() { + } + + @ApiModelProperty(example = "USD") + public String code; + @ApiModelProperty(example = "US Dollar") + public String name; + @ApiModelProperty(example = "2") + public Integer decimalPlaces; + @ApiModelProperty(example = "1") + public Integer inMultiplesOf; + @ApiModelProperty(example = "$") + public String displaySymbol; + @ApiModelProperty(example = "currency.USD") + public String nameCode; + @ApiModelProperty(example = "US Dollar ($)") + public String displayLabel; + } + + final class GetRecurringDepositAccountsInterestCompoundingPeriodType { + private GetRecurringDepositAccountsInterestCompoundingPeriodType() { + } + + @ApiModelProperty(example = "4") + public Integer id; + @ApiModelProperty(example = "savings.interest.period.savingsCompoundingInterestPeriodType.monthly") + public String code; + @ApiModelProperty(example = "Monthly") + public String value; + } + + final class GetRecurringDepositAccountsInterestPostingPeriodType { + private GetRecurringDepositAccountsInterestPostingPeriodType() { + } + + @ApiModelProperty(example = "4") + public Integer id; + @ApiModelProperty(example = "savings.interest.posting.period.savingsPostingInterestPeriodType.monthly") + public String code; + @ApiModelProperty(example = "Monthly") + public String value; + } + + final class GetRecurringDepositAccountsInterestCalculationType { + private GetRecurringDepositAccountsInterestCalculationType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "savingsInterestCalculationType.dailybalance") + public String code; + @ApiModelProperty(example = "Daily Balance") + public String value; + } + + final class GetRecurringDepositAccountsInterestCalculationDaysInYearType { + private GetRecurringDepositAccountsInterestCalculationDaysInYearType() { + } + + @ApiModelProperty(example = "365") + public Integer id; + @ApiModelProperty(example = "savingsInterestCalculationDaysInYearType.days365") + public String code; + @ApiModelProperty(example = "365 Days") + public String value; + } + + final class GetRecurringDepositAccountsSummary { + private GetRecurringDepositAccountsSummary() { + } + + public GetRecurringDepositAccountsCurrency currency; + @ApiModelProperty(example = "0") + public Float accountBalance; + } + + final class GetRecurringDepositAccountsMinDepositTermType { + private GetRecurringDepositAccountsMinDepositTermType() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "deposit.term.savingsPeriodFrequencyType.months") + public String code; + @ApiModelProperty(example = "Months") + public String value; + } + + final class GetRecurringDepositAccountsMaxDepositTermType { + private GetRecurringDepositAccountsMaxDepositTermType() { + } + + @ApiModelProperty(example = "3") + public Integer id; + @ApiModelProperty(example = "deposit.term.savingsPeriodFrequencyType.years") + public String code; + @ApiModelProperty(example = "Years") + public String value; + } + + final class GetRecurringDepositAccountsDepositPeriodFrequency { + private GetRecurringDepositAccountsDepositPeriodFrequency() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "deposit.period.savingsPeriodFrequencyType.months") + public String code; + @ApiModelProperty(example = "Months") + public String value; + } + + final class GetRecurringDepositAccountsRecurringDepositFrequencyType { + private GetRecurringDepositAccountsRecurringDepositFrequencyType() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "recurring.deposit.savingsPeriodFrequencyType.months") + public String code; + @ApiModelProperty(example = "Months") + public String value; + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "000000001") + public Long accountNo; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "Sangamesh N") + public String clientName; + @ApiModelProperty(example = "3") + public Integer savingsProductId; + @ApiModelProperty(example = "RD01") + public String savingsProductName; + @ApiModelProperty(example = "0") + public Integer fieldOfficerId; + public GetRecurringDepositAccountsStatus status; + public GetRecurringDepositAccountsTimeline timeline; + public GetRecurringDepositAccountsCurrency currency; + public GetRecurringDepositAccountsInterestCompoundingPeriodType interestCompoundingPeriodType; + public GetRecurringDepositAccountsInterestPostingPeriodType interestPostingPeriodType; + public GetRecurringDepositAccountsInterestCalculationType interestCalculationType; + public GetRecurringDepositAccountsInterestCalculationDaysInYearType interestCalculationDaysInYearType; + public GetRecurringDepositAccountsSummary summary; + @ApiModelProperty(example = "1150") + public Float depositAmount; + @ApiModelProperty(example = "252.59") + public Float maturityAmount; + @ApiModelProperty(example = "[2014, 4, 3]") + public LocalDate maturityDate; + @ApiModelProperty(example = "100") + public Integer recurringDepositAmount; + @ApiModelProperty(example = "1") + public Integer recurringDepositFrequency; + public GetRecurringDepositAccountsRecurringDepositFrequencyType recurringDepositFrequencyType; + @ApiModelProperty(example = "false") + public Boolean preClosurePenalApplicable; + @ApiModelProperty(example = "3") + public Integer minDepositTerm; + @ApiModelProperty(example = "4") + public Integer maxDepositTerm; + public GetRecurringDepositAccountsMinDepositTermType minDepositTermType; + public GetRecurringDepositAccountsMaxDepositTermType maxDepositTermType; + @ApiModelProperty(example = "6") + public Integer depositPeriod; + public GetRecurringDepositAccountsDepositPeriodFrequency depositPeriodFrequency; + } + + @ApiModel(value = "PostRecurringDepositAccountsRequest") + public final static class PostRecurringDepositAccountsRequest { + private PostRecurringDepositAccountsRequest() { + } + + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "1") + public Integer productId; + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "dd MMMM yyyy") + public String dateFormat; + @ApiModelProperty(example = "02 June 2014") + public String submittedOnDate; + @ApiModelProperty(example = "20") + public Integer depositPeriod; + @ApiModelProperty(example = "1") + public Integer depositPeriodFrequencyId; + @ApiModelProperty(example = "10000") + public Float depositAmount; + @ApiModelProperty(example = "false") + public Boolean isCalendarInherited; + @ApiModelProperty(example = "2") + public Integer recurringFrequency; + @ApiModelProperty(example = "1") + public Integer recurringFrequencyType; + @ApiModelProperty(example = "2000") + public Long mandatoryRecommendedDepositAmount; + } + + @ApiModel(value = "PostRecurringDepositAccountsResponse") + public final static class PostRecurringDepositAccountsResponse { + private PostRecurringDepositAccountsResponse() { + } + + @ApiModelProperty(example = "2") + public Integer officeId; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "1") + public Integer savingsId; + @ApiModelProperty(example = "1") + public Integer resourceId; + } + + @ApiModel(value = "GetRecurringDepositAccountsAccountIdResponse") + public final static class GetRecurringDepositAccountsAccountIdResponse { + private GetRecurringDepositAccountsAccountIdResponse() { + } + + final class GetRecurringDepositAccountsAccountChart { + private GetRecurringDepositAccountsAccountChart() { + } + + final class GetRecurringDepositAccountsChartSlabs { + private GetRecurringDepositAccountsChartSlabs() { + } + + final class GetRecurringDepositAccountsPeriodType { + private GetRecurringDepositAccountsPeriodType() { + } + + @ApiModelProperty(example = "0") + public Integer id; + @ApiModelProperty(example = "interestChartPeriodType.days") + public String code; + @ApiModelProperty(example = "Days") + public String value; + } + + final class GetRecurringDepositAccountsAccountChartCurrency { + private GetRecurringDepositAccountsAccountChartCurrency() { + } + + @ApiModelProperty(example = "USD") + public String code; + @ApiModelProperty(example = "US Dollar") + public String name; + @ApiModelProperty(example = "2") + public Integer decimalPlaces; + @ApiModelProperty(example = "$") + public String displaySymbol; + @ApiModelProperty(example = "currency.USD") + public String nameCode; + @ApiModelProperty(example = "US Dollar ($)") + public String displayLabel; + } + + @ApiModelProperty(example = "13") + public Integer id; + public GetRecurringDepositAccountsPeriodType periodType; + @ApiModelProperty(example = "181") + public Integer fromPeriod; + @ApiModelProperty(example = "365") + public Integer toPeriod; + @ApiModelProperty(example = "5.5") + public Double annualInterestRate; + public GetRecurringDepositAccountsAccountChartCurrency currency; + } + + final class GetRecurringDepositAccountsPeriodTypes { + private GetRecurringDepositAccountsPeriodTypes() { + } + + @ApiModelProperty(example = "0") + public Integer id; + @ApiModelProperty(example = "interestChartPeriodType.days") + public String code; + @ApiModelProperty(example = "Days") + public String value; + } + + @ApiModelProperty(example = "4") + public Integer id; + @ApiModelProperty(example = "[2013, 10, 2]") + public LocalDate fromDate; + @ApiModelProperty(example = "5") + public Integer accountId; + @ApiModelProperty(example = "RD000023") + public Long accountNumber; + public Set chartSlabs; + public Set periodTypes; + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "RD000023") + public Long accountNo; + @ApiModelProperty(example = "RD-23") + public String externalId; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "Sangamesh N") + public String clientName; + @ApiModelProperty(example = "3") + public Integer savingsProductId; + @ApiModelProperty(example = "RD01") + public String savingsProductName; + @ApiModelProperty(example = "0") + public Integer fieldOfficerId; + public GetRecurringDepositAccountsResponse.GetRecurringDepositAccountsStatus status; + public GetRecurringDepositAccountsResponse.GetRecurringDepositAccountsTimeline timeline; + public GetRecurringDepositAccountsResponse.GetRecurringDepositAccountsCurrency currency; + public GetRecurringDepositAccountsResponse.GetRecurringDepositAccountsInterestCompoundingPeriodType interestCompoundingPeriodType; + public GetRecurringDepositAccountsResponse.GetRecurringDepositAccountsInterestPostingPeriodType interestPostingPeriodType; + public GetRecurringDepositAccountsResponse.GetRecurringDepositAccountsInterestCalculationType interestCalculationType; + public GetRecurringDepositAccountsResponse.GetRecurringDepositAccountsInterestCalculationDaysInYearType interestCalculationDaysInYearType; + @ApiModelProperty(example = "false") + public Boolean preClosurePenalApplicable; + @ApiModelProperty(example = "3") + public Integer minDepositTerm; + @ApiModelProperty(example = "4") + public Integer maxDepositTerm; + public GetRecurringDepositAccountsResponse.GetRecurringDepositAccountsMinDepositTermType minDepositTermType; + public GetRecurringDepositAccountsResponse.GetRecurringDepositAccountsMaxDepositTermType maxDepositTermType; + @ApiModelProperty(example = "100") + public Integer recurringDepositAmount; + @ApiModelProperty(example = "1") + public Integer recurringDepositFrequency; + @ApiModelProperty(example = "[2014, 4, 2]") + public LocalDate expectedFirstDepositOnDate; + public GetRecurringDepositAccountsResponse.GetRecurringDepositAccountsRecurringDepositFrequencyType recurringDepositFrequencyType; + @ApiModelProperty(example = "6") + public Integer depositPeriod; + public GetRecurringDepositAccountsResponse.GetRecurringDepositAccountsDepositPeriodFrequency depositPeriodFrequency; + public GetRecurringDepositAccountsResponse.GetRecurringDepositAccountsSummary summary; + public GetRecurringDepositAccountsAccountChart accountChart; + } + + @ApiModel(value = "PutRecurringDepositAccountsAccountIdRequest") + public final static class PutRecurringDepositAccountsAccountIdRequest { + private PutRecurringDepositAccountsAccountIdRequest() { + } + + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "6000") + public Integer depositAmount; + } + + @ApiModel(value = "PutRecurringDepositAccountsAccountIdResponse") + public final static class PutRecurringDepositAccountsAccountIdResponse { + private PutRecurringDepositAccountsAccountIdResponse() { + } + + final class PutRecurringDepositAccountsChanges { + private PutRecurringDepositAccountsChanges() { + } + + @ApiModelProperty(example = "6000") + public Integer depositAmount; + @ApiModelProperty(example = "en") + public String locale; + } + + @ApiModelProperty(example = "2") + public Integer officeId; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "1") + public Integer savingsId; + @ApiModelProperty(example = "1") + public Integer resourceId; + public PutRecurringDepositAccountsChanges changes; + } + + @ApiModel(value = "PostRecurringDepositAccountsAccountIdRequest") + public final static class PostRecurringDepositAccountsAccountIdRequest { + private PostRecurringDepositAccountsAccountIdRequest() { + } + } + + @ApiModel(value = "PostRecurringDepositAccountsAccountIdResponse") + public final static class PostRecurringDepositAccountsAccountIdResponse { + private PostRecurringDepositAccountsAccountIdResponse() { + } + + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "1") + public Integer savingsId; + @ApiModelProperty(example = "1") + public Integer resourceId; + } + + @ApiModel(value = "DeleteRecurringDepositAccountsResponse") + public final static class DeleteRecurringDepositAccountsResponse { + private DeleteRecurringDepositAccountsResponse() { + } + + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "1") + public Integer resourceId; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/RecurringDepositProductsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/RecurringDepositProductsApiResource.java index cd0b7b711..ea475bb2c 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/RecurringDepositProductsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/RecurringDepositProductsApiResource.java @@ -18,23 +18,7 @@ */ package org.apache.fineract.portfolio.savings.api; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriInfo; - +import io.swagger.annotations.*; import org.apache.fineract.accounting.common.AccountingDropdownReadPlatformService; import org.apache.fineract.accounting.common.AccountingEnumerations; import org.apache.fineract.accounting.common.AccountingRuleType; @@ -60,12 +44,7 @@ import org.apache.fineract.portfolio.interestratechart.data.InterestRateChartDat import org.apache.fineract.portfolio.interestratechart.service.InterestRateChartReadPlatformService; import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeData; import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadPlatformService; -import org.apache.fineract.portfolio.savings.DepositAccountType; -import org.apache.fineract.portfolio.savings.DepositsApiConstants; -import org.apache.fineract.portfolio.savings.SavingsCompoundingInterestPeriodType; -import org.apache.fineract.portfolio.savings.SavingsInterestCalculationDaysInYearType; -import org.apache.fineract.portfolio.savings.SavingsInterestCalculationType; -import org.apache.fineract.portfolio.savings.SavingsPostingInterestPeriodType; +import org.apache.fineract.portfolio.savings.*; import org.apache.fineract.portfolio.savings.data.RecurringDepositProductData; import org.apache.fineract.portfolio.savings.service.DepositProductReadPlatformService; import org.apache.fineract.portfolio.savings.service.DepositsDropdownReadPlatformService; @@ -78,9 +57,19 @@ import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; + @Path("/recurringdepositproducts") @Component @Scope("singleton") +@Api(value = "Recurring Deposit Product", description = "Recurring Deposits are a special kind of Term Deposits offered by MFI's. The Recurring Deposit Products (aka RD) product offerings are modeled using this API.\n" + "\n" + "Recurring Deposits help people with regular incomes to deposit a fixed amount every month (specified recurring frequency) into their Recurring Deposit account.\n" + "\n" + "When creating recurring deposit accounts, the details from the recurring deposit product are used to auto fill details of the recurring deposit account application process.") public class RecurringDepositProductsApiResource { private final DepositProductReadPlatformService depositProductReadPlatformService; @@ -135,7 +124,10 @@ public class RecurringDepositProductsApiResource { @POST @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String create(final String apiRequestBodyAsJson) { + @ApiOperation(value = "Create a Recurring Deposit Product", httpMethod = "POST", notes = "Creates a Recurring Deposit Product\n\n" + "Mandatory Fields: name, shortName, description, currencyCode, digitsAfterDecimal,inMultiplesOf, interestCompoundingPeriodType, interestCalculationType, interestCalculationDaysInYearType, minDepositTerm, minDepositTermTypeId, recurringDepositFrequency, recurringDepositFrequencyTypeId, accountingRule, depositAmount\n\n" + "Mandatory Fields for Cash based accounting (accountingRule = 2): savingsReferenceAccountId, savingsControlAccountId, interestOnSavingsAccountId, incomeFromFeeAccountId, transfersInSuspenseAccountId, incomeFromPenaltyAccountId\n\n" + "Optional Fields: lockinPeriodFrequency, lockinPeriodFrequencyType, maxDepositTerm, maxDepositTermTypeId, inMultiplesOfDepositTerm, inMultiplesOfDepositTermTypeId, preClosurePenalApplicable, preClosurePenalInterest, preClosurePenalInterestOnTypeId, feeToIncomeAccountMappings, penaltyToIncomeAccountMappings, charges, charts, minDepositAmount, maxDepositAmount, withHoldTax, taxGroupId") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = RecurringDepositProductsApiResourceSwagger.PostRecurringDepositProductsRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = RecurringDepositProductsApiResourceSwagger.PostRecurringDepositProductsResponse.class)}) + public String create(@ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder().createRecurringDepositProduct().withJson(apiRequestBodyAsJson) .build(); @@ -149,7 +141,10 @@ public class RecurringDepositProductsApiResource { @Path("{productId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String update(@PathParam("productId") final Long productId, final String apiRequestBodyAsJson) { + @ApiOperation(value = "Update a Recurring Deposit Product", httpMethod = "PUT", notes = "Updates a Recurring Deposit Product") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = RecurringDepositProductsApiResourceSwagger.PutRecurringDepositProductsRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = RecurringDepositProductsApiResourceSwagger.PutRecurringDepositProductsResponse.class)}) + public String update(@PathParam("productId") @ApiParam(value = "productId") final Long productId, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder().updateRecurringDepositProduct(productId) .withJson(apiRequestBodyAsJson).build(); @@ -163,6 +158,8 @@ public class RecurringDepositProductsApiResource { @GET @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) + @ApiOperation(value = "List Recuring Deposit Products", httpMethod = "GET", notes = "Lists Recuring Deposit Products\n\n" + "Example Requests:\n" + "\n" + "recurringdepositproducts\n" + "\n" + "\n" + "recurringdepositproducts?fields=name") + @ApiResponses({@ApiResponse(code = 200, message = "OK", responseContainer = "List", response = RecurringDepositProductsApiResourceSwagger.GetRecurringDepositProductsResponse.class)}) public String retrieveAll(@Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(DepositsApiConstants.RECURRING_DEPOSIT_PRODUCT_RESOURCE_NAME); @@ -180,7 +177,9 @@ public class RecurringDepositProductsApiResource { @Path("{productId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveOne(@PathParam("productId") final Long productId, @Context final UriInfo uriInfo) { + @ApiOperation(value = "Retrieve a Recurring Deposit Product", httpMethod = "GET", notes = "Retrieves a Recurring Deposit Product\n\n" + "Example Requests:\n" + "\n" + "recurringdepositproducts/1\n" + "\n" + "\n" + "recurringdepositproducts/1?template=true\n" + "\n" + "\n" + "recurringdepositproducts/1?fields=name,description") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = RecurringDepositProductsApiResourceSwagger.GetRecurringDepositProductsProductIdResponse.class)}) + public String retrieveOne(@PathParam("productId") @ApiParam(value = "productId") final Long productId, @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(DepositsApiConstants.RECURRING_DEPOSIT_PRODUCT_RESOURCE_NAME); @@ -316,7 +315,9 @@ public class RecurringDepositProductsApiResource { @Path("{productId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String delete(@PathParam("productId") final Long productId) { + @ApiOperation(value = "Delete a Recurring Deposit Product", httpMethod = "DELETE", notes = "Deletes a Recurring Deposit Product") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = RecurringDepositProductsApiResourceSwagger.DeleteRecurringDepositProductsProductIdResponse.class)}) + public String delete(@PathParam("productId") @ApiParam(value = "productId") final Long productId) { final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteRecurringDepositProduct(productId).build(); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/RecurringDepositProductsApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/RecurringDepositProductsApiResourceSwagger.java new file mode 100644 index 000000000..d25d4a675 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/RecurringDepositProductsApiResourceSwagger.java @@ -0,0 +1,612 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.savings.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.time.LocalDate; +import java.util.Set; + +/** + * Created by Chirag Gupta on 12/27/17. + */ +final class RecurringDepositProductsApiResourceSwagger { + private RecurringDepositProductsApiResourceSwagger() { + } + + @ApiModel(value = "PostRecurringDepositProductsRequest") + public final static class PostRecurringDepositProductsRequest { + private PostRecurringDepositProductsRequest() { + } + + final class PostRecurringDepositProductsCharts { + private PostRecurringDepositProductsCharts() { + } + + final class PostRecurringDepositProductsChartSlabs { + private PostRecurringDepositProductsChartSlabs() { + } + + @ApiModelProperty(example = "from 0 to 90 days") + public String description; + @ApiModelProperty(example = "1") + public Integer periodType; + @ApiModelProperty(example = "0") + public Integer fromPeriod; + @ApiModelProperty(example = "90") + public Integer toPeriod; + @ApiModelProperty(example = "4.5") + public Double annualInterestRate; + } + + @ApiModelProperty(example = "01 Jan 2014") + public String fromDate; + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "dd MMMM yyyy") + public String dateFormat; + public Set chartSlabs; + } + + @ApiModelProperty(example = "Recurring deposit product") + public String name; + @ApiModelProperty(example = "RD01") + public String shortName; + @ApiModelProperty(example = "Daily compounding using Daily Balance, 5% per year, 365 days in year") + public String description; + @ApiModelProperty(example = "USD") + public String currencyCode; + @ApiModelProperty(example = "2") + public Integer digitsAfterDecimal; + @ApiModelProperty(example = "0") + public Integer inMultiplesOf; + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "1") + public Integer interestCompoundingPeriodType; + @ApiModelProperty(example = "4") + public Integer interestPostingPeriodType; + @ApiModelProperty(example = "1") + public Integer interestCalculationType; + @ApiModelProperty(example = "365") + public Integer interestCalculationDaysInYearType; + @ApiModelProperty(example = "1") + public Integer accountingRule; + @ApiModelProperty(example = "1") + public Integer recurringDepositFrequency; + @ApiModelProperty(example = "2") + public Integer recurringDepositFrequencyTypeId; + @ApiModelProperty(example = "true") + public Boolean preClosurePenalApplicable; + @ApiModelProperty(example = "1.75") + public Double preClosurePenalInterest; + @ApiModelProperty(example = "1") + public Integer preClosurePenalInterestOnTypeId; + @ApiModelProperty(example = "1") + public Integer minDepositTerm; + @ApiModelProperty(example = "1") + public Integer minDepositTermTypeId; + @ApiModelProperty(example = "5") + public Integer maxDepositTerm; + @ApiModelProperty(example = "3") + public Integer maxDepositTermTypeId; + @ApiModelProperty(example = "10000") + public Long depositAmount; + @ApiModelProperty(example = "100") + public Long minDepositAmount; + @ApiModelProperty(example = "1000000") + public Long maxDepositAmount; + public Set charts; + } + + @ApiModel(value = "PostRecurringDepositProductsResponse") + public final static class PostRecurringDepositProductsResponse { + private PostRecurringDepositProductsResponse() { + } + + @ApiModelProperty(example = "1") + public Integer resourceId; + } + + @ApiModel(value = "PutRecurringDepositProductsRequest") + public final static class PutRecurringDepositProductsRequest { + private PutRecurringDepositProductsRequest() { + } + + @ApiModelProperty(example = "Recurring deposit product new offerings") + public String description; + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "5") + public Integer minDepositTerm; + @ApiModelProperty(example = "1") + public Integer minDepositTermTypeId; + } + + @ApiModel(value = "PutRecurringDepositProductsResponse") + public final static class PutRecurringDepositProductsResponse { + private PutRecurringDepositProductsResponse() { + } + + final class PutRecurringDepositProductsChanges { + private PutRecurringDepositProductsChanges() { + } + + @ApiModelProperty(example = "Recurring deposit product new offerings") + public String description; + @ApiModelProperty(example = "5") + public Integer minDepositTerm; + } + + @ApiModelProperty(example = "1") + public Integer resourceId; + public PutRecurringDepositProductsChanges changes; + } + + @ApiModel(value = "GetRecurringDepositProductsResponse") + public final static class GetRecurringDepositProductsResponse { + private GetRecurringDepositProductsResponse() { + } + + final class GetRecurringDepositProductsCurrency { + private GetRecurringDepositProductsCurrency() { + } + + @ApiModelProperty(example = "USD") + public String code; + @ApiModelProperty(example = "US Dollar") + public String name; + @ApiModelProperty(example = "2") + public Integer decimalPlaces; + @ApiModelProperty(example = "1") + public Integer inMultiplesOf; + @ApiModelProperty(example = "$") + public String displaySymbol; + @ApiModelProperty(example = "currency.USD") + public String nameCode; + @ApiModelProperty(example = "US Dollar ($)") + public String displayLabel; + } + + final class GetRecurringDepositProductsMinDepositTermType { + private GetRecurringDepositProductsMinDepositTermType() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "deposit.term.savingsPeriodFrequencyType.months") + public String code; + @ApiModelProperty(example = "Months") + public String value; + } + + final class GetRecurringDepositProductsMaxDepositTermType { + private GetRecurringDepositProductsMaxDepositTermType() { + } + + @ApiModelProperty(example = "3") + public Integer id; + @ApiModelProperty(example = "deposit.term.savingsPeriodFrequencyType.years") + public String code; + @ApiModelProperty(example = "Years") + public String value; + } + + final class GetRecurringDepositProductsInterestCompoundingPeriodType { + private GetRecurringDepositProductsInterestCompoundingPeriodType() { + } + + @ApiModelProperty(example = "4") + public Integer id; + @ApiModelProperty(example = "savings.interest.period.savingsCompoundingInterestPeriodType.monthly") + public String code; + @ApiModelProperty(example = "Monthly") + public String value; + } + + final class GetRecurringDepositProductsInterestPostingPeriodType { + private GetRecurringDepositProductsInterestPostingPeriodType() { + } + + @ApiModelProperty(example = "4") + public Integer id; + @ApiModelProperty(example = "savings.interest.posting.period.savingsPostingInterestPeriodType.monthly") + public String code; + @ApiModelProperty(example = "Monthly") + public String value; + } + + final class GetRecurringDepositProductsInterestCalculationType { + private GetRecurringDepositProductsInterestCalculationType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "savingsInterestCalculationType.dailybalance") + public String code; + @ApiModelProperty(example = "Daily Balance") + public String value; + } + + final class GetRecurringDepositProductsInterestCalculationDaysInYearType { + private GetRecurringDepositProductsInterestCalculationDaysInYearType() { + } + + @ApiModelProperty(example = "365") + public Integer id; + @ApiModelProperty(example = "savingsInterestCalculationDaysInYearType.days365") + public String code; + @ApiModelProperty(example = "365 Days") + public String value; + } + + final class GetRecurringDepositProductsAccountingRule { + private GetRecurringDepositProductsAccountingRule() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "accountingRuleType.none") + public String code; + @ApiModelProperty(example = "NONE") + public String value; + } + + final class GetRecurringDepositProductsRecurringDepositFrequencyType { + private GetRecurringDepositProductsRecurringDepositFrequencyType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "recurring.deposit.savingsPeriodFrequencyType.months") + public String code; + @ApiModelProperty(example = "Months") + public String value; + } + + @ApiModelProperty(example = "3") + public Integer id; + @ApiModelProperty(example = "RD01") + public String name; + @ApiModelProperty(example = "RD01") + public String shortName; + @ApiModelProperty(example = "RD01") + public String description; + public GetRecurringDepositProductsCurrency currency; + @ApiModelProperty(example = "1") + public Integer recurringDepositFrequency; + public GetRecurringDepositProductsRecurringDepositFrequencyType recurringDepositFrequencyType; + @ApiModelProperty(example = "false") + public Boolean preClosurePenalApplicable; + @ApiModelProperty(example = "3") + public Integer minDepositTerm; + @ApiModelProperty(example = "4") + public Integer maxDepositTerm; + public GetRecurringDepositProductsMinDepositTermType minDepositTermType; + public GetRecurringDepositProductsMaxDepositTermType maxDepositTermType; + @ApiModelProperty(example = "0") + public Double nominalAnnualInterestRate; + public GetRecurringDepositProductsInterestCompoundingPeriodType interestCompoundingPeriodType; + public GetRecurringDepositProductsInterestPostingPeriodType interestPostingPeriodType; + public GetRecurringDepositProductsInterestCalculationType interestCalculationType; + public GetRecurringDepositProductsInterestCalculationDaysInYearType interestCalculationDaysInYearType; + public GetRecurringDepositProductsAccountingRule accountingRule; + } + + @ApiModel(value = "GetRecurringDepositProductsProductIdResponse") + public final static class GetRecurringDepositProductsProductIdResponse { + private GetRecurringDepositProductsProductIdResponse() { + } + + final class GetRecurringDepositProductsProductIdCurrency { + private GetRecurringDepositProductsProductIdCurrency() { + } + + @ApiModelProperty(example = "USD") + public String code; + @ApiModelProperty(example = "US Dollar") + public String name; + @ApiModelProperty(example = "2") + public Integer decimalPlaces; + @ApiModelProperty(example = "$") + public String displaySymbol; + @ApiModelProperty(example = "currency.USD") + public String nameCode; + @ApiModelProperty(example = "US Dollar ($)") + public String displayLabel; + } + + final class GetRecurringDepositProductsProductIdInterestCompoundingPeriodType { + private GetRecurringDepositProductsProductIdInterestCompoundingPeriodType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "savings.interest.period.savingsCompoundingInterestPeriodType.daily") + public String code; + @ApiModelProperty(example = "Daily") + public String value; + } + + final class GetRecurringDepositProductsProductIdAccountingMappings { + private GetRecurringDepositProductsProductIdAccountingMappings() { + } + + final class GetRecurringDepositProductsProductIdSavingsReferenceAccount { + private GetRecurringDepositProductsProductIdSavingsReferenceAccount() { + } + + @ApiModelProperty(example = "12") + public Integer id; + @ApiModelProperty(example = "savings ref") + public String name; + @ApiModelProperty(example = "20") + public Integer glCode; + } + + final class GetRecurringDepositProductsProductIdIncomeFromFeeAccount { + private GetRecurringDepositProductsProductIdIncomeFromFeeAccount() { + } + + @ApiModelProperty(example = "16") + public Integer id; + @ApiModelProperty(example = "income from savings fee") + public String name; + @ApiModelProperty(example = "24") + public Integer glCode; + } + + final class GetRecurringDepositProductsProductIdIncomeFromPenaltyAccount { + private GetRecurringDepositProductsProductIdIncomeFromPenaltyAccount() { + } + + @ApiModelProperty(example = "17") + public Integer id; + @ApiModelProperty(example = "income from sav penalties") + public String name; + @ApiModelProperty(example = "25") + public Integer glCode; + } + + final class GetRecurringDepositProductsProductIdInterestOnSavingsAccount { + private GetRecurringDepositProductsProductIdInterestOnSavingsAccount() { + } + + @ApiModelProperty(example = "15") + public Integer id; + @ApiModelProperty(example = "interest on savings") + public String name; + @ApiModelProperty(example = "23") + public Integer glCode; + } + + final class GetRecurringDepositProductsProductIdSavingsControlAccount { + private GetRecurringDepositProductsProductIdSavingsControlAccount() { + } + + @ApiModelProperty(example = "13") + public Integer id; + @ApiModelProperty(example = "savings ref tool kit") + public String name; + @ApiModelProperty(example = "21") + public Integer glCode; + } + + final class GetRecurringDepositProductsProductIdTransfersInSuspenseAccount { + private GetRecurringDepositProductsProductIdTransfersInSuspenseAccount() { + } + + @ApiModelProperty(example = "14") + public Integer id; + @ApiModelProperty(example = "saving transfers") + public String name; + @ApiModelProperty(example = "22") + public Integer glCode; + } + + public GetRecurringDepositProductsProductIdSavingsReferenceAccount savingsReferenceAccount; + public GetRecurringDepositProductsProductIdIncomeFromFeeAccount incomeFromFeeAccount; + public GetRecurringDepositProductsProductIdIncomeFromPenaltyAccount incomeFromPenaltyAccount; + public GetRecurringDepositProductsProductIdInterestOnSavingsAccount interestOnSavingsAccount; + public GetRecurringDepositProductsProductIdSavingsControlAccount savingsControlAccount; + public GetRecurringDepositProductsProductIdTransfersInSuspenseAccount transfersInSuspenseAccount; + } + + final class GetRecurringDepositProductsProductIdFeeToIncomeAccountMappings { + private GetRecurringDepositProductsProductIdFeeToIncomeAccountMappings() { + } + + final class GetRecurringDepositProductsProductIdFeeToIncomeAccountMappingsCharge { + private GetRecurringDepositProductsProductIdFeeToIncomeAccountMappingsCharge() { + } + + @ApiModelProperty(example = "11") + public Integer id; + @ApiModelProperty(example = "sav charge") + public String name; + @ApiModelProperty(example = "false") + public Boolean active; + @ApiModelProperty(example = "false") + public Boolean penalty; + } + + final class GetRecurringDepositProductsProductIdFeeToIncomeAccountMappingsIncomeAccount { + private GetRecurringDepositProductsProductIdFeeToIncomeAccountMappingsIncomeAccount() { + } + + @ApiModelProperty(example = "16") + public Integer id; + @ApiModelProperty(example = "income from savings fee") + public String name; + @ApiModelProperty(example = "24") + public Integer glCode; + } + + public GetRecurringDepositProductsProductIdFeeToIncomeAccountMappingsCharge charge; + public GetRecurringDepositProductsProductIdFeeToIncomeAccountMappingsIncomeAccount incomeAccount; + } + + final class GetRecurringDepositProductsProductIdPenaltyToIncomeAccountMappings { + private GetRecurringDepositProductsProductIdPenaltyToIncomeAccountMappings() { + } + + final class GetRecurringDepositProductsProductIdPenaltyToIncomeAccountMappingsCharge { + private GetRecurringDepositProductsProductIdPenaltyToIncomeAccountMappingsCharge() { + } + + @ApiModelProperty(example = "12") + public Integer id; + @ApiModelProperty(example = "sav 2") + public String name; + @ApiModelProperty(example = "false") + public Boolean active; + @ApiModelProperty(example = "true") + public Boolean penalty; + } + + public GetRecurringDepositProductsProductIdPenaltyToIncomeAccountMappingsCharge charge; + public GetRecurringDepositProductsProductIdAccountingMappings.GetRecurringDepositProductsProductIdIncomeFromPenaltyAccount incomeAccount; + } + + final class GetRecurringDepositProductsProductIdPreClosurePenalInterestOnType { + private GetRecurringDepositProductsProductIdPreClosurePenalInterestOnType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "preClosurePenalInterestOnType.wholeTerm") + public String code; + @ApiModelProperty(example = "Whole term") + public String value; + } + + final class GetRecurringDepositProductsProductIdMinDepositTermType { + private GetRecurringDepositProductsProductIdMinDepositTermType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "deposit.term.savingsPeriodFrequencyType.weeks") + public String code; + @ApiModelProperty(example = "Weeks") + public String value; + } + + final class GetRecurringDepositProductsProductIdMaxDepositTermType { + private GetRecurringDepositProductsProductIdMaxDepositTermType() { + } + + @ApiModelProperty(example = "3") + public Integer id; + @ApiModelProperty(example = "deposit.term.savingsPeriodFrequencyType.years") + public String code; + @ApiModelProperty(example = "Years") + public String value; + } + + final class GetRecurringDepositProductsProductIdActiveChart { + private GetRecurringDepositProductsProductIdActiveChart() { + } + + final class GetRecurringDepositProductsProductIdChartSlabs { + private GetRecurringDepositProductsProductIdChartSlabs() { + } + + final class GetRecurringDepositProductsProductIdPeriodType { + private GetRecurringDepositProductsProductIdPeriodType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "interestChartPeriodType.weeks") + public String code; + @ApiModelProperty(example = "Weeks") + public String value; + } + + @ApiModelProperty(example = "18") + public Integer id; + @ApiModelProperty(example = "from 0 to 90 days") + public String description; + public GetRecurringDepositProductsProductIdPeriodType periodType; + @ApiModelProperty(example = "0") + public Integer fromPeriod; + @ApiModelProperty(example = "90") + public Integer toPeriod; + @ApiModelProperty(example = "4.5") + public Double annualInterestRate; + public GetRecurringDepositProductsProductIdCurrency currency; + } + + @ApiModelProperty(example = "8") + public Integer id; + @ApiModelProperty(example = "[2014, 1, 1]") + public LocalDate fromDate; + @ApiModelProperty(example = "8") + public Integer savingsProductId; + @ApiModelProperty(example = "Recurring deposit product") + public String savingsProductName; + public Set chartSlabs; + public Set periodTypes; + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "Recurring deposit product") + public String name; + @ApiModelProperty(example = "RD01") + public String shortName; + @ApiModelProperty(example = "Daily compounding using Daily Balance, 5% per year, 365 days in year") + public String description; + public GetRecurringDepositProductsProductIdCurrency currency; + public GetRecurringDepositProductsProductIdInterestCompoundingPeriodType interestCompoundingPeriodType; + public GetRecurringDepositProductsResponse.GetRecurringDepositProductsInterestPostingPeriodType interestPostingPeriodType; + public GetRecurringDepositProductsResponse.GetRecurringDepositProductsInterestCalculationType interestCalculationType; + public GetRecurringDepositProductsResponse.GetRecurringDepositProductsInterestCalculationDaysInYearType interestCalculationDaysInYearType; + public GetRecurringDepositProductsProductIdAccountingMappings accountingMappings; + public Set feeToIncomeAccountMappings; + public Set penaltyToIncomeAccountMappings; + @ApiModelProperty(example = "1") + public Integer recurringDepositFrequency; + public GetRecurringDepositProductsResponse.GetRecurringDepositProductsRecurringDepositFrequencyType recurringDepositFrequencyType; + @ApiModelProperty(example = "true") + public Boolean preClosurePenalApplicable; + @ApiModelProperty(example = "1.75") + public Double preClosurePenalInterest; + public GetRecurringDepositProductsProductIdPreClosurePenalInterestOnType preClosurePenalInterestOnType; + @ApiModelProperty(example = "1") + public Integer minDepositTerm; + public GetRecurringDepositProductsProductIdMinDepositTermType minDepositTermType; + @ApiModelProperty(example = "5") + public Integer maxDepositTerm; + public GetRecurringDepositProductsProductIdMaxDepositTermType maxDepositTermType; + public GetRecurringDepositProductsProductIdActiveChart activeChart; + } + + @ApiModel(value = "DeleteRecurringDepositProductsProductIdResponse") + public final static class DeleteRecurringDepositProductsProductIdResponse { + private DeleteRecurringDepositProductsProductIdResponse() { + } + + @ApiModelProperty(example = "1") + public Integer resourceId; + } +} + diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsAccountChargesApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsAccountChargesApiResource.java index 78bd349d7..136d5fdf7 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsAccountChargesApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsAccountChargesApiResource.java @@ -17,28 +17,7 @@ * under the License. */ package org.apache.fineract.portfolio.savings.api; - -import static org.apache.fineract.portfolio.savings.SavingsApiConstants.COMMAND_INACTIVATE_CHARGE; -import static org.apache.fineract.portfolio.savings.SavingsApiConstants.COMMAND_PAY_CHARGE; -import static org.apache.fineract.portfolio.savings.SavingsApiConstants.COMMAND_WAIVE_CHARGE; -import static org.apache.fineract.portfolio.savings.SavingsApiConstants.SAVINGS_ACCOUNT_CHARGE_RESOURCE_NAME; - -import java.util.Collection; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriInfo; - +import io.swagger.annotations.*; import org.apache.commons.lang.StringUtils; import org.apache.fineract.commands.domain.CommandWrapper; import org.apache.fineract.commands.service.CommandWrapperBuilder; @@ -51,16 +30,24 @@ import org.apache.fineract.infrastructure.core.serialization.DefaultToApiJsonSer import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; import org.apache.fineract.portfolio.charge.data.ChargeData; import org.apache.fineract.portfolio.charge.service.ChargeReadPlatformService; -import org.apache.fineract.portfolio.savings.SavingsApiConstants; import org.apache.fineract.portfolio.savings.data.SavingsAccountChargeData; import org.apache.fineract.portfolio.savings.service.SavingsAccountChargeReadPlatformService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; +import java.util.Collection; + +import static org.apache.fineract.portfolio.savings.SavingsApiConstants.*; + @Path("/savingsaccounts/{savingsAccountId}/charges") @Component @Scope("singleton") +@Api(value = "Savings Charges", description = "Its typical for MFIs to add maintenance and operating charges. They can be either Fees or Penalties.\n" + "\n" + "Savings Charges are instances of Charges and represent either fees and penalties for savings products. Refer Charges for documentation of the various properties of a charge, Only additional properties ( specific to the context of a Charge being associated with a Savings account) are described here") public class SavingsAccountChargesApiResource { private final PlatformSecurityContext context; @@ -92,8 +79,10 @@ public class SavingsAccountChargesApiResource { @GET @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveAllSavingsAccountCharges(@PathParam("savingsAccountId") final Long savingsAccountId, - @DefaultValue("all") @QueryParam("chargeStatus") final String chargeStatus, @Context final UriInfo uriInfo) { + @ApiOperation(value = "List Savings Charges", httpMethod = "GET", notes = "Lists Savings Charges\n\n" + "Example Requests:\n" + "\n" + "savingsaccounts/1/charges\n" + "\n" + "savingsaccounts/1/charges?chargeStatus=all\n" + "\n" + "savingsaccounts/1/charges?chargeStatus=inactive\n" + "\n" + "savingsaccounts/1/charges?chargeStatus=active\n" + "\n" + "savingsaccounts/1/charges?fields=name,amountOrPercentage") + @ApiResponses({@ApiResponse(code = 200, message = "OK", responseContainer = "List", response = SavingsAccountChargesApiResourceSwagger.GetSavingsAccountsSavingsAccountIdChargesResponse.class)}) + public String retrieveAllSavingsAccountCharges(@PathParam("savingsAccountId") @ApiParam(value = "savingsAccountId") final Long savingsAccountId, + @DefaultValue("all") @QueryParam("chargeStatus") @ApiParam(value = "chargeStatus") final String chargeStatus, @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(SAVINGS_ACCOUNT_CHARGE_RESOURCE_NAME); @@ -112,7 +101,9 @@ public class SavingsAccountChargesApiResource { @Path("template") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveTemplate(@PathParam("savingsAccountId") final Long savingsAccountId, @Context final UriInfo uriInfo) { + @ApiOperation(value = "Retrieve Savings Charges Template", httpMethod = "GET", notes = "This is a convenience resource. It can be useful when building maintenance user interface screens for client applications. The template data returned consists of any or all of:\n" + "\n" + "Field Defaults\n" + "Allowed Value Lists\n" + "Example Request:\n" + "\n" + "savingsaccounts/1/charges/template") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = SavingsAccountChargesApiResourceSwagger.GetSavingsAccountsSavingsAccountIdChargesTemplateResponse.class)}) + public String retrieveTemplate(@PathParam("savingsAccountId") @ApiParam(value = "savingsAccountId")final Long savingsAccountId, @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(SAVINGS_ACCOUNT_CHARGE_RESOURCE_NAME); @@ -128,8 +119,10 @@ public class SavingsAccountChargesApiResource { @Path("{savingsAccountChargeId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveSavingsAccountCharge(@PathParam("savingsAccountId") final Long savingsAccountId, - @PathParam("savingsAccountChargeId") final Long savingsAccountChargeId, @Context final UriInfo uriInfo) { + @ApiOperation(value = "Retrieve a Savings account Charge", httpMethod = "GET", notes = "Retrieves a Savings account Charge\n\n" + "Example Requests:\n" + "\n" + "/savingsaccounts/1/charges/5\n" + "\n" + "\n" + "/savingsaccounts/1/charges/5?fields=name,amountOrPercentage") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = SavingsAccountChargesApiResourceSwagger.GetSavingsAccountsSavingsAccountIdChargesSavingsAccountChargeIdResponse.class)}) + public String retrieveSavingsAccountCharge(@PathParam("savingsAccountId") @ApiParam(value = "savingsAccountId")final Long savingsAccountId, + @PathParam("savingsAccountChargeId") @ApiParam(value = "savingsAccountChargeId") final Long savingsAccountChargeId, @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(SAVINGS_ACCOUNT_CHARGE_RESOURCE_NAME); @@ -144,7 +137,10 @@ public class SavingsAccountChargesApiResource { @POST @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String addSavingsAccountCharge(@PathParam("savingsAccountId") final Long savingsAccountId, final String apiRequestBodyAsJson) { + @ApiOperation(value = "Create a Savings account Charge", httpMethod = "POST", notes = "Creates a Savings account Charge\n\n" + "Mandatory Fields for Savings account Charges: chargeId, amount\n\n" + "chargeId, amount, dueDate, dateFormat, locale\n\n" + "chargeId, amount, feeOnMonthDay, monthDayFormat, locale") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = SavingsAccountChargesApiResourceSwagger.PostSavingsAccountsSavingsAccountIdChargesRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = SavingsAccountChargesApiResourceSwagger.PostSavingsAccountsSavingsAccountIdChargesResponse.class)}) + public String addSavingsAccountCharge(@PathParam("savingsAccountId") @ApiParam(value = "savingsAccountId")final Long savingsAccountId, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder().createSavingsAccountCharge(savingsAccountId) .withJson(apiRequestBodyAsJson).build(); @@ -158,8 +154,11 @@ public class SavingsAccountChargesApiResource { @Path("{savingsAccountChargeId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String updateSavingsAccountCharge(@PathParam("savingsAccountId") final Long savingsAccountId, - @PathParam("savingsAccountChargeId") final Long savingsAccountChargeId, final String apiRequestBodyAsJson) { + @ApiOperation(value = "Update a Savings account Charge", httpMethod = "PUT", notes = "Currently Savings account Charges may be updated only if the Savings account is not yet approved.") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = SavingsAccountChargesApiResourceSwagger.PutSavingsAccountsSavingsAccountIdChargesSavingsAccountChargeIdRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = SavingsAccountChargesApiResourceSwagger.PutSavingsAccountsSavingsAccountIdChargesSavingsAccountChargeIdResponse.class)}) + public String updateSavingsAccountCharge(@PathParam("savingsAccountId") @ApiParam(value = "savingsAccountId")final Long savingsAccountId, + @PathParam("savingsAccountChargeId") @ApiParam(value = "savingsAccountChargeId") final Long savingsAccountChargeId, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder() .updateSavingsAccountCharge(savingsAccountId, savingsAccountChargeId).withJson(apiRequestBodyAsJson).build(); @@ -173,9 +172,12 @@ public class SavingsAccountChargesApiResource { @Path("{savingsAccountChargeId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String payOrWaiveSavingsAccountCharge(@PathParam("savingsAccountId") final Long savingsAccountId, - @PathParam("savingsAccountChargeId") final Long savingsAccountChargeId, @QueryParam("command") final String commandParam, - final String apiRequestBodyAsJson) { + @ApiOperation(value = "Pay a Savings account Charge | Waive off a Savings account Charge | Inactivate a Savings account Charge", httpMethod = "POST", notes = "Pay a Savings account Charge:\n\n" + "An active charge will be paid when savings account is active and having sufficient balance.\n\n" + "Waive off a Savings account Charge:\n\n" + "Outstanding charge amount will be waived off.\n\n" + "Inactivate a Savings account Charge:\n\n" + "A charge will be allowed to inactivate when savings account is active and not having any dues as of today. If charge is overpaid, corresponding charge payment transactions will be reversed.\n\n" + "Showing request/response for 'Pay a Savings account Charge'") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = SavingsAccountChargesApiResourceSwagger.PostSavingsAccountsSavingsAccountIdChargesSavingsAccountChargeIdRequest.class)}) + @ApiResponses({@ApiResponse(code = 200,message = "OK", response = SavingsAccountChargesApiResourceSwagger.PostSavingsAccountsSavingsAccountIdChargesSavingsAccountChargeIdResponse.class)}) + public String payOrWaiveSavingsAccountCharge(@PathParam("savingsAccountId") @ApiParam(value = "savingsAccountId") final Long savingsAccountId, + @PathParam("savingsAccountChargeId") @ApiParam(value = "savingsAccountChargeId")final Long savingsAccountChargeId, @QueryParam("command") @ApiParam(value = "command") final String commandParam, + @ApiParam(hidden = true) final String apiRequestBodyAsJson) { String json = ""; if (is(commandParam, COMMAND_WAIVE_CHARGE)) { @@ -211,8 +213,10 @@ public class SavingsAccountChargesApiResource { @Path("{savingsAccountChargeId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String deleteSavingsAccountCharge(@PathParam("savingsAccountId") final Long savingsAccountId, - @PathParam("savingsAccountChargeId") final Long savingsAccountChargeId) { + @ApiOperation(value = "Delete a Savings account Charge", httpMethod = "DELETE", notes = "Note: Currently, A Savings account Charge may only be removed from Savings that are not yet approved.") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = SavingsAccountChargesApiResourceSwagger.DeleteSavingsAccountsSavingsAccountIdChargesSavingsAccountChargeIdResponse.class)}) + public String deleteSavingsAccountCharge(@PathParam("savingsAccountId") @ApiParam(value = "savingsAccountId") final Long savingsAccountId, + @PathParam("savingsAccountChargeId") @ApiParam(value = "savingsAccountChargeId") final Long savingsAccountChargeId) { final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteSavingsAccountCharge(savingsAccountId, savingsAccountChargeId).build(); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsAccountChargesApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsAccountChargesApiResourceSwagger.java new file mode 100644 index 000000000..c512190ab --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsAccountChargesApiResourceSwagger.java @@ -0,0 +1,323 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.savings.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Set; + +/** + * Created by Chirag Gupta on 12/30/17. + */ +final class SavingsAccountChargesApiResourceSwagger { + private SavingsAccountChargesApiResourceSwagger() { + } + + @ApiModel(value = "GetSavingsAccountsSavingsAccountIdChargesResponse") + public final static class GetSavingsAccountsSavingsAccountIdChargesResponse { + private GetSavingsAccountsSavingsAccountIdChargesResponse() { + } + + final class GetChargesCurrencyResponse { + @ApiModelProperty(example = "USD") + public String code; + @ApiModelProperty(example = "US Dollar") + public String name; + @ApiModelProperty(example = "2") + public Integer decimalPlaces; + @ApiModelProperty(example = "$") + public String displaySymbol; + @ApiModelProperty(example = "currency.USD") + public String nameCode; + @ApiModelProperty(example = "US Dollar ($)") + public String displayLabel; + } + + final class GetChargesChargeCalculationType { + private GetChargesChargeCalculationType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "chargeCalculationType.flat") + public String code; + @ApiModelProperty(example = "Flat") + public String value; + } + + final class GetChargesChargeTimeType { + private GetChargesChargeTimeType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "chargeTimeType.specifiedDueDate") + public String code; + @ApiModelProperty(example = "Specified due date") + public String value; + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "3") + public Integer chargeId; + @ApiModelProperty(example = "57") + public Integer accountId; + @ApiModelProperty(example = "Savings account maintenance fee") + public String name; + public GetChargesChargeTimeType chargeTimeType; + public GetChargesChargeCalculationType chargeCalculationType; + @ApiModelProperty(example = "0") + public Double percentage; + @ApiModelProperty(example = "0") + public Double amountPercentageAppliedTo; + public GetChargesCurrencyResponse currency; + @ApiModelProperty(example = "100") + public Float amount; + @ApiModelProperty(example = "0") + public Float amountPaid; + @ApiModelProperty(example = "0") + public Float amountWaived; + @ApiModelProperty(example = "0") + public Float amountWrittenOff; + @ApiModelProperty(example = "100") + public Float amountOutstanding; + @ApiModelProperty(example = "100") + public Float amountOrPercentage; + @ApiModelProperty(example = "false") + public Boolean penalty; + } + + @ApiModel(value = "GetSavingsAccountsSavingsAccountIdChargesTemplateResponse") + public final static class GetSavingsAccountsSavingsAccountIdChargesTemplateResponse { + private GetSavingsAccountsSavingsAccountIdChargesTemplateResponse() { + } + + final class GetSavingsChargesOptions { + private GetSavingsChargesOptions() { + } + + final class GetSavingsChargesChargeTimeType { + private GetSavingsChargesChargeTimeType() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "chargeTimeType.specifiedDueDate") + public String code; + @ApiModelProperty(example = "Specified due date") + public String value; + } + + final class GetChargesAppliesTo { + private GetChargesAppliesTo() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "chargeAppliesTo.savings") + public String code; + @ApiModelProperty(example = "Savings") + public String value; + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "Passbook Fee") + public String name; + @ApiModelProperty(example = "true") + public Boolean active; + @ApiModelProperty(example = "false") + public Boolean penalty; + public GetSavingsAccountsSavingsAccountIdChargesResponse.GetChargesCurrencyResponse currency; + @ApiModelProperty(example = "100") + public Float amount; + public GetSavingsChargesChargeTimeType chargeTimeType; + public GetChargesAppliesTo chargesAppliesTo; + public GetSavingsAccountsSavingsAccountIdChargesResponse.GetChargesChargeCalculationType chargeCalculationType; + } + + @ApiModelProperty(example = "0") + public Float amountPaid; + @ApiModelProperty(example = "0") + public Float amountWaived; + @ApiModelProperty(example = "0") + public Float amountWrittenOff; + public Set chargeOptions; + @ApiModelProperty(example = "false") + public Boolean penalty; + } + + @ApiModel(value = "GetSavingsAccountsSavingsAccountIdChargesSavingsAccountChargeIdResponse") + public final static class GetSavingsAccountsSavingsAccountIdChargesSavingsAccountChargeIdResponse { + private GetSavingsAccountsSavingsAccountIdChargesSavingsAccountChargeIdResponse() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "1") + public Integer chargeId; + @ApiModelProperty(example = "Passbook fee") + public String name; + public GetSavingsAccountsSavingsAccountIdChargesResponse.GetChargesChargeTimeType chargeTimeType; + public GetSavingsAccountsSavingsAccountIdChargesResponse.GetChargesChargeCalculationType chargeCalculationType; + @ApiModelProperty(example = "0") + public Double percentage; + @ApiModelProperty(example = "0") + public Double amountPercentageAppliedTo; + public GetSavingsAccountsSavingsAccountIdChargesResponse.GetChargesCurrencyResponse currency; + @ApiModelProperty(example = "100") + public Float amount; + @ApiModelProperty(example = "0") + public Float amountPaid; + @ApiModelProperty(example = "0") + public Float amountWaived; + @ApiModelProperty(example = "0") + public Float amountWrittenOff; + @ApiModelProperty(example = "100") + public Float amountOutstanding; + @ApiModelProperty(example = "100") + public Float amountOrPercentage; + @ApiModelProperty(example = "false") + public Boolean penalty; + } + + @ApiModel(value = "PostSavingsAccountsSavingsAccountIdChargesRequest") + public final static class PostSavingsAccountsSavingsAccountIdChargesRequest { + private PostSavingsAccountsSavingsAccountIdChargesRequest() { + } + + @ApiModelProperty(example = "2") + public Integer chargeId; + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "100") + public Float amount; + @ApiModelProperty(example = "dd MMMM yyyy") + public String dateFormat; + @ApiModelProperty(example = "29 April 2013") + public String dueDate; + } + + @ApiModel(value = "PostSavingsAccountsSavingsAccountIdChargesResponse") + public final static class PostSavingsAccountsSavingsAccountIdChargesResponse { + private PostSavingsAccountsSavingsAccountIdChargesResponse() { + } + + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "1") + public Integer savingsId; + @ApiModelProperty(example = "6") + public Integer resourceId; + } + + @ApiModel(value = "PutSavingsAccountsSavingsAccountIdChargesSavingsAccountChargeIdRequest") + public final static class PutSavingsAccountsSavingsAccountIdChargesSavingsAccountChargeIdRequest { + private PutSavingsAccountsSavingsAccountIdChargesSavingsAccountChargeIdRequest() { + } + + @ApiModelProperty(example = "dd MMMM yyyy") + public String dateFormat; + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "60") + public Float amount; + @ApiModelProperty(example = "27 March 2013") + public String dueDate; + } + + @ApiModel(value = "PutSavingsAccountsSavingsAccountIdChargesSavingsAccountChargeIdResponse") + public final static class PutSavingsAccountsSavingsAccountIdChargesSavingsAccountChargeIdResponse { + private PutSavingsAccountsSavingsAccountIdChargesSavingsAccountChargeIdResponse() { + } + + final class PutSavingsChanges { + private PutSavingsChanges() { + } + + @ApiModelProperty(example = "27 March 2013") + public String dueDate; + @ApiModelProperty(example = "dd MMMM yyyy") + public String dateFormat; + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "60.0") + public Float amount; + } + + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "1") + public Integer savingsId; + @ApiModelProperty(example = "6") + public Integer resourceId; + public PutSavingsChanges changes; + } + + @ApiModel(value = "PostSavingsAccountsSavingsAccountIdChargesSavingsAccountChargeIdRequest") + public final static class PostSavingsAccountsSavingsAccountIdChargesSavingsAccountChargeIdRequest { + private PostSavingsAccountsSavingsAccountIdChargesSavingsAccountChargeIdRequest() { + } + + @ApiModelProperty(example = "dd MMMM yyyy") + public String dateFormat; + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "60") + public Float amount; + @ApiModelProperty(example = "12 September 2013") + public String dueDate; + } + + @ApiModel(value = "PostSavingsAccountsSavingsAccountIdChargesSavingsAccountChargeIdResponse") + public final static class PostSavingsAccountsSavingsAccountIdChargesSavingsAccountChargeIdResponse { + private PostSavingsAccountsSavingsAccountIdChargesSavingsAccountChargeIdResponse() { + } + + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "1") + public Integer savingsId; + @ApiModelProperty(example = "2") + public Integer resourceId; + } + + @ApiModel(value = "DeleteSavingsAccountsSavingsAccountIdChargesSavingsAccountChargeIdResponse") + public final static class DeleteSavingsAccountsSavingsAccountIdChargesSavingsAccountChargeIdResponse { + private DeleteSavingsAccountsSavingsAccountIdChargesSavingsAccountChargeIdResponse() { + } + + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "1") + public Integer savingsId; + @ApiModelProperty(example = "2") + public Integer resourceId; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsAccountsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsAccountsApiResource.java index 05feb6374..7acf6a7fa 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsAccountsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsAccountsApiResource.java @@ -18,25 +18,7 @@ */ package org.apache.fineract.portfolio.savings.api; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriInfo; - +import io.swagger.annotations.*; import org.apache.commons.lang.StringUtils; import org.apache.fineract.commands.domain.CommandWrapper; import org.apache.fineract.commands.service.CommandWrapperBuilder; @@ -62,9 +44,19 @@ import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + @Path("/savingsaccounts") @Component @Scope("singleton") +@Api(value = "Savings Account", description = "Savings accounts are instances of a particular savings product created for an individual or group. An application process around the creation of accounts is also supported.") public class SavingsAccountsApiResource { private final SavingsAccountReadPlatformService savingsAccountReadPlatformService; @@ -92,10 +84,12 @@ public class SavingsAccountsApiResource { @Path("template") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String template(@QueryParam("clientId") final Long clientId, @QueryParam("groupId") final Long groupId, - @QueryParam("productId") final Long productId, - @DefaultValue("false") @QueryParam("staffInSelectedOfficeOnly") final boolean staffInSelectedOfficeOnly, - @Context final UriInfo uriInfo) { + @ApiOperation(value = "Retrieve Savings Account Template", httpMethod = "GET", notes = "This is a convenience resource. It can be useful when building maintenance user interface screens for client applications. The template data returned consists of any or all of:\n" + "\n" + "Field Defaults\n" + "Allowed Value Lists\n\n" + "Example Requests:\n" + "\n" + "savingsaccounts/template?clientId=1\n" + "\n" + "\n" + "savingsaccounts/template?clientId=1&productId=1") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = SavingsAccountsApiResourceSwagger.GetSavingsAccountsTemplateResponse.class)}) + public String template(@QueryParam("clientId") @ApiParam(value = "clientId") final Long clientId, @QueryParam("groupId") @ApiParam(value = "groupId") final Long groupId, + @QueryParam("productId") @ApiParam(value = "productId") final Long productId, + @DefaultValue("false") @QueryParam("staffInSelectedOfficeOnly") @ApiParam(value = "staffInSelectedOfficeOnly") final boolean staffInSelectedOfficeOnly, + @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(SavingsApiConstants.SAVINGS_ACCOUNT_RESOURCE_NAME); @@ -110,11 +104,13 @@ public class SavingsAccountsApiResource { @GET @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveAll(@Context final UriInfo uriInfo, @QueryParam("sqlSearch") final String sqlSearch, - @QueryParam("externalId") final String externalId, + @ApiOperation(value = "List savings applications/accounts", httpMethod = "GET", notes = "Lists savings applications/accounts\n\n" + "Example Requests:\n" + "\n" + "savingsaccounts\n" + "\n" + "\n" + "savingsaccounts?fields=name") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = SavingsAccountsApiResourceSwagger.GetSavingsAccountsResponse.class)}) + public String retrieveAll(@Context final UriInfo uriInfo, @QueryParam("sqlSearch") @ApiParam(value = "sqlSearch") final String sqlSearch, + @QueryParam("externalId") @ApiParam(value = "externalId") final String externalId, // @QueryParam("underHierarchy") final String hierarchy, - @QueryParam("offset") final Integer offset, @QueryParam("limit") final Integer limit, - @QueryParam("orderBy") final String orderBy, @QueryParam("sortOrder") final String sortOrder) { + @QueryParam("offset") @ApiParam(value = "offset") final Integer offset, @QueryParam("limit") @ApiParam(value = "limit") final Integer limit, + @QueryParam("orderBy") @ApiParam(value = "orderBy") final String orderBy, @QueryParam("sortOrder") @ApiParam(value = "sortOrder") final String sortOrder) { this.context.authenticatedUser().validateHasReadPermission(SavingsApiConstants.SAVINGS_ACCOUNT_RESOURCE_NAME); @@ -130,7 +126,10 @@ public class SavingsAccountsApiResource { @POST @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String submitApplication(final String apiRequestBodyAsJson) { + @ApiOperation(value = "Submit new savings application", httpMethod = "POST", notes = "Submits new savings application\n\n" + "Mandatory Fields: clientId or groupId, productId, submittedOnDate\n\n" + "Optional Fields: accountNo, externalId, fieldOfficerId\n\n" + "Inherited from Product (if not provided): nominalAnnualInterestRate, interestCompoundingPeriodType, interestCalculationType, interestCalculationDaysInYearType, minRequiredOpeningBalance, lockinPeriodFrequency, lockinPeriodFrequencyType, withdrawalFeeForTransfers, allowOverdraft, overdraftLimit, withHoldTax\n\n" + "Additional Mandatory Field if Entity-Datatable Check is enabled for the entity of type Savings: datatables") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = SavingsAccountsApiResourceSwagger.PostSavingsAccountsRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = SavingsAccountsApiResourceSwagger.PostSavingsAccountsResponse.class)}) + public String submitApplication(@ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder().createSavingsAccount().withJson(apiRequestBodyAsJson).build(); @@ -143,9 +142,11 @@ public class SavingsAccountsApiResource { @Path("{accountId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveOne(@PathParam("accountId") final Long accountId, - @DefaultValue("false") @QueryParam("staffInSelectedOfficeOnly") final boolean staffInSelectedOfficeOnly, - @DefaultValue("all") @QueryParam("chargeStatus") final String chargeStatus, @Context final UriInfo uriInfo) { + @ApiOperation(value = "Retrieve a savings application/account", httpMethod = "GET", notes = "Retrieves a savings application/account\n\n" + "Example Requests :\n" + "\n" + "savingsaccounts/1\n" + "\n" + "\n" + "savingsaccounts/1?associations=all") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = SavingsAccountsApiResourceSwagger.GetSavingsAccountsAccountIdResponse.class)}) + public String retrieveOne(@PathParam("accountId") @ApiParam(value = "accountId") final Long accountId, + @DefaultValue("false") @QueryParam("staffInSelectedOfficeOnly") @ApiParam(value = "staffInSelectedOfficeOnly") final boolean staffInSelectedOfficeOnly, + @DefaultValue("all") @QueryParam("chargeStatus") @ApiParam(value = "chargeStatus") final String chargeStatus, @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(SavingsApiConstants.SAVINGS_ACCOUNT_RESOURCE_NAME); @@ -211,8 +212,11 @@ public class SavingsAccountsApiResource { @Path("{accountId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String update(@PathParam("accountId") final Long accountId, final String apiRequestBodyAsJson, - @QueryParam("command") final String commandParam) { + @ApiOperation(value = "Modify a savings application | Modify savings account withhold tax applicability", httpMethod = "PUT", notes = "Modify a savings application:\n\n" + "Savings application can only be modified when in 'Submitted and pending approval' state. Once the application is approved, the details cannot be changed using this method. Specific api endpoints will be created to allow change of interest detail such as rate, compounding period, posting period etc\n\n" + "Modify savings account withhold tax applicability:\n\n"+ "Savings application's withhold tax can be modified when in 'Active' state. Once the application is activated, can modify the account withhold tax to post tax or vice-versa" +"Showing request/response for 'Modify a savings application'") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = SavingsAccountsApiResourceSwagger.PutSavingsAccountsAccountIdRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = SavingsAccountsApiResourceSwagger.PutSavingsAccountsAccountIdResponse.class)}) + public String update(@PathParam("accountId") @ApiParam(value = "accountId") final Long accountId, @ApiParam(hidden = true) final String apiRequestBodyAsJson, + @QueryParam("command") @ApiParam(value = "command") final String commandParam) { if (is(commandParam, "updateWithHoldTax")) { final CommandWrapper commandRequest = new CommandWrapperBuilder().withJson(apiRequestBodyAsJson).updateWithHoldTax(accountId) @@ -233,8 +237,11 @@ public class SavingsAccountsApiResource { @Path("{accountId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String handleCommands(@PathParam("accountId") final Long accountId, @QueryParam("command") final String commandParam, - final String apiRequestBodyAsJson) { + @ApiOperation(value = "Approve savings application | Undo approval savings application | Assign Savings Officer | Unassign Savings Officer | Reject savings application | Withdraw savings application | Activate a savings account | Close a savings account | Calculate Interest on Savings Account | Post Interest on Savings Account | Block Savings Account | Unblock Savings Account | Block Savings Account Credit transactions | Unblock Savings Account Credit transactions | Block Savings Account Debit transactions | Unblock Savings Account debit transactions", httpMethod = "POST", notes = "Approve savings application:\n\n" + "Approves savings application so long as its in 'Submitted and pending approval' state.\n\n" + "Undo approval savings application:\n\n" + "Will move 'approved' savings application back to 'Submitted and pending approval' state.\n\n" + "Assign Savings Officer:\n\n" + "Allows you to assign Savings Officer for existing Savings Account.\n\n" + "Unassign Savings Officer:\n\n" + "Allows you to unassign the Savings Officer.\n\n" + "Reject savings application:\n\n" + "Rejects savings application so long as its in 'Submitted and pending approval' state.\n\n" + "Withdraw savings application:\n\n" + "Used when an applicant withdraws from the savings application. It must be in 'Submitted and pending approval' state.\n\n" + "Activate a savings account:\n\n" + "Results in an approved savings application being converted into an 'active' savings account.\n\n" + "Close a savings account:\n\n" + "Results in an Activated savings application being converted into an 'closed' savings account.\n" + "\n" + "closedOnDate is closure date of savings account\n" + "\n" + "withdrawBalance is a boolean value, true value of this field performs a withdrawal transaction with account's running balance.\n\n" + "Mandatory Fields: dateFormat,locale,closedOnDate\n\n" + "Optional Fields: note, withdrawBalance, paymentTypeId, accountNumber, checkNumber, routingCode, receiptNumber, bankNumber\n\n" + "Calculate Interest on Savings Account:\n\n" + "Calculates interest earned on a savings account based on todays date. It does not attempt to post or credit the interest on the account. That is responsibility of the Post Interest API that will likely be called by overnight process.\n\n" + "Post Interest on Savings Account:\n\n" + "Calculates and Posts interest earned on a savings account based on today's date and whether an interest posting or crediting event is due.\n\n" + "Block Savings Account:\n\n" + "Blocks Savings account from all types of credit and debit transactions\n\n" + "Unblock Savings Account:\n\n" + "Unblock a blocked account. On unblocking account, user can perform debit and credit transactions\n\n" + "Block Savings Account Credit transactions:\n\n" + "Savings account will be blocked from all types of credit transactions.\n\n" + "Unblock Savings Account Credit transactions:\n\n" + "It unblocks the Saving account's credit operations. Now all types of credits can be transacted to Savings account\n\n" + "Block Savings Account Debit transactions:\n\n" + "All types of debit operations from Savings account wil be blocked\n\n" + "Unblock Savings Account debit transactions:\n\n" + "It unblocks the Saving account's debit operations. Now all types of debits can be transacted from Savings account\n\n" + "Showing request/response for 'Unassign Savings Officer'") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = SavingsAccountsApiResourceSwagger.PostSavingsAccountsAccountIdRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = SavingsAccountsApiResourceSwagger.PostSavingsAccountsAccountIdResponse.class)}) + public String handleCommands(@PathParam("accountId") @ApiParam(value = "accountId") final Long accountId, @QueryParam("command") @ApiParam(value = "command") final String commandParam, + @ApiParam(hidden = true) final String apiRequestBodyAsJson) { String jsonApiRequest = apiRequestBodyAsJson; if (StringUtils.isBlank(jsonApiRequest)) { @@ -319,7 +326,9 @@ public class SavingsAccountsApiResource { @Path("{accountId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String delete(@PathParam("accountId") final Long accountId) { + @ApiOperation(value = "Delete a savings application", httpMethod = "DELETE", notes = "At present we support hard delete of savings application so long as its in 'Submitted and pending approval' state. One the application is moves past this state, it is not possible to do a 'hard' delete of the application or the account. An API endpoint will be added to close/de-activate the savings account.") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = SavingsAccountsApiResourceSwagger.DeleteSavingsAccountsAccountIdResponse.class)}) + public String delete(@PathParam("accountId") @ApiParam(value = "accountId") final Long accountId) { final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteSavingsAccount(accountId).build(); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsAccountsApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsAccountsApiResourceSwagger.java new file mode 100644 index 000000000..676991fd6 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsAccountsApiResourceSwagger.java @@ -0,0 +1,359 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.savings.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.time.LocalDate; +import java.util.Set; + +/** + * Created by Chirag Gupta on 12/29/17. + */ +final class SavingsAccountsApiResourceSwagger { + private SavingsAccountsApiResourceSwagger() { + } + + @ApiModel(value = "GetSavingsAccountsTemplateResponse") + public final static class GetSavingsAccountsTemplateResponse { + private GetSavingsAccountsTemplateResponse() { + } + + final class GetSavingsProductOptions { + private GetSavingsProductOptions() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "Passbook Savings") + public String name; + } + + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "small business") + public String clientName; + public Set productOptions; + } + + @ApiModel(value = "GetSavingsAccountsResponse") + public final static class GetSavingsAccountsResponse { + private GetSavingsAccountsResponse() { + } + + final class GetSavingsPageItems { + private GetSavingsPageItems() { + } + + final class GetSavingsStatus { + private GetSavingsStatus() { + } + + @ApiModelProperty(example = "100") + public Integer id; + @ApiModelProperty(example = "savingsAccountStatusType.submitted.and.pending.approval") + public String code; + @ApiModelProperty(example = "Submitted and pending approval") + public String value; + @ApiModelProperty(example = "true") + public Boolean submittedAndPendingApproval; + @ApiModelProperty(example = "false") + public Boolean approved; + @ApiModelProperty(example = "false") + public Boolean rejected; + @ApiModelProperty(example = "false") + public Boolean withdrawnByApplicant; + @ApiModelProperty(example = "false") + public Boolean active; + @ApiModelProperty(example = "false") + public Boolean closed; + + } + + final class GetSavingsTimeline { + private GetSavingsTimeline() { + } + + @ApiModelProperty(example = "[2013, 3, 1]") + public LocalDate submittedOnDate; + } + + final class GetSavingsCurrency { + private GetSavingsCurrency() { + } + + @ApiModelProperty(example = "USD") + public String code; + @ApiModelProperty(example = "US Dollar") + public String name; + @ApiModelProperty(example = "2") + public Integer decimalPlaces; + @ApiModelProperty(example = "$") + public String displaySymbol; + @ApiModelProperty(example = "currency.USD") + public String nameCode; + @ApiModelProperty(example = "US Dollar ($)") + public String displayLabel; + } + + final class GetSavingsInterestCompoundingPeriodType { + private GetSavingsInterestCompoundingPeriodType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "savings.interest.period.savingsCompoundingInterestPeriodType.daily") + public String code; + @ApiModelProperty(example = "Daily") + public String value; + } + + final class GetSavingsInterestPostingPeriodType { + private GetSavingsInterestPostingPeriodType() { + } + + @ApiModelProperty(example = "4") + public Integer id; + @ApiModelProperty(example = "savings.interest.posting.period.savingsPostingInterestPeriodType.monthly") + public String code; + @ApiModelProperty(example = "Monthly") + public String value; + } + + final class GetSavingsInterestCalculationType { + private GetSavingsInterestCalculationType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "savingsInterestCalculationType.dailybalance") + public String code; + @ApiModelProperty(example = "Daily Balance") + public String value; + } + + final class GetSavingsInterestCalculationDaysInYearType { + private GetSavingsInterestCalculationDaysInYearType() { + } + + @ApiModelProperty(example = "365") + public Integer id; + @ApiModelProperty(example = "savingsInterestCalculationDaysInYearType.days365") + public String code; + @ApiModelProperty(example = "365 Days") + public String value; + } + + final class GetSavingsSummary { + private GetSavingsSummary() { + } + + public GetSavingsCurrency currency; + @ApiModelProperty(example = "0") + public Integer accountBalance; + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "000000001") + public String accountNo; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "small business") + public String clientName; + @ApiModelProperty(example = "1") + public Integer savingsProductId; + @ApiModelProperty(example = "Passbook Savings") + public String savingsProductName; + @ApiModelProperty(example = "0") + public Integer fieldOfficerId; + public GetSavingsStatus status; + public GetSavingsTimeline timeline; + public GetSavingsCurrency currency; + @ApiModelProperty(example = "5") + public Double nominalAnnualInterestRate; + public GetSavingsInterestCompoundingPeriodType interestCompoundingPeriodType; + public GetSavingsInterestPostingPeriodType interestPostingPeriodType; + public GetSavingsInterestCalculationType interestCalculationType; + public GetSavingsInterestCalculationDaysInYearType interestCalculationDaysInYearType; + public GetSavingsSummary summary; + } + + @ApiModelProperty(example = "1") + public Integer totalFilteredRecords; + public Set pageItems; + } + + @ApiModel(value = "PostSavingsAccountsRequest") + public final static class PostSavingsAccountsRequest { + private PostSavingsAccountsRequest() { + } + + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "1") + public Integer productId; + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "dd MMMM yyyy") + public String dateFormat; + @ApiModelProperty(example = "01 March 2011") + public String submittedOnDate; + } + + @ApiModel(value = "PostSavingsAccountsResponse") + public final static class PostSavingsAccountsResponse { + private PostSavingsAccountsResponse() { + } + + @ApiModelProperty(example = "2") + public Integer officeId; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "1") + public Integer savingsId; + @ApiModelProperty(example = "1") + public Integer resourceId; + } + + @ApiModel(value = "GetSavingsAccountsAccountIdResponse") + public final static class GetSavingsAccountsAccountIdResponse { + private GetSavingsAccountsAccountIdResponse() { + } + + final class GetSavingsAccountsSummary { + private GetSavingsAccountsSummary() { + } + + public GetSavingsAccountsResponse.GetSavingsPageItems.GetSavingsCurrency currency; + @ApiModelProperty(example = "0") + public Integer accountBalance; + @ApiModelProperty(example = "0") + public Integer availableBalance; + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "000000001") + public String accountNo; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "small business") + public String clientName; + @ApiModelProperty(example = "1") + public Integer savingsProductId; + @ApiModelProperty(example = "Passbook Savings") + public String savingsProductName; + @ApiModelProperty(example = "0") + public Integer fieldOfficerId; + public GetSavingsAccountsResponse.GetSavingsPageItems.GetSavingsStatus status; + public GetSavingsAccountsResponse.GetSavingsPageItems.GetSavingsTimeline timeline; + public GetSavingsAccountsResponse.GetSavingsPageItems.GetSavingsCurrency currency; + @ApiModelProperty(example = "5") + public Double nominalAnnualInterestRate; + public GetSavingsAccountsResponse.GetSavingsPageItems.GetSavingsInterestCompoundingPeriodType interestCompoundingPeriodType; + public GetSavingsAccountsResponse.GetSavingsPageItems.GetSavingsInterestPostingPeriodType interestPostingPeriodType; + public GetSavingsAccountsResponse.GetSavingsPageItems.GetSavingsInterestCalculationType interestCalculationType; + public GetSavingsAccountsResponse.GetSavingsPageItems.GetSavingsInterestCalculationDaysInYearType interestCalculationDaysInYearType; + public GetSavingsAccountsSummary summary; + } + + @ApiModel(value = "PutSavingsAccountsAccountIdRequest") + public final static class PutSavingsAccountsAccountIdRequest { + private PutSavingsAccountsAccountIdRequest() { + } + + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "5.9999999999") + public Double nominalAnnualInterestRate; + } + + @ApiModel(value = "PutSavingsAccountsAccountIdResponse") + public final static class PutSavingsAccountsAccountIdResponse { + private PutSavingsAccountsAccountIdResponse() { + } + + final class PutSavingsAccountsChanges { + private PutSavingsAccountsChanges() { + } + + @ApiModelProperty(example = "5.9999999999") + public Double nominalAnnualInterestRate; + @ApiModelProperty(example = "en") + public String locale; + } + + @ApiModelProperty(example = "2") + public Integer officeId; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "1") + public Integer savingsId; + @ApiModelProperty(example = "1") + public Integer resourceId; + public PutSavingsAccountsChanges changes; + } + + @ApiModel(value = "PostSavingsAccountsAccountIdRequest") + public final static class PostSavingsAccountsAccountIdRequest { + private PostSavingsAccountsAccountIdRequest() { + } + + @ApiModelProperty(example = "dd MMMM yyyy") + public String dateFormat; + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "05 September 2014") + public String unassignedDate; + } + + @ApiModel(value = "PostSavingsAccountsAccountIdResponse") + public final static class PostSavingsAccountsAccountIdResponse { + private PostSavingsAccountsAccountIdResponse() { + } + + final class PostSavingsAccountsAccountIdChanges { + private PostSavingsAccountsAccountIdChanges() { + } + } + + @ApiModelProperty(example = "2") + public Integer officeId; + @ApiModelProperty(example = "8") + public Integer clientId; + @ApiModelProperty(example = "8") + public Integer resourceId; + public PostSavingsAccountsAccountIdChanges changes; + } + + @ApiModel(value = "DeleteSavingsAccountsAccountIdResponse") + public final static class DeleteSavingsAccountsAccountIdResponse { + private DeleteSavingsAccountsAccountIdResponse() { + } + + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "1") + public Integer resourceId; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsProductsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsProductsApiResource.java index 016aaae68..7762d0920 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsProductsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsProductsApiResource.java @@ -18,23 +18,7 @@ */ package org.apache.fineract.portfolio.savings.api; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriInfo; - +import io.swagger.annotations.*; import org.apache.fineract.accounting.common.AccountingDropdownReadPlatformService; import org.apache.fineract.accounting.common.AccountingEnumerations; import org.apache.fineract.accounting.common.AccountingRuleType; @@ -57,11 +41,7 @@ import org.apache.fineract.portfolio.charge.data.ChargeData; import org.apache.fineract.portfolio.charge.service.ChargeReadPlatformService; import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeData; import org.apache.fineract.portfolio.paymenttype.service.PaymentTypeReadPlatformService; -import org.apache.fineract.portfolio.savings.SavingsApiConstants; -import org.apache.fineract.portfolio.savings.SavingsCompoundingInterestPeriodType; -import org.apache.fineract.portfolio.savings.SavingsInterestCalculationDaysInYearType; -import org.apache.fineract.portfolio.savings.SavingsInterestCalculationType; -import org.apache.fineract.portfolio.savings.SavingsPostingInterestPeriodType; +import org.apache.fineract.portfolio.savings.*; import org.apache.fineract.portfolio.savings.data.SavingsProductData; import org.apache.fineract.portfolio.savings.service.SavingsDropdownReadPlatformService; import org.apache.fineract.portfolio.savings.service.SavingsEnumerations; @@ -73,9 +53,19 @@ import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; + @Path("/savingsproducts") @Component @Scope("singleton") +@Api(value = "Savings Product", description = "An MFIs savings product offerings are modeled using this API.\n" + "\n" + "When creating savings accounts, the details from the savings product are used to auto fill details of the savings account application process.") public class SavingsProductsApiResource { private final SavingsProductReadPlatformService savingProductReadPlatformService; @@ -119,7 +109,10 @@ public class SavingsProductsApiResource { @POST @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String create(final String apiRequestBodyAsJson) { + @ApiOperation(value = "Create a Savings Product", httpMethod = "POST", notes = "Creates a Savings Product\n\n" + "Mandatory Fields: name, shortName, description, currencyCode, digitsAfterDecimal,inMultiplesOf, nominalAnnualInterestRate, interestCompoundingPeriodType, interestCalculationType, interestCalculationDaysInYearType,accountingRule\n\n" + "Mandatory Fields for Cash based accounting (accountingRule = 2): savingsReferenceAccountId, savingsControlAccountId, interestOnSavingsAccountId, incomeFromFeeAccountId, transfersInSuspenseAccountId, incomeFromPenaltyAccountId\n\n" + "Optional Fields: minRequiredOpeningBalance, lockinPeriodFrequency, lockinPeriodFrequencyType, withdrawalFeeForTransfers, paymentChannelToFundSourceMappings, feeToIncomeAccountMappings, penaltyToIncomeAccountMappings, charges, allowOverdraft, overdraftLimit, minBalanceForInterestCalculation,withHoldTax,taxGroupId") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = SavingsProductsApiResourceSwagger.PostSavingsProductsRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = SavingsProductsApiResourceSwagger.PostSavingsProductsResponse.class)}) + public String create(@ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder().createSavingProduct().withJson(apiRequestBodyAsJson).build(); @@ -132,7 +125,10 @@ public class SavingsProductsApiResource { @Path("{productId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String update(@PathParam("productId") final Long productId, final String apiRequestBodyAsJson) { + @ApiOperation(value = "Update a Savings Product", httpMethod = "PUT", notes = "Updates a Savings Product") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = SavingsProductsApiResourceSwagger.PutSavingsProductsProductIdRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = SavingsProductsApiResourceSwagger.PutSavingsProductsProductIdResponse.class)}) + public String update(@PathParam("productId") @ApiParam(value = "productId") final Long productId, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder().updateSavingProduct(productId).withJson(apiRequestBodyAsJson) .build(); @@ -146,6 +142,8 @@ public class SavingsProductsApiResource { @GET @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) + @ApiOperation(value = "List Savings Products", httpMethod = "GET", notes = "Lists Savings Products\n\n" + "Example Requests:\n" + "\n" + "savingsproducts\n" + "\n" + "savingsproducts?fields=name") + @ApiResponses({@ApiResponse(code = 200, message = "OK", responseContainer = "List", response = SavingsProductsApiResourceSwagger.GetSavingsProductsResponse.class)}) public String retrieveAll(@Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(SavingsApiConstants.SAVINGS_PRODUCT_RESOURCE_NAME); @@ -161,7 +159,9 @@ public class SavingsProductsApiResource { @Path("{productId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveOne(@PathParam("productId") final Long productId, @Context final UriInfo uriInfo) { + @ApiOperation(value = "Retrieve a Savings Product", httpMethod = "GET", notes = "Retrieves a Savings Product\n\n" + "Example Requests:\n" + "\n" + "savingsproducts/1\n" + "\n" + "savingsproducts/1?template=true\n" + "\n" + "savingsproducts/1?fields=name,description") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = SavingsProductsApiResourceSwagger.GetSavingsProductsProductIdResponse.class)}) + public String retrieveOne(@PathParam("productId") @ApiParam(value = "productId") final Long productId, @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(SavingsApiConstants.SAVINGS_PRODUCT_RESOURCE_NAME); @@ -198,6 +198,8 @@ public class SavingsProductsApiResource { @Path("template") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) + @ApiOperation(value = "Retrieve Savings Product Template", httpMethod = "GET", notes = "This is a convenience resource. It can be useful when building maintenance user interface screens for client applications. The template data returned consists of any or all of:\n" + "\n" + "Field Defaults\n" + "Allowed Value Lists\n" + "Example Request:\n" + "\n" + "savingsproducts/template") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = SavingsProductsApiResourceSwagger.GetSavingsProductsTemplateResponse.class)}) public String retrieveTemplate(@Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(SavingsApiConstants.SAVINGS_PRODUCT_RESOURCE_NAME); @@ -284,7 +286,9 @@ public class SavingsProductsApiResource { @Path("{productId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String delete(@PathParam("productId") final Long productId) { + @ApiOperation(value = "Delete a Savings Product", httpMethod = "DELETE", notes = "Deletes a Savings Product") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = SavingsProductsApiResourceSwagger.DeleteSavingsProductsProductIdResponse.class)}) + public String delete(@PathParam("productId") @ApiParam(value = "productId") final Long productId) { final CommandWrapper commandRequest = new CommandWrapperBuilder().deleteSavingProduct(productId).build(); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsProductsApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsProductsApiResourceSwagger.java new file mode 100644 index 000000000..24cf5714e --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/SavingsProductsApiResourceSwagger.java @@ -0,0 +1,737 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.savings.api; + + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.math.BigDecimal; +import java.util.List; +import java.util.Set; + +/** + * Created by Chirag Gupta on 12/31/17. + */ +final class SavingsProductsApiResourceSwagger { + private SavingsProductsApiResourceSwagger() { + } + + @ApiModel(value = "PostSavingsProductsRequest") + public final static class PostSavingsProductsRequest { + private PostSavingsProductsRequest() { + } + + final class PostSavingsCharges { + private PostSavingsCharges() { + } + + @ApiModelProperty(example = "1") + public Integer id; + } + + @ApiModelProperty(example = "Passbook Savings") + public String name; + @ApiModelProperty(example = "PBSV") + public String shortName; + @ApiModelProperty(example = "Daily compounding using Daily Balance, 5% per year, 365 days in year") + public String description; + @ApiModelProperty(example = "USD") + public String currencyCode; + @ApiModelProperty(example = "2") + public Integer digitsAfterDecimal; + @ApiModelProperty(example = "0") + public Integer inMultiplesOf; + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "5.0") + public Double nominalAnnualInterestRate; + @ApiModelProperty(example = "1") + public Integer interestCompoundingPeriodType; + @ApiModelProperty(example = "4") + public Integer interestPostingPeriodType; + @ApiModelProperty(example = "1") + public Integer interestCalculationType; + @ApiModelProperty(example = "365") + public Integer interestCalculationDaysInYearType; + @ApiModelProperty(example = "1") + public Integer accountingRule; + public Set charges; + } + + @ApiModel(value = "PostSavingsProductsResponse") + public final static class PostSavingsProductsResponse { + private PostSavingsProductsResponse() { + } + + @ApiModelProperty(example = "1") + public Integer resourceId; + } + + @ApiModel(value = "PutSavingsProductsProductIdRequest") + public final static class PutSavingsProductsProductIdRequest { + private PutSavingsProductsProductIdRequest() { + } + + @ApiModelProperty(example = "Passbook Savings Lite.") + public String description; + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "5.73") + public Double interestRate; + } + + @ApiModel(value = "PutSavingsProductsProductIdResponse") + public final static class PutSavingsProductsProductIdResponse { + private PutSavingsProductsProductIdResponse() { + } + + final class PutSavingsChanges { + private PutSavingsChanges() { + } + + @ApiModelProperty(example = "Passbook Savings Lite.") + public String description; + @ApiModelProperty(example = "5.73") + public Double interestRate; + @ApiModelProperty(example = "en") + public String locale; + } + + @ApiModelProperty(example = "1") + public Integer resourceId; + public PutSavingsChanges changes; + } + + @ApiModel(value = "GetSavingsProductsResponse") + public final static class GetSavingsProductsResponse { + private GetSavingsProductsResponse() { + } + + final class GetSavingsCurrency { + private GetSavingsCurrency() { + } + + @ApiModelProperty(example = "USD") + public String code; + @ApiModelProperty(example = "US Dollar") + public String name; + @ApiModelProperty(example = "2") + public Integer decimalPlaces; + @ApiModelProperty(example = "$") + public String displaySymbol; + @ApiModelProperty(example = "currency.USD") + public String nameCode; + @ApiModelProperty(example = "US Dollar ($)") + public String displayLabel; + } + + final class GetSavingsProductsInterestCompoundingPeriodType { + private GetSavingsProductsInterestCompoundingPeriodType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "savings.interest.period.savingsCompoundingInterestPeriodType.daily") + public String code; + @ApiModelProperty(example = "Daily") + public String value; + } + + final class GetSavingsProductsInterestPostingPeriodType { + private GetSavingsProductsInterestPostingPeriodType() { + } + + @ApiModelProperty(example = "4") + public Integer id; + @ApiModelProperty(example = "savings.interest.posting.period.savingsPostingInterestPeriodType.monthly") + public String code; + @ApiModelProperty(example = "Monthly") + public String value; + } + + final class GetSavingsProductsInterestCalculationType { + private GetSavingsProductsInterestCalculationType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "savingsInterestCalculationType.dailybalance") + public String code; + @ApiModelProperty(example = "Daily Balance") + public String value; + } + + final class GetSavingsProductsInterestCalculationDaysInYearType { + private GetSavingsProductsInterestCalculationDaysInYearType() { + } + + @ApiModelProperty(example = "365") + public Integer id; + @ApiModelProperty(example = "savingsInterestCalculationDaysInYearType.days365") + public String code; + @ApiModelProperty(example = "365 Days") + public String value; + } + + final class GetSavingsProductsAccountingRule { + private GetSavingsProductsAccountingRule() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "accountingRuleType.cash") + public String code; + @ApiModelProperty(example = "CASH BASED") + public String value; + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "Savings product") + public String name; + @ApiModelProperty(example = "sa1") + public String shortName; + @ApiModelProperty(example = "gtasga") + public String description; + public GetSavingsCurrency currency; + @ApiModelProperty(example = "5.000000") + public BigDecimal nominalAnnualInterestRate; + public GetSavingsProductsInterestCompoundingPeriodType interestCompoundingPeriodType; + public GetSavingsProductsInterestPostingPeriodType interestPostingPeriodType; + public GetSavingsProductsInterestCalculationType interestCalculationType; + public GetSavingsProductsInterestCalculationDaysInYearType interestCalculationDaysInYearType; + @ApiModelProperty(example = "false") + public Boolean withdrawalFeeForTransfers; + public GetSavingsProductsAccountingRule accountingRule; + } + + @ApiModel(value = "GetSavingsProductsProductIdResponse") + public final static class GetSavingsProductsProductIdResponse { + private GetSavingsProductsProductIdResponse() { + } + + final class GetSavingsProductsAccountingMappings { + private GetSavingsProductsAccountingMappings() { + } + + final class GetSavingsProductsSavingsReferenceAccount { + private GetSavingsProductsSavingsReferenceAccount() { + } + + @ApiModelProperty(example = "12") + public Integer id; + @ApiModelProperty(example = "savings ref") + public String name; + @ApiModelProperty(example = "20") + public Integer glCode; + } + + final class GetSavingsProductsIncomeFromFeeAccount { + private GetSavingsProductsIncomeFromFeeAccount() { + } + + @ApiModelProperty(example = "16") + public Integer id; + @ApiModelProperty(example = "income from savings fee") + public String name; + @ApiModelProperty(example = "24") + public Integer glCode; + } + + final class GetSavingsProductsIncomeFromPenaltyAccount { + private GetSavingsProductsIncomeFromPenaltyAccount() { + } + + @ApiModelProperty(example = "17") + public Integer id; + @ApiModelProperty(example = "income from sav penalties") + public String name; + @ApiModelProperty(example = "25") + public Integer glCode; + } + + final class GetSavingsProductsInterestOnSavingsAccount { + private GetSavingsProductsInterestOnSavingsAccount() { + } + + @ApiModelProperty(example = "15") + public Integer id; + @ApiModelProperty(example = "interest on savings") + public String name; + @ApiModelProperty(example = "23") + public Integer glCode; + } + + final class GetSavingsProductsSavingsControlAccount { + private GetSavingsProductsSavingsControlAccount() { + } + + @ApiModelProperty(example = "13") + public Integer id; + @ApiModelProperty(example = "savings ref tool kit") + public String name; + @ApiModelProperty(example = "21") + public Integer glCode; + } + + final class GetSavingsProductsTransfersInSuspenseAccount { + private GetSavingsProductsTransfersInSuspenseAccount() { + } + + @ApiModelProperty(example = "14") + public Integer id; + @ApiModelProperty(example = "saving transfers") + public String name; + @ApiModelProperty(example = "22") + public Integer glCode; + } + + public GetSavingsProductsSavingsReferenceAccount savingsReferenceAccount; + public GetSavingsProductsIncomeFromFeeAccount incomeFromFeeAccount; + public GetSavingsProductsIncomeFromPenaltyAccount incomeFromPenaltyAccount; + public GetSavingsProductsInterestOnSavingsAccount interestOnSavingsAccount; + public GetSavingsProductsSavingsControlAccount savingsControlAccount; + public GetSavingsProductsTransfersInSuspenseAccount transfersInSuspenseAccount; + } + + final class GetSavingsProductsPaymentChannelToFundSourceMappings { + private GetSavingsProductsPaymentChannelToFundSourceMappings() { + } + + final class GetSavingsProductsPaymentType { + private GetSavingsProductsPaymentType() { + } + + @ApiModelProperty(example = "10") + public Integer id; + @ApiModelProperty(example = "check") + public String name; + } + + final class GetSavingsProductsFundSourceAccount { + private GetSavingsProductsFundSourceAccount() { + } + + @ApiModelProperty(example = "12") + public Integer id; + @ApiModelProperty(example = "savings ref") + public String name; + @ApiModelProperty(example = "20") + public Integer glCode; + } + + public GetSavingsProductsPaymentType paymentType; + public GetSavingsProductsFundSourceAccount fundSourceAccount; + } + + final class GetSavingsProductsFeeToIncomeAccountMappings { + private GetSavingsProductsFeeToIncomeAccountMappings() { + } + + final class GetSavingsProductsFeeToIncomeAccountMappingsCharge { + private GetSavingsProductsFeeToIncomeAccountMappingsCharge() { + } + + @ApiModelProperty(example = "11") + public Integer id; + @ApiModelProperty(example = "sav charge") + public String name; + @ApiModelProperty(example = "false") + public Boolean active; + @ApiModelProperty(example = "false") + public Boolean penalty; + } + + final class GetSavingsProductsFeeToIncomeAccountMappingsIncomeAccount { + private GetSavingsProductsFeeToIncomeAccountMappingsIncomeAccount() { + } + + @ApiModelProperty(example = "16") + public Integer id; + @ApiModelProperty(example = "income from savings fee") + public String name; + @ApiModelProperty(example = "24") + public Integer glCode; + } + + public GetSavingsProductsFeeToIncomeAccountMappingsCharge charge; + public GetSavingsProductsFeeToIncomeAccountMappingsIncomeAccount incomeAccount; + } + + final class GetSavingsProductsPenaltyToIncomeAccountMappings { + private GetSavingsProductsPenaltyToIncomeAccountMappings() { + } + + final class GetSavingsProductsPenaltyToIncomeAccountMappingsCharge { + private GetSavingsProductsPenaltyToIncomeAccountMappingsCharge() { + } + + @ApiModelProperty(example = "12") + public Integer id; + @ApiModelProperty(example = "sav 2") + public String name; + @ApiModelProperty(example = "false") + public Boolean active; + @ApiModelProperty(example = "true") + public Boolean penalty; + } + + public GetSavingsProductsPenaltyToIncomeAccountMappingsCharge charge; + public GetSavingsProductsAccountingMappings.GetSavingsProductsIncomeFromPenaltyAccount incomeAccount; + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "savings product") + public String name; + @ApiModelProperty(example = "sa1") + public String shortName; + @ApiModelProperty(example = "gtasga") + public String description; + public GetSavingsProductsResponse.GetSavingsCurrency currency; + @ApiModelProperty(example = "5") + public BigDecimal nominalAnnualInterestRate; + public GetSavingsProductsResponse.GetSavingsProductsInterestCompoundingPeriodType interestCompoundingPeriodType; + public GetSavingsProductsResponse.GetSavingsProductsInterestPostingPeriodType interestPostingPeriodType; + public GetSavingsProductsResponse.GetSavingsProductsInterestCalculationType interestCalculationType; + public GetSavingsProductsResponse.GetSavingsProductsInterestCalculationDaysInYearType interestCalculationDaysInYearType; + @ApiModelProperty(example = "false") + public Boolean withdrawalFeeForTransfers; + public GetSavingsProductsResponse.GetSavingsProductsAccountingRule accountingRule; + public GetSavingsProductsAccountingMappings accountingMappings; + public Set paymentChannelToFundSourceMappings; + public Set feeToIncomeAccountMappings; + public Set penaltyToIncomeAccountMappings; + @ApiModelProperty(example = "[]") + public List charges; + } + + @ApiModel(value = "GetSavingsProductsTemplateResponse") + public final static class GetSavingsProductsTemplateResponse { + private GetSavingsProductsTemplateResponse() { + } + + final class GetSavingsProductsTemplateAccountingRule { + private GetSavingsProductsTemplateAccountingRule() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "accountingRuleType.none") + public String code; + @ApiModelProperty(example = "NONE") + public String value; + } + + final class GetSavingsProductsLockinPeriodFrequencyTypeOptions { + private GetSavingsProductsLockinPeriodFrequencyTypeOptions() { + } + + @ApiModelProperty(example = "0") + public Integer id; + @ApiModelProperty(example = "savings.lockin.savingsPeriodFrequencyType.days") + public String code; + @ApiModelProperty(example = "Days") + public String value; + } + + final class GetSavingsProductsWithdrawalFeeTypeOptions { + private GetSavingsProductsWithdrawalFeeTypeOptions() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "savingsWithdrawalFeesType.flat") + public String code; + @ApiModelProperty(example = "Flat") + public String value; + } + + final class GetSavingsProductsPaymentTypeOptions { + private GetSavingsProductsPaymentTypeOptions() { + } + + @ApiModelProperty(example = "14") + public Integer id; + @ApiModelProperty(example = "Wire Transfer") + public String name; + @ApiModelProperty(example = "0") + public Integer position; + } + + final class GetSavingsProductsAccountingMappingOptions { + private GetSavingsProductsAccountingMappingOptions() { + } + + final class GetSavingsProductsLiabilityAccountOptions { + private GetSavingsProductsLiabilityAccountOptions() { + } + + final class GetSavingsProductsLiabilityType { + private GetSavingsProductsLiabilityType() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "accountType.liability") + public String code; + @ApiModelProperty(example = "LIABILITY") + public String value; + } + + final class GetSavingsProductsLiabilityUsage { + private GetSavingsProductsLiabilityUsage() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "accountUsage.detail") + public String code; + @ApiModelProperty(example = "DETAIL") + public String value; + } + + final class GetSavingsProductsLiabilityTagId { + private GetSavingsProductsLiabilityTagId() { + } + + @ApiModelProperty(example = "0") + public Integer id; + } + + @ApiModelProperty(example = "15") + public Integer id; + @ApiModelProperty(example = "Savings Control") + public String name; + @ApiModelProperty(example = "50001") + public Integer glCode; + @ApiModelProperty(example = "false") + public Boolean disabled; + @ApiModelProperty(example = "true") + public Boolean manualEntriesAllowed; + public GetSavingsProductsLiabilityType type; + public GetSavingsProductsLiabilityUsage usage; + @ApiModelProperty(example = "Savings Control") + public String nameDecorated; + public GetSavingsProductsLiabilityTagId tagId; + } + + final class GetSavingsProductsAssetAccountOptions { + private GetSavingsProductsAssetAccountOptions() { + } + + final class GetSavingsAssetLiabilityType { + private GetSavingsAssetLiabilityType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "accountType.asset") + public String code; + @ApiModelProperty(example = "ASSET") + public String value; + } + + final class GetSavingsAssetTagId { + private GetSavingsAssetTagId() { + } + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "Cash") + public String name; + @ApiModelProperty(example = "100001") + public Integer glCode; + @ApiModelProperty(example = "false") + public Boolean disabled; + @ApiModelProperty(example = "true") + public Boolean manualEntriesAllowed; + public GetSavingsAssetLiabilityType type; + public GetSavingsProductsLiabilityAccountOptions.GetSavingsProductsLiabilityUsage usage; + public GetSavingsAssetTagId tagId; + } + + final class GetSavingsProductsExpenseAccountOptions { + private GetSavingsProductsExpenseAccountOptions() { + } + + final class GetSavingsProductsExpenseType { + private GetSavingsProductsExpenseType() { + } + + @ApiModelProperty(example = "5") + public Integer id; + @ApiModelProperty(example = "accountType.expense") + public String code; + @ApiModelProperty(example = "EXPENSE") + public String value; + } + + @ApiModelProperty(example = "6") + public Integer id; + @ApiModelProperty(example = "Write Off Expenses") + public String name; + @ApiModelProperty(example = "60001") + public Integer glCode; + @ApiModelProperty(example = "false") + public Boolean disabled; + @ApiModelProperty(example = "true") + public Boolean manualEntriesAllowed; + public GetSavingsProductsExpenseType type; + public GetSavingsProductsLiabilityAccountOptions.GetSavingsProductsLiabilityUsage usage; + public GetSavingsProductsAssetAccountOptions.GetSavingsAssetTagId tagId; + } + + final class GetSavingsProductsIncomeAccountOptions { + private GetSavingsProductsIncomeAccountOptions() { + } + + final class GetSavingsProductsIncomeType { + private GetSavingsProductsIncomeType() { + } + + @ApiModelProperty(example = "4") + public Integer id; + @ApiModelProperty(example = "accountType.income") + public String code; + @ApiModelProperty(example = "INCOME") + public String value; + } + + @ApiModelProperty(example = "3") + public Integer id; + @ApiModelProperty(example = "income from interest") + public String name; + @ApiModelProperty(example = "40001") + public Integer glCode; + @ApiModelProperty(example = "false") + public Boolean disabled; + @ApiModelProperty(example = "true") + public Boolean manualEntriesAllowed; + public GetSavingsProductsIncomeType type; + public GetSavingsProductsLiabilityAccountOptions.GetSavingsProductsLiabilityUsage usage; + public GetSavingsProductsAssetAccountOptions.GetSavingsAssetTagId tagId; + + } + + public Set liabilityAccountOptions; + public Set assetAccountOptions; + public Set expenseAccountOptions; + public Set incomeAccountOptions; + } + + final class GetSavingsProductsChargeOptions { + private GetSavingsProductsChargeOptions() { + } + + final class GetSavingsChargeTimeType { + private GetSavingsChargeTimeType() { + } + + @ApiModelProperty(example = "chargeTimeType.specifiedDueDate") + public String code; + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "Specified due date") + public String value; + } + + final class GetSavingsProductsChargeAppliesTo { + private GetSavingsProductsChargeAppliesTo() { + } + + @ApiModelProperty(example = "chargeAppliesTo.savings") + public String code; + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "Savings") + public String value; + } + + final class GetSavingsChargeCalculationType { + private GetSavingsChargeCalculationType() { + } + + @ApiModelProperty(example = "chargeCalculationType.flat") + public String code; + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "Flat") + public String value; + } + + final class GetSavingsChargePaymentMode { + private GetSavingsChargePaymentMode() { + } + + @ApiModelProperty(example = "chargepaymentmode.regular") + public String code; + @ApiModelProperty(example = "0") + public Integer id; + @ApiModelProperty(example = "chargepaymentmode.regular") + public String value; + } + + @ApiModelProperty(example = "true") + public Boolean active; + @ApiModelProperty(example = "200") + public Long amount; + public GetSavingsProductsChargeAppliesTo chargeAppliesTo; + public GetSavingsChargeCalculationType chargeCalculationType; + public GetSavingsChargePaymentMode chargePaymentMode; + public GetSavingsChargeTimeType chargeTimeType; + public GetSavingsProductsResponse.GetSavingsCurrency currency; + @ApiModelProperty(example = "4") + public Integer id; + @ApiModelProperty(example = "Savings charge 1") + public String name; + @ApiModelProperty(example = "false") + public Boolean penalty; + } + + public GetSavingsProductsResponse.GetSavingsCurrency currency; + public GetSavingsProductsResponse.GetSavingsProductsInterestCompoundingPeriodType interestCompoundingPeriodType; + public GetSavingsProductsResponse.GetSavingsProductsInterestPostingPeriodType interestPostingPeriodType; + public GetSavingsProductsResponse.GetSavingsProductsInterestCalculationType interestCalculationType; + public GetSavingsProductsResponse.GetSavingsProductsInterestCalculationDaysInYearType interestCalculationDaysInYearType; + public GetSavingsProductsTemplateAccountingRule accountingRule; + public Set currencyOptions; + public Set interestCompoundingPeriodTypeOptions; + public Set interestPostingPeriodTypeOptions; + public Set interestCalculationTypeOptions; + public Set interestCalculationDaysInYearTypeOptions; + public Set lockinPeriodFrequencyTypeOptions; + public Set withdrawalFeeTypeOptions; + public Set paymentTypeOptions; + public Set accountingRuleOptions; + public Set accountingMappingOptions; + public Set chargeOptions; + } + + @ApiModel(value = "DeleteSavingsProductsProductIdResponse") + public final static class DeleteSavingsProductsProductIdResponse { + private DeleteSavingsProductsProductIdResponse() { + } + + @ApiModelProperty(example = "1") + public Integer resourceId; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/account/api/SelfBeneficiariesTPTApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/account/api/SelfBeneficiariesTPTApiResource.java index 5f2ff4838..0990fe4c5 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/account/api/SelfBeneficiariesTPTApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/account/api/SelfBeneficiariesTPTApiResource.java @@ -18,23 +18,7 @@ */ package org.apache.fineract.portfolio.self.account.api; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriInfo; - +import io.swagger.annotations.*; import org.apache.fineract.commands.domain.CommandWrapper; import org.apache.fineract.commands.service.CommandWrapperBuilder; import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService; @@ -52,9 +36,19 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + @Path("/self/beneficiaries/tpt") @Component @Scope("singleton") +@Api(value = "Beneficiary Third Party Transfer", description = "") public class SelfBeneficiariesTPTApiResource { private final PlatformSecurityContext context; @@ -88,6 +82,8 @@ public class SelfBeneficiariesTPTApiResource { @Path("template") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) + @ApiOperation(value = "Beneficiary Third Party Transfer Template", httpMethod = "GET", notes = "Returns Account Type enumerations. Self User is expected to know office name and account number to be able to add beneficiary.\n" + "\n" + "Example Requests:\n" + "\n" + "/self/beneficiaries/tpt/template") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = SelfBeneficiariesTPTApiResourceSwagger.GetSelfBeneficiariesTPTTemplateResponse.class)}) public String template(@Context final UriInfo uriInfo) { final EnumOptionData loanAccountType = AccountTransferEnumerations @@ -109,7 +105,10 @@ public class SelfBeneficiariesTPTApiResource { @POST @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String add(final String apiRequestBodyAsJson) { + @ApiOperation(value = "Add TPT Beneficiary", httpMethod = "POST", notes = "Api to add third party beneficiary linked to current user.\n" + "\n" + "Parameter Definitions\n" + "\n" + "name : Nick name for beneficiary, should be unique for an self service user\n" + "\n" + "officeName : Office Name of beneficiary(not id)\n" + "\n" + "accountNumber : Account Number of beneficiary(not id)\n" + "\n" + "transferLimit : Each transfer initiated to this account will not exceed this amount\n" + "\n" + "Example Requests:\n" + "\n" + "/self/beneficiaries/tpt\n\n" + "Mandatory Fields: name, officeName, accountNumber, accountType\n\n" + "Optional Fields: transferLimit") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = SelfBeneficiariesTPTApiResourceSwagger.PostSelfBeneficiariesTPTRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = SelfBeneficiariesTPTApiResourceSwagger.PostSelfBeneficiariesTPTResponse.class)}) + public String add(@ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder() .addSelfServiceBeneficiaryTPT().withJson(apiRequestBodyAsJson) @@ -123,8 +122,11 @@ public class SelfBeneficiariesTPTApiResource { @Path("{beneficiaryId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String update(@PathParam("beneficiaryId") final Long beneficiaryId, - final String apiRequestBodyAsJson) { + @ApiOperation(value = "Update TPT Beneficiary", httpMethod = "PUT", notes = "Api to update third party beneficiary linked to current user.\n" + "\n" + "Example Requests:\n" + "\n" + "/self/beneficiaries/tpt/{beneficiaryId}\n\n" + "Optional Fields: name, transferLimit") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = SelfBeneficiariesTPTApiResourceSwagger.PutSelfBeneficiariesTPTBeneficiaryIdRequest.class)}) + @ApiResponses({@ApiResponse(code = 200,message = "OK", response = SelfBeneficiariesTPTApiResourceSwagger.PutSelfBeneficiariesTPTBeneficiaryIdResponse.class)}) + public String update(@PathParam("beneficiaryId") @ApiParam(value = "beneficiaryId") final Long beneficiaryId, + @ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder() .updateSelfServiceBeneficiaryTPT(beneficiaryId) @@ -138,8 +140,10 @@ public class SelfBeneficiariesTPTApiResource { @Path("{beneficiaryId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) + @ApiOperation(value = "Delete TPT Beneficiary", httpMethod = "DELETE", notes = "Api to delete third party beneficiary linked to current user.\n" + "\n" + "Example Requests:\n" + "\n" + "/self/beneficiaries/tpt/{beneficiaryId}") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = SelfBeneficiariesTPTApiResourceSwagger.DeleteSelfBeneficiariesTPTBeneficiaryIdResponse.class)}) public String delete(@PathParam("beneficiaryId") final Long beneficiaryId, - final String apiRequestBodyAsJson) { + @ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder() .deleteSelfServiceBeneficiaryTPT(beneficiaryId) @@ -152,6 +156,8 @@ public class SelfBeneficiariesTPTApiResource { @GET @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) + @ApiOperation(value = "Get All TPT Beneficiary", httpMethod = "GET", notes = "Api to get all third party beneficiary linked to current user.\n" + "\n" + "Example Requests:\n" + "\n" + "/self/beneficiaries/tpt") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = SelfBeneficiariesTPTApiResourceSwagger.GetSelfBeneficiariesTPTResponse.class, responseContainer = "List")}) public String retrieveAll(@Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission( diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/account/api/SelfBeneficiariesTPTApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/account/api/SelfBeneficiariesTPTApiResourceSwagger.java new file mode 100644 index 000000000..810fc3683 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/account/api/SelfBeneficiariesTPTApiResourceSwagger.java @@ -0,0 +1,141 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.self.account.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.Set; + +/** + * Created by Chirag Gupta on 12/22/17. + */ +final class SelfBeneficiariesTPTApiResourceSwagger { + private SelfBeneficiariesTPTApiResourceSwagger() { + } + + @ApiModel(value = "GetSelfBeneficiariesTPTTemplateResponse") + public final static class GetSelfBeneficiariesTPTTemplateResponse { + private GetSelfBeneficiariesTPTTemplateResponse() { + } + + final class GetSelfBeneficiariesAccountOptions { + private GetSelfBeneficiariesAccountOptions() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "accountType.savings") + public String code; + @ApiModelProperty(example = "Savings Account") + public String value; + } + + public Set accountTypeOptions; + } + + @ApiModel(value = "PostSelfBeneficiariesTPTRequest") + public final static class PostSelfBeneficiariesTPTRequest { + private PostSelfBeneficiariesTPTRequest() { + } + + @ApiModelProperty(example = "en_GB") + public String locale; + @ApiModelProperty(example = "beneficiary nick name") + public String name; + @ApiModelProperty(example = "HEAD OFFICE") + public String officeName; + @ApiModelProperty(example = "0000001") + public Long accountNumber; + @ApiModelProperty(example = "1") + public Integer accountType; + @ApiModelProperty(example = "1000") + public Integer transferLimit; + } + + @ApiModel(value = "PostSelfBeneficiariesTPTResponse") + public final static class PostSelfBeneficiariesTPTResponse { + private PostSelfBeneficiariesTPTResponse() { + } + + @ApiModelProperty(example = "5") + public Integer resourceId; + } + + @ApiModel(value = "PutSelfBeneficiariesTPTBeneficiaryIdRequest") + public final static class PutSelfBeneficiariesTPTBeneficiaryIdRequest { + private PutSelfBeneficiariesTPTBeneficiaryIdRequest() { + } + + @ApiModelProperty(example = "beneficiary nick name") + public String name; + @ApiModelProperty(example = "1000") + public Integer transferLimit; + } + + @ApiModel(value = "PutSelfBeneficiariesTPTBeneficiaryIdResponse") + public final static class PutSelfBeneficiariesTPTBeneficiaryIdResponse { + private PutSelfBeneficiariesTPTBeneficiaryIdResponse() { + } + + final class PutSelfBeneficiariesChanges { + private PutSelfBeneficiariesChanges() { + } + + @ApiModelProperty(example = "1000") + public Integer transferLimit; + @ApiModelProperty(example = "Client22") + public String name; + } + + @ApiModelProperty(example = "5") + public Integer resourceId; + public PutSelfBeneficiariesChanges changes; + } + + @ApiModel(value = "DeleteSelfBeneficiariesTPTBeneficiaryIdResponse") + public final static class DeleteSelfBeneficiariesTPTBeneficiaryIdResponse { + private DeleteSelfBeneficiariesTPTBeneficiaryIdResponse() { + } + + @ApiModelProperty(example = "5") + public Integer resourceId; + } + + @ApiModel(value = "GetSelfBeneficiariesTPTResponse") + public final static class GetSelfBeneficiariesTPTResponse { + private GetSelfBeneficiariesTPTResponse() { + } + + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "Client2Savings") + public String name; + @ApiModelProperty(example = "Test Office") + public String officeName; + @ApiModelProperty(example = "FN2 LN2") + public String clientName; + public GetSelfBeneficiariesTPTTemplateResponse.GetSelfBeneficiariesAccountOptions accountType; + @ApiModelProperty(example = "000000002") + public Long accountNumber; + @ApiModelProperty(example = "0") + public Integer transferLimit; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/client/api/SelfClientsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/client/api/SelfClientsApiResource.java index b50c33ed4..a68bd902d 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/client/api/SelfClientsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/client/api/SelfClientsApiResource.java @@ -18,18 +18,7 @@ */ package org.apache.fineract.portfolio.self.client.api; -import javax.ws.rs.Consumes; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriInfo; - +import io.swagger.annotations.*; import org.apache.fineract.infrastructure.documentmanagement.api.ImagesApiResource; import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; import org.apache.fineract.portfolio.client.api.ClientApiConstants; @@ -44,9 +33,16 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriInfo; + @Path("/self/clients") @Component @Scope("singleton") +@Api(value = "Self Client", description = "") public class SelfClientsApiResource { private final PlatformSecurityContext context; @@ -78,14 +74,16 @@ public class SelfClientsApiResource { @GET @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) + @ApiOperation(value = "List Clients associated to the user", httpMethod = "GET", notes = "The list capability of clients can support pagination and sorting.\n\n" + "Example Requests:\n" + "\n" + "self/clients\n" + "\n" + "self/clients?fields=displayName,officeName\n" + "\n" + "self/clients?offset=10&limit=50\n" + "\n" + "self/clients?orderBy=displayName&sortOrder=DESC") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = SelfClientsApiResourceSwagger.GetSelfClientsResponse.class)}) public String retrieveAll(@Context final UriInfo uriInfo, - @QueryParam("displayName") final String displayName, - @QueryParam("firstName") final String firstname, - @QueryParam("lastName") final String lastname, - @QueryParam("offset") final Integer offset, - @QueryParam("limit") final Integer limit, - @QueryParam("orderBy") final String orderBy, - @QueryParam("sortOrder") final String sortOrder) { + @QueryParam("displayName") @ApiParam(value = "displayName") final String displayName, + @QueryParam("firstName") @ApiParam(value = "firstName") final String firstname, + @QueryParam("lastName") @ApiParam(value = "lastName") final String lastname, + @QueryParam("offset") @ApiParam(value = "offset") final Integer offset, + @QueryParam("limit") @ApiParam(value = "limit") final Integer limit, + @QueryParam("orderBy") @ApiParam(value = "orderBy") final String orderBy, + @QueryParam("sortOrder") @ApiParam(value = "sortOrder") final String sortOrder) { final String sqlSearch = null; final Long officeId = null; @@ -101,7 +99,9 @@ public class SelfClientsApiResource { @Path("{clientId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveOne(@PathParam("clientId") final Long clientId, + @ApiOperation(value = "Retrieve a Client", httpMethod = "GET", notes = "Retrieves a Client\n\n" + "Example Requests:\n" + "\n" + "self/clients/1\n" + "\n" + "self/clients/1?fields=id,displayName,officeName") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = SelfClientsApiResourceSwagger.GetSelfClientsClientIdResponse.class)}) + public String retrieveOne(@PathParam("clientId") @ApiParam(value = "clientId") final Long clientId, @Context final UriInfo uriInfo) { this.dataValidator.validateRetrieveOne(uriInfo); @@ -117,8 +117,10 @@ public class SelfClientsApiResource { @Path("{clientId}/accounts") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) + @ApiOperation(value = "Retrieve client accounts overview", httpMethod = "GET", notes = "An example of how a loan portfolio summary can be provided. This is requested in a specific use case of the community application.\n" + "It is quite reasonable to add resources like this to simplify User Interface development.\n" + "\n" + "Example Requests:\n" + "\n" + "self/clients/1/accounts\n" + "\n" + "\n" + "self/clients/1/accounts?fields=loanAccounts,savingsAccounts") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = SelfClientsApiResourceSwagger.GetSelfClientsClientIdAccountsResponse.class)}) public String retrieveAssociatedAccounts( - @PathParam("clientId") final Long clientId, + @PathParam("clientId") @ApiParam(value = "clientId") final Long clientId, @Context final UriInfo uriInfo) { validateAppuserClientsMapping(clientId); @@ -132,10 +134,12 @@ public class SelfClientsApiResource { @Consumes({ MediaType.TEXT_PLAIN, MediaType.TEXT_HTML, MediaType.APPLICATION_JSON }) @Produces({ MediaType.TEXT_PLAIN }) - public Response retrieveImage(@PathParam("clientId") final Long clientId, - @QueryParam("maxWidth") final Integer maxWidth, - @QueryParam("maxHeight") final Integer maxHeight, - @QueryParam("output") final String output) { + @ApiOperation(value = "Retrieve Client Image", httpMethod = "GET", notes = "Optional arguments are identical to those of Get Image associated with an Entity (Binary file)\n" + "\n" + "Example Requests:\n" + "\n" + "self/clients/1/images") + @ApiResponses({@ApiResponse(code = 200, message = "OK")}) + public Response retrieveImage(@PathParam("clientId") @ApiParam(value = "clientId") final Long clientId, + @QueryParam("maxWidth") @ApiParam(example = "maxWidth") final Integer maxWidth, + @QueryParam("maxHeight") @ApiParam(example = "maxHeight") final Integer maxHeight, + @QueryParam("output") @ApiParam(example = "output") final String output) { validateAppuserClientsMapping(clientId); @@ -147,13 +151,15 @@ public class SelfClientsApiResource { @Path("{clientId}/charges") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) + @ApiOperation(value = "List Client Charges", httpMethod = "GET", notes = "The list capability of client charges supports pagination.\n\n" + "Example Requests:\n" + "\n" + "self/clients/1/charges\n\n" + "self/clients/1/charges?offset=0&limit=5") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = SelfClientsApiResourceSwagger.GetSelfClientsClientIdChargesResponse.class)}) public String retrieveAllClientCharges( - @PathParam("clientId") final Long clientId, - @DefaultValue(ClientApiConstants.CLIENT_CHARGE_QUERY_PARAM_STATUS_VALUE_ALL) @QueryParam(ClientApiConstants.CLIENT_CHARGE_QUERY_PARAM_STATUS) final String chargeStatus, - @QueryParam("pendingPayment") final Boolean pendingPayment, + @PathParam("clientId") @ApiParam(value = "clientId") final Long clientId, + @DefaultValue(ClientApiConstants.CLIENT_CHARGE_QUERY_PARAM_STATUS_VALUE_ALL) @QueryParam(ClientApiConstants.CLIENT_CHARGE_QUERY_PARAM_STATUS) @ApiParam(value = "chargeStatus") final String chargeStatus, + @QueryParam("pendingPayment") @ApiParam(value = "pendingPayment") final Boolean pendingPayment, @Context final UriInfo uriInfo, - @QueryParam("limit") final Integer limit, - @QueryParam("offset") final Integer offset) { + @QueryParam("limit") @ApiParam(value = "limit") final Integer limit, + @QueryParam("offset") @ApiParam(value = "offset") final Integer offset) { validateAppuserClientsMapping(clientId); @@ -165,9 +171,11 @@ public class SelfClientsApiResource { @Path("{clientId}/charges/{chargeId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) + @ApiOperation(value = "Retrieve a Client Charge", httpMethod = "GET", notes = "Retrieves a Client Charge\n\n" + "Example Requests:\n" + "\n" + "self/clients/1/charges/1\n" + "\n" + "\n" + "self/clients/1/charges/1?fields=name,id") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = SelfClientsApiResourceSwagger.GetSelfClientsClientIdChargesChargeIdResponse.class)}) public String retrieveClientCharge( - @PathParam("clientId") final Long clientId, - @PathParam("chargeId") final Long chargeId, + @PathParam("clientId") @ApiParam(value = "clientId") final Long clientId, + @PathParam("chargeId") @ApiParam(value = "chargeId") final Long chargeId, @Context final UriInfo uriInfo) { this.dataValidator.validateClientCharges(uriInfo); @@ -182,11 +190,13 @@ public class SelfClientsApiResource { @Path("{clientId}/transactions") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) + @ApiOperation(value = "List Client Transactions", httpMethod = "GET", notes = "The list capability of client transaction can support pagination.\n\n" + "Example Requests:\n" + "\n" + "self/clients/189/transactions\n\n" + "self/clients/189/transactions?offset=10&limit=50") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = SelfClientsApiResourceSwagger.GetSelfClientsClientIdTransactionsResponse.class)}) public String retrieveAllClientTransactions( - @PathParam("clientId") final Long clientId, + @PathParam("clientId") @ApiParam(value = "clientId") final Long clientId, @Context final UriInfo uriInfo, - @QueryParam("offset") final Integer offset, - @QueryParam("limit") final Integer limit) { + @QueryParam("offset") @ApiParam(value = "offset") final Integer offset, + @QueryParam("limit") @ApiParam(value = "limit") final Integer limit) { validateAppuserClientsMapping(clientId); @@ -198,9 +208,11 @@ public class SelfClientsApiResource { @Path("{clientId}/transactions/{transactionId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) + @ApiOperation(value = "Retrieve a Client Transaction", httpMethod = "GET", notes = "Retrieves a Client Transaction" + "Example Requests:\n" + "\n" + "self/clients/1/transactions/1\n" + "\n" + "\n" + "self/clients/1/transactions/1?fields=id,officeName") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = SelfClientsApiResourceSwagger.GetSelfClientsClientIdTransactionsTransactionIdResponse.class)}) public String retrieveClientTransaction( - @PathParam("clientId") final Long clientId, - @PathParam("transactionId") final Long transactionId, + @PathParam("clientId") @ApiParam(value = "clientId") final Long clientId, + @PathParam("transactionId") @ApiParam(value = "transactionId") final Long transactionId, @Context final UriInfo uriInfo) { validateAppuserClientsMapping(clientId); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/client/api/SelfClientsApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/client/api/SelfClientsApiResourceSwagger.java new file mode 100644 index 000000000..d2e998982 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/client/api/SelfClientsApiResourceSwagger.java @@ -0,0 +1,439 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.self.client.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.time.LocalDate; +import java.util.List; +import java.util.Set; + +/** + * Created by Chirag Gupta on 12/21/17. + */ + +final class SelfClientsApiResourceSwagger { + private SelfClientsApiResourceSwagger() { + } + + @ApiModel(value = "GetSelfClientsResponse") + public final static class GetSelfClientsResponse { + private GetSelfClientsResponse() { + } + + final class GetSelfClientsPageItems { + private GetSelfClientsPageItems() { + } + + final class GetSelfClientsStatus { + private GetSelfClientsStatus() { + } + + @ApiModelProperty(example = "300") + public Integer id; + @ApiModelProperty(example = "clientStatusType.active") + public String code; + @ApiModelProperty(example = "Active") + public String value; + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "000000001") + public Long accountNo; + public GetSelfClientsStatus status; + @ApiModelProperty(example = "true") + public Boolean active; + @ApiModelProperty(example = "[2013, 3, 1]") + public LocalDate activationDate; + @ApiModelProperty(example = "Small shop") + public String fullname; + @ApiModelProperty(example = "Small shop") + public String displayName; + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "Head Office") + public String officeName; + } + + @ApiModelProperty(example = "2") + public Integer totalFilteredRecords; + public Set pageItems; + } + + @ApiModel(value = "GetSelfClientsClientIdResponse") + public final static class GetSelfClientsClientIdResponse { + private GetSelfClientsClientIdResponse() { + } + + final class GetSelfClientsTimeline { + private GetSelfClientsTimeline() { + } + + @ApiModelProperty(example = "[2013, 1, 1]") + public LocalDate submittedOnDate; + @ApiModelProperty(example = "mifos") + public String submittedByUsername; + @ApiModelProperty(example = "App") + public String submittedByFirstname; + @ApiModelProperty(example = "Administrator") + public String submittedByLastname; + @ApiModelProperty(example = "[2013, 1, 1]") + public LocalDate activatedOnDate; + @ApiModelProperty(example = "mifos") + public String activatedByUsername; + @ApiModelProperty(example = "App") + public String activatedByFirstname; + @ApiModelProperty(example = "Administrator") + public String activatedByLastname; + + } + + @ApiModelProperty(example = "27") + public Integer id; + @ApiModelProperty(example = "000000027") + public Long accountNo; + public GetSelfClientsResponse.GetSelfClientsPageItems.GetSelfClientsStatus status; + @ApiModelProperty(example = "true") + public Boolean active; + @ApiModelProperty(example = "[2013, 1, 1]") + public LocalDate activationDate; + @ApiModelProperty(example = "savings") + public String firstname; + @ApiModelProperty(example = "test") + public String lastname; + @ApiModelProperty(example = "savings test") + public String displayName; + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "Head Office") + public String officeName; + public GetSelfClientsTimeline timeline; + @ApiModelProperty(example = "4") + public Integer savingsProductId; + @ApiModelProperty(example = "account overdraft") + public String savingsProductName; + @ApiModelProperty(example = "") + public List groups; + } + + @ApiModel(value = "GetSelfClientsClientIdAccountsResponse") + public final static class GetSelfClientsClientIdAccountsResponse { + private GetSelfClientsClientIdAccountsResponse() { + } + + final class GetSelfClientsLoanAccounts { + private GetSelfClientsLoanAccounts() { + } + + final class GetSelfClientsLoanAccountsStatus { + private GetSelfClientsLoanAccountsStatus() { + } + + @ApiModelProperty(example = "300") + public Integer id; + @ApiModelProperty(example = "loanStatusType.active") + public String code; + @ApiModelProperty(example = "Active") + public String value; + @ApiModelProperty(example = "false") + public Boolean pendingApproval; + @ApiModelProperty(example = "false") + public Boolean waitingForDisbursal; + @ApiModelProperty(example = "true") + public Boolean active; + @ApiModelProperty(example = "false") + public Boolean closedObligationsMet; + @ApiModelProperty(example = "false") + public Boolean closedWrittenOff; + @ApiModelProperty(example = "false") + public Boolean closedRescheduled; + @ApiModelProperty(example = "false") + public Boolean closed; + @ApiModelProperty(example = "false") + public Boolean overpaid; + } + + final class GetSelfClientsLoanAccountsType { + private GetSelfClientsLoanAccountsType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "loanType.individual") + public String code; + @ApiModelProperty(example = "Individual") + public String value; + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "000000001") + public Long accountNo; + @ApiModelProperty(example = "456") + public Integer externalId; + @ApiModelProperty(example = "1") + public Integer productId; + @ApiModelProperty(example = "TestOne") + public String productName; + public GetSelfClientsLoanAccountsStatus status; + public GetSelfClientsLoanAccountsType loanType; + @ApiModelProperty(example = "1") + public Integer loanCycle; + } + + final class GetSelfClientsSavingsAccounts { + private GetSelfClientsSavingsAccounts() { + } + + final class GetSelfClientsSavingsAccountsCurrency { + private GetSelfClientsSavingsAccountsCurrency() { + } + + @ApiModelProperty(example = "USD") + public String code; + @ApiModelProperty(example = "US Dollar") + public String name; + @ApiModelProperty(example = "2") + public Integer decimalPlaces; + @ApiModelProperty(example = "$") + public String displaySymbol; + @ApiModelProperty(example = "currency.USD") + public String nameCode; + @ApiModelProperty(example = "US Dollar ($)") + public String displayLabel; + } + + final class GetSelfClientsSavingsAccountsStatus { + private GetSelfClientsSavingsAccountsStatus() { + } + + @ApiModelProperty(example = "100") + public Integer id; + @ApiModelProperty(example = "savingsAccountStatusType.submitted.and.pending.approval") + public String code; + @ApiModelProperty(example = "Submitted and pending approval") + public String value; + @ApiModelProperty(example = "true") + public Boolean submittedAndPendingApproval; + @ApiModelProperty(example = "false") + public Boolean approved; + @ApiModelProperty(example = "false") + public Boolean rejected; + @ApiModelProperty(example = "false") + public Boolean withdrawnByApplicant; + @ApiModelProperty(example = "false") + public Boolean active; + @ApiModelProperty(example = "false") + public Boolean closed; + } + + @ApiModelProperty(example = "7") + public Integer id; + @ApiModelProperty(example = "000000007") + public Long accountNo; + @ApiModelProperty(example = "2") + public Integer productId; + @ApiModelProperty(example = "Other product") + public String productName; + public GetSelfClientsSavingsAccountsStatus status; + public GetSelfClientsSavingsAccountsCurrency currency; + } + + public Set loanAccounts; + public Set savingsAccounts; + } + + @ApiModel(value = "GetSelfClientsClientIdChargesResponse") + public final static class GetSelfClientsClientIdChargesResponse { + private GetSelfClientsClientIdChargesResponse() { + } + + final class GetSelfClientsChargesPageItems { + private GetSelfClientsChargesPageItems() { + } + + final class GetSelfClientsChargeTimeType { + private GetSelfClientsChargeTimeType() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "chargeTimeType.specifiedDueDate") + public String code; + @ApiModelProperty(example = "Specified due date") + public String value; + } + + final class GetSelfClientsChargeCalculationType { + private GetSelfClientsChargeCalculationType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "chargeCalculationType.flat") + public String code; + @ApiModelProperty(example = "Flat") + public String value; + } + + @ApiModelProperty(example = "5") + public Integer id; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "6") + public Integer chargeId; + @ApiModelProperty(example = "Client Fees 2") + public String name; + public GetSelfClientsChargeTimeType chargeTimeType; + @ApiModelProperty(example = "[2015, 9, 1]") + public LocalDate dueDate; + public GetSelfClientsChargeCalculationType chargeCalculationType; + public GetSelfClientsClientIdAccountsResponse.GetSelfClientsSavingsAccounts.GetSelfClientsSavingsAccountsCurrency currency; + @ApiModelProperty(example = "550") + public Float amount; + @ApiModelProperty(example = "0") + public Float amountPaid; + @ApiModelProperty(example = "0") + public Float amountWaived; + @ApiModelProperty(example = "0") + public Float amountWrittenOff; + @ApiModelProperty(example = "550") + public Float amountOutstanding; + @ApiModelProperty(example = "false") + public Boolean penalty; + @ApiModelProperty(example = "true") + public Boolean isActive; + @ApiModelProperty(example = "false") + public Boolean isPaid; + @ApiModelProperty(example = "false") + public Boolean isWaived; + } + + @ApiModelProperty(example = "4") + public Integer totalFilteredRecords; + public Set pageItems; + } + + @ApiModel(value = "GetSelfClientsClientIdChargesChargeIdResponse") + public final static class GetSelfClientsClientIdChargesChargeIdResponse { + private GetSelfClientsClientIdChargesChargeIdResponse() { + } + + @ApiModelProperty(example = "3") + public Integer id; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "5") + public Integer chargeId; + @ApiModelProperty(example = "Client Fee 1") + public String name; + public GetSelfClientsClientIdChargesResponse.GetSelfClientsChargesPageItems.GetSelfClientsChargeTimeType chargeTimeType; + @ApiModelProperty(example = "[2015, 8, 17]") + public LocalDate dueDate; + public GetSelfClientsClientIdChargesResponse.GetSelfClientsChargesPageItems.GetSelfClientsChargeCalculationType chargeCalculationType; + public GetSelfClientsClientIdAccountsResponse.GetSelfClientsSavingsAccounts.GetSelfClientsSavingsAccountsCurrency currency; + @ApiModelProperty(example = "100") + public Float amount; + @ApiModelProperty(example = "0") + public Float amountPaid; + @ApiModelProperty(example = "100") + public Float amountWaived; + @ApiModelProperty(example = "0") + public Float amountWrittenOff; + @ApiModelProperty(example = "0") + public Float amountOutstanding; + @ApiModelProperty(example = "true") + public Boolean penalty; + @ApiModelProperty(example = "true") + public Boolean isActive; + @ApiModelProperty(example = "false") + public Boolean isPaid; + @ApiModelProperty(example = "true") + public Boolean isWaived; + } + + @ApiModel(value = "GetSelfClientsClientIdTransactionsResponse") + public final static class GetSelfClientsClientIdTransactionsResponse { + private GetSelfClientsClientIdTransactionsResponse() { + } + + final class GetSelfClientsClientIdTransactionsPageItems { + private GetSelfClientsClientIdTransactionsPageItems() { + } + + final class GetSelfClientsClientIdTransactionsType { + private GetSelfClientsClientIdTransactionsType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "clientTransactionType.payCharge") + public String code; + @ApiModelProperty(example = "PAY_CHARGE") + public String value; + } + + @ApiModelProperty(example = "226") + public Integer id; + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "Head Office") + public String officeName; + public GetSelfClientsClientIdTransactionsType type; + @ApiModelProperty(example = "[2015, 9, 2]") + public LocalDate date; + public GetSelfClientsClientIdAccountsResponse.GetSelfClientsSavingsAccounts.GetSelfClientsSavingsAccountsCurrency currency; + @ApiModelProperty(example = "22") + public Double amount; + @ApiModelProperty(example = "[2015, 9, 2]") + public LocalDate submittedOnDate; + @ApiModelProperty(example = "false") + public Boolean reversed; + } + + @ApiModelProperty(example = "20") + public Integer totalFilteredRecords; + public Set pageItems; + } + + @ApiModel(value = "GetSelfClientsClientIdTransactionsTransactionIdResponse") + public final static class GetSelfClientsClientIdTransactionsTransactionIdResponse { + private GetSelfClientsClientIdTransactionsTransactionIdResponse() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "Head Office") + public String officeName; + public GetSelfClientsClientIdTransactionsResponse.GetSelfClientsClientIdTransactionsPageItems.GetSelfClientsClientIdTransactionsType type; + @ApiModelProperty(example = "[2015, 8, 17]") + public LocalDate date; + public GetSelfClientsClientIdAccountsResponse.GetSelfClientsSavingsAccounts.GetSelfClientsSavingsAccountsCurrency currency; + @ApiModelProperty(example = "60.000000") + public Float amount; + @ApiModelProperty(example = "[2015, 8, 19]") + public LocalDate submittedOnDate; + @ApiModelProperty(example = "true") + public Boolean reversed; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/loanaccount/api/SelfLoansApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/loanaccount/api/SelfLoansApiResource.java index 728175288..f747de999 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/loanaccount/api/SelfLoansApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/loanaccount/api/SelfLoansApiResource.java @@ -18,20 +18,7 @@ */ package org.apache.fineract.portfolio.self.loanaccount.api; -import java.util.HashMap; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriInfo; - +import io.swagger.annotations.*; import org.apache.commons.lang.StringUtils; import org.apache.fineract.infrastructure.core.exception.UnrecognizedQueryParamException; import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; @@ -50,9 +37,16 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; +import java.util.HashMap; + @Path("/self/loans") @Component @Scope("singleton") +@Api(value = "Self Loans", description = "") public class SelfLoansApiResource { private final PlatformSecurityContext context; @@ -84,7 +78,9 @@ public class SelfLoansApiResource { @Path("{loanId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveLoan(@PathParam("loanId") final Long loanId, + @ApiOperation(value = "Retrieve a Loan", httpMethod = "GET", notes = "Retrieves a Loan\n\n" + "Example Requests:\n" + "\n" + "self/loans/1\n" + "\n" + "\n" + "self/loans/1?fields=id,principal,annualInterestRate\n" + "\n" + "\n" + "self/loans/1?fields=id,principal,annualInterestRate&associations=repaymentSchedule,transactions") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = SelfLoansApiResourceSwagger.GetSelfLoansLoanIdResponse.class)}) + public String retrieveLoan(@PathParam("loanId") @ApiParam(value = "loanId") final Long loanId, @Context final UriInfo uriInfo) { this.dataValidator.validateRetrieveLoan(uriInfo); @@ -100,8 +96,10 @@ public class SelfLoansApiResource { @Path("{loanId}/transactions/{transactionId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveTransaction(@PathParam("loanId") final Long loanId, - @PathParam("transactionId") final Long transactionId, + @ApiOperation(value = "Retrieve a Loan Transaction Details", httpMethod = "GET", notes = "Retrieves a Loan Transaction Details" + "Example Request:\n" + "\n" + "self/loans/5/transactions/3") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = SelfLoansApiResourceSwagger.GetSelfLoansLoanIdTransactionsTransactionIdResponse.class)}) + public String retrieveTransaction(@PathParam("loanId") @ApiParam(value = "loanId") final Long loanId, + @PathParam("transactionId") @ApiParam(value = "transactionId") final Long transactionId, @Context final UriInfo uriInfo) { this.dataValidator.validateRetrieveTransaction(uriInfo); @@ -116,8 +114,10 @@ public class SelfLoansApiResource { @Path("{loanId}/charges") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) + @ApiOperation(value = "List Loan Charges", httpMethod = "GET", notes = "Lists loan Charges\n\n" + "Example Requests:\n" + "\n" + "self/loans/1/charges\n" + "\n" + "\n" + "self/loans/1/charges?fields=name,amountOrPercentage") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = SelfLoansApiResourceSwagger.GetSelfLoansLoanIdChargesResponse.class, responseContainer = "List")}) public String retrieveAllLoanCharges( - @PathParam("loanId") final Long loanId, + @PathParam("loanId") @ApiParam(value = "loanId") final Long loanId, @Context final UriInfo uriInfo) { validateAppuserLoanMapping(loanId); @@ -130,8 +130,10 @@ public class SelfLoansApiResource { @Path("{loanId}/charges/{chargeId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveLoanCharge(@PathParam("loanId") final Long loanId, - @PathParam("chargeId") final Long loanChargeId, + @ApiOperation(value = "Retrieve a Loan Charge", httpMethod = "GET", notes = "Retrieves a Loan Charge\n\n" + "Example Requests:\n" + "\n" + "self/loans/1/charges/1\n" + "\n" + "\n" + "self/loans/1/charges/1?fields=name,amountOrPercentage") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = SelfLoansApiResourceSwagger.GetSelfLoansLoanIdChargesResponse.class)}) + public String retrieveLoanCharge(@PathParam("loanId") @ApiParam(value = "loanId") final Long loanId, + @PathParam("chargeId") @ApiParam(value = "chargeId") final Long loanChargeId, @Context final UriInfo uriInfo) { validateAppuserLoanMapping(loanId); @@ -143,9 +145,11 @@ public class SelfLoansApiResource { @Path("template") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String template(@QueryParam("clientId") final Long clientId, - @QueryParam("productId") final Long productId, - @QueryParam("templateType") final String templateType, + @ApiOperation(value = "Retrieve Loan Details Template", httpMethod = "GET", notes = "Retrieves Loan Details Template\n\n" + "This is a convenience resource. It can be useful when building maintenance user interface screens for client applications. The template data returned consists of any or all of:\n" + "\n" + "Field Defaults\n" + "Allowed Value Lists\n\n" + "Example Requests:\n" + "\n" + "self/loans/template?templateType=individual&clientId=1\n" + "\n" + "\n" + "self/loans/template?templateType=individual&clientId=1&productId=1") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = SelfLoansApiResourceSwagger.GetSelfLoansTemplateResponse.class)}) + public String template(@QueryParam("clientId") @ApiParam(value = "clientId") final Long clientId, + @QueryParam("productId") @ApiParam(value = "productId") final Long productId, + @QueryParam("templateType") @ApiParam(value = "templateType") final String templateType, @Context final UriInfo uriInfo) { if(clientId != null){ @@ -171,8 +175,11 @@ public class SelfLoansApiResource { @POST @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String calculateLoanScheduleOrSubmitLoanApplication(@QueryParam("command") final String commandParam, - @Context final UriInfo uriInfo, final String apiRequestBodyAsJson) { + @ApiOperation(value = "Calculate Loan Repayment Schedule | Submit a new Loan Application", httpMethod = "POST", notes = "Calculate Loan Repayment Schedule:\n\n" + "Calculates Loan Repayment Schedule\n\n" + "Mandatory Fields: productId, principal, loanTermFrequency, loanTermFrequencyType, numberOfRepayments, repaymentEvery, repaymentFrequencyType, interestRatePerPeriod, amortizationType, interestType, interestCalculationPeriodType, expectedDisbursementDate, transactionProcessingStrategyId\n\n" + "Submit a new Loan Application:\n\n" + "Mandatory Fields: clientId, productId, principal, loanTermFrequency, loanTermFrequencyType, loanType, numberOfRepayments, repaymentEvery, repaymentFrequencyType, interestRatePerPeriod, amortizationType, interestType, interestCalculationPeriodType, transactionProcessingStrategyId, expectedDisbursementDate, submittedOnDate, loanType\n\n" + "Additional Mandatory Fields if interest recalculation is enabled for product and Rest frequency not same as repayment period: recalculationRestFrequencyDate\n\n" + "Additional Mandatory Fields if interest recalculation with interest/fee compounding is enabled for product and compounding frequency not same as repayment period: recalculationCompoundingFrequencyDate\n\n" + "Additional Mandatory Field if Entity-Datatable Check is enabled for the entity of type loan: datatables\n\n" + "Optional Fields: graceOnPrincipalPayment, graceOnInterestPayment, graceOnInterestCharged, linkAccountId, allowPartialPeriodInterestCalcualtion, fixedEmiAmount, maxOutstandingLoanBalance, disbursementData, graceOnArrearsAgeing, createStandingInstructionAtDisbursement (requires linkedAccountId if set to true)\n\n" + "Showing request/response for 'Submit a new Loan Application'") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = SelfLoansApiResourceSwagger.PostSelfLoansRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = SelfLoansApiResourceSwagger.PostSelfLoansResponse.class)}) + public String calculateLoanScheduleOrSubmitLoanApplication(@QueryParam("command") @ApiParam(value = "command") final String commandParam, + @Context final UriInfo uriInfo, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { HashMap attr = this.dataValidator.validateLoanApplication(apiRequestBodyAsJson); final Long clientId = (Long) attr.get("clientId"); @@ -186,7 +193,10 @@ public class SelfLoansApiResource { @Path("{loanId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String modifyLoanApplication(@PathParam("loanId") final Long loanId, final String apiRequestBodyAsJson) { + @ApiOperation(value = "Update a Loan Application", httpMethod = "PUT", notes = "Loan application can only be modified when in 'Submitted and pending approval' state. Once the application is approved, the details cannot be changed using this method.") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = SelfLoansApiResourceSwagger.PutSelfLoansLoanIdRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = SelfLoansApiResourceSwagger.PutSelfLoansLoanIdResponse.class)}) + public String modifyLoanApplication(@PathParam("loanId") @ApiParam(value = "loanId") final Long loanId, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { HashMap attr = this.dataValidator.validateModifyLoanApplication(apiRequestBodyAsJson); validateAppuserLoanMapping(loanId); @@ -202,8 +212,11 @@ public class SelfLoansApiResource { @Path("{loanId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String stateTransitions(@PathParam("loanId") final Long loanId, @QueryParam("command") final String commandParam, - final String apiRequestBodyAsJson) { + @ApiOperation(value = "Applicant Withdraws from Loan Application", httpMethod = "POST", notes = "Applicant Withdraws from Loan Application\n\n" + "Mandatory Fields: withdrawnOnDate") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = SelfLoansApiResourceSwagger.PostSelfLoansLoanIdRequest.class)}) + @ApiResponses({@ApiResponse(code = 200,message = "OK", response = SelfLoansApiResourceSwagger.PostSelfLoansLoanIdResponse.class)}) + public String stateTransitions(@PathParam("loanId") @ApiParam(value = "loanId") final Long loanId, @QueryParam("command") @ApiParam(value = "command") final String commandParam, + @ApiParam(hidden = true) final String apiRequestBodyAsJson) { if (!is(commandParam, "withdrawnByApplicant")) { throw new UnrecognizedQueryParamException("command", commandParam); } @@ -233,4 +246,4 @@ public class SelfLoansApiResource { return StringUtils.isNotBlank(commandParam) && commandParam.trim().equalsIgnoreCase(commandValue); } -} \ No newline at end of file +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/loanaccount/api/SelfLoansApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/loanaccount/api/SelfLoansApiResourceSwagger.java new file mode 100644 index 000000000..d9c3f9afd --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/loanaccount/api/SelfLoansApiResourceSwagger.java @@ -0,0 +1,845 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.self.loanaccount.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.time.LocalDate; +import java.util.Set; + +/** + * Created by Chirag Gupta on 12/19/17. + */ +final class SelfLoansApiResourceSwagger { + private SelfLoansApiResourceSwagger() { + } + + @ApiModel(value = "GetSelfLoansLoanIdResponse") + public final static class GetSelfLoansLoanIdResponse { + private GetSelfLoansLoanIdResponse() { + } + + final class GetLoansLoanIdStatus { + private GetLoansLoanIdStatus() { + } + + @ApiModelProperty(example = "300") + public Integer id; + @ApiModelProperty(example = "loanStatusType.active") + public String code; + @ApiModelProperty(example = "Active") + public String value; + @ApiModelProperty(example = "false") + public Boolean pendingApproval; + @ApiModelProperty(example = "false") + public Boolean waitingForDisbursal; + @ApiModelProperty(example = "true") + public Boolean active; + @ApiModelProperty(example = "false") + public Boolean closedObligationsMet; + @ApiModelProperty(example = "false") + public Boolean closedWrittenOff; + @ApiModelProperty(example = "false") + public Boolean closedRescheduled; + @ApiModelProperty(example = "false") + public Boolean closed; + @ApiModelProperty(example = "false") + public Boolean overpaid; + } + + final class GetLoansLoanIdLoanType { + private GetLoansLoanIdLoanType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "loanType.individual") + public String code; + @ApiModelProperty(example = "Individual") + public String value; + } + + final class GetLoansLoanIdCurrency { + private GetLoansLoanIdCurrency() { + } + + @ApiModelProperty(example = "UGX") + public String code; + @ApiModelProperty(example = "Uganda Shilling") + public String name; + @ApiModelProperty(example = "2") + public Integer decimalPlaces; + @ApiModelProperty(example = "USh") + public String displaySymbol; + @ApiModelProperty(example = "currency.UGX") + public String nameCode; + @ApiModelProperty(example = "Uganda Shilling (USh)") + public String displayLabel; + } + + final class GetLoansLoanIdTermPeriodFrequencyType { + private GetLoansLoanIdTermPeriodFrequencyType() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "termFrequency.periodFrequencyType.months") + public String code; + @ApiModelProperty(example = "Months") + public String value; + } + + final class GetLoansLoanIdRepaymentFrequencyType { + private GetLoansLoanIdRepaymentFrequencyType() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "repaymentFrequency.periodFrequencyType.months") + public String code; + @ApiModelProperty(example = "Months") + public String value; + } + + final class GetLoansLoanIdInterestRateFrequencyType { + private GetLoansLoanIdInterestRateFrequencyType() { + } + + @ApiModelProperty(example = "3") + public Integer id; + @ApiModelProperty(example = "interestRateFrequency.periodFrequencyType.years") + public String code; + @ApiModelProperty(example = "Per year") + public String value; + } + + final class GetLoansLoanIdAmortizationType { + private GetLoansLoanIdAmortizationType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "amortizationType.equal.installments") + public String code; + @ApiModelProperty(example = "Equal installments") + public String value; + } + + final class GetLoansLoanIdInterestType { + private GetLoansLoanIdInterestType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "interestType.flat") + public String code; + @ApiModelProperty(example = "Flat") + public String value; + } + + final class GetLoansLoanIdInterestCalculationPeriodType { + private GetLoansLoanIdInterestCalculationPeriodType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "interestCalculationPeriodType.same.as.repayment.period") + public String code; + @ApiModelProperty(example = "Same as repayment period") + public String value; + } + + final class GetLoansLoanIdTimeline { + private GetLoansLoanIdTimeline() { + } + + @ApiModelProperty(example = "[2012, 4, 3]") + public LocalDate submittedOnDate; + @ApiModelProperty(example = "admin") + public String submittedByUsername; + @ApiModelProperty(example = "App") + public String submittedByFirstname; + @ApiModelProperty(example = "Administrator") + public String submittedByLastname; + @ApiModelProperty(example = "[2012, 4, 3]") + public LocalDate approvedOnDate; + @ApiModelProperty(example = "admin") + public String approvedByUsername; + @ApiModelProperty(example = "App") + public String approvedByFirstname; + @ApiModelProperty(example = "Administrator") + public String approvedByLastname; + @ApiModelProperty(example = "[2012, 4, 10]") + public LocalDate expectedDisbursementDate; + @ApiModelProperty(example = "[2012, 4, 10]") + public LocalDate actualDisbursementDate; + @ApiModelProperty(example = "admin") + public String disbursedByUsername; + @ApiModelProperty(example = "App") + public String disbursedByFirstname; + @ApiModelProperty(example = "Administrator") + public String disbursedByLastname; + @ApiModelProperty(example = "[2012, 4, 10]") + public LocalDate expectedMaturityDate; + } + + final class GetLoansLoanIdSummary { + private GetLoansLoanIdSummary() { + } + + final class GetLoansLoanIdEmiVariations { + private GetLoansLoanIdEmiVariations() { + } + } + + final class GetLoansLoanIdLinkedAccount { + private GetLoansLoanIdLinkedAccount() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "000000001") + public Long accountNo; + } + + final class GetLoansLoanIdDisbursementDetails { + private GetLoansLoanIdDisbursementDetails() { + } + + @ApiModelProperty(example = "71") + public Integer id; + @ApiModelProperty(example = "[2013, 11, 1]") + public LocalDate expectedDisbursementDate; + @ApiModelProperty(example = "22000.000000") + public Float principal; + @ApiModelProperty(example = "22000.000000") + public Float approvedPrincipal; + } + + final class GetLoansLoanIdOverdueCharges { + private GetLoansLoanIdOverdueCharges() { + } + + final class GetLoansLoanIdChargeTimeType { + private GetLoansLoanIdChargeTimeType() { + } + + @ApiModelProperty(example = "9") + public Integer id; + @ApiModelProperty(example = "chargeTimeType.overdueInstallment") + public String code; + @ApiModelProperty(example = "overdue fees") + public String value; + } + + final class GetLoansLoanIdChargeCalculationType { + private GetLoansLoanIdChargeCalculationType() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "chargeCalculationType.percent.of.amount") + public String code; + @ApiModelProperty(example = "% Amount") + public String value; + } + + final class GetLoansLoanIdChargePaymentMode { + private GetLoansLoanIdChargePaymentMode() { + } + + @ApiModelProperty(example = "0") + public Integer id; + @ApiModelProperty(example = "chargepaymentmode.regular") + public String code; + @ApiModelProperty(example = "Regular") + public String value; + } + + final class GetLoansLoanIdFeeFrequency { + private GetLoansLoanIdFeeFrequency() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "feeFrequencyperiodFrequencyType.weeks") + public String code; + @ApiModelProperty(example = "Weeks") + public String value; + } + + final class GetLoanCurrency { + private GetLoanCurrency() { + } + + @ApiModelProperty(example = "USD") + public String code; + @ApiModelProperty(example = "US Dollar") + public String name; + @ApiModelProperty(example = "2") + public Integer decimalPlaces; + @ApiModelProperty(example = "$") + public String displaySymbol; + @ApiModelProperty(example = "currency.USD") + public String nameCode; + @ApiModelProperty(example = "US Dollar ($)") + public String displayLabel; + } + + final class GetLoanChargeTemplateChargeAppliesTo { + private GetLoanChargeTemplateChargeAppliesTo() { + } + + @ApiModelProperty(example = "1 ") + public Integer id; + @ApiModelProperty(example = "chargeAppliesTo.loan") + public String code; + @ApiModelProperty(example = "Loan") + public String value; + } + + @ApiModelProperty(example = "20") + public Integer id; + @ApiModelProperty(example = "overdraft penality") + public String name; + @ApiModelProperty(example = "true") + public Boolean active; + @ApiModelProperty(example = "true") + public Boolean penalty; + public GetLoanCurrency currency; + @ApiModelProperty(example = "3.000000") + public Float amount; + public GetLoansLoanIdChargeTimeType chargeTimeType; + public GetLoanChargeTemplateChargeAppliesTo chargeAppliesTo; + public GetLoansLoanIdChargeCalculationType chargeCalculationType; + public GetLoansLoanIdChargePaymentMode chargePaymentMode; + @ApiModelProperty(example = "2") + public Integer feeInterval; + public GetLoansLoanIdFeeFrequency feeFrequency; + } + + public GetLoansLoanIdCurrency currency; + @ApiModelProperty(example = "1000000") + public Long principalDisbursed; + @ApiModelProperty(example = "0") + public Long principalPaid; + @ApiModelProperty(example = "0") + public Long principalWrittenOff; + @ApiModelProperty(example = "1000000") + public Long principalOutstanding; + @ApiModelProperty(example = "833333.3") + public Double principalOverdue; + @ApiModelProperty(example = "240000") + public Long interestCharged; + @ApiModelProperty(example = "0") + public Long interestPaid; + @ApiModelProperty(example = "0") + public Long interestWaived; + @ApiModelProperty(example = "0") + public Long interestWrittenOff; + @ApiModelProperty(example = "240000") + public Long interestOutstanding; + @ApiModelProperty(example = "200000") + public Long interestOverdue; + @ApiModelProperty(example = "18000") + public Long feeChargesCharged; + @ApiModelProperty(example = "0") + public Long feeChargesDueAtDisbursementCharged; + @ApiModelProperty(example = "0") + public Long feeChargesPaid; + @ApiModelProperty(example = "0") + public Long feeChargesWaived; + @ApiModelProperty(example = "0") + public Long feeChargesWrittenOff; + @ApiModelProperty(example = "18000") + public Long feeChargesOutstanding; + @ApiModelProperty(example = "15000") + public Long feeChargesOverdue; + @ApiModelProperty(example = "0") + public Long penaltyChargesCharged; + @ApiModelProperty(example = "0") + public Long penaltyChargesPaid; + @ApiModelProperty(example = "0") + public Long penaltyChargesWaived; + @ApiModelProperty(example = "0") + public Long penaltyChargesWrittenOff; + @ApiModelProperty(example = "0") + public Long penaltyChargesOutstanding; + @ApiModelProperty(example = "0") + public Long penaltyChargesOverdue; + @ApiModelProperty(example = "1258000") + public Long totalExpectedRepayment; + @ApiModelProperty(example = "0") + public Long totalRepayment; + @ApiModelProperty(example = "258000") + public Long totalExpectedCostOfLoan; + @ApiModelProperty(example = "0") + public Long totalCostOfLoan; + @ApiModelProperty(example = "0") + public Long totalWaived; + @ApiModelProperty(example = "0") + public Long totalWrittenOff; + @ApiModelProperty(example = "1258000") + public Long totalOutstanding; + @ApiModelProperty(example = "1048333.3") + public Double totalOverdue; + @ApiModelProperty(example = "[2012, 5, 10]") + public LocalDate overdueSinceDate; + public GetLoansLoanIdLinkedAccount linkedAccount; + public Set disbursementDetails; + @ApiModelProperty(example = "1100.000000") + public Float fixedEmiAmount; + @ApiModelProperty(example = "35000") + public Long maxOutstandingLoanBalance; + @ApiModelProperty(example = "false") + public Boolean canDisburse; + public Set emiAmountVariations; + @ApiModelProperty(example = "true") + public Boolean inArrears; + @ApiModelProperty(example = "false") + public Boolean isNPA; + public Set overdueCharges; + } + + @ApiModelProperty(example = "1") + public Long id; + @ApiModelProperty(example = "000000001") + public Long accountNo; + public GetLoansLoanIdStatus status; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "Kampala first Client") + public String clientName; + @ApiModelProperty(example = "2") + public Integer clientOfficeId; + @ApiModelProperty(example = "1") + public Integer loanProductId; + @ApiModelProperty(example = "Kampala Product (with cash accounting)") + public String loanProductName; + @ApiModelProperty(example = "Typical Kampala loan product with cash accounting enabled for testing.") + public String loanProductDescription; + @ApiModelProperty(example = "22") + public Integer loanPurposeId; + @ApiModelProperty(example = "option.HousingImprovement") + public String loanPurposeName; + @ApiModelProperty(example = "2") + public Integer loanOfficerId; + @ApiModelProperty(example = "LoanOfficer, Kampala") + public String loanOfficerName; + public GetLoansLoanIdLoanType loanType; + public GetLoansLoanIdCurrency currency; + @ApiModelProperty(example = "1000000") + public Long principal; + @ApiModelProperty(example = "12") + public Integer termFrequency; + public GetLoansLoanIdTermPeriodFrequencyType termPeriodFrequencyType; + @ApiModelProperty(example = "12") + public Integer numberOfRepayments; + @ApiModelProperty(example = "1") + public Integer repaymentEvery; + public GetLoansLoanIdRepaymentFrequencyType repaymentFrequencyType; + @ApiModelProperty(example = "24") + public Integer interestRatePerPeriod; + public GetLoansLoanIdInterestRateFrequencyType interestRateFrequencyType; + @ApiModelProperty(example = "24") + public Integer annualInterestRate; + public GetLoansLoanIdAmortizationType amortizationType; + public GetLoansLoanIdInterestType interestType; + public GetLoansLoanIdInterestCalculationPeriodType interestCalculationPeriodType; + @ApiModelProperty(example = "2") + public Integer transactionProcessingStrategyId; + public GetLoansLoanIdTimeline timeline; + public GetLoansLoanIdSummary summary; + } + + @ApiModel(value = "GetSelfLoansLoanIdTransactionsTransactionIdResponse") + public final static class GetSelfLoansLoanIdTransactionsTransactionIdResponse { + private GetSelfLoansLoanIdTransactionsTransactionIdResponse() { + } + + final class GetSelfLoansLoanIdTransactionsType { + private GetSelfLoansLoanIdTransactionsType() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "loanTransactionType.repayment") + public String code; + @ApiModelProperty(example = "Repayment") + public String value; + @ApiModelProperty(example = "false") + public Boolean disbursement; + @ApiModelProperty(example = "false") + public Boolean repaymentAtDisbursement; + @ApiModelProperty(example = "true") + public Boolean repayment; + @ApiModelProperty(example = "false") + public Boolean contra; + @ApiModelProperty(example = "false") + public Boolean waiveInterest; + @ApiModelProperty(example = "false") + public Boolean waiveCharges; + @ApiModelProperty(example = "false") + public Boolean writeOff; + @ApiModelProperty(example = "false") + public Boolean recoveryRepayment; + } + + @ApiModelProperty(example = "3") + public Integer id; + public GetSelfLoansLoanIdTransactionsType type; + @ApiModelProperty(example = "[2012, 5, 14]") + public LocalDate date; + @ApiModelProperty(example = "false") + public Boolean manuallyReversed; + public GetSelfLoansLoanIdResponse.GetLoansLoanIdSummary.GetLoansLoanIdOverdueCharges.GetLoanCurrency currency; + @ApiModelProperty(example = "559.88") + public Float amount; + @ApiModelProperty(example = "559.88") + public Float interestPortion; + } + + @ApiModel(value = "GetSelfLoansLoanIdChargesResponse") + public final static class GetSelfLoansLoanIdChargesResponse { + private GetSelfLoansLoanIdChargesResponse() { + } + + final class GetSelfLoansChargeTimeType { + private GetSelfLoansChargeTimeType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "chargeTimeType.disbursement") + public String code; + @ApiModelProperty(example = "Disbursement") + public String value; + } + + final class GetSelfLoansChargeCalculationType { + private GetSelfLoansChargeCalculationType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "chargeCalculationType.flat") + public String code; + @ApiModelProperty(example = "Flat") + public String value; + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "1") + public Integer chargeId; + @ApiModelProperty(example = "Loan Processing fee") + public String name; + public GetSelfLoansChargeTimeType chargeTimeType; + public GetSelfLoansChargeCalculationType chargeCalculationType; + @ApiModelProperty(example = "0") + public Double percentage; + @ApiModelProperty(example = "0") + public Double amountPercentageAppliedTo; + public GetSelfLoansLoanIdResponse.GetLoansLoanIdSummary.GetLoansLoanIdOverdueCharges.GetLoanCurrency currency; + @ApiModelProperty(example = "100") + public Float amount; + @ApiModelProperty(example = "0") + public Float amountPaid; + @ApiModelProperty(example = "0") + public Float amountWaived; + @ApiModelProperty(example = "0") + public Float amountWrittenOff; + @ApiModelProperty(example = "100") + public Float amountOutstanding; + @ApiModelProperty(example = "100") + public Float amountOrPercentage; + @ApiModelProperty(example = "false") + public Boolean penalty; + } + + @ApiModel(value = "GetSelfLoansTemplateResponse") + public final static class GetSelfLoansTemplateResponse { + private GetSelfLoansTemplateResponse() { + } + + final class GetSelfLoansTimeline { + private GetSelfLoansTimeline() { + } + + @ApiModelProperty(example = "[2013, 3, 8]") + public LocalDate expectedDisbursementDate; + } + + final class GetSelfLoansProductOptions { + private GetSelfLoansProductOptions() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "Kampala Product (with cash accounting)") + public String name; + } + + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "Kampala first Client") + public String clientName; + @ApiModelProperty(example = "2") + public Integer clientOfficeId; + public GetSelfLoansTimeline timeline; + public Set productOptions; + } + + @ApiModel(value = "PostSelfLoansRequest") + public final static class PostSelfLoansRequest { + private PostSelfLoansRequest() { + } + + final class PostSelfLoansDisbursementData { + private PostSelfLoansDisbursementData() { + } + + @ApiModelProperty(example = "01 November 2013") + public String expectedDisbursementDate; + @ApiModelProperty(example = "22000") + public Long principal; + @ApiModelProperty(example = "22000") + public Long approvedPrincipal; + } + + final class PostSelfLoansDatatables { + private PostSelfLoansDatatables() { + } + + final class PostSelfLoansData { + private PostSelfLoansData() { + } + + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "01 December 2016 00:00") + public String Activation_Date; + @ApiModelProperty(example = "dd MMMM yyyy HH:mm") + public String dateFormat; + } + + @ApiModelProperty(example = "Date Loan Field") + public String registeredTableName; + public PostSelfLoansData data; + } + + @ApiModelProperty(example = "dd MMMM yyyy") + public String dateFormat; + @ApiModelProperty(example = "en_GB") + public String locale; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "1") + public Integer productId; + @ApiModelProperty(example = "10,000.00") + public Double principal; + @ApiModelProperty(example = "12") + public Integer loanTermFrequency; + @ApiModelProperty(example = "2") + public Integer loanTermFrequencyType; + @ApiModelProperty(example = "individual") + public String loanType; + @ApiModelProperty(example = "10") + public Integer numberOfRepayments; + @ApiModelProperty(example = "1") + public Integer repaymentEvery; + @ApiModelProperty(example = "2") + public Integer repaymentFrequencyType; + @ApiModelProperty(example = "10") + public Integer interestRatePerPeriod; + @ApiModelProperty(example = "1") + public Integer amortizationType; + @ApiModelProperty(example = "0") + public Integer interestType; + @ApiModelProperty(example = "1") + public Integer interestCalculationPeriodType; + @ApiModelProperty(example = "1") + public Integer transactionProcessingStrategyId; + @ApiModelProperty(example = "10 Jun 2013") + public String expectedDisbursementDate; + @ApiModelProperty(example = "10 Jun 2013") + public String submittedOnDate; + @ApiModelProperty(example = "1") + public Integer linkAccountId; + @ApiModelProperty(example = "1100") + public Integer fixedEmiAmount; + @ApiModelProperty(example = "35000") + public Long maxOutstandingLoanBalance; + public Set disbursementData; + public Set datatables; + } + + @ApiModel(value = "PostSelfLoansResponse") + public final static class PostSelfLoansResponse { + private PostSelfLoansResponse() { + } + + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "1") + public Integer loanId; + @ApiModelProperty(example = "1") + public Integer resourceId; + } + + @ApiModel(value = "PutSelfLoansLoanIdRequest") + public final static class PutSelfLoansLoanIdRequest { + private PutSelfLoansLoanIdRequest() { + } + + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "dd MMMM yyyy") + public String dateFormat; + @ApiModelProperty(example = "1") + public Integer productId; + @ApiModelProperty(example = "5000") + public Long principal; + @ApiModelProperty(example = "10") + public Integer loanTermFrequency; + @ApiModelProperty(example = "0") + public Integer loanTermFrequencyType; + @ApiModelProperty(example = "10") + public Integer numberOfRepayments; + @ApiModelProperty(example = "1") + public Integer repaymentEvery; + @ApiModelProperty(example = "0") + public Integer repaymentFrequencyType; + @ApiModelProperty(example = "2") + public Integer interestRatePerPeriod; + @ApiModelProperty(example = "0") + public Integer interestType; + @ApiModelProperty(example = "0") + public Integer interestCalculationPeriodType; + @ApiModelProperty(example = "1") + public Integer amortizationType; + @ApiModelProperty(example = "04 March 2014") + public String expectedDisbursementDate; + @ApiModelProperty(example = "1") + public Integer transactionProcessingStrategyId; + } + + @ApiModel(value = "PutSelfLoansLoanIdResponse") + public final static class PutSelfLoansLoanIdResponse { + private PutSelfLoansLoanIdResponse() { + } + + final class PutSelfLoansChanges { + private PutSelfLoansChanges() { + } + + @ApiModelProperty(example = "5000") + public Long principal; + @ApiModelProperty(example = "en") + public String locale; + } + + @ApiModelProperty(example = "2") + public Integer officeId; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "1") + public Integer loanId; + @ApiModelProperty(example = "1") + public Integer resourceId; + public PutSelfLoansChanges changes; + } + + @ApiModel(value = "PostSelfLoansLoanIdRequest") + public final static class PostSelfLoansLoanIdRequest { + private PostSelfLoansLoanIdRequest() { + } + + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "dd MMMM yyyy") + public String dateFormat; + @ApiModelProperty(example = "20 September 2011") + public String withdrawnOnDate; + @ApiModelProperty(example = "Reason loan applicant withdrew from application.") + public String note; + } + + @ApiModel(value = "PostSelfLoansLoanIdResponse") + public final static class PostSelfLoansLoanIdResponse { + private PostSelfLoansLoanIdResponse() { + } + + final class PostSelfLoansLoanIdChanges { + private PostSelfLoansLoanIdChanges() { + } + + final class PostSelfLoansLoanIdStatus { + private PostSelfLoansLoanIdStatus() { + } + + @ApiModelProperty(example = "400") + public Integer id; + @ApiModelProperty(example = "loanStatusType.withdrawn.by.client") + public String code; + @ApiModelProperty(example = "Withdrawn by applicant") + public String value; + @ApiModelProperty(example = "false") + public Boolean pendingApproval; + @ApiModelProperty(example = "false") + public Boolean waitingForDisbursal; + @ApiModelProperty(example = "false") + public Boolean active; + @ApiModelProperty(example = "false") + public Boolean closedObligationsMet; + @ApiModelProperty(example = "false") + public Boolean closedWrittenOff; + @ApiModelProperty(example = "false") + public Boolean closedRescheduled; + @ApiModelProperty(example = "false") + public Boolean closed; + @ApiModelProperty(example = "false") + public Boolean overpaid; + } + + public PostSelfLoansLoanIdStatus status; + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "dd MMMM yyyy") + public String dateFormat; + @ApiModelProperty(example = "20 September 2011") + public String withdrawnOnDate; + @ApiModelProperty(example = "20 September 2011") + public String closedOnDate; + } + + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "2") + public Integer loanId; + @ApiModelProperty(example = "2") + public Integer resourceId; + public PostSelfLoansLoanIdChanges changes; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/savings/api/SelfSavingsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/savings/api/SelfSavingsApiResource.java index bfcd11d05..6fe46fa75 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/savings/api/SelfSavingsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/savings/api/SelfSavingsApiResource.java @@ -18,17 +18,7 @@ */ package org.apache.fineract.portfolio.self.savings.api; -import javax.ws.rs.Consumes; -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriInfo; - +import io.swagger.annotations.*; import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext; import org.apache.fineract.portfolio.savings.api.SavingsAccountChargesApiResource; import org.apache.fineract.portfolio.savings.api.SavingsAccountTransactionsApiResource; @@ -41,9 +31,15 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; + @Path("/self/savingsaccounts") @Component @Scope("singleton") +@Api(value = "Self Savings Account", description = "") public class SelfSavingsApiResource { private final PlatformSecurityContext context; @@ -73,9 +69,11 @@ public class SelfSavingsApiResource { @Path("{accountId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) + @ApiOperation(value = "Retrieve a savings account", httpMethod = "GET", notes = "Retrieves a savings account\n\n" + "Example Requests :\n" + "\n" + "self/savingsaccounts/1\n" + "\n" + "\n" + "self/savingsaccounts/1?associations=transactions") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = SelfSavingsApiResourceSwagger.GetSelfSavingsAccountsResponse.class)}) public String retrieveSavings( - @PathParam("accountId") final Long accountId, - @DefaultValue("all") @QueryParam("chargeStatus") final String chargeStatus, + @PathParam("accountId") @ApiParam(value = "accountId") final Long accountId, + @DefaultValue("all") @QueryParam("chargeStatus") @ApiParam(value = "chargeStatus") final String chargeStatus, @Context final UriInfo uriInfo) { this.dataValidator.validateRetrieveSavings(uriInfo); @@ -91,9 +89,11 @@ public class SelfSavingsApiResource { @Path("{accountId}/transactions/{transactionId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) + @ApiOperation(value = "Retrieve Savings Account Transaction", httpMethod = "GET", notes = "Retrieves Savings Account Transaction\n\n" + "Example Requests:\n" + "\n" + "self/savingsaccounts/1/transactions/1") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = SelfSavingsApiResourceSwagger.GetSelfSavingsAccountsAccountIdTransactionsTransactionIdResponse.class)}) public String retrieveSavingsTransaction( - @PathParam("accountId") final Long accountId, - @PathParam("transactionId") final Long transactionId, + @PathParam("accountId") @ApiParam(value = "accountId") final Long accountId, + @PathParam("transactionId") @ApiParam(value = "transactionId") final Long transactionId, @Context final UriInfo uriInfo) { this.dataValidator.validateRetrieveSavingsTransaction(uriInfo); @@ -108,9 +108,11 @@ public class SelfSavingsApiResource { @Path("{accountId}/charges") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) + @ApiOperation(value = "List Savings Charges", httpMethod = "GET", notes = "Lists Savings Charges\n\n" + "Example Requests:\n" + "\n" + "self/savingsaccounts/1/charges\n" + "\n" + "self/savingsaccounts/1/charges?chargeStatus=inactive\n" + "\n" + "self/savingsaccounts/1/charges?fields=name,amountOrPercentage") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = SelfSavingsApiResourceSwagger.GetSelfSavingsAccountsAccountIdChargesResponse.class, responseContainer = "List")}) public String retrieveAllSavingsAccountCharges( - @PathParam("accountId") final Long accountId, - @DefaultValue("all") @QueryParam("chargeStatus") final String chargeStatus, + @PathParam("accountId") @ApiParam(value = "accountId") final Long accountId, + @DefaultValue("all") @QueryParam("chargeStatus") @ApiParam(value = "chargeStatus") final String chargeStatus, @Context final UriInfo uriInfo) { validateAppuserSavingsAccountMapping(accountId); @@ -124,9 +126,11 @@ public class SelfSavingsApiResource { @Path("{accountId}/charges/{savingsAccountChargeId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) + @ApiOperation(value = "Retrieve a Savings account Charge", httpMethod = "GET", notes = "Retrieves a Savings account Charge\n\n" + "Example Requests:\n" + "\n" + "self/savingsaccounts/1/charges/5\n" + "\n" + "\n" + "self/savingsaccounts/1/charges/5?fields=name,amountOrPercentage") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = SelfSavingsApiResourceSwagger.GetSelfSavingsAccountsAccountIdChargesSavingsAccountChargeIdResponse.class)}) public String retrieveSavingsAccountCharge( - @PathParam("accountId") final Long accountId, - @PathParam("savingsAccountChargeId") final Long savingsAccountChargeId, + @PathParam("accountId") @ApiParam(value = "accountId") final Long accountId, + @PathParam("savingsAccountChargeId") @ApiParam(value = "savingsAccountChargeId") final Long savingsAccountChargeId, @Context final UriInfo uriInfo) { validateAppuserSavingsAccountMapping(accountId); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/savings/api/SelfSavingsApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/savings/api/SelfSavingsApiResourceSwagger.java new file mode 100644 index 000000000..92d68a301 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/savings/api/SelfSavingsApiResourceSwagger.java @@ -0,0 +1,358 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.self.savings.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.time.LocalDate; + +/** + * Created by Chirag Gupta on 12/25/17. + */ +final class SelfSavingsApiResourceSwagger { + private SelfSavingsApiResourceSwagger() { + } + + @ApiModel(value = "GetSelfSavingsAccountsResponse") + public final static class GetSelfSavingsAccountsResponse { + private GetSelfSavingsAccountsResponse() { + } + + final class GetSelfSavingsStatus { + private GetSelfSavingsStatus() { + } + + @ApiModelProperty(example = "100") + public Integer id; + @ApiModelProperty(example = "savingsAccountStatusType.submitted.and.pending.approval") + public String code; + @ApiModelProperty(example = "Submitted and pending approval") + public String value; + @ApiModelProperty(example = "true") + public Boolean submittedAndPendingApproval; + @ApiModelProperty(example = "false") + public Boolean approved; + @ApiModelProperty(example = "false") + public Boolean rejected; + @ApiModelProperty(example = "false") + public Boolean withdrawnByApplicant; + @ApiModelProperty(example = "false") + public Boolean active; + @ApiModelProperty(example = "false") + public Boolean closed; + + } + + final class GetSelfSavingsTimeline { + private GetSelfSavingsTimeline() { + } + + @ApiModelProperty(example = "[2013, 3, 1]") + public LocalDate submittedOnDate; + } + + final class GetSelfSavingsCurrency { + private GetSelfSavingsCurrency() { + } + + @ApiModelProperty(example = "USD") + public String code; + @ApiModelProperty(example = "US Dollar") + public String name; + @ApiModelProperty(example = "2") + public Integer decimalPlaces; + @ApiModelProperty(example = "$") + public String displaySymbol; + @ApiModelProperty(example = "currency.USD") + public String nameCode; + @ApiModelProperty(example = "US Dollar ($)") + public String displayLabel; + } + + final class GetSelfSavingsInterestCompoundingPeriodType { + private GetSelfSavingsInterestCompoundingPeriodType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "savings.interest.period.savingsCompoundingInterestPeriodType.daily") + public String code; + @ApiModelProperty(example = "Daily") + public String value; + } + + final class GetSelfSavingsInterestPostingPeriodType { + private GetSelfSavingsInterestPostingPeriodType() { + } + + @ApiModelProperty(example = "4") + public Integer id; + @ApiModelProperty(example = "savings.interest.posting.period.savingsPostingInterestPeriodType.monthly") + public String code; + @ApiModelProperty(example = "Monthly") + public String value; + } + + final class GetSelfSavingsInterestCalculationType { + private GetSelfSavingsInterestCalculationType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "savingsInterestCalculationType.dailybalance") + public String code; + @ApiModelProperty(example = "Daily Balance") + public String value; + } + + final class GetSelfSavingsInterestCalculationDaysInYearType { + private GetSelfSavingsInterestCalculationDaysInYearType() { + } + + @ApiModelProperty(example = "365") + public Integer id; + @ApiModelProperty(example = "savingsInterestCalculationDaysInYearType.days365") + public String code; + @ApiModelProperty(example = "365 Days") + public String value; + } + + final class GetSelfSavingsSummary { + private GetSelfSavingsSummary() { + } + + public GetSelfSavingsCurrency currency; + @ApiModelProperty(example = "0") + public Integer accountBalance; + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "000000001") + public Long accountNo; + @ApiModelProperty(example = "1") + public Integer clientId; + @ApiModelProperty(example = "small business") + public String clientName; + @ApiModelProperty(example = "1") + public Integer savingsProductId; + @ApiModelProperty(example = "Passbook Savings") + public String savingsProductName; + @ApiModelProperty(example = "0") + public Integer fieldOfficerId; + public GetSelfSavingsStatus status; + public GetSelfSavingsTimeline timeline; + public GetSelfSavingsCurrency currency; + @ApiModelProperty(example = "5") + public Double nominalAnnualInterestRate; + public GetSelfSavingsInterestCompoundingPeriodType interestCompoundingPeriodType; + public GetSelfSavingsInterestPostingPeriodType interestPostingPeriodType; + public GetSelfSavingsInterestCalculationType interestCalculationType; + public GetSelfSavingsInterestCalculationDaysInYearType interestCalculationDaysInYearType; + public GetSelfSavingsSummary summary; + } + + @ApiModel(value = "GetSelfSavingsAccountsAccountIdTransactionsTransactionIdResponse") + public final static class GetSelfSavingsAccountsAccountIdTransactionsTransactionIdResponse { + private GetSelfSavingsAccountsAccountIdTransactionsTransactionIdResponse() { + } + + final class GetSelfSavingsTransactionType { + private GetSelfSavingsTransactionType() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "savingsAccountTransactionType.withdrawal") + public String code; + @ApiModelProperty(example = "Withdrawal") + public String value; + @ApiModelProperty(example = "false") + public Boolean deposit; + @ApiModelProperty(example = "true") + public Boolean withdrawal; + @ApiModelProperty(example = "false") + public Boolean interestPosting; + @ApiModelProperty(example = "false") + public Boolean feeDeduction; + } + + final class GetSelfSavingsTransactionCurrency { + private GetSelfSavingsTransactionCurrency() { + } + + @ApiModelProperty(example = "USD") + public String code; + @ApiModelProperty(example = "US Dollar") + public String name; + @ApiModelProperty(example = "2") + public Integer decimalPlaces; + @ApiModelProperty(example = "0") + public Integer inMultiplesOf; + @ApiModelProperty(example = "$") + public String displaySymbol; + @ApiModelProperty(example = "currency.USD") + public String nameCode; + @ApiModelProperty(example = "US Dollar ($)") + public String displayLabel; + } + + final class GetSelfSavingsPaymentDetailData { + private GetSelfSavingsPaymentDetailData() { + } + + final class GetSelfSavingsPaymentType { + private GetSelfSavingsPaymentType() { + } + + @ApiModelProperty(example = "11") + public Integer id; + @ApiModelProperty(example = "cash") + public String name; + } + + @ApiModelProperty(example = "62") + public Integer id; + public GetSelfSavingsPaymentType paymentType; + @ApiModelProperty(example = "") + public Integer accountNumber; + @ApiModelProperty(example = "") + public Integer checkNumber; + @ApiModelProperty(example = "") + public Integer routingCode; + @ApiModelProperty(example = "") + public Integer receiptNumber; + @ApiModelProperty(example = "") + public Integer bankNumber; + } + + @ApiModelProperty(example = "1") + public Integer id; + public GetSelfSavingsTransactionType transactionType; + @ApiModelProperty(example = "1") + public Integer accountId; + @ApiModelProperty(example = "000000001") + public Long accountNo; + @ApiModelProperty(example = "[2013, 8, 7]") + public LocalDate date; + public GetSelfSavingsTransactionCurrency currency; + public GetSelfSavingsPaymentDetailData paymentDetailData; + @ApiModelProperty(example = "5000") + public Integer amount; + @ApiModelProperty(example = "0") + public Integer runningBalance; + @ApiModelProperty(example = "true") + public Boolean reversed; + } + + @ApiModel(value = "GetSelfSavingsAccountsAccountIdChargesResponse") + public final static class GetSelfSavingsAccountsAccountIdChargesResponse { + private GetSelfSavingsAccountsAccountIdChargesResponse() { + } + + final class GetSelfSavingsChargeTimeType { + private GetSelfSavingsChargeTimeType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "chargeTimeType.specifiedDueDate") + public String code; + @ApiModelProperty(example = "Specified due date") + public String value; + } + + final class GetSelfSavingsChargeCalculationType { + private GetSelfSavingsChargeCalculationType() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "chargeCalculationType.flat") + public String code; + @ApiModelProperty(example = "Flat") + public String value; + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "3") + public Integer chargeId; + @ApiModelProperty(example = "57") + public Integer accountId; + @ApiModelProperty(example = "Savings account maintenance fee") + public String name; + public GetSelfSavingsChargeTimeType chargeTimeType; + public GetSelfSavingsChargeCalculationType chargeCalculationType; + @ApiModelProperty(example = "0") + public Double percentage; + @ApiModelProperty(example = "0") + public Double amountPercentageAppliedTo; + public GetSelfSavingsAccountsResponse.GetSelfSavingsCurrency currency; + @ApiModelProperty(example = "100") + public Integer amount; + @ApiModelProperty(example = "0") + public Integer amountPaid; + @ApiModelProperty(example = "0") + public Integer amountWaived; + @ApiModelProperty(example = "0") + public Integer amountWrittenOff; + @ApiModelProperty(example = "100") + public Integer amountOutstanding; + @ApiModelProperty(example = "100") + public Integer amountOrPercentage; + @ApiModelProperty(example = "false") + public Boolean penalty; + } + + @ApiModel(value = "GetSelfSavingsAccountsAccountIdChargesSavingsAccountChargeIdResponse") + public final static class GetSelfSavingsAccountsAccountIdChargesSavingsAccountChargeIdResponse { + private GetSelfSavingsAccountsAccountIdChargesSavingsAccountChargeIdResponse() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "1") + public Integer chargeId; + @ApiModelProperty(example = "Passbook fee") + public String name; + public GetSelfSavingsAccountsAccountIdChargesResponse.GetSelfSavingsChargeTimeType chargeTimeType; + public GetSelfSavingsAccountsAccountIdChargesResponse.GetSelfSavingsChargeCalculationType chargeCalculationType; + @ApiModelProperty(example = "0") + public Double percentage; + @ApiModelProperty(example = "0") + public Double amountPercentageAppliedTo; + public GetSelfSavingsAccountsResponse.GetSelfSavingsCurrency currency; + @ApiModelProperty(example = "100") + public Integer amount; + @ApiModelProperty(example = "0") + public Integer amountPaid; + @ApiModelProperty(example = "0") + public Integer amountWaived; + @ApiModelProperty(example = "0") + public Integer amountWrittenOff; + @ApiModelProperty(example = "100") + public Integer amountOutstanding; + @ApiModelProperty(example = "100") + public Integer amountOrPercentage; + @ApiModelProperty(example = "false") + public Boolean penalty; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/security/api/SelfAuthenticationApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/security/api/SelfAuthenticationApiResource.java index 7b9b0f69b..b5b6671b4 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/security/api/SelfAuthenticationApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/security/api/SelfAuthenticationApiResource.java @@ -18,22 +18,24 @@ */ package org.apache.fineract.portfolio.self.security.api; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; - +import io.swagger.annotations.*; import org.apache.fineract.infrastructure.security.api.AuthenticationApiResource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Profile; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + @Path("/self/authentication") @Component @Profile("basicauth") @Scope("singleton") +@Api(value = "Self Authentication", description = "") public class SelfAuthenticationApiResource { private final AuthenticationApiResource authenticationApiResource; @@ -46,8 +48,10 @@ public class SelfAuthenticationApiResource { @POST @Produces({ MediaType.APPLICATION_JSON }) - public String authenticate(@QueryParam("username") final String username, - @QueryParam("password") final String password) { + @ApiOperation(value = "Verify authentication", httpMethod = "POST", notes = "Authenticates the credentials provided and returns the set roles and permissions allowed.\n\n" + "Please visit this link for more info - https://demo.openmf.org/api-docs/apiLive.htm#selfbasicauth") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = SelfAuthenticationApiResourceSwagger.PostSelfAuthenticationResponse.class)}) + public String authenticate(@QueryParam("username") @ApiParam(value = "username") final String username, + @QueryParam("password") @ApiParam(value = "password") final String password) { return this.authenticationApiResource.authenticate(username, password); } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/security/api/SelfAuthenticationApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/security/api/SelfAuthenticationApiResourceSwagger.java new file mode 100644 index 000000000..532aec0b4 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/security/api/SelfAuthenticationApiResourceSwagger.java @@ -0,0 +1,88 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.self.security.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.List; +import java.util.Set; + +/** + * Created by Chirag Gupta on 12/22/17. + */ +final class SelfAuthenticationApiResourceSwagger { + private SelfAuthenticationApiResourceSwagger() { + } + + @ApiModel(value = "PostSelfAuthenticationResponse") + public final static class PostSelfAuthenticationResponse { + private PostSelfAuthenticationResponse() { + } + + final class GetSelfUserDetailsOrganisationalRole { + private GetSelfUserDetailsOrganisationalRole() { + } + + @ApiModelProperty(example = "100") + public Integer id; + @ApiModelProperty(example = "staffOrganisationalRoleType.programDirector") + public String code; + @ApiModelProperty(example = "Program Director") + public String value; + } + + final class GetSelfUserDetailsRoles { + private GetSelfUserDetailsRoles() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "Super user") + public String name; + @ApiModelProperty(example = "This role provides all application permissions.") + public String description; + } + + @ApiModelProperty(example = "mifos") + public String username; + @ApiModelProperty(example = "1") + public Integer userId; + @ApiModelProperty(example = "bWlmb3M6cGFzc3dvcmQ=") + public String base64EncodedAuthenticationKey; + @ApiModelProperty(example = "true") + public Boolean authenticated; + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "Head Office") + public String officeName; + @ApiModelProperty(example = "1") + public Integer staffId; + @ApiModelProperty(example = "Director, Program") + public String staffDisplayName; + public GetSelfUserDetailsOrganisationalRole organisationalRole; + public Set roles; + @ApiModelProperty(example = "ALL_FUNCTIONS") + public List permissions; + @ApiModelProperty(example = "true") + public Boolean isSelfServiceUser; + @ApiModelProperty(example = "1, 2, 3") + public List clients; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/security/api/SelfUserApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/security/api/SelfUserApiResource.java index 76de0b392..2632c63cd 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/security/api/SelfUserApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/security/api/SelfUserApiResource.java @@ -19,15 +19,8 @@ package org.apache.fineract.portfolio.self.security.api; -import java.lang.reflect.Type; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import javax.ws.rs.PUT; -import javax.ws.rs.Path; - +import com.google.gson.reflect.TypeToken; +import io.swagger.annotations.*; import org.apache.commons.lang.StringUtils; import org.apache.fineract.infrastructure.core.exception.InvalidJsonException; import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper; @@ -37,10 +30,17 @@ import org.apache.fineract.useradministration.domain.AppUser; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import com.google.gson.reflect.TypeToken; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import java.lang.reflect.Type; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; @Path("/self/user") @Component +@Api(value = "Self User", description = "") public class SelfUserApiResource { private final UsersApiResource usersApiResource; @@ -59,7 +59,10 @@ public class SelfUserApiResource { } @PUT - public String update(final String apiRequestBodyAsJson) { + @ApiOperation(value = "Update User", httpMethod = "PUT", notes = "This API can be used by Self Service user to update their own user information. Currently, \"password\" and \"repeatPassword\" are the only parameters accepted.") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = SelfUserApiResourceSwagger.PutSelfUserRequest.class)}) + @ApiResponses({@ApiResponse(code = 200,message = "OK", response = SelfUserApiResourceSwagger.PutSelfUserResponse.class)}) + public String update(@ApiParam(hidden = true) final String apiRequestBodyAsJson) { if (StringUtils.isBlank(apiRequestBodyAsJson)) { throw new InvalidJsonException(); } final Type typeOfMap = new TypeToken>() {}.getType(); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/security/api/SelfUserApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/security/api/SelfUserApiResourceSwagger.java new file mode 100644 index 000000000..65af58c59 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/security/api/SelfUserApiResourceSwagger.java @@ -0,0 +1,62 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.fineract.portfolio.self.security.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +/** + * Created by Chirag Gupta on 12/20/17. + */ +final class SelfUserApiResourceSwagger { + private SelfUserApiResourceSwagger() { + } + + @ApiModel(value = "PutSelfUserRequest") + public final static class PutSelfUserRequest { + private PutSelfUserRequest() { + } + + @ApiModelProperty(example = "Abcd1234") + public String password; + @ApiModelProperty(example = "Abcd1234") + public String repeatPassword; + } + + @ApiModel(value = "PutSelfUserResponse") + public final static class PutSelfUserResponse { + private PutSelfUserResponse() { + } + + final class PutSelfUserChanges { + private PutSelfUserChanges() { + } + + @ApiModelProperty(example = "6a72a630795be86fe926ce540fc45b6b922fe5ba130f185fe806a26b5e5efcdd") + public String passwordEncoded; + } + + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "6") + public Integer resourceId; + public PutSelfUserChanges changes; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/security/api/SelfUserDetailsApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/security/api/SelfUserDetailsApiResource.java index 56b348935..4d5ad19c6 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/security/api/SelfUserDetailsApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/security/api/SelfUserDetailsApiResource.java @@ -18,22 +18,24 @@ */ package org.apache.fineract.portfolio.self.security.api; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.MediaType; - +import io.swagger.annotations.*; import org.apache.fineract.infrastructure.security.api.UserDetailsApiResource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Profile; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.MediaType; + @Path("/self/userdetails") @Component @Profile("oauth") @Scope("singleton") +@Api(value = "Self User Details", description = "") public class SelfUserDetailsApiResource { private final UserDetailsApiResource userDetailsApiResource; @@ -46,8 +48,10 @@ public class SelfUserDetailsApiResource { @GET @Produces({ MediaType.APPLICATION_JSON }) + @ApiOperation(value = "Fetch authenticated user details", httpMethod = "GET", notes = "Checks the Authentication and returns the set roles and permissions allowed\n\n" + "For more info visit this link - https://demo.openmf.org/api-docs/apiLive.htm#selfoauth") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = SelfUserDetailsApiResourceSwagger.GetSelfUserDetailsResponse.class)}) public String fetchAuthenticatedUserData( - @QueryParam("access_token") final String accessToken) { + @QueryParam("access_token") @ApiParam(value = "äccess_token") final String accessToken) { return this.userDetailsApiResource .fetchAuthenticatedUserData(accessToken); } diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/security/api/SelfUserDetailsApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/security/api/SelfUserDetailsApiResourceSwagger.java new file mode 100644 index 000000000..e629e94dd --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/security/api/SelfUserDetailsApiResourceSwagger.java @@ -0,0 +1,88 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.self.security.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.List; +import java.util.Set; + +/** + * Created by Chirag Gupta on 12/20/17. + */ +final class SelfUserDetailsApiResourceSwagger { + private SelfUserDetailsApiResourceSwagger() { + } + + @ApiModel(value = "GetSelfUserDetailsResponse") + public final static class GetSelfUserDetailsResponse { + private GetSelfUserDetailsResponse() { + } + + final class GetSelfUserDetailsOrganisationalRole { + private GetSelfUserDetailsOrganisationalRole() { + } + + @ApiModelProperty(example = "100") + public Integer id; + @ApiModelProperty(example = "staffOrganisationalRoleType.programDirector") + public String code; + @ApiModelProperty(example = "Program Director") + public String value; + } + + final class GetSelfUserDetailsRoles { + private GetSelfUserDetailsRoles() { + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "Super user") + public String name; + @ApiModelProperty(example = "This role provides all application permissions.") + public String description; + } + + @ApiModelProperty(example = "mifos") + public String username; + @ApiModelProperty(example = "1") + public Integer userId; + @ApiModelProperty(example = "bWlmb3M6cGFzc3dvcmQ=") + public String base64EncodedAuthenticationKey; + @ApiModelProperty(example = "true") + public Boolean authenticated; + @ApiModelProperty(example = "1") + public Integer officeId; + @ApiModelProperty(example = "Head Office") + public String officeName; + @ApiModelProperty(example = "1") + public Integer staffId; + @ApiModelProperty(example = "Director, Program") + public String staffDisplayName; + public GetSelfUserDetailsOrganisationalRole organisationalRole; + public Set roles; + @ApiModelProperty(example = "ALL_FUNCTIONS") + public List permissions; + @ApiModelProperty(example = "true") + public Boolean isSelfServiceUser; + @ApiModelProperty(example = "[1, 2, 3]") + public List clients; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/tax/api/TaxComponentApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/tax/api/TaxComponentApiResource.java index 9d9b5e3b0..d22cfa76d 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/tax/api/TaxComponentApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/tax/api/TaxComponentApiResource.java @@ -18,19 +18,7 @@ */ package org.apache.fineract.portfolio.tax.api; -import java.util.Collection; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriInfo; - +import io.swagger.annotations.*; import org.apache.fineract.commands.domain.CommandWrapper; import org.apache.fineract.commands.service.CommandWrapperBuilder; import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService; @@ -45,9 +33,16 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; +import java.util.Collection; + @Path("/taxes/component") @Component @Scope("singleton") +@Api(value = "Tax Components", description = "This defines the Tax Components") public class TaxComponentApiResource { private final String resourceNameForPermissions = "TAXCOMPONENT"; @@ -73,6 +68,8 @@ public class TaxComponentApiResource { @GET @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) + @ApiOperation(value = "List Tax Components", httpMethod = "GET", notes = "List Tax Components") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = TaxComponentApiResourceSwagger.GetTaxesComponentsResponse.class, responseContainer = "List")}) public String retrieveAllTaxComponents(@Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions); @@ -87,7 +84,9 @@ public class TaxComponentApiResource { @Path("{taxComponentId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveTaxComponent(@PathParam("taxComponentId") final Long taxComponentId, @Context final UriInfo uriInfo) { + @ApiOperation(value = "Retrieve Tax Component", httpMethod = "GET", notes = "Retrieve Tax Component") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = TaxComponentApiResourceSwagger.GetTaxesComponentsResponse.class)}) + public String retrieveTaxComponent(@PathParam("taxComponentId") @ApiParam(value = "taxComponentId") final Long taxComponentId, @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions); @@ -114,7 +113,10 @@ public class TaxComponentApiResource { @POST @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String createTaxCompoent(final String apiRequestBodyAsJson) { + @ApiOperation(value = "Create a new Tax Component", httpMethod = "POST", notes = "Creates a new Tax Component\n\n" + "Mandatory Fields: name, percentage\n\n" + "Optional Fields: debitAccountType, debitAcountId, creditAccountType, creditAcountId, startDate") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = TaxComponentApiResourceSwagger.PostTaxesComponentsRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = TaxComponentApiResourceSwagger.PostTaxesComponentsResponse.class)}) + public String createTaxCompoent(@ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder().createTaxComponent().withJson(apiRequestBodyAsJson).build(); @@ -127,7 +129,10 @@ public class TaxComponentApiResource { @Path("{taxComponentId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String updateTaxCompoent(@PathParam("taxComponentId") final Long taxComponentId, final String apiRequestBodyAsJson) { + @ApiOperation(value = "Update Tax Component", httpMethod = "PUT", notes = "Updates Tax component. Debit and credit account details cannot be modified. All the future tax components would be replaced with the new percentage.") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body",dataTypeClass = TaxComponentApiResourceSwagger.PutTaxesComponentsTaxComponentIdRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = TaxComponentApiResourceSwagger.PutTaxesComponentsTaxComponentIdResponse.class)}) + public String updateTaxCompoent(@PathParam("taxComponentId") @ApiParam(value = "taxComponentId") final Long taxComponentId, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder().updateTaxComponent(taxComponentId).withJson(apiRequestBodyAsJson) .build(); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/tax/api/TaxComponentApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/tax/api/TaxComponentApiResourceSwagger.java new file mode 100644 index 000000000..7f7d0c4a4 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/tax/api/TaxComponentApiResourceSwagger.java @@ -0,0 +1,149 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.tax.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.time.LocalDate; +import java.util.Set; + +/** + * Created by Chirag Gupta on 12/20/17. + */ +final class TaxComponentApiResourceSwagger { + private TaxComponentApiResourceSwagger() { + } + + @ApiModel(value = "GetTaxesComponentsResponse") + public final static class GetTaxesComponentsResponse { + private GetTaxesComponentsResponse() { + } + + final class GetTaxesComponentsCreditAccountType { + private GetTaxesComponentsCreditAccountType() { + } + + @ApiModelProperty(example = "2") + public Integer id; + @ApiModelProperty(example = "accountType.liability") + public String code; + @ApiModelProperty(example = "LIABILITY") + public String value; + } + + final class GetTaxesComponentsCreditAccount { + private GetTaxesComponentsCreditAccount() { + } + + @ApiModelProperty(example = "4") + public Integer id; + @ApiModelProperty(example = "ACCOUNT_NAME_7BR9C") + public String name; + @ApiModelProperty(example = "LIABILITY_PA1460364665046") + public String glCode; + } + + final class GetTaxesComponentsHistories { + private GetTaxesComponentsHistories() { + } + } + + @ApiModelProperty(example = "1") + public Integer id; + @ApiModelProperty(example = "tax component 1") + public String name; + @ApiModelProperty(example = "10.000000") + public Float percentage; + public GetTaxesComponentsCreditAccountType creditAccountType; + public GetTaxesComponentsCreditAccount creditAccount; + @ApiModelProperty(example = "[2016, 4, 11]") + public LocalDate startDate; + public Set taxComponentsHistories; + } + + @ApiModel(value = "PostTaxesComponentsRequest") + public final static class PostTaxesComponentsRequest { + private PostTaxesComponentsRequest() { + } + + @ApiModelProperty(example = "tax component 1") + public String name; + @ApiModelProperty(example = "10") + public Float percentage; + @ApiModelProperty(example = "2") + public Integer creditAccountType; + @ApiModelProperty(example = "4") + public Integer creditAcountId; + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "dd MMMM yyyy") + public String dateFormat; + @ApiModelProperty(example = "11 April 2016") + public String startDate; + } + + @ApiModel(value = "PostTaxesComponentsResponse") + public final static class PostTaxesComponentsResponse { + private PostTaxesComponentsResponse() { + } + + @ApiModelProperty(example = "1") + public Integer resourceId; + } + + @ApiModel(value = "PutTaxesComponentsTaxComponentIdRequest") + public final static class PutTaxesComponentsTaxComponentIdRequest { + private PutTaxesComponentsTaxComponentIdRequest() { + } + + @ApiModelProperty(example = "tax component 2") + public String name; + @ApiModelProperty(example = "15") + public Float percentage; + @ApiModelProperty(example = "en") + public String locale; + @ApiModelProperty(example = "dd MMMM yyyy") + public String dateFormat; + @ApiModelProperty(example = "15 April 2016") + public String startDate; + } + + @ApiModel(value = "PutTaxesComponentsTaxComponentIdResponse") + public final static class PutTaxesComponentsTaxComponentIdResponse { + private PutTaxesComponentsTaxComponentIdResponse() { + } + + final class PutTaxesComponentsChanges { + private PutTaxesComponentsChanges() { + } + + @ApiModelProperty(example = "15") + public Float percentage; + @ApiModelProperty(example = "tax component 2") + public String name; + @ApiModelProperty(example = "[2016, 4, 15]") + public LocalDate startDate; + } + + @ApiModelProperty(example = "1") + public Integer resourceId; + public PutTaxesComponentsChanges changes; + } +} diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/tax/api/TaxGroupApiResource.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/tax/api/TaxGroupApiResource.java index 446450029..5c66f74b6 100644 --- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/tax/api/TaxGroupApiResource.java +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/tax/api/TaxGroupApiResource.java @@ -18,19 +18,7 @@ */ package org.apache.fineract.portfolio.tax.api; -import java.util.Collection; - -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.UriInfo; - +import io.swagger.annotations.*; import org.apache.fineract.commands.domain.CommandWrapper; import org.apache.fineract.commands.service.CommandWrapperBuilder; import org.apache.fineract.commands.service.PortfolioCommandSourceWritePlatformService; @@ -45,9 +33,16 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; +import javax.ws.rs.*; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.UriInfo; +import java.util.Collection; + @Path("/taxes/group") @Component @Scope("singleton") +@Api(value = "Tax Group", description = "This defines the Tax Group") public class TaxGroupApiResource { private final String resourceNameForPermissions = "TAXGROUP"; @@ -72,6 +67,8 @@ public class TaxGroupApiResource { @GET @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) + @ApiOperation(value = "List Tax Group", httpMethod = "GET", notes = "List Tax Group") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = TaxGroupApiResourceSwagger.GetTaxesGroupResponse.class, responseContainer = "List")}) public String retrieveAllTaxGroups(@Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions); @@ -86,7 +83,9 @@ public class TaxGroupApiResource { @Path("{taxGroupId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String retrieveTaxGroup(@PathParam("taxGroupId") final Long taxGroupId, @Context final UriInfo uriInfo) { + @ApiOperation(value = "Retrieve Tax Group", httpMethod = "GET", notes = "Retrieve Tax Group") + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = TaxGroupApiResourceSwagger.GetTaxesGroupResponse.class)}) + public String retrieveTaxGroup(@PathParam("taxGroupId") @ApiParam(value = "taxGroupId") final Long taxGroupId, @Context final UriInfo uriInfo) { this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions); @@ -117,7 +116,10 @@ public class TaxGroupApiResource { @POST @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String createTaxGroup(final String apiRequestBodyAsJson) { + @ApiOperation(value = "Create a new Tax Group", httpMethod = "POST", notes = "Create a new Tax Group\n" + "Mandatory Fields: name and taxComponents\n" + "Mandatory Fields in taxComponents: taxComponentId\n" + "Optional Fields in taxComponents: id, startDate and endDate") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = TaxGroupApiResourceSwagger.PostTaxesGroupRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = TaxGroupApiResourceSwagger.PostTaxesGroupResponse.class)}) + public String createTaxGroup(@ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder().createTaxGroup().withJson(apiRequestBodyAsJson).build(); @@ -130,7 +132,10 @@ public class TaxGroupApiResource { @Path("{taxGroupId}") @Consumes({ MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_JSON }) - public String updateTaxGroup(@PathParam("taxGroupId") final Long taxGroupId, final String apiRequestBodyAsJson) { + @ApiOperation(value = "Update Tax Group", httpMethod = "PUT", notes = "Updates Tax Group. Only end date can be up-datable and can insert new tax components.") + @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, paramType = "body", dataType = "body", format = "body", dataTypeClass = TaxGroupApiResourceSwagger.PutTaxesGroupTaxGroupIdRequest.class)}) + @ApiResponses({@ApiResponse(code = 200, message = "OK", response = TaxGroupApiResourceSwagger.PutTaxesGroupTaxGroupIdResponse.class)}) + public String updateTaxGroup(@PathParam("taxGroupId") @ApiParam(value = "taxGroupId") final Long taxGroupId, @ApiParam(hidden = true) final String apiRequestBodyAsJson) { final CommandWrapper commandRequest = new CommandWrapperBuilder().updateTaxGroup(taxGroupId).withJson(apiRequestBodyAsJson).build(); diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/tax/api/TaxGroupApiResourceSwagger.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/tax/api/TaxGroupApiResourceSwagger.java new file mode 100644 index 000000000..66625c57c --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/tax/api/TaxGroupApiResourceSwagger.java @@ -0,0 +1,157 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.portfolio.tax.api; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.time.LocalDate; +import java.util.List; +import java.util.Set; + +/** + * Created by Chirag Gupta on 12/14/17. + */ +final class TaxGroupApiResourceSwagger { + private TaxGroupApiResourceSwagger() { + } + + @ApiModel(value = "GetTaxesGroupResponse") + public final static class GetTaxesGroupResponse { + private GetTaxesGroupResponse() { + } + + final class GetTaxesGroupTaxAssociations { + private GetTaxesGroupTaxAssociations() { + } + + final class GetTaxesGroupTaxComponent { + private GetTaxesGroupTaxComponent() { + } + + @ApiModelProperty(example = "7") + public Integer id; + @ApiModelProperty(example = "tax component 2") + public String name; + } + + @ApiModelProperty(example = "7") + public Integer id; + public GetTaxesGroupTaxComponent taxComponent; + @ApiModelProperty(example = "[2016, 4, 11]") + public LocalDate startDate; + } + + @ApiModelProperty(example = "7") + public Integer id; + @ApiModelProperty(example = "tax group 1") + public String name; + public Set taxAssociations; + } + + @ApiModel(value = "PostTaxesGroupRequest") + public final static class PostTaxesGroupRequest { + private PostTaxesGroupRequest() { + } + + final class PostTaxesGroupTaxComponents { + private PostTaxesGroupTaxComponents() { + } + + @ApiModelProperty(example = "7") + public Integer taxComponentId; + @ApiModelProperty(example = "11 April 2016") + public String startDate; + } + + @ApiModelProperty(example = "tax group 1") + public String name; + @ApiModelProperty(example = "en") + public String locale; + public Set taxComponents; + @ApiModelProperty(example = "dd MMMM yyyy") + public String dateFormat; + } + + @ApiModel(value = "PostTaxesGroupResponse") + public static final class PostTaxesGroupResponse { + private PostTaxesGroupResponse() { + } + + @ApiModelProperty(example = "1") + public Integer resourceId; + } + + @ApiModel(value = "PutTaxesGroupTaxGroupIdRequest") + public final static class PutTaxesGroupTaxGroupIdRequest { + private PutTaxesGroupTaxGroupIdRequest() { + } + + final class PutTaxesGroupTaxComponents { + private PutTaxesGroupTaxComponents() { + } + + @ApiModelProperty(example = "7") + public Integer id; + @ApiModelProperty(example = "7") + public Integer taxComponentId; + @ApiModelProperty(example = "22 April 2016") + public String endDate; + } + + @ApiModelProperty(example = "tax group 2") + public String name; + @ApiModelProperty(example = "en") + public String locale; + public Set taxComponents; + @ApiModelProperty(example = "dd MMMM yyyy") + public String dateFormat; + } + + @ApiModel(value = "PutTaxesGroupTaxGroupIdResponse") + public final static class PutTaxesGroupTaxGroupIdResponse { + private PutTaxesGroupTaxGroupIdResponse() { + } + + final class PutTaxesGroupChanges { + private PutTaxesGroupChanges() { + } + + final class PutTaxesGroupModifiedComponents { + private PutTaxesGroupModifiedComponents() { + } + + @ApiModelProperty(example = "Apr 22, 2016 12:00:00 AM") + public String endDate; + @ApiModelProperty(example = "7") + public Integer taxComponentId; + } + + @ApiModelProperty(example = "[6]") + public List addComponents; + public Set modifiedComponents; + @ApiModelProperty(example = "tax group 2") + public String name; + } + + @ApiModelProperty(example = "7") + public Integer resourceId; + public PutTaxesGroupChanges changes; + } +}