@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.
- package/dist/api/fineract-creditlines-api.d.ts +95 -0
- package/dist/api/fineract-creditlines-api.d.ts.map +1 -0
- package/dist/api/fineract-creditlines-api.js +196 -0
- package/dist/api/fineract-creditlines-api.js.map +1 -0
- package/dist/api/fineract-datatable-api.d.ts +64 -0
- package/dist/api/fineract-datatable-api.d.ts.map +1 -0
- package/dist/api/fineract-datatable-api.js +146 -0
- package/dist/api/fineract-datatable-api.js.map +1 -0
- package/dist/api/fineract-holidays-api.d.ts +29 -0
- package/dist/api/fineract-holidays-api.d.ts.map +1 -0
- package/dist/api/fineract-holidays-api.js +57 -0
- package/dist/api/fineract-holidays-api.js.map +1 -0
- package/dist/api/fineract-loanproducts-api.d.ts +57 -0
- package/dist/api/fineract-loanproducts-api.d.ts.map +1 -0
- package/dist/api/fineract-loanproducts-api.js +140 -0
- package/dist/api/fineract-loanproducts-api.js.map +1 -0
- package/dist/api/fineract-loansaccounts-api.d.ts +77 -0
- package/dist/api/fineract-loansaccounts-api.d.ts.map +1 -0
- package/dist/api/fineract-loansaccounts-api.js +209 -0
- package/dist/api/fineract-loansaccounts-api.js.map +1 -0
- package/dist/api/fineract-reports-api.d.ts +33 -0
- package/dist/api/fineract-reports-api.d.ts.map +1 -0
- package/dist/api/fineract-reports-api.js +94 -0
- package/dist/api/fineract-reports-api.js.map +1 -0
- package/dist/api/fineract-savingsaccounts-api.d.ts +59 -0
- package/dist/api/fineract-savingsaccounts-api.d.ts.map +1 -0
- package/dist/api/fineract-savingsaccounts-api.js +141 -0
- package/dist/api/fineract-savingsaccounts-api.js.map +1 -0
- package/dist/api/fineract-savingsproducts-api.d.ts +86 -0
- package/dist/api/fineract-savingsproducts-api.d.ts.map +1 -0
- package/dist/api/fineract-savingsproducts-api.js +184 -0
- package/dist/api/fineract-savingsproducts-api.js.map +1 -0
- package/dist/api/fineract-sme-api.d.ts +39 -0
- package/dist/api/fineract-sme-api.d.ts.map +1 -0
- package/dist/api/fineract-sme-api.js +82 -0
- package/dist/api/fineract-sme-api.js.map +1 -0
- package/dist/api/fineract-workingdays-api.d.ts +28 -0
- package/dist/api/fineract-workingdays-api.d.ts.map +1 -0
- package/dist/api/fineract-workingdays-api.js +84 -0
- package/dist/api/fineract-workingdays-api.js.map +1 -0
- package/dist/examples/run-examples.d.ts +2 -0
- package/dist/examples/run-examples.d.ts.map +1 -0
- package/dist/examples/run-examples.js +868 -0
- package/dist/examples/run-examples.js.map +1 -0
- package/dist/fineract-sdk.d.ts +50 -0
- package/dist/fineract-sdk.d.ts.map +1 -0
- package/dist/fineract-sdk.js +55 -0
- package/dist/fineract-sdk.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -0
- package/dist/types/creditlines.d.ts +271 -0
- package/dist/types/creditlines.d.ts.map +1 -0
- package/dist/types/creditlines.js +3 -0
- package/dist/types/creditlines.js.map +1 -0
- package/dist/types/datatable.d.ts +36 -0
- package/dist/types/datatable.d.ts.map +1 -0
- package/dist/types/datatable.js +3 -0
- package/dist/types/datatable.js.map +1 -0
- package/dist/types/errors.d.ts +7 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/errors.js +17 -0
- package/dist/types/errors.js.map +1 -0
- package/dist/types/holidays.d.ts +32 -0
- package/dist/types/holidays.d.ts.map +1 -0
- package/dist/types/holidays.js +3 -0
- package/dist/types/holidays.js.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +25 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/loanproducts.d.ts +1 -0
- package/dist/types/loanproducts.d.ts.map +1 -0
- package/dist/types/loanproducts.js +2 -0
- package/dist/types/loanproducts.js.map +1 -0
- package/dist/types/loansaccounts.d.ts +195 -0
- package/dist/types/loansaccounts.d.ts.map +1 -0
- package/dist/types/loansaccounts.js +3 -0
- package/dist/types/loansaccounts.js.map +1 -0
- package/dist/types/reports.d.ts +49 -0
- package/dist/types/reports.d.ts.map +1 -0
- package/dist/types/reports.js +4 -0
- package/dist/types/reports.js.map +1 -0
- package/dist/types/savingsaccounts.d.ts +145 -0
- package/dist/types/savingsaccounts.d.ts.map +1 -0
- package/dist/types/savingsaccounts.js +3 -0
- package/dist/types/savingsaccounts.js.map +1 -0
- package/dist/types/savingsproducts.d.ts +83 -0
- package/dist/types/savingsproducts.d.ts.map +1 -0
- package/dist/types/savingsproducts.js +3 -0
- package/dist/types/savingsproducts.js.map +1 -0
- package/dist/types/sme.d.ts +68 -0
- package/dist/types/sme.d.ts.map +1 -0
- package/dist/types/sme.js +3 -0
- package/dist/types/sme.js.map +1 -0
- package/dist/types/workingdays.d.ts +41 -0
- package/dist/types/workingdays.d.ts.map +1 -0
- package/dist/types/workingdays.js +3 -0
- package/dist/types/workingdays.js.map +1 -0
- package/dist/utils/http-client.d.ts +29 -0
- package/dist/utils/http-client.d.ts.map +1 -0
- package/dist/utils/http-client.js +93 -0
- package/dist/utils/http-client.js.map +1 -0
- package/package.json +51 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { HttpClient } from "../utils/http-client";
|
|
2
|
+
import { CreateCreditLineRequest, CreateCreditLineResponse, GetCreditLinesResponse, GetChargesResponse, GetChargesParams, CreditLineTemplate, StatusOption, ProductTypeOption, ReviewPeriodOption, CashMarginTypeOption, InterestChargeTimeOption, LoanOfficer } from "../types/creditlines";
|
|
3
|
+
/**
|
|
4
|
+
* API client for Fineract Credit Lines related operations.
|
|
5
|
+
* It uses the HttpClient for making requests.
|
|
6
|
+
*/
|
|
7
|
+
export declare class FineractCreditLinesApi {
|
|
8
|
+
private readonly httpClient;
|
|
9
|
+
constructor(httpClient: HttpClient);
|
|
10
|
+
/**
|
|
11
|
+
* Creates a new credit line for a client in Fineract.
|
|
12
|
+
* Corresponds to the POST /clients/{clientId}/creditlines endpoint.
|
|
13
|
+
*
|
|
14
|
+
* @param clientId The ID of the client to create the credit line for.
|
|
15
|
+
* @param creditLineData The data for the new credit line.
|
|
16
|
+
* @returns A promise that resolves to the creation response or rejects with an error.
|
|
17
|
+
*/
|
|
18
|
+
createCreditLine(clientId: number, creditLineData: CreateCreditLineRequest): Promise<CreateCreditLineResponse>;
|
|
19
|
+
/**
|
|
20
|
+
* Retrieves all credit lines for a specific client.
|
|
21
|
+
* Corresponds to the GET /clients/{clientId}/creditlines endpoint.
|
|
22
|
+
*
|
|
23
|
+
* @param clientId The ID of the client to get credit lines for.
|
|
24
|
+
* @returns A promise that resolves to the list of credit lines with their associated loans or rejects with an error.
|
|
25
|
+
*/
|
|
26
|
+
getCreditLines(clientId: number): Promise<GetCreditLinesResponse>;
|
|
27
|
+
/**
|
|
28
|
+
* Retrieves all available charges from Fineract.
|
|
29
|
+
* Corresponds to the GET /charges endpoint.
|
|
30
|
+
* This is useful for discovering which charges can be applied to credit lines.
|
|
31
|
+
*
|
|
32
|
+
* @param params Optional parameters for filtering charges.
|
|
33
|
+
* @returns A promise that resolves to the list of charges or rejects with an error.
|
|
34
|
+
*/
|
|
35
|
+
getCharges(params?: GetChargesParams): Promise<GetChargesResponse>;
|
|
36
|
+
/**
|
|
37
|
+
* Retrieves charges that are specifically applicable to Line of Credit.
|
|
38
|
+
* This is a convenience method that filters charges for credit line use.
|
|
39
|
+
*
|
|
40
|
+
* @returns A promise that resolves to the list of credit line applicable charges or rejects with an error.
|
|
41
|
+
*/
|
|
42
|
+
getCreditLineCharges(): Promise<GetChargesResponse>;
|
|
43
|
+
/**
|
|
44
|
+
* Retrieves the credit line template for a specific client.
|
|
45
|
+
* Corresponds to the GET /clients/{clientId}/creditlines/template endpoint.
|
|
46
|
+
* This provides all the available options for creating a credit line.
|
|
47
|
+
*
|
|
48
|
+
* @param clientId The ID of the client to get the template for.
|
|
49
|
+
* @returns A promise that resolves to the credit line template or rejects with an error.
|
|
50
|
+
*/
|
|
51
|
+
getCreditLineTemplate(clientId: number): Promise<CreditLineTemplate>;
|
|
52
|
+
/**
|
|
53
|
+
* Retrieves status options for credit lines.
|
|
54
|
+
*
|
|
55
|
+
* @param clientId The ID of the client to get options for.
|
|
56
|
+
* @returns A promise that resolves to the list of status options.
|
|
57
|
+
*/
|
|
58
|
+
getCreditLineStatusOptions(clientId: number): Promise<StatusOption[]>;
|
|
59
|
+
/**
|
|
60
|
+
* Retrieves product type options for credit lines.
|
|
61
|
+
*
|
|
62
|
+
* @param clientId The ID of the client to get options for.
|
|
63
|
+
* @returns A promise that resolves to the list of product type options.
|
|
64
|
+
*/
|
|
65
|
+
getCreditLineProductTypeOptions(clientId: number): Promise<ProductTypeOption[]>;
|
|
66
|
+
/**
|
|
67
|
+
* Retrieves review period options for credit lines.
|
|
68
|
+
*
|
|
69
|
+
* @param clientId The ID of the client to get options for.
|
|
70
|
+
* @returns A promise that resolves to the list of review period options.
|
|
71
|
+
*/
|
|
72
|
+
getCreditLineReviewPeriodOptions(clientId: number): Promise<ReviewPeriodOption[]>;
|
|
73
|
+
/**
|
|
74
|
+
* Retrieves cash margin type options for credit lines.
|
|
75
|
+
*
|
|
76
|
+
* @param clientId The ID of the client to get options for.
|
|
77
|
+
* @returns A promise that resolves to the list of cash margin type options.
|
|
78
|
+
*/
|
|
79
|
+
getCreditLineCashMarginTypeOptions(clientId: number): Promise<CashMarginTypeOption[]>;
|
|
80
|
+
/**
|
|
81
|
+
* Retrieves interest charge time options for credit lines.
|
|
82
|
+
*
|
|
83
|
+
* @param clientId The ID of the client to get options for.
|
|
84
|
+
* @returns A promise that resolves to the list of interest charge time options.
|
|
85
|
+
*/
|
|
86
|
+
getCreditLineInterestChargeTimeOptions(clientId: number): Promise<InterestChargeTimeOption[]>;
|
|
87
|
+
/**
|
|
88
|
+
* Retrieves loan officers available for credit lines.
|
|
89
|
+
*
|
|
90
|
+
* @param clientId The ID of the client to get options for.
|
|
91
|
+
* @returns A promise that resolves to the list of loan officers.
|
|
92
|
+
*/
|
|
93
|
+
getCreditLineLoanOfficers(clientId: number): Promise<LoanOfficer[]>;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=fineract-creditlines-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fineract-creditlines-api.d.ts","sourceRoot":"","sources":["../../src/api/fineract-creditlines-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGlD,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,sBAAsB,EACtB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,wBAAwB,EACxB,WAAW,EACZ,MAAM,sBAAsB,CAAC;AAE9B;;;GAGG;AACH,qBAAa,sBAAsB;IACjC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;gBAE5B,UAAU,EAAE,UAAU;IAIlC;;;;;;;OAOG;IACG,gBAAgB,CACpB,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,uBAAuB,GACtC,OAAO,CAAC,wBAAwB,CAAC;IAuBpC;;;;;;OAMG;IACG,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAsBvE;;;;;;;OAOG;IACG,UAAU,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAoCxE;;;;;OAKG;IACG,oBAAoB,IAAI,OAAO,CAAC,kBAAkB,CAAC;IA4BzD;;;;;;;OAOG;IACG,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAoB1E;;;;;OAKG;IACG,0BAA0B,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC;IAK3E;;;;;OAKG;IACG,+BAA+B,CACnC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAK/B;;;;;OAKG;IACG,gCAAgC,CACpC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAKhC;;;;;OAKG;IACG,kCAAkC,CACtC,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,oBAAoB,EAAE,CAAC;IAKlC;;;;;OAKG;IACG,sCAAsC,CAC1C,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,wBAAwB,EAAE,CAAC;IAKtC;;;;;OAKG;IACG,yBAAyB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;CAI1E"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FineractCreditLinesApi = void 0;
|
|
4
|
+
const errors_1 = require("../types/errors");
|
|
5
|
+
/**
|
|
6
|
+
* API client for Fineract Credit Lines related operations.
|
|
7
|
+
* It uses the HttpClient for making requests.
|
|
8
|
+
*/
|
|
9
|
+
class FineractCreditLinesApi {
|
|
10
|
+
constructor(httpClient) {
|
|
11
|
+
this.httpClient = httpClient;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new credit line for a client in Fineract.
|
|
15
|
+
* Corresponds to the POST /clients/{clientId}/creditlines endpoint.
|
|
16
|
+
*
|
|
17
|
+
* @param clientId The ID of the client to create the credit line for.
|
|
18
|
+
* @param creditLineData The data for the new credit line.
|
|
19
|
+
* @returns A promise that resolves to the creation response or rejects with an error.
|
|
20
|
+
*/
|
|
21
|
+
async createCreditLine(clientId, creditLineData) {
|
|
22
|
+
try {
|
|
23
|
+
const apiPath = `/fineract-provider/api/v1/clients/${clientId}/creditlines`;
|
|
24
|
+
const response = await this.httpClient.post(apiPath, creditLineData);
|
|
25
|
+
return response.data;
|
|
26
|
+
}
|
|
27
|
+
catch (rawError) {
|
|
28
|
+
const errorPayload = rawError;
|
|
29
|
+
const message = errorPayload?.message ||
|
|
30
|
+
errorPayload?.error ||
|
|
31
|
+
"Fineract API request failed";
|
|
32
|
+
throw new errors_1.FineractApiError(message, errorPayload?.statusCode, errorPayload?.details, errorPayload?.error);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Retrieves all credit lines for a specific client.
|
|
37
|
+
* Corresponds to the GET /clients/{clientId}/creditlines endpoint.
|
|
38
|
+
*
|
|
39
|
+
* @param clientId The ID of the client to get credit lines for.
|
|
40
|
+
* @returns A promise that resolves to the list of credit lines with their associated loans or rejects with an error.
|
|
41
|
+
*/
|
|
42
|
+
async getCreditLines(clientId) {
|
|
43
|
+
try {
|
|
44
|
+
const apiPath = `/fineract-provider/api/v1/clients/${clientId}/creditlines`;
|
|
45
|
+
const response = await this.httpClient.get(apiPath);
|
|
46
|
+
return response.data;
|
|
47
|
+
}
|
|
48
|
+
catch (rawError) {
|
|
49
|
+
const errorPayload = rawError;
|
|
50
|
+
const message = errorPayload?.message ||
|
|
51
|
+
errorPayload?.error ||
|
|
52
|
+
"Fineract API request failed";
|
|
53
|
+
throw new errors_1.FineractApiError(message, errorPayload?.statusCode, errorPayload?.details, errorPayload?.error);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Retrieves all available charges from Fineract.
|
|
58
|
+
* Corresponds to the GET /charges endpoint.
|
|
59
|
+
* This is useful for discovering which charges can be applied to credit lines.
|
|
60
|
+
*
|
|
61
|
+
* @param params Optional parameters for filtering charges.
|
|
62
|
+
* @returns A promise that resolves to the list of charges or rejects with an error.
|
|
63
|
+
*/
|
|
64
|
+
async getCharges(params) {
|
|
65
|
+
try {
|
|
66
|
+
let apiPath = "/fineract-provider/api/v1/charges";
|
|
67
|
+
// Add query parameters if provided
|
|
68
|
+
const queryParams = [];
|
|
69
|
+
if (params?.chargeAppliesTo) {
|
|
70
|
+
queryParams.push(`chargeAppliesTo=${encodeURIComponent(params.chargeAppliesTo)}`);
|
|
71
|
+
}
|
|
72
|
+
if (params?.active !== undefined) {
|
|
73
|
+
queryParams.push(`active=${params.active}`);
|
|
74
|
+
}
|
|
75
|
+
if (queryParams.length > 0) {
|
|
76
|
+
apiPath += `?${queryParams.join("&")}`;
|
|
77
|
+
}
|
|
78
|
+
const response = await this.httpClient.get(apiPath);
|
|
79
|
+
return response.data;
|
|
80
|
+
}
|
|
81
|
+
catch (rawError) {
|
|
82
|
+
const errorPayload = rawError;
|
|
83
|
+
const message = errorPayload?.message ||
|
|
84
|
+
errorPayload?.error ||
|
|
85
|
+
"Fineract API request failed";
|
|
86
|
+
throw new errors_1.FineractApiError(message, errorPayload?.statusCode, errorPayload?.details, errorPayload?.error);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Retrieves charges that are specifically applicable to Line of Credit.
|
|
91
|
+
* This is a convenience method that filters charges for credit line use.
|
|
92
|
+
*
|
|
93
|
+
* @returns A promise that resolves to the list of credit line applicable charges or rejects with an error.
|
|
94
|
+
*/
|
|
95
|
+
async getCreditLineCharges() {
|
|
96
|
+
try {
|
|
97
|
+
const allCharges = await this.getCharges();
|
|
98
|
+
// Filter charges that are applicable to Line of Credit
|
|
99
|
+
const creditLineCharges = allCharges.filter((charge) => charge.active &&
|
|
100
|
+
(charge.chargeAppliesTo.code === "chargeAppliesTo.lineOfCredit" ||
|
|
101
|
+
charge.chargeAppliesTo.code === "chargeAppliesTo.loan"));
|
|
102
|
+
return creditLineCharges;
|
|
103
|
+
}
|
|
104
|
+
catch (rawError) {
|
|
105
|
+
const errorPayload = rawError;
|
|
106
|
+
const message = errorPayload?.message ||
|
|
107
|
+
errorPayload?.error ||
|
|
108
|
+
"Fineract API request failed";
|
|
109
|
+
throw new errors_1.FineractApiError(message, errorPayload?.statusCode, errorPayload?.details, errorPayload?.error);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Retrieves the credit line template for a specific client.
|
|
114
|
+
* Corresponds to the GET /clients/{clientId}/creditlines/template endpoint.
|
|
115
|
+
* This provides all the available options for creating a credit line.
|
|
116
|
+
*
|
|
117
|
+
* @param clientId The ID of the client to get the template for.
|
|
118
|
+
* @returns A promise that resolves to the credit line template or rejects with an error.
|
|
119
|
+
*/
|
|
120
|
+
async getCreditLineTemplate(clientId) {
|
|
121
|
+
try {
|
|
122
|
+
const apiPath = `/fineract-provider/api/v1/clients/${clientId}/creditlines/template`;
|
|
123
|
+
const response = await this.httpClient.get(apiPath);
|
|
124
|
+
return response.data;
|
|
125
|
+
}
|
|
126
|
+
catch (rawError) {
|
|
127
|
+
const errorPayload = rawError;
|
|
128
|
+
const message = errorPayload?.message ||
|
|
129
|
+
errorPayload?.error ||
|
|
130
|
+
"Fineract API request failed";
|
|
131
|
+
throw new errors_1.FineractApiError(message, errorPayload?.statusCode, errorPayload?.details, errorPayload?.error);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Retrieves status options for credit lines.
|
|
136
|
+
*
|
|
137
|
+
* @param clientId The ID of the client to get options for.
|
|
138
|
+
* @returns A promise that resolves to the list of status options.
|
|
139
|
+
*/
|
|
140
|
+
async getCreditLineStatusOptions(clientId) {
|
|
141
|
+
const template = await this.getCreditLineTemplate(clientId);
|
|
142
|
+
return template.statusOptions;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Retrieves product type options for credit lines.
|
|
146
|
+
*
|
|
147
|
+
* @param clientId The ID of the client to get options for.
|
|
148
|
+
* @returns A promise that resolves to the list of product type options.
|
|
149
|
+
*/
|
|
150
|
+
async getCreditLineProductTypeOptions(clientId) {
|
|
151
|
+
const template = await this.getCreditLineTemplate(clientId);
|
|
152
|
+
return template.productTypeOptions;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Retrieves review period options for credit lines.
|
|
156
|
+
*
|
|
157
|
+
* @param clientId The ID of the client to get options for.
|
|
158
|
+
* @returns A promise that resolves to the list of review period options.
|
|
159
|
+
*/
|
|
160
|
+
async getCreditLineReviewPeriodOptions(clientId) {
|
|
161
|
+
const template = await this.getCreditLineTemplate(clientId);
|
|
162
|
+
return template.reviewPeriodsOptions;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Retrieves cash margin type options for credit lines.
|
|
166
|
+
*
|
|
167
|
+
* @param clientId The ID of the client to get options for.
|
|
168
|
+
* @returns A promise that resolves to the list of cash margin type options.
|
|
169
|
+
*/
|
|
170
|
+
async getCreditLineCashMarginTypeOptions(clientId) {
|
|
171
|
+
const template = await this.getCreditLineTemplate(clientId);
|
|
172
|
+
return template.cashMarginTypeOptions;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Retrieves interest charge time options for credit lines.
|
|
176
|
+
*
|
|
177
|
+
* @param clientId The ID of the client to get options for.
|
|
178
|
+
* @returns A promise that resolves to the list of interest charge time options.
|
|
179
|
+
*/
|
|
180
|
+
async getCreditLineInterestChargeTimeOptions(clientId) {
|
|
181
|
+
const template = await this.getCreditLineTemplate(clientId);
|
|
182
|
+
return template.interestChargeTimeOptions;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Retrieves loan officers available for credit lines.
|
|
186
|
+
*
|
|
187
|
+
* @param clientId The ID of the client to get options for.
|
|
188
|
+
* @returns A promise that resolves to the list of loan officers.
|
|
189
|
+
*/
|
|
190
|
+
async getCreditLineLoanOfficers(clientId) {
|
|
191
|
+
const template = await this.getCreditLineTemplate(clientId);
|
|
192
|
+
return template.loanOfficers;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
exports.FineractCreditLinesApi = FineractCreditLinesApi;
|
|
196
|
+
//# sourceMappingURL=fineract-creditlines-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fineract-creditlines-api.js","sourceRoot":"","sources":["../../src/api/fineract-creditlines-api.ts"],"names":[],"mappings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AC5D,OAAO,QAAQ,CAAC,aAAa,CAAC;IAChC,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,+BAA+B,CACnC,QAAgB;QAEhB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC;QAC5D,OAAO,QAAQ,CAAC,kBAAkB,CAAC;IACrC,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,gCAAgC,CACpC,QAAgB;QAEhB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC;QAC5D,OAAO,QAAQ,CAAC,oBAAoB,CAAC;IACvC,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,kCAAkC,CACtC,QAAgB;QAEhB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC;QAC5D,OAAO,QAAQ,CAAC,qBAAqB,CAAC;IACxC,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,sCAAsC,CAC1C,QAAgB;QAEhB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC;QAC5D,OAAO,QAAQ,CAAC,yBAAyB,CAAC;IAC5C,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,yBAAyB,CAAC,QAAgB;QAC9C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC;QAC5D,OAAO,QAAQ,CAAC,YAAY,CAAC;IAC/B,CAAC;CACF;AAzPD,wDAyPC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { HttpClient } from "../utils/http-client";
|
|
2
|
+
import { Datatable, DatatableListResponse } from "../types/datatable";
|
|
3
|
+
/**
|
|
4
|
+
* API client for Fineract Datatable related operations.
|
|
5
|
+
* It uses the HttpClient for making requests.
|
|
6
|
+
*/
|
|
7
|
+
export declare class FineractDatatableApi {
|
|
8
|
+
private readonly httpClient;
|
|
9
|
+
constructor(httpClient: HttpClient);
|
|
10
|
+
/**
|
|
11
|
+
* Retrieves all datatables from Fineract.
|
|
12
|
+
* Corresponds to the GET /datatables endpoint.
|
|
13
|
+
*
|
|
14
|
+
* @returns A promise that resolves to the list of datatables or rejects with an error.
|
|
15
|
+
*/
|
|
16
|
+
getAll(): Promise<DatatableListResponse>;
|
|
17
|
+
/**
|
|
18
|
+
* Retrieves a specific datatable by name from Fineract.
|
|
19
|
+
* Corresponds to the GET /datatables/{datatableName} endpoint.
|
|
20
|
+
*
|
|
21
|
+
* @param datatableName The name of the datatable to retrieve.
|
|
22
|
+
* @returns A promise that resolves to the datatable details or rejects with an error.
|
|
23
|
+
*/
|
|
24
|
+
getByName(datatableName: string): Promise<Datatable>;
|
|
25
|
+
/**
|
|
26
|
+
* Retrieves datatable entries for a specific entity.
|
|
27
|
+
* Corresponds to the GET /datatables/{datatableName}/{entityId} endpoint.
|
|
28
|
+
*
|
|
29
|
+
* @param datatableName The name of the datatable.
|
|
30
|
+
* @param entityId The id of the entity (e.g. m_client.id) to retrieve datatable entries for.
|
|
31
|
+
* @returns A promise that resolves to the datatable entries or rejects with an error.
|
|
32
|
+
*/
|
|
33
|
+
getEntries(datatableName: string, entityId: number): Promise<any[]>;
|
|
34
|
+
/**
|
|
35
|
+
* Creates a new datatable entry for a specific entity.
|
|
36
|
+
* Corresponds to the POST /datatables/{datatableName}/{entityId} endpoint.
|
|
37
|
+
*
|
|
38
|
+
* @param datatableName The name of the datatable.
|
|
39
|
+
* @param entityId The id of the entity (e.g. m_client.id) to create the datatable entry for.
|
|
40
|
+
* @param entryData The data for the new datatable entry.
|
|
41
|
+
* @returns A promise that resolves to the creation response or rejects with an error.
|
|
42
|
+
*/
|
|
43
|
+
createEntry(datatableName: string, entityId: number, entryData: any): Promise<any>;
|
|
44
|
+
/**
|
|
45
|
+
* Updates a datatable entry for a specific entity.
|
|
46
|
+
* Corresponds to the PUT /datatables/{datatableName}/{entityId} endpoint.
|
|
47
|
+
*
|
|
48
|
+
* @param datatableName The name of the datatable.
|
|
49
|
+
* @param entityId The id of the entity (e.g. m_client.id).
|
|
50
|
+
* @param entryData The updated data for the datatable entry.
|
|
51
|
+
* @returns A promise that resolves to the update response or rejects with an error.
|
|
52
|
+
*/
|
|
53
|
+
updateEntry(datatableName: string, entityId: number, entryData: any): Promise<any>;
|
|
54
|
+
/**
|
|
55
|
+
* Deletes a datatable entry for a specific entity.
|
|
56
|
+
* Corresponds to the DELETE /datatables/{datatableName}/{entityId} endpoint.
|
|
57
|
+
*
|
|
58
|
+
* @param datatableName The name of the datatable.
|
|
59
|
+
* @param entityId The id of the entity (e.g. m_client.id).
|
|
60
|
+
* @returns A promise that resolves to the deletion response or rejects with an error.
|
|
61
|
+
*/
|
|
62
|
+
deleteEntry(datatableName: string, entityId: number): Promise<any>;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=fineract-datatable-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fineract-datatable-api.d.ts","sourceRoot":"","sources":["../../src/api/fineract-datatable-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAGtE;;;GAGG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;gBAE5B,UAAU,EAAE,UAAU;IAIlC;;;;;OAKG;IACG,MAAM,IAAI,OAAO,CAAC,qBAAqB,CAAC;IAsB9C;;;;;;OAMG;IACG,SAAS,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAoB1D;;;;;;;OAOG;IACG,UAAU,CAAC,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAoBzE;;;;;;;;OAQG;IACG,WAAW,CACf,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,GAAG,GACb,OAAO,CAAC,GAAG,CAAC;IAoBf;;;;;;;;OAQG;IACG,WAAW,CACf,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,GAAG,GACb,OAAO,CAAC,GAAG,CAAC;IAoBf;;;;;;;OAOG;IACG,WAAW,CAAC,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;CAmBzE"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FineractDatatableApi = void 0;
|
|
4
|
+
const errors_1 = require("../types/errors");
|
|
5
|
+
/**
|
|
6
|
+
* API client for Fineract Datatable related operations.
|
|
7
|
+
* It uses the HttpClient for making requests.
|
|
8
|
+
*/
|
|
9
|
+
class FineractDatatableApi {
|
|
10
|
+
constructor(httpClient) {
|
|
11
|
+
this.httpClient = httpClient;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Retrieves all datatables from Fineract.
|
|
15
|
+
* Corresponds to the GET /datatables endpoint.
|
|
16
|
+
*
|
|
17
|
+
* @returns A promise that resolves to the list of datatables or rejects with an error.
|
|
18
|
+
*/
|
|
19
|
+
async getAll() {
|
|
20
|
+
try {
|
|
21
|
+
const apiPath = "/fineract-provider/api/v1/datatables";
|
|
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 datatable by name from Fineract.
|
|
35
|
+
* Corresponds to the GET /datatables/{datatableName} endpoint.
|
|
36
|
+
*
|
|
37
|
+
* @param datatableName The name of the datatable to retrieve.
|
|
38
|
+
* @returns A promise that resolves to the datatable details or rejects with an error.
|
|
39
|
+
*/
|
|
40
|
+
async getByName(datatableName) {
|
|
41
|
+
try {
|
|
42
|
+
const apiPath = `/fineract-provider/api/v1/datatables/${datatableName}`;
|
|
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
|
+
* Retrieves datatable entries for a specific entity.
|
|
56
|
+
* Corresponds to the GET /datatables/{datatableName}/{entityId} endpoint.
|
|
57
|
+
*
|
|
58
|
+
* @param datatableName The name of the datatable.
|
|
59
|
+
* @param entityId The id of the entity (e.g. m_client.id) to retrieve datatable entries for.
|
|
60
|
+
* @returns A promise that resolves to the datatable entries or rejects with an error.
|
|
61
|
+
*/
|
|
62
|
+
async getEntries(datatableName, entityId) {
|
|
63
|
+
try {
|
|
64
|
+
const apiPath = `/fineract-provider/api/v1/datatables/${datatableName}/${entityId}`;
|
|
65
|
+
const response = await this.httpClient.get(apiPath);
|
|
66
|
+
return response.data;
|
|
67
|
+
}
|
|
68
|
+
catch (rawError) {
|
|
69
|
+
const errorPayload = rawError;
|
|
70
|
+
const message = errorPayload?.message ||
|
|
71
|
+
errorPayload?.error ||
|
|
72
|
+
"Fineract API request failed";
|
|
73
|
+
throw new errors_1.FineractApiError(message, errorPayload?.statusCode, errorPayload?.details, errorPayload?.error);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Creates a new datatable entry for a specific entity.
|
|
78
|
+
* Corresponds to the POST /datatables/{datatableName}/{entityId} endpoint.
|
|
79
|
+
*
|
|
80
|
+
* @param datatableName The name of the datatable.
|
|
81
|
+
* @param entityId The id of the entity (e.g. m_client.id) to create the datatable entry for.
|
|
82
|
+
* @param entryData The data for the new datatable entry.
|
|
83
|
+
* @returns A promise that resolves to the creation response or rejects with an error.
|
|
84
|
+
*/
|
|
85
|
+
async createEntry(datatableName, entityId, entryData) {
|
|
86
|
+
try {
|
|
87
|
+
const apiPath = `/fineract-provider/api/v1/datatables/${datatableName}/${entityId}`;
|
|
88
|
+
const response = await this.httpClient.post(apiPath, entryData);
|
|
89
|
+
return response.data;
|
|
90
|
+
}
|
|
91
|
+
catch (rawError) {
|
|
92
|
+
const errorPayload = rawError;
|
|
93
|
+
const message = errorPayload?.message ||
|
|
94
|
+
errorPayload?.error ||
|
|
95
|
+
"Fineract API request failed";
|
|
96
|
+
throw new errors_1.FineractApiError(message, errorPayload?.statusCode, errorPayload?.details, errorPayload?.error);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Updates a datatable entry for a specific entity.
|
|
101
|
+
* Corresponds to the PUT /datatables/{datatableName}/{entityId} endpoint.
|
|
102
|
+
*
|
|
103
|
+
* @param datatableName The name of the datatable.
|
|
104
|
+
* @param entityId The id of the entity (e.g. m_client.id).
|
|
105
|
+
* @param entryData The updated data for the datatable entry.
|
|
106
|
+
* @returns A promise that resolves to the update response or rejects with an error.
|
|
107
|
+
*/
|
|
108
|
+
async updateEntry(datatableName, entityId, entryData) {
|
|
109
|
+
try {
|
|
110
|
+
const apiPath = `/fineract-provider/api/v1/datatables/${datatableName}/${entityId}`;
|
|
111
|
+
const response = await this.httpClient.put(apiPath, entryData);
|
|
112
|
+
return response.data;
|
|
113
|
+
}
|
|
114
|
+
catch (rawError) {
|
|
115
|
+
const errorPayload = rawError;
|
|
116
|
+
const message = errorPayload?.message ||
|
|
117
|
+
errorPayload?.error ||
|
|
118
|
+
"Fineract API request failed";
|
|
119
|
+
throw new errors_1.FineractApiError(message, errorPayload?.statusCode, errorPayload?.details, errorPayload?.error);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Deletes a datatable entry for a specific entity.
|
|
124
|
+
* Corresponds to the DELETE /datatables/{datatableName}/{entityId} endpoint.
|
|
125
|
+
*
|
|
126
|
+
* @param datatableName The name of the datatable.
|
|
127
|
+
* @param entityId The id of the entity (e.g. m_client.id).
|
|
128
|
+
* @returns A promise that resolves to the deletion response or rejects with an error.
|
|
129
|
+
*/
|
|
130
|
+
async deleteEntry(datatableName, entityId) {
|
|
131
|
+
try {
|
|
132
|
+
const apiPath = `/fineract-provider/api/v1/datatables/${datatableName}/${entityId}`;
|
|
133
|
+
const response = await this.httpClient.delete(apiPath);
|
|
134
|
+
return response.data;
|
|
135
|
+
}
|
|
136
|
+
catch (rawError) {
|
|
137
|
+
const errorPayload = rawError;
|
|
138
|
+
const message = errorPayload?.message ||
|
|
139
|
+
errorPayload?.error ||
|
|
140
|
+
"Fineract API request failed";
|
|
141
|
+
throw new errors_1.FineractApiError(message, errorPayload?.statusCode, errorPayload?.details, errorPayload?.error);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
exports.FineractDatatableApi = FineractDatatableApi;
|
|
146
|
+
//# sourceMappingURL=fineract-datatable-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fineract-datatable-api.js","sourceRoot":"","sources":["../../src/api/fineract-datatable-api.ts"],"names":[],"mappings":";;;AAGA,4CAAmD;AAEnD;;;GAGG;AACH,MAAa,oBAAoB;IAG/B,YAAY,UAAsB;QAChC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED;;;;;OAKG;IACH,KAAK,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,GAAG,CAAM,OAAO,EAAE,SAAS,CAAC,CAAC;YACpE,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;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,WAAW,CAAC,aAAqB,EAAE,QAAgB;QACvD,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,wCAAwC,aAAa,IAAI,QAAQ,EAAE,CAAC;YACpF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAM,OAAO,CAAC,CAAC;YAC5D,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;AAvLD,oDAuLC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { HttpClient } from "../utils/http-client";
|
|
2
|
+
import { GetHolidaysResponse, GetHolidaysParams } from "../types/holidays";
|
|
3
|
+
/**
|
|
4
|
+
* API client for Fineract Holidays related operations.
|
|
5
|
+
* It uses the HttpClient for making requests.
|
|
6
|
+
*/
|
|
7
|
+
export declare class FineractHolidaysApi {
|
|
8
|
+
private readonly httpClient;
|
|
9
|
+
constructor(httpClient: HttpClient);
|
|
10
|
+
/**
|
|
11
|
+
* Retrieves holidays from Fineract.
|
|
12
|
+
* Corresponds to the GET /holidays endpoint.
|
|
13
|
+
* Only returns holidays with status.code === "holidayStatusType.active"
|
|
14
|
+
*
|
|
15
|
+
* @param params Optional parameters for filtering holidays.
|
|
16
|
+
* @returns A promise that resolves to the list of active holidays or rejects with an error.
|
|
17
|
+
*/
|
|
18
|
+
getHolidays(params?: GetHolidaysParams): Promise<GetHolidaysResponse>;
|
|
19
|
+
/**
|
|
20
|
+
* Retrieves holidays for a specific office from Fineract.
|
|
21
|
+
* This is a convenience method that wraps getHolidays with officeId parameter.
|
|
22
|
+
* Only returns holidays with status.code === "holidayStatusType.active"
|
|
23
|
+
*
|
|
24
|
+
* @param officeId The ID of the office to get holidays for.
|
|
25
|
+
* @returns A promise that resolves to the list of active holidays for the specified office or rejects with an error.
|
|
26
|
+
*/
|
|
27
|
+
getHolidaysByOffice(officeId: number): Promise<GetHolidaysResponse>;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=fineract-holidays-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fineract-holidays-api.d.ts","sourceRoot":"","sources":["../../src/api/fineract-holidays-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGlD,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAE3E;;;GAGG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;gBAE5B,UAAU,EAAE,UAAU;IAIlC;;;;;;;OAOG;IACG,WAAW,CAAC,MAAM,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAkC3E;;;;;;;OAOG;IACG,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAG1E"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FineractHolidaysApi = void 0;
|
|
4
|
+
const errors_1 = require("../types/errors");
|
|
5
|
+
/**
|
|
6
|
+
* API client for Fineract Holidays related operations.
|
|
7
|
+
* It uses the HttpClient for making requests.
|
|
8
|
+
*/
|
|
9
|
+
class FineractHolidaysApi {
|
|
10
|
+
constructor(httpClient) {
|
|
11
|
+
this.httpClient = httpClient;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Retrieves holidays from Fineract.
|
|
15
|
+
* Corresponds to the GET /holidays endpoint.
|
|
16
|
+
* Only returns holidays with status.code === "holidayStatusType.active"
|
|
17
|
+
*
|
|
18
|
+
* @param params Optional parameters for filtering holidays.
|
|
19
|
+
* @returns A promise that resolves to the list of active holidays or rejects with an error.
|
|
20
|
+
*/
|
|
21
|
+
async getHolidays(params) {
|
|
22
|
+
try {
|
|
23
|
+
let apiPath = "/fineract-provider/api/v1/holidays";
|
|
24
|
+
// Add query parameters if provided
|
|
25
|
+
if (params?.officeId) {
|
|
26
|
+
apiPath += `?officeId=${params.officeId}`;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
apiPath += `?officeId=1`; // to ensure valid URL if no params
|
|
30
|
+
}
|
|
31
|
+
const response = await this.httpClient.get(apiPath);
|
|
32
|
+
// Filter to only return active holidays
|
|
33
|
+
const activeHolidays = response.data.filter((holiday) => holiday.status.code === "holidayStatusType.active");
|
|
34
|
+
return activeHolidays;
|
|
35
|
+
}
|
|
36
|
+
catch (rawError) {
|
|
37
|
+
const errorPayload = rawError;
|
|
38
|
+
const message = errorPayload?.message ||
|
|
39
|
+
errorPayload?.error ||
|
|
40
|
+
"Fineract API request failed";
|
|
41
|
+
throw new errors_1.FineractApiError(message, errorPayload?.statusCode, errorPayload?.details, errorPayload?.error);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Retrieves holidays for a specific office from Fineract.
|
|
46
|
+
* This is a convenience method that wraps getHolidays with officeId parameter.
|
|
47
|
+
* Only returns holidays with status.code === "holidayStatusType.active"
|
|
48
|
+
*
|
|
49
|
+
* @param officeId The ID of the office to get holidays for.
|
|
50
|
+
* @returns A promise that resolves to the list of active holidays for the specified office or rejects with an error.
|
|
51
|
+
*/
|
|
52
|
+
async getHolidaysByOffice(officeId) {
|
|
53
|
+
return this.getHolidays({ officeId });
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.FineractHolidaysApi = FineractHolidaysApi;
|
|
57
|
+
//# sourceMappingURL=fineract-holidays-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fineract-holidays-api.js","sourceRoot":"","sources":["../../src/api/fineract-holidays-api.ts"],"names":[],"mappings":";;;AAEA,4CAAmD;AAGnD;;;GAGG;AACH,MAAa,mBAAmB;IAG9B,YAAY,UAAsB;QAChC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,WAAW,CAAC,MAA0B;QAC1C,IAAI,CAAC;YACH,IAAI,OAAO,GAAG,oCAAoC,CAAC;YAEnD,mCAAmC;YACnC,IAAI,MAAM,EAAE,QAAQ,EAAE,CAAC;gBACrB,OAAO,IAAI,aAAa,MAAM,CAAC,QAAQ,EAAE,CAAC;YAC5C,CAAC;iBAAM,CAAC;gBACN,OAAO,IAAI,aAAa,CAAC,CAAC,mCAAmC;YAC/D,CAAC;YAED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAsB,OAAO,CAAC,CAAC;YAEzE,wCAAwC;YACxC,MAAM,cAAc,GAAG,QAAQ,CAAC,IAAI,CAAC,MAAM,CACzC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC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