@crediblex.io/fineract-api-client 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/dist/api/fineract-creditlines-api.d.ts +95 -0
  2. package/dist/api/fineract-creditlines-api.d.ts.map +1 -0
  3. package/dist/api/fineract-creditlines-api.js +196 -0
  4. package/dist/api/fineract-creditlines-api.js.map +1 -0
  5. package/dist/api/fineract-datatable-api.d.ts +64 -0
  6. package/dist/api/fineract-datatable-api.d.ts.map +1 -0
  7. package/dist/api/fineract-datatable-api.js +146 -0
  8. package/dist/api/fineract-datatable-api.js.map +1 -0
  9. package/dist/api/fineract-holidays-api.d.ts +29 -0
  10. package/dist/api/fineract-holidays-api.d.ts.map +1 -0
  11. package/dist/api/fineract-holidays-api.js +57 -0
  12. package/dist/api/fineract-holidays-api.js.map +1 -0
  13. package/dist/api/fineract-loanproducts-api.d.ts +57 -0
  14. package/dist/api/fineract-loanproducts-api.d.ts.map +1 -0
  15. package/dist/api/fineract-loanproducts-api.js +140 -0
  16. package/dist/api/fineract-loanproducts-api.js.map +1 -0
  17. package/dist/api/fineract-loansaccounts-api.d.ts +77 -0
  18. package/dist/api/fineract-loansaccounts-api.d.ts.map +1 -0
  19. package/dist/api/fineract-loansaccounts-api.js +209 -0
  20. package/dist/api/fineract-loansaccounts-api.js.map +1 -0
  21. package/dist/api/fineract-reports-api.d.ts +33 -0
  22. package/dist/api/fineract-reports-api.d.ts.map +1 -0
  23. package/dist/api/fineract-reports-api.js +94 -0
  24. package/dist/api/fineract-reports-api.js.map +1 -0
  25. package/dist/api/fineract-savingsaccounts-api.d.ts +59 -0
  26. package/dist/api/fineract-savingsaccounts-api.d.ts.map +1 -0
  27. package/dist/api/fineract-savingsaccounts-api.js +141 -0
  28. package/dist/api/fineract-savingsaccounts-api.js.map +1 -0
  29. package/dist/api/fineract-savingsproducts-api.d.ts +86 -0
  30. package/dist/api/fineract-savingsproducts-api.d.ts.map +1 -0
  31. package/dist/api/fineract-savingsproducts-api.js +184 -0
  32. package/dist/api/fineract-savingsproducts-api.js.map +1 -0
  33. package/dist/api/fineract-sme-api.d.ts +39 -0
  34. package/dist/api/fineract-sme-api.d.ts.map +1 -0
  35. package/dist/api/fineract-sme-api.js +82 -0
  36. package/dist/api/fineract-sme-api.js.map +1 -0
  37. package/dist/api/fineract-workingdays-api.d.ts +28 -0
  38. package/dist/api/fineract-workingdays-api.d.ts.map +1 -0
  39. package/dist/api/fineract-workingdays-api.js +84 -0
  40. package/dist/api/fineract-workingdays-api.js.map +1 -0
  41. package/dist/examples/run-examples.d.ts +2 -0
  42. package/dist/examples/run-examples.d.ts.map +1 -0
  43. package/dist/examples/run-examples.js +868 -0
  44. package/dist/examples/run-examples.js.map +1 -0
  45. package/dist/fineract-sdk.d.ts +50 -0
  46. package/dist/fineract-sdk.d.ts.map +1 -0
  47. package/dist/fineract-sdk.js +55 -0
  48. package/dist/fineract-sdk.js.map +1 -0
  49. package/dist/index.d.ts +8 -0
  50. package/dist/index.d.ts.map +1 -0
  51. package/dist/index.js +36 -0
  52. package/dist/index.js.map +1 -0
  53. package/dist/types/creditlines.d.ts +271 -0
  54. package/dist/types/creditlines.d.ts.map +1 -0
  55. package/dist/types/creditlines.js +3 -0
  56. package/dist/types/creditlines.js.map +1 -0
  57. package/dist/types/datatable.d.ts +36 -0
  58. package/dist/types/datatable.d.ts.map +1 -0
  59. package/dist/types/datatable.js +3 -0
  60. package/dist/types/datatable.js.map +1 -0
  61. package/dist/types/errors.d.ts +7 -0
  62. package/dist/types/errors.d.ts.map +1 -0
  63. package/dist/types/errors.js +17 -0
  64. package/dist/types/errors.js.map +1 -0
  65. package/dist/types/holidays.d.ts +32 -0
  66. package/dist/types/holidays.d.ts.map +1 -0
  67. package/dist/types/holidays.js +3 -0
  68. package/dist/types/holidays.js.map +1 -0
  69. package/dist/types/index.d.ts +7 -0
  70. package/dist/types/index.d.ts.map +1 -0
  71. package/dist/types/index.js +25 -0
  72. package/dist/types/index.js.map +1 -0
  73. package/dist/types/loanproducts.d.ts +1 -0
  74. package/dist/types/loanproducts.d.ts.map +1 -0
  75. package/dist/types/loanproducts.js +2 -0
  76. package/dist/types/loanproducts.js.map +1 -0
  77. package/dist/types/loansaccounts.d.ts +195 -0
  78. package/dist/types/loansaccounts.d.ts.map +1 -0
  79. package/dist/types/loansaccounts.js +3 -0
  80. package/dist/types/loansaccounts.js.map +1 -0
  81. package/dist/types/reports.d.ts +49 -0
  82. package/dist/types/reports.d.ts.map +1 -0
  83. package/dist/types/reports.js +4 -0
  84. package/dist/types/reports.js.map +1 -0
  85. package/dist/types/savingsaccounts.d.ts +145 -0
  86. package/dist/types/savingsaccounts.d.ts.map +1 -0
  87. package/dist/types/savingsaccounts.js +3 -0
  88. package/dist/types/savingsaccounts.js.map +1 -0
  89. package/dist/types/savingsproducts.d.ts +83 -0
  90. package/dist/types/savingsproducts.d.ts.map +1 -0
  91. package/dist/types/savingsproducts.js +3 -0
  92. package/dist/types/savingsproducts.js.map +1 -0
  93. package/dist/types/sme.d.ts +68 -0
  94. package/dist/types/sme.d.ts.map +1 -0
  95. package/dist/types/sme.js +3 -0
  96. package/dist/types/sme.js.map +1 -0
  97. package/dist/types/workingdays.d.ts +41 -0
  98. package/dist/types/workingdays.d.ts.map +1 -0
  99. package/dist/types/workingdays.js +3 -0
  100. package/dist/types/workingdays.js.map +1 -0
  101. package/dist/utils/http-client.d.ts +29 -0
  102. package/dist/utils/http-client.d.ts.map +1 -0
  103. package/dist/utils/http-client.js +93 -0
  104. package/dist/utils/http-client.js.map +1 -0
  105. package/package.json +51 -0
@@ -0,0 +1,57 @@
1
+ import { HttpClient } from "../utils/http-client";
2
+ /**
3
+ * API client for Fineract Loan Products related operations.
4
+ * It uses the HttpClient for making requests.
5
+ */
6
+ export declare class FineractLoanProductsApi {
7
+ private readonly httpClient;
8
+ constructor(httpClient: HttpClient);
9
+ /**
10
+ * Retrieves all loan products from Fineract.
11
+ * Corresponds to the GET /loanproducts endpoint.
12
+ *
13
+ * @returns A promise that resolves to the list of loan products or rejects with an error.
14
+ */
15
+ getAll(): Promise<any[]>;
16
+ /**
17
+ * Retrieves a specific loan product by ID from Fineract.
18
+ * Corresponds to the GET /loanproducts/{productId} endpoint.
19
+ *
20
+ * @param productId The ID of the loan product to retrieve.
21
+ * @returns A promise that resolves to the loan product details or rejects with an error.
22
+ */
23
+ getById(productId: number): Promise<any>;
24
+ /**
25
+ * Creates a new loan product in Fineract.
26
+ * Corresponds to the POST /loanproducts endpoint.
27
+ *
28
+ * @param productData The data for the new loan product.
29
+ * @returns A promise that resolves to the creation response or rejects with an error.
30
+ */
31
+ create(productData: any): Promise<any>;
32
+ /**
33
+ * Updates an existing loan product in Fineract.
34
+ * Corresponds to the PUT /loanproducts/{productId} endpoint.
35
+ *
36
+ * @param productId The ID of the loan product to update.
37
+ * @param productData The updated data for the loan product.
38
+ * @returns A promise that resolves to the update response or rejects with an error.
39
+ */
40
+ update(productId: number, productData: any): Promise<any>;
41
+ /**
42
+ * Deletes a loan product from Fineract.
43
+ * Corresponds to the DELETE /loanproducts/{productId} endpoint.
44
+ *
45
+ * @param productId The ID of the loan product to delete.
46
+ * @returns A promise that resolves to the deletion response or rejects with an error.
47
+ */
48
+ delete(productId: number): Promise<any>;
49
+ /**
50
+ * Retrieves template data for creating a new loan product.
51
+ * Corresponds to the GET /loanproducts/template endpoint.
52
+ *
53
+ * @returns A promise that resolves to the template data or rejects with an error.
54
+ */
55
+ getTemplate(): Promise<any>;
56
+ }
57
+ //# sourceMappingURL=fineract-loanproducts-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fineract-loanproducts-api.d.ts","sourceRoot":"","sources":["../../src/api/fineract-loanproducts-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAIlD;;;GAGG;AACH,qBAAa,uBAAuB;IAClC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;gBAE5B,UAAU,EAAE,UAAU;IAIlC;;;;;OAKG;IACG,MAAM,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAoB9B;;;;;;OAMG;IACG,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAoB9C;;;;;;OAMG;IACG,MAAM,CAAC,WAAW,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAoB5C;;;;;;;OAOG;IACG,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAoB/D;;;;;;OAMG;IACG,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAoB7C;;;;;OAKG;IACG,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC;CAmBlC"}
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FineractLoanProductsApi = void 0;
4
+ const errors_1 = require("../types/errors");
5
+ /**
6
+ * API client for Fineract Loan Products related operations.
7
+ * It uses the HttpClient for making requests.
8
+ */
9
+ class FineractLoanProductsApi {
10
+ constructor(httpClient) {
11
+ this.httpClient = httpClient;
12
+ }
13
+ /**
14
+ * Retrieves all loan products from Fineract.
15
+ * Corresponds to the GET /loanproducts endpoint.
16
+ *
17
+ * @returns A promise that resolves to the list of loan products or rejects with an error.
18
+ */
19
+ async getAll() {
20
+ try {
21
+ const apiPath = "/fineract-provider/api/v1/loanproducts";
22
+ const response = await this.httpClient.get(apiPath);
23
+ return response.data;
24
+ }
25
+ catch (rawError) {
26
+ const errorPayload = rawError;
27
+ const message = errorPayload?.message ||
28
+ errorPayload?.error ||
29
+ "Fineract API request failed";
30
+ throw new errors_1.FineractApiError(message, errorPayload?.statusCode, errorPayload?.details, errorPayload?.error);
31
+ }
32
+ }
33
+ /**
34
+ * Retrieves a specific loan product by ID from Fineract.
35
+ * Corresponds to the GET /loanproducts/{productId} endpoint.
36
+ *
37
+ * @param productId The ID of the loan product to retrieve.
38
+ * @returns A promise that resolves to the loan product details or rejects with an error.
39
+ */
40
+ async getById(productId) {
41
+ try {
42
+ const apiPath = `/fineract-provider/api/v1/loanproducts/${productId}`;
43
+ const response = await this.httpClient.get(apiPath);
44
+ return response.data;
45
+ }
46
+ catch (rawError) {
47
+ const errorPayload = rawError;
48
+ const message = errorPayload?.message ||
49
+ errorPayload?.error ||
50
+ "Fineract API request failed";
51
+ throw new errors_1.FineractApiError(message, errorPayload?.statusCode, errorPayload?.details, errorPayload?.error);
52
+ }
53
+ }
54
+ /**
55
+ * Creates a new loan product in Fineract.
56
+ * Corresponds to the POST /loanproducts endpoint.
57
+ *
58
+ * @param productData The data for the new loan product.
59
+ * @returns A promise that resolves to the creation response or rejects with an error.
60
+ */
61
+ async create(productData) {
62
+ try {
63
+ const apiPath = "/fineract-provider/api/v1/loanproducts";
64
+ const response = await this.httpClient.post(apiPath, productData);
65
+ return response.data;
66
+ }
67
+ catch (rawError) {
68
+ const errorPayload = rawError;
69
+ const message = errorPayload?.message ||
70
+ errorPayload?.error ||
71
+ "Fineract API request failed";
72
+ throw new errors_1.FineractApiError(message, errorPayload?.statusCode, errorPayload?.details, errorPayload?.error);
73
+ }
74
+ }
75
+ /**
76
+ * Updates an existing loan product in Fineract.
77
+ * Corresponds to the PUT /loanproducts/{productId} endpoint.
78
+ *
79
+ * @param productId The ID of the loan product to update.
80
+ * @param productData The updated data for the loan product.
81
+ * @returns A promise that resolves to the update response or rejects with an error.
82
+ */
83
+ async update(productId, productData) {
84
+ try {
85
+ const apiPath = `/fineract-provider/api/v1/loanproducts/${productId}`;
86
+ const response = await this.httpClient.put(apiPath, productData);
87
+ return response.data;
88
+ }
89
+ catch (rawError) {
90
+ const errorPayload = rawError;
91
+ const message = errorPayload?.message ||
92
+ errorPayload?.error ||
93
+ "Fineract API request failed";
94
+ throw new errors_1.FineractApiError(message, errorPayload?.statusCode, errorPayload?.details, errorPayload?.error);
95
+ }
96
+ }
97
+ /**
98
+ * Deletes a loan product from Fineract.
99
+ * Corresponds to the DELETE /loanproducts/{productId} endpoint.
100
+ *
101
+ * @param productId The ID of the loan product to delete.
102
+ * @returns A promise that resolves to the deletion response or rejects with an error.
103
+ */
104
+ async delete(productId) {
105
+ try {
106
+ const apiPath = `/fineract-provider/api/v1/loanproducts/${productId}`;
107
+ const response = await this.httpClient.delete(apiPath);
108
+ return response.data;
109
+ }
110
+ catch (rawError) {
111
+ const errorPayload = rawError;
112
+ const message = errorPayload?.message ||
113
+ errorPayload?.error ||
114
+ "Fineract API request failed";
115
+ throw new errors_1.FineractApiError(message, errorPayload?.statusCode, errorPayload?.details, errorPayload?.error);
116
+ }
117
+ }
118
+ /**
119
+ * Retrieves template data for creating a new loan product.
120
+ * Corresponds to the GET /loanproducts/template endpoint.
121
+ *
122
+ * @returns A promise that resolves to the template data or rejects with an error.
123
+ */
124
+ async getTemplate() {
125
+ try {
126
+ const apiPath = "/fineract-provider/api/v1/loanproducts/template";
127
+ const response = await this.httpClient.get(apiPath);
128
+ return response.data;
129
+ }
130
+ catch (rawError) {
131
+ const errorPayload = rawError;
132
+ const message = errorPayload?.message ||
133
+ errorPayload?.error ||
134
+ "Fineract API request failed";
135
+ throw new errors_1.FineractApiError(message, errorPayload?.statusCode, errorPayload?.details, errorPayload?.error);
136
+ }
137
+ }
138
+ }
139
+ exports.FineractLoanProductsApi = FineractLoanProductsApi;
140
+ //# sourceMappingURL=fineract-loanproducts-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fineract-loanproducts-api.js","sourceRoot":"","sources":["../../src/api/fineract-loanproducts-api.ts"],"names":[],"mappings":";;;AAEA,4CAAmD;AAEnD;;;GAGG;AACH,MAAa,uBAAuB;IAGlC,YAAY,UAAsB;QAChC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,MAAM;QACV,IAAI,CA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;YAClB,MAAM,YAAY,GAAG,QAAiC,CAAC;YACvD,MAAM,OAAO,GACX,YAAY,EAAE,OAAO;gBACrB,YAAY,EAAE,KAAK;gBACnB,6BAA6B,CAAC;YAChC,MAAM,IAAI,yBAAgB,CACxB,OAAO,EACP,YAAY,EAAE,UAAU,EACxB,YAAY,EAAE,OAAO,EACrB,YAAY,EAAE,KAAK,CACpB,CAAC;QACJ,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,WAAW;QACf,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,iDAAiD,CAAC;YAClE,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAM,OAAO,CAAC,CAAC;YACzD,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;QAAC,OAAO,QAAQ,EAAE,CAAC;YAClB,MAAM,YAAY,GAAG,QAAiC,CAAC;YACvD,MAAM,OAAO,GACX,YAAY,EAAE,OAAO;gBACrB,YAAY,EAAE,KAAK;gBACnB,6BAA6B,CAAC;YAChC,MAAM,IAAI,yBAAgB,CACxB,OAAO,EACP,YAAY,EAAE,UAAU,EACxB,YAAY,EAAE,OAAO,EACrB,YAAY,EAAE,KAAK,CACpB,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAvKD,0DAuKC"}
@@ -0,0 +1,77 @@
1
+ import { HttpClient } from "../utils/http-client";
2
+ import { CalculateLoanRepaymentScheduleRequest, CalculateLoanRepaymentScheduleResponse, CreateLoanAccountRequest, CreateLoanAccountResponse, ApproveLoanAccountRequest, ApproveLoanAccountResponse } from "../types/loansaccounts";
3
+ /**
4
+ * API client for Fineract Loan Accounts related operations.
5
+ * It uses the HttpClient for making requests.
6
+ */
7
+ export declare class FineractLoansAccountsApi {
8
+ private readonly httpClient;
9
+ constructor(httpClient: HttpClient);
10
+ /**
11
+ * Retrieves all loan accounts from Fineract.
12
+ * Corresponds to the GET /loans endpoint.
13
+ *
14
+ * @returns A promise that resolves to the list of loan accounts or rejects with an error.
15
+ */
16
+ getAll(): Promise<any>;
17
+ /**
18
+ * Retrieves a specific loan account by ID from Fineract.
19
+ * Corresponds to the GET /loans/{loanId} endpoint.
20
+ *
21
+ * @param loanId The ID of the loan account to retrieve.
22
+ * @returns A promise that resolves to the loan account details or rejects with an error.
23
+ */
24
+ getById(loanId: number): Promise<any>;
25
+ /**
26
+ * Creates a new loan account in Fineract.
27
+ * Corresponds to the POST /loans endpoint.
28
+ *
29
+ * @param loanData The data for the new loan account.
30
+ * @returns A promise that resolves to the creation response or rejects with an error.
31
+ */
32
+ create(loanData: CreateLoanAccountRequest): Promise<CreateLoanAccountResponse>;
33
+ /**
34
+ * Updates a loan account in Fineract.
35
+ * Corresponds to the PUT /loans/{loanId} endpoint.
36
+ *
37
+ * @param loanId The ID of the loan account to update.
38
+ * @param loanData The updated data for the loan account.
39
+ * @returns A promise that resolves to the update response or rejects with an error.
40
+ */
41
+ update(loanId: number, loanData: any): Promise<any>;
42
+ /**
43
+ * Deletes a loan account from Fineract.
44
+ * Corresponds to the DELETE /loans/{loanId} endpoint.
45
+ *
46
+ * @param loanId The ID of the loan account to delete.
47
+ * @returns A promise that resolves to the deletion response or rejects with an error.
48
+ */
49
+ delete(loanId: number): Promise<any>;
50
+ /**
51
+ * Calculates and retrieves the repayment schedule for a loan account.
52
+ * Corresponds to the GET /loans?command=calculateLoanSchedule endpoint.
53
+ *
54
+ * @param loanData The loan data for which to calculate the repayment schedule.
55
+ * @returns A promise that resolves to the calculated loan schedule or rejects with an error.
56
+ */
57
+ getRepaymentSchedule(loanData: CalculateLoanRepaymentScheduleRequest): Promise<CalculateLoanRepaymentScheduleResponse>;
58
+ /**
59
+ * Retrieves a specific loan account summary by ID from Fineract.
60
+ * Corresponds to the GET /loans/{loanId} endpoint.
61
+ *
62
+ * @param loanId The ID of the loan account to retrieve summary for.
63
+ * @returns A promise that resolves to the loan account details or rejects with an error.
64
+ */
65
+ getSummaryById(loanId: number): Promise<any>;
66
+ getRepaymentScheduleById(loanId: number): Promise<any>;
67
+ /**
68
+ * Approves a loan account in Fineract.
69
+ * Corresponds to the POST /loans/{loanId}?command=approve endpoint.
70
+ *
71
+ * @param loanId The ID of the loan account to approve.
72
+ * @param approvalData The data for approving the loan account.
73
+ * @returns A promise that resolves to the approval response or rejects with an error.
74
+ */
75
+ approve(loanId: number, approvalData: ApproveLoanAccountRequest): Promise<ApproveLoanAccountResponse>;
76
+ }
77
+ //# sourceMappingURL=fineract-loansaccounts-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fineract-loansaccounts-api.d.ts","sourceRoot":"","sources":["../../src/api/fineract-loansaccounts-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGlD,OAAO,EACL,qCAAqC,EACrC,sCAAsC,EACtC,wBAAwB,EACxB,yBAAyB,EACzB,yBAAyB,EACzB,0BAA0B,EAC3B,MAAM,wBAAwB,CAAC;AAEhC;;;GAGG;AACH,qBAAa,wBAAwB;IACnC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;gBAE5B,UAAU,EAAE,UAAU;IAIlC;;;;;OAKG;IACG,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC;IAoB5B;;;;;;OAMG;IACG,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAoB3C;;;;;;OAMG;IACG,MAAM,CACV,QAAQ,EAAE,wBAAwB,GACjC,OAAO,CAAC,yBAAyB,CAAC;IAuBrC;;;;;;;OAOG;IACG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAoBzD;;;;;;OAMG;IACG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAoB1C;;;;;;OAMG;IACG,oBAAoB,CACxB,QAAQ,EAAE,qCAAqC,GAC9C,OAAO,CAAC,sCAAsC,CAAC;IA2BlD;;;;;;OAMG;IACG,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IA0B5C,wBAAwB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IA0B5D;;;;;;;OAOG;IACG,OAAO,CACX,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,yBAAyB,GACtC,OAAO,CAAC,0BAA0B,CAAC;CAsBvC"}
@@ -0,0 +1,209 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FineractLoansAccountsApi = void 0;
4
+ const errors_1 = require("../types/errors");
5
+ /**
6
+ * API client for Fineract Loan Accounts related operations.
7
+ * It uses the HttpClient for making requests.
8
+ */
9
+ class FineractLoansAccountsApi {
10
+ constructor(httpClient) {
11
+ this.httpClient = httpClient;
12
+ }
13
+ /**
14
+ * Retrieves all loan accounts from Fineract.
15
+ * Corresponds to the GET /loans endpoint.
16
+ *
17
+ * @returns A promise that resolves to the list of loan accounts or rejects with an error.
18
+ */
19
+ async getAll() {
20
+ try {
21
+ const apiPath = "/fineract-provider/api/v1/loans";
22
+ const response = await this.httpClient.get(apiPath);
23
+ return response.data;
24
+ }
25
+ catch (rawError) {
26
+ const errorPayload = rawError;
27
+ const message = errorPayload?.message ||
28
+ errorPayload?.error ||
29
+ "Fineract API request failed";
30
+ throw new errors_1.FineractApiError(message, errorPayload?.statusCode, errorPayload?.details, errorPayload?.error);
31
+ }
32
+ }
33
+ /**
34
+ * Retrieves a specific loan account by ID from Fineract.
35
+ * Corresponds to the GET /loans/{loanId} endpoint.
36
+ *
37
+ * @param loanId The ID of the loan account to retrieve.
38
+ * @returns A promise that resolves to the loan account details or rejects with an error.
39
+ */
40
+ async getById(loanId) {
41
+ try {
42
+ const apiPath = `/fineract-provider/api/v1/loans/${loanId}`;
43
+ const response = await this.httpClient.get(apiPath);
44
+ return response.data;
45
+ }
46
+ catch (rawError) {
47
+ const errorPayload = rawError;
48
+ const message = errorPayload?.message ||
49
+ errorPayload?.error ||
50
+ "Fineract API request failed";
51
+ throw new errors_1.FineractApiError(message, errorPayload?.statusCode, errorPayload?.details, errorPayload?.error);
52
+ }
53
+ }
54
+ /**
55
+ * Creates a new loan account in Fineract.
56
+ * Corresponds to the POST /loans endpoint.
57
+ *
58
+ * @param loanData The data for the new loan account.
59
+ * @returns A promise that resolves to the creation response or rejects with an error.
60
+ */
61
+ async create(loanData) {
62
+ try {
63
+ const apiPath = "/fineract-provider/api/v1/loans";
64
+ const response = await this.httpClient.post(apiPath, loanData);
65
+ return response.data;
66
+ }
67
+ catch (rawError) {
68
+ const errorPayload = rawError;
69
+ const message = errorPayload?.message ||
70
+ errorPayload?.error ||
71
+ "Fineract API request failed";
72
+ throw new errors_1.FineractApiError(message, errorPayload?.statusCode, errorPayload?.details, errorPayload?.error);
73
+ }
74
+ }
75
+ /**
76
+ * Updates a loan account in Fineract.
77
+ * Corresponds to the PUT /loans/{loanId} endpoint.
78
+ *
79
+ * @param loanId The ID of the loan account to update.
80
+ * @param loanData The updated data for the loan account.
81
+ * @returns A promise that resolves to the update response or rejects with an error.
82
+ */
83
+ async update(loanId, loanData) {
84
+ try {
85
+ const apiPath = `/fineract-provider/api/v1/loans/${loanId}`;
86
+ const response = await this.httpClient.put(apiPath, loanData);
87
+ return response.data;
88
+ }
89
+ catch (rawError) {
90
+ const errorPayload = rawError;
91
+ const message = errorPayload?.message ||
92
+ errorPayload?.error ||
93
+ "Fineract API request failed";
94
+ throw new errors_1.FineractApiError(message, errorPayload?.statusCode, errorPayload?.details, errorPayload?.error);
95
+ }
96
+ }
97
+ /**
98
+ * Deletes a loan account from Fineract.
99
+ * Corresponds to the DELETE /loans/{loanId} endpoint.
100
+ *
101
+ * @param loanId The ID of the loan account to delete.
102
+ * @returns A promise that resolves to the deletion response or rejects with an error.
103
+ */
104
+ async delete(loanId) {
105
+ try {
106
+ const apiPath = `/fineract-provider/api/v1/loans/${loanId}`;
107
+ const response = await this.httpClient.delete(apiPath);
108
+ return response.data;
109
+ }
110
+ catch (rawError) {
111
+ const errorPayload = rawError;
112
+ const message = errorPayload?.message ||
113
+ errorPayload?.error ||
114
+ "Fineract API request failed";
115
+ throw new errors_1.FineractApiError(message, errorPayload?.statusCode, errorPayload?.details, errorPayload?.error);
116
+ }
117
+ }
118
+ /**
119
+ * Calculates and retrieves the repayment schedule for a loan account.
120
+ * Corresponds to the GET /loans?command=calculateLoanSchedule endpoint.
121
+ *
122
+ * @param loanData The loan data for which to calculate the repayment schedule.
123
+ * @returns A promise that resolves to the calculated loan schedule or rejects with an error.
124
+ */
125
+ async getRepaymentSchedule(loanData) {
126
+ try {
127
+ const apiPath = "/fineract-provider/api/v1/loans?command=calculateLoanSchedule";
128
+ const response = await this.httpClient.post(apiPath, loanData);
129
+ return response.data;
130
+ }
131
+ catch (rawError) {
132
+ const errorPayload = rawError;
133
+ const message = errorPayload?.message ||
134
+ errorPayload?.error ||
135
+ "Fineract API request failed";
136
+ console.log("errorPayload.details.errors", errorPayload.details.errors);
137
+ throw new errors_1.FineractApiError(message, errorPayload?.statusCode, errorPayload?.details, errorPayload?.error);
138
+ }
139
+ }
140
+ /**
141
+ * Retrieves a specific loan account summary by ID from Fineract.
142
+ * Corresponds to the GET /loans/{loanId} endpoint.
143
+ *
144
+ * @param loanId The ID of the loan account to retrieve summary for.
145
+ * @returns A promise that resolves to the loan account details or rejects with an error.
146
+ */
147
+ async getSummaryById(loanId) {
148
+ const params = new URLSearchParams({
149
+ staffInSelectedOfficeOnly: "false",
150
+ associations: "summary",
151
+ exclude: "guarantors, futureSchedule",
152
+ });
153
+ try {
154
+ const apiPath = `/fineract-provider/api/v1/loans/${loanId}?${params.toString()}`;
155
+ const response = await this.httpClient.get(apiPath);
156
+ return response.data;
157
+ }
158
+ catch (rawError) {
159
+ const errorPayload = rawError;
160
+ const message = errorPayload?.message ||
161
+ errorPayload?.error ||
162
+ "Fineract API request failed";
163
+ throw new errors_1.FineractApiError(message, errorPayload?.statusCode, errorPayload?.details, errorPayload?.error);
164
+ }
165
+ }
166
+ async getRepaymentScheduleById(loanId) {
167
+ const params = new URLSearchParams({
168
+ staffInSelectedOfficeOnly: "false",
169
+ associations: "summary, repaymentSchedule",
170
+ exclude: "guarantors, futureSchedule",
171
+ });
172
+ try {
173
+ const apiPath = `/fineract-provider/api/v1/loans/${loanId}?${params.toString()}`;
174
+ const response = await this.httpClient.get(apiPath);
175
+ return response.data;
176
+ }
177
+ catch (rawError) {
178
+ const errorPayload = rawError;
179
+ const message = errorPayload?.message ||
180
+ errorPayload?.error ||
181
+ "Fineract API request failed";
182
+ throw new errors_1.FineractApiError(message, errorPayload?.statusCode, errorPayload?.details, errorPayload?.error);
183
+ }
184
+ }
185
+ /**
186
+ * Approves a loan account in Fineract.
187
+ * Corresponds to the POST /loans/{loanId}?command=approve endpoint.
188
+ *
189
+ * @param loanId The ID of the loan account to approve.
190
+ * @param approvalData The data for approving the loan account.
191
+ * @returns A promise that resolves to the approval response or rejects with an error.
192
+ */
193
+ async approve(loanId, approvalData) {
194
+ try {
195
+ const apiPath = `/fineract-provider/api/v1/loans/${loanId}?command=approve`;
196
+ const response = await this.httpClient.post(apiPath, approvalData);
197
+ return response.data;
198
+ }
199
+ catch (rawError) {
200
+ const errorPayload = rawError;
201
+ const message = errorPayload?.message ||
202
+ errorPayload?.error ||
203
+ "Fineract API request failed";
204
+ throw new errors_1.FineractApiError(message, errorPayload?.statusCode, errorPayload?.details, errorPayload?.error);
205
+ }
206
+ }
207
+ }
208
+ exports.FineractLoansAccountsApi = FineractLoansAccountsApi;
209
+ //# sourceMappingURL=fineract-loansaccounts-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fineract-loansaccounts-api.js","sourceRoot":"","sources":["../../src/api/fineract-loansaccounts-api.ts"],"names":[],"mappings":";;;AAEA,4CAAmD;AAUnD;;;GAGG;AACH,MAAa,wBAAwB;IAGnC,YAAY,UAAsB;QAChC,IAAI,CAAC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AC,OAAO,CACX,MAAc,EACd,YAAuC;QAEvC,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,mCAAmC,MAAM,kBAAkB,CAAC;YAC5E,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CACzC,OAAO,EACP,YAAY,CACb,CAAC;YACF,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;QAAC,OAAO,QAAQ,EAAE,CAAC;YAClB,MAAM,YAAY,GAAG,QAAiC,CAAC;YACvD,MAAM,OAAO,GACX,YAAY,EAAE,OAAO;gBACrB,YAAY,EAAE,KAAK;gBACnB,6BAA6B,CAAC;YAChC,MAAM,IAAI,yBAAgB,CACxB,OAAO,EACP,YAAY,EAAE,UAAU,EACxB,YAAY,EAAE,OAAO,EACrB,YAAY,EAAE,KAAK,CACpB,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAnRD,4DAmRC"}
@@ -0,0 +1,33 @@
1
+ import { HttpClient } from "../utils/http-client";
2
+ import { MappedReportResponse, LoanPaymentsDueParams, LoanPaymentsDueOverdueParams, ExpectedPaymentsByDateBasicParams } from "../types/reports";
3
+ /**
4
+ * API client for Fineract "run reports" functionality.
5
+ * Provides helper methods to execute reports and obtain their tabular data.
6
+ */
7
+ export declare class FineractReportsApi {
8
+ private readonly httpClient;
9
+ private readonly basePath;
10
+ private mapReportResponse;
11
+ constructor(httpClient: HttpClient);
12
+ /**
13
+ * Internal generic report executor (intentionally private to restrict consumers
14
+ * to approved convenience methods only).
15
+ */
16
+ private run;
17
+ /**
18
+ * Convenience wrapper for the specific "Loan payments due" report.
19
+ * @param params Report parameters (office, fromX, toY, loanOfficerId)
20
+ */
21
+ getLoanPaymentsDue(params: LoanPaymentsDueParams): Promise<MappedReportResponse>;
22
+ /**
23
+ * Convenience wrapper for the "Loan payments due (Overdue Loans)" report.
24
+ * @param params Report parameters including overdue range.
25
+ */
26
+ getLoanPaymentsDueOverdue(params: LoanPaymentsDueOverdueParams): Promise<MappedReportResponse>;
27
+ /**
28
+ * Convenience wrapper for the "Expected Payments By Date - Basic" report.
29
+ * @param params Report parameters including date range and office/officer.
30
+ */
31
+ getExpectedPaymentsByDateBasic(params: ExpectedPaymentsByDateBasicParams): Promise<MappedReportResponse>;
32
+ }
33
+ //# sourceMappingURL=fineract-reports-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fineract-reports-api.d.ts","sourceRoot":"","sources":["../../src/api/fineract-reports-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGlD,OAAO,EAEL,oBAAoB,EACpB,qBAAqB,EACrB,4BAA4B,EAC5B,iCAAiC,EAElC,MAAM,kBAAkB,CAAC;AAE1B;;;GAGG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;IACxC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA0C;IAEnE,OAAO,CAAC,iBAAiB;gBAYb,UAAU,EAAE,UAAU;IAIlC;;;OAGG;YACW,GAAG;IA4BjB;;;OAGG;IACG,kBAAkB,CACtB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,oBAAoB,CAAC;IAWhC;;;OAGG;IACG,yBAAyB,CAC7B,MAAM,EAAE,4BAA4B,GACnC,OAAO,CAAC,oBAAoB,CAAC;IAahC;;;OAGG;IACG,8BAA8B,CAClC,MAAM,EAAE,iCAAiC,GACxC,OAAO,CAAC,oBAAoB,CAAC;CAYjC"}
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FineractReportsApi = void 0;
4
+ const errors_1 = require("../types/errors");
5
+ /**
6
+ * API client for Fineract "run reports" functionality.
7
+ * Provides helper methods to execute reports and obtain their tabular data.
8
+ */
9
+ class FineractReportsApi {
10
+ // Key normalization strategy: use raw columnName as-is. Optionally could camelCase later.
11
+ mapReportResponse(raw) {
12
+ const columnNames = raw.columnHeaders.map((c) => c.columnName);
13
+ const data = raw.data.map((rowObj) => {
14
+ const record = {};
15
+ columnNames.forEach((col, idx) => {
16
+ record[col] = rowObj.row[idx];
17
+ });
18
+ return record;
19
+ });
20
+ return { data };
21
+ }
22
+ constructor(httpClient) {
23
+ this.basePath = "/fineract-provider/api/v1/runreports";
24
+ this.httpClient = httpClient;
25
+ }
26
+ /**
27
+ * Internal generic report executor (intentionally private to restrict consumers
28
+ * to approved convenience methods only).
29
+ */
30
+ async run(reportName, params = {}) {
31
+ // Encode report name for URL path while leaving query params separate
32
+ const encodedName = encodeURIComponent(reportName);
33
+ try {
34
+ const apiPath = `${this.basePath}/${encodedName}`;
35
+ const response = await this.httpClient.get(apiPath, params);
36
+ return response.data;
37
+ }
38
+ catch (rawError) {
39
+ const errorPayload = rawError;
40
+ const message = errorPayload?.message ||
41
+ errorPayload?.error ||
42
+ "Fineract report request failed";
43
+ throw new errors_1.FineractApiError(message, errorPayload?.statusCode, errorPayload?.details, errorPayload?.error);
44
+ }
45
+ }
46
+ /**
47
+ * Convenience wrapper for the specific "Loan payments due" report.
48
+ * @param params Report parameters (office, fromX, toY, loanOfficerId)
49
+ */
50
+ async getLoanPaymentsDue(params) {
51
+ const mapped = {
52
+ R_officeId: 1,
53
+ R_loanOfficerId: -1,
54
+ R_fromX: params.fromInstallment,
55
+ R_toY: params.toInstallment,
56
+ };
57
+ const raw = await this.run("Loan payments due", mapped);
58
+ return this.mapReportResponse(raw);
59
+ }
60
+ /**
61
+ * Convenience wrapper for the "Loan payments due (Overdue Loans)" report.
62
+ * @param params Report parameters including overdue range.
63
+ */
64
+ async getLoanPaymentsDueOverdue(params) {
65
+ const mapped = {
66
+ R_officeId: 1,
67
+ R_loanOfficerId: -1,
68
+ R_fromX: params.fromInstallment,
69
+ R_toY: params.toInstallment,
70
+ R_overdueX: params.overdueFromDays,
71
+ R_overdueY: params.overdueToDays,
72
+ };
73
+ const raw = await this.run("Loan payments due (Overdue Loans)", mapped);
74
+ return this.mapReportResponse(raw);
75
+ }
76
+ /**
77
+ * Convenience wrapper for the "Expected Payments By Date - Basic" report.
78
+ * @param params Report parameters including date range and office/officer.
79
+ */
80
+ async getExpectedPaymentsByDateBasic(params) {
81
+ const mapped = {
82
+ R_officeId: 1,
83
+ R_loanOfficerId: -1,
84
+ R_startDate: params.startDate,
85
+ R_endDate: params.endDate,
86
+ locale: params.locale,
87
+ dateFormat: params.dateFormat,
88
+ };
89
+ const raw = await this.run("Expected Payments By Date - Basic", mapped);
90
+ return this.mapReportResponse(raw);
91
+ }
92
+ }
93
+ exports.FineractReportsApi = FineractReportsApi;
94
+ //# sourceMappingURL=fineract-reports-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fineract-reports-api.js","sourceRoot":"","sources":["../../src/api/fineract-reports-api.ts"],"names":[],"mappings":";;;AACA,4CAAmD;AAWnD;;;GAGG;AACH,MAAa,kBAAkB;IAG7B,0FAA0F;IAClF,iBAAiB,CAAC,GAAmB;QAC3C,MAAM,WAAW,GAAG,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC;QAC/D,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;YACnC,MAAM,MAAM,GAAwB,EAAE,CAAC;YACvC,WAAW,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;gBAC/B,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAChC,CAAC,CAAC,CAAC;YACH,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC,CAAC;QACH,OAAO,EAAE,IAAI,EAAE,CAAC;IAClB,CAAC;IAED,YAAY,UAAsB;QAdjB,aAAQ,GAAG,sCAAsC,CAAC;QAejE,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED;;;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