-
Notifications
You must be signed in to change notification settings - Fork 20
GSoC 2019 Phase 1, 2 & 3 work submission #14
base: master
Are you sure you want to change the base?
Changes from all commits
52b7df4
47a1854
f828f47
aa4d0c4
a8f706c
eb1ceb7
f83519e
57456c9
4ed1f07
458a859
62d95b2
38c93a2
62f3ebf
a6a565b
09e198a
c5d6835
bc34b0d
6355f6a
4c5180b
082af69
c686347
47233e0
6a3ae4f
a0e6869
b107e8d
d2733f0
bbce0da
a09656a
93f456d
7aa38f8
013587e
710fa30
1e923a1
bcfafb8
8a13220
4009160
25e82e7
8c964f1
d261a51
2f2e853
cf24c0f
5537ccf
44555f8
3da5365
7703d67
7c3c60c
a23ba30
a9dace2
53954e9
dbe450f
939d3ba
a9383ab
b0bdc67
e77d571
29fd628
c383eba
ce36a4c
24955ad
b5eb1b4
c6f4f86
716fb7b
9a0250a
a2af033
b1bcb37
c9c27e5
9da7479
4f3dc95
6b7a9ed
b9a266e
95571d2
3389431
91a7268
04447f6
f23f5cb
5a06fdf
90f8552
46da0ad
99e5b1f
0d12c94
81ab0a5
c474cb1
bdcb581
f7e84b6
be048f8
d846e17
95328ea
8acf203
7db2089
0355b02
e1a43d8
4595dd5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ | |
| import org.apache.commons.lang3.time.FastDateFormat; | ||
| import org.mifos.chatbot.adapter.handler.HandlerUtils; | ||
| import org.mifos.chatbot.client.ApiException; | ||
| import org.mifos.chatbot.client.Configuration; | ||
| import org.mifos.chatbot.client.api.LoansApi; | ||
| import org.mifos.chatbot.client.model.GetLoansLoanIdResponse; | ||
| import org.mifos.chatbot.core.model.Intent; | ||
|
|
@@ -35,13 +36,14 @@ | |
| @Slf4j | ||
| @Component | ||
| public class ArrearDayHandler extends BaseLoanIntentHandler { | ||
| private static final String[] INTENT_KEYWORDS = {"arrear", "day"}; | ||
| private static final String[] INTENT_KEYWORDS = {"arrear_day"}; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move to static file
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This INTENT_KEYWORDS is specific for this class, so my intention is to keep it here or should i move it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keep it here then. |
||
|
|
||
| @Autowired | ||
| private LoansApi loansApi; | ||
|
|
||
| @Override | ||
| public Boolean canHandle(Intent intent) { | ||
| // not removing this logic because it is possible that multiple intent can be handled with same handler | ||
| for(String intent_keyword : INTENT_KEYWORDS) { | ||
| if (!intent.getKeyword().toLowerCase().contains(intent_keyword.toLowerCase())) { | ||
| return false; | ||
|
|
@@ -53,10 +55,15 @@ public Boolean canHandle(Intent intent) { | |
|
|
||
| @Override | ||
| public MifosResponse handle(Intent intent) { | ||
| loansApi.setApiClient(Configuration.getDefaultApiClient()); | ||
| MifosResponse response = new MifosResponse(); | ||
| try { | ||
| GetLoansLoanIdResponse result = loansApi.retrieveLoan(intent.getParameterAsLong("ID"), false); | ||
| List<Long> overdueSinceDate = result.getSummary().getOverdueSinceDate(); | ||
| if(overdueSinceDate == null) { | ||
| response.setContent("No data found for the given id."); | ||
| return response; | ||
| } | ||
| // | ||
| // StringBuffer sb = new StringBuffer(); | ||
| // sb.append(String.format("%04d", overdueSinceDate.get(0))); | ||
|
|
@@ -74,7 +81,7 @@ public MifosResponse handle(Intent intent) { | |
|
|
||
| long diffDays = TimeUnit.DAYS.convert(diff, TimeUnit.MILLISECONDS); | ||
|
|
||
| response.setContent(String.valueOf(diffDays) + " days"); | ||
| response.setContent(diffDays + " days"); | ||
| } catch (ApiException e) { | ||
| log.info("Error", e); | ||
| response.setContent(e.getMessage()); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ | |
| import lombok.extern.slf4j.Slf4j; | ||
| import org.mifos.chatbot.adapter.handler.HandlerUtils; | ||
| import org.mifos.chatbot.client.ApiException; | ||
| import org.mifos.chatbot.client.Configuration; | ||
| import org.mifos.chatbot.client.api.ClientApi; | ||
| import org.mifos.chatbot.client.model.GetClientsClientIdResponse; | ||
| import org.mifos.chatbot.core.model.Intent; | ||
|
|
@@ -30,7 +31,7 @@ | |
| @Slf4j | ||
| @Component | ||
| public class ClientActivationDateHandler extends BaseLoanIntentHandler { | ||
| private static final String[] INTENT_KEYWORDS = {"client", "activation", "date"}; | ||
| private static final String[] INTENT_KEYWORDS = {"client_activation_date"}; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All such hard coded strings to static files
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolved |
||
|
|
||
| @Autowired | ||
| private ClientApi clientApi; | ||
|
|
@@ -48,6 +49,7 @@ public Boolean canHandle(Intent intent) { | |
|
|
||
| @Override | ||
| public MifosResponse handle(Intent intent) { | ||
| clientApi.setApiClient(Configuration.getDefaultApiClient()); | ||
| MifosResponse response = new MifosResponse(); | ||
| try { | ||
| GetClientsClientIdResponse result = clientApi.retrieveOne(intent.getParameterAsLong("ID"), false); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can potentially look into encrypting these fields at the database level for when we want to extend this work.