[
https://issues.apache.org/jira/browse/FINERACT-628?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16698897#comment-16698897
]
ASF GitHub Bot commented on FINERACT-628:
-----------------------------------------
ShruthiRajaram closed pull request #484: FINERACT-628 Self service APIs for
Surveys
URL: https://github.com/apache/fineract/pull/484
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/api-docs/apiLive.htm b/api-docs/apiLive.htm
index 9e10be258..4ead11adc 100644
--- a/api-docs/apiLive.htm
+++ b/api-docs/apiLive.htm
@@ -3617,6 +3617,14 @@ <h2 class="flybar-button">Self Service</h2>
<td></td>
<td></td>
</tr>
+ <tr>
+ <td></td>
+
<td>self/clients/{clientId}/images</td>
+ <td></td>
+ <td></td>
+ <td></td>
+ <td><a
href="#self_client_image_delete">Delete client image</a></td>
+ </tr>
<tr>
<td><a
href="#self_loanproducts">Loan Product</a></td>
<td>self/loanproducts?clientId={clientId}</td>
@@ -3651,14 +3659,6 @@ <h2 class="flybar-button">Self Service</h2>
<td></td>
<td></td>
</tr>
- <tr>
- <td></td>
-
<td>self/clients/{clientId}/images</td>
- <td></td>
- <td></td>
- <td></td>
- <td><a
href="#self_client_image_delete">Delete client image</a></td>
- </tr>
<tr>
<td><a
href="#self_shareproducts_list">Share Product</a></td>
<td>self/shareproducts?clientId={clientId}</td>
@@ -3875,6 +3875,30 @@ <h2 class="flybar-button">Self Service</h2>
<td></td>
<td></td>
</tr>
+ <tr>
+ <td><a
href="#active_surveys">Surveys</a></td>
+
<td>self/surveys?isActive=true</td>
+ <td></td>
+ <td><a
href="#active_surveys">Retrieve Active Surveys</a></td>
+ <td></td>
+ <td></td>
+ </tr>
+ <tr>
+ <td></td>
+
<td>self/surveys/scorecards/{surveyId}</td>
+ <td><a
href="#submit_survey">Take Survey</a></td>
+ <td></td>
+ <td></td>
+ <td></td>
+ </tr>
+ <tr>
+ <td></td>
+
<td>self/surveys/scorecards/clients/{clientId}</td>
+ <td></td>
+ <td><a
href="#survey_score">Survey Scorecards</a></td>
+ <td></td>
+ <td></td>
+ </tr>
</table>
</div>
</div>
@@ -49700,8 +49724,7 @@ <h4>List Loan Products</h4>
]
</code>
</div>
- </div>
-
+ </div>
<a id="self_loanproducts_retrieve"
name="self_loanproducts_retrieve"
class="old-syle-anchor"> </a>
@@ -50414,6 +50437,123 @@ <h4>Retrieve a Share Product</h4>
</code>
</div>
</div>
+
+<a id="active_surveys" name="active_surveys" class="old-syle-anchor"> </a>
+ <div class="method-section">
+ <div class="method-description">
+ <h2>Retrieve Active Surveys</h2>
+
+ <p>Example Requests : </p>
+ <div class=apiClick>self/surveys?isActive=true</div>
+ </div>
+ <div class="method-example">
+ <code class="method-declaration">GET
https://domainname/api/v1/self/surveys?isActive=true</code>
+ <code class="method-response">
+[
+ {
+ "id":1,
+ "componentDatas":[
+
+ ],
+ "questionDatas":[
+ {
+ "id":1,
+ "responseDatas":[
+ {
+ "id":2,
+ "text":"Own",
+ "value":1,
+ "sequenceNo":1
+ },
+ {
+ "id":1,
+ "text":"Rent",
+ "value":0,
+ "sequenceNo":2
+ }
+ ],
+ "componentKey":Test,
+ "key":"t1",
+ "text":"Type of house",
+ "description":Test,
+ "sequenceNo":1
+ }
+ ],
+ "key":"test",
+ "name":"test",
+ "description":"test",
+ "countryCode":"in",
+ "validFrom":1540233000000,
+ "validTo":4695906600000
+ }
+]
+ </code>
+ </div>
+</div>
+
+<a id="submit_survey" name="submit_survey" class="old-syle-anchor"> </a>
+ <div class="method-section">
+ <div class="method-description">
+ <h2>Submit Survey</h2>
+
+ <p>Example Requests : </p>
+ <div class=apiClick>self/surveys/scorecards/1</div>
+ </div>
+ <div class="method-example">
+ <code class="method-declaration">POST
https://domainname/api/v1/self/surveys/scorecards/{surveyId}</code>
+ <code class="method-request">
+{
+ "userId":3,
+ "clientId":"1",
+ "surveyId":1,
+ "scorecardValues":[
+ {
+ "questionId":1,
+ "responseId":2,
+ "value":1,
+ "createdOn":1540291482379
+ }
+ ],
+ "surveyName":"",
+ "username":"",
+ "id":0
+}
+ </code>
+ </div>
+</div>
+
+<a id="survey_score" name="survey_score" class="old-syle-anchor"> </a>
+ <div class="method-section">
+ <div class="method-description">
+ <h2>Retrieve Survey records</h2>
+
+ <p>Example Requests : </p>
+ <div class=apiClick>self/surveys/scorecards/clients/1</div>
+ </div>
+ <div class="method-example">
+ <code class="method-declaration">GET
https://domainname/api/v1/self/surveys/scorecards/clients/{clientId}</code>
+ <code class="method-response">
+[
+ {
+ "id":8,
+ "userId":,
+ "username":"mifos",
+ "clientId":3,
+ "surveyId":1,
+ "surveyName":"test",
+ "scorecardValues":[
+ {
+ "questionId":1,
+ "responseId":2,
+ "value":1,
+ "createdOn":1540233000000
+ }
+ ]
+ }
+] </code>
+ </div>
+</div>
+
<!-- end of Customer Self Service APIs-->
</div>
<!-- main-content-wrapper -->
diff --git
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/spm/api/SelfScorecardApiResource.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/spm/api/SelfScorecardApiResource.java
new file mode 100644
index 000000000..b097e10b4
--- /dev/null
+++
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/spm/api/SelfScorecardApiResource.java
@@ -0,0 +1,93 @@
+/**
+ * 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.spm.api;
+
+import java.util.List;
+
+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.MediaType;
+
+import
org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
+import org.apache.fineract.portfolio.client.exception.ClientNotFoundException;
+import
org.apache.fineract.portfolio.self.client.service.AppuserClientMapperReadService;
+import org.apache.fineract.spm.api.ScorecardApiResource;
+import org.apache.fineract.spm.data.ScorecardData;
+import org.apache.fineract.useradministration.domain.AppUser;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+
+@Path("/self/surveys/scorecards")
+@Component
+@Scope("singleton")
+public class SelfScorecardApiResource {
+
+ private final PlatformSecurityContext context;
+ private final ScorecardApiResource scorecardApiResource;
+ private final AppuserClientMapperReadService
appuserClientMapperReadService;
+
+ @Autowired
+ public SelfScorecardApiResource(final PlatformSecurityContext
securityContext,
+ final AppuserClientMapperReadService
appuserClientMapperReadService,
+ final ScorecardApiResource scorecardApiResource) {
+ this.context = securityContext;
+ this.scorecardApiResource = scorecardApiResource;
+ this.appuserClientMapperReadService =
appuserClientMapperReadService;
+ }
+
+ @GET
+ @Path("clients/{clientId}")
+ @Consumes({ MediaType.APPLICATION_JSON })
+ @Produces({ MediaType.APPLICATION_JSON })
+ @Transactional
+ public List<ScorecardData> findByClient(@PathParam("clientId") final
Long clientId) {
+
+ validateAppuserClientsMapping(clientId);
+ return this.scorecardApiResource.findByClient(clientId);
+ }
+
+ @POST
+ @Path("{surveyId}")
+ @Consumes({ MediaType.APPLICATION_JSON })
+ @Produces({ MediaType.APPLICATION_JSON })
+ @Transactional
+ public void createScorecard(@PathParam("surveyId") final Long surveyId,
final ScorecardData scorecardData) {
+ if (scorecardData.getClientId() != null) {
+
validateAppuserClientsMapping(scorecardData.getClientId());
+ this.scorecardApiResource.createScorecard(surveyId,
scorecardData);
+ }
+
+ }
+
+ private void validateAppuserClientsMapping(final Long clientId) {
+ AppUser user = this.context.authenticatedUser();
+ final boolean mappedClientId =
this.appuserClientMapperReadService.isClientMappedToUser(clientId,
user.getId());
+ if (!mappedClientId) {
+ throw new ClientNotFoundException(clientId);
+ }
+ }
+
+}
diff --git
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/spm/api/SelfSpmApiResource.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/spm/api/SelfSpmApiResource.java
new file mode 100644
index 000000000..5e2f5003c
--- /dev/null
+++
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/self/spm/api/SelfSpmApiResource.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.spm.api;
+
+import java.util.List;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import
org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
+import org.apache.fineract.spm.api.SpmApiResource;
+import org.apache.fineract.spm.data.SurveyData;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Scope;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+
+@Path("/self/surveys")
+@Component
+@Scope("singleton")
+public class SelfSpmApiResource {
+
+ private final PlatformSecurityContext securityContext;
+ private final SpmApiResource spmApiResource;
+
+ @Autowired
+ public SelfSpmApiResource(final PlatformSecurityContext
securityContext, final SpmApiResource spmApiResource) {
+ this.securityContext = securityContext;
+ this.spmApiResource = spmApiResource;
+ }
+
+ @GET
+ @Consumes({ MediaType.APPLICATION_JSON })
+ @Produces({ MediaType.APPLICATION_JSON })
+ @Transactional
+ public List<SurveyData> fetchAllSurveys() {
+ securityContext.authenticatedUser();
+ final Boolean isActive = true;
+ return this.spmApiResource.fetchAllSurveys(isActive);
+ }
+
+}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Creation Of API's for Self-Service App
> --------------------------------------
>
> Key: FINERACT-628
> URL: https://issues.apache.org/jira/browse/FINERACT-628
> Project: Apache Fineract
> Issue Type: New Feature
> Affects Versions: 1.1.0
> Reporter: Saksham Handu
> Assignee: Shruthi M R
> Priority: Major
>
> List Of API's needed are mentioned below,
> 1) Support for applying for savings accounts
> 2) Support for viewing share accounts
> 3) Support for adding guarantors
> 4) Support for editing user details.
> 5) Support for viewing reports
> 6) Support for surveys
> 7) Support for Applying for new Shares Account
> 8) Support for uploading new Client's Image
> 9) Support for the list of Loan, Savings, Shares product along with their
> details
> 10) Support for viewing Recent Transactions
> 11) Support for viewing Charges
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)