Skip to content

Commit

Permalink
2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
arkni-fintecture committed Jul 6, 2022
1 parent a757bce commit 19dc244
Show file tree
Hide file tree
Showing 12 changed files with 125 additions and 115 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fintecture-client",
"version": "2.0.2",
"version": "2.1.0",
"description": "Fintecture Open Banking API Gateway enabling secure bank connections and payments",
"main": "lib/fintecture-client.js",
"types": "lib/fintecture-client.d.ts",
Expand Down
124 changes: 65 additions & 59 deletions src/Ais.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,34 +43,37 @@ export class AIS {
state?: string,
model?: string,
psuId?: string,
psuIpAddress?: string
psuIpAddress?: string,
): Promise<object> {
if (accessToken) {
return await this._authorizeWithAccessToken(accessToken, providerId, redirectUri, state, model, psuId, psuIpAddress);
return await this._authorizeWithAccessToken(
accessToken,
providerId,
redirectUri,
state,
model,
psuId,
psuIpAddress,
);
} else {
return await this._authorizeWithAppId(providerId, redirectUri, state, model, psuId, psuIpAddress);
}
}


/**
* This API is used to poll the authentication status within
* This API is used to poll the authentication status within
* the decoupled model. Once the decoupled authentication flow
* as initiated, the status is "PENDING". Once the PSU has
* successfully authenticated, the status becomes "COMPLETED".
* If the authentication times out, is cancelled or failed,
* as initiated, the status is "PENDING". Once the PSU has
* successfully authenticated, the status becomes "COMPLETED".
* If the authentication times out, is cancelled or failed,
* the status becomes "FAILED".
*
* @param {string} accessToken
* @param {string} providerId
* @param {string} pollingId
* @returns {Promise<object>}
*/
public async decoupled(
accessToken: string,
providerId: string,
pollingId: string
): Promise<object> {
public async decoupled(accessToken: string, providerId: string, pollingId: string): Promise<object> {
if (accessToken) {
return await this._decoupledWithAccesToken(accessToken, providerId, pollingId);
} else {
Expand All @@ -86,16 +89,21 @@ export class AIS {
* @param {object} queryParameters (optional)
* @returns {Promise<object>}
*/
public async getAccounts(accessToken: string, customerId: string, queryParameters?: object, headerParameters?: object): Promise<object> {
const url = `${Endpoints.AISCUSTOMER}/${customerId}/accounts${queryParameters ? '?' + qs.stringify(queryParameters) : ''}`;
public async getAccounts(
accessToken: string,
customerId: string,
queryParameters?: object,
headerParameters?: object,
): Promise<object> {
const url = `${Endpoints.AISCUSTOMER}/${customerId}/accounts${
queryParameters ? '?' + qs.stringify(queryParameters) : ''
}`;

const headers = apiService.getHeaders('get', url, accessToken, this.config, null, headerParameters);

return await this.axiosInstance
.get(url, { headers })
.then(response => {
return response.data;
});
return await this.axiosInstance.get(url, { headers }).then(response => {
return response.data;
});
}

/**
Expand All @@ -109,21 +117,27 @@ export class AIS {
* @param {string} paginationUrl (optional)
* @returns {Promise<object>}
*/
public async getTransactions(accessToken: string, customerId: string, accountId: string, queryParameters?: object, headerParameters?: object, paginationUrl?: string): Promise<object> {

public async getTransactions(
accessToken: string,
customerId: string,
accountId: string,
queryParameters?: object,
headerParameters?: object,
paginationUrl?: string,
): Promise<object> {
let url = paginationUrl;

if (!url) {
url = `${Endpoints.AISCUSTOMER}/${customerId}/accounts/${accountId}/transactions${queryParameters ? '?' + qs.stringify(queryParameters) : ''}` ;
url = `${Endpoints.AISCUSTOMER}/${customerId}/accounts/${accountId}/transactions${
queryParameters ? '?' + qs.stringify(queryParameters) : ''
}`;
}

const headers = apiService.getHeaders('get', url, accessToken, this.config, null, headerParameters);

return await this.axiosInstance
.get(url, { headers })
.then(response => {
return response.data;
});
return await this.axiosInstance.get(url, { headers }).then(response => {
return response.data;
});
}

/**
Expand All @@ -135,16 +149,21 @@ export class AIS {
* @param {object} queryParameters (optional)
* @returns {Promise<object>}
*/
public async getAccountHolders(accessToken: string, customerId: string, queryParameters: object, headerParameters?: object): Promise<object> {
const url = `${Endpoints.AISCUSTOMER}/${customerId}/accountholders${queryParameters ? '?' + qs.stringify(queryParameters) : ''}`;
public async getAccountHolders(
accessToken: string,
customerId: string,
queryParameters: object,
headerParameters?: object,
): Promise<object> {
const url = `${Endpoints.AISCUSTOMER}/${customerId}/accountholders${
queryParameters ? '?' + qs.stringify(queryParameters) : ''
}`;

const headers = apiService.getHeaders('get', url, accessToken, this.config, null, headerParameters);

return await this.axiosInstance
.get(url, { headers },)
.then(response => {
return response.data;
});
return await this.axiosInstance.get(url, { headers }).then(response => {
return response.data;
});
}

/**
Expand All @@ -159,9 +178,7 @@ export class AIS {

const headers = apiService.getHeaders('delete', url, accessToken, this.config);

return await this.axiosInstance
.delete(url, { headers })
.then(response => response.data);
return await this.axiosInstance.delete(url, { headers }).then(response => response.data);
}

/**
Expand All @@ -181,11 +198,10 @@ export class AIS {
providerId: string,
redirectUri: string,
state?: string,
model?: string,
psuId?: string,
psuIpAddress?: string
model?: string,
psuId?: string,
psuIpAddress?: string,
): Promise<object> {

const queryParameters = {
redirect_uri: redirectUri,
};
Expand All @@ -203,12 +219,10 @@ export class AIS {
const headers = apiService.getHeaders('get', url, accessToken, this.config);

if (model === Constants.DECOUPLEDMODEL) {
headers["x-psu-id"] = psuId;
headers["x-psu-ip-address"] = psuIpAddress
headers['x-psu-id'] = psuId;
headers['x-psu-ip-address'] = psuIpAddress;
}



const response = await this.axiosInstance.get(url, { headers });
return response.data;
}
Expand All @@ -218,10 +232,9 @@ export class AIS {
redirectUri: string,
state?: string,
model?: string,
psuId?: string,
psuIpAddress?: string
psuId?: string,
psuIpAddress?: string,
): Promise<object> {

const queryParameters = {
response_type: 'code',
redirect_uri: redirectUri,
Expand All @@ -240,19 +253,15 @@ export class AIS {
const headers = apiService.getHeaders('get', url, null, this.config);

if (model === Constants.DECOUPLEDMODEL) {
headers["x-psu-id"] = psuId;
headers["x-psu-ip-address"] = psuIpAddress
headers['x-psu-id'] = psuId;
headers['x-psu-ip-address'] = psuIpAddress;
}

const response = await this.axiosInstance.get(url, { headers });
return response.data;
}

private async _decoupledWithAccesToken(
accessToken: string,
providerId: string,
pollingId: string
): Promise<object> {
private async _decoupledWithAccesToken(accessToken: string, providerId: string, pollingId: string): Promise<object> {
const url = `${Endpoints.AISPROVIDER}/${providerId}/authorize/decoupled/${pollingId}`;

const headers = apiService.getHeaders('get', url, accessToken, this.config);
Expand All @@ -261,10 +270,7 @@ export class AIS {
return response.data;
}

private async _decoupledWithAppId(
providerId: string,
pollingId: string
): Promise<object> {
private async _decoupledWithAppId(providerId: string, pollingId: string): Promise<object> {
const url = `${Endpoints.AISPROVIDER}/${providerId}/authorize/decoupled/${pollingId}`;

const headers = apiService.getHeaders('get', url, null, this.config);
Expand Down
7 changes: 3 additions & 4 deletions src/Authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ export class Authentication {
code: authCode,
grant_type: 'authorization_code',
};
}
else {
} else {
data = {
scope: 'PIS',
app_id: this.appId,
Expand All @@ -84,9 +83,9 @@ export class Authentication {
}

if (scopes) {
data["scope"] = scopes;
data['scope'] = scopes;
}

return qs.stringify(data);
}

Expand Down
8 changes: 4 additions & 4 deletions src/Connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class Connect {

const queryParameters = qs.stringify({
redirect_uri: connectConfig.redirect_uri,
state: connectConfig.state
state: connectConfig.state,
});
const url = `${Endpoints.AISCONNECT}?${queryParameters}`;

Expand All @@ -47,7 +47,7 @@ export class Connect {
const { data } = await this.axiosInstance.get(url, { headers });

return {
url: data.meta.url
url: data.meta.url,
};
}

Expand All @@ -66,7 +66,7 @@ export class Connect {
const queryParameters = qs.stringify({
origin_uri: connectConfig.origin_uri,
redirect_uri: connectConfig.redirect_uri,
state: connectConfig.state
state: connectConfig.state,
});
const url = `${Endpoints.PISCONNECT}?${queryParameters}`;

Expand Down Expand Up @@ -137,7 +137,7 @@ export class Connect {
psu_email: payment.customer_email,
psu_ip: payment.customer_ip,
psu_phone: payment.customer_phone,
psu_address: payment.customer_address
psu_address: payment.customer_address,
};

const data: IData = {
Expand Down
21 changes: 11 additions & 10 deletions src/Pis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ export class PIS {
* @param {object} payload
* @returns {Promise<object>}
*/
public async prepare(
accessToken: string,
payload: object,
): Promise<object> {
public async prepare(accessToken: string, payload: object): Promise<object> {
const url = `${Endpoints.PIS}/prepare`;

const headers = apiService.getHeaders('post', url, accessToken, this.config, payload);
Expand All @@ -61,7 +58,9 @@ export class PIS {
redirectUri: string,
state?: string,
): Promise<object> {
const url = `${Endpoints.PISPROVIDER}/${providerId}/initiate?redirect_uri=${redirectUri}${state ? '&state=' + state : ''}`;
const url = `${Endpoints.PISPROVIDER}/${providerId}/initiate?redirect_uri=${redirectUri}${
state ? '&state=' + state : ''
}`;

const headers = apiService.getHeaders('post', url, accessToken, this.config, payload);

Expand Down Expand Up @@ -105,8 +104,8 @@ export class PIS {
if (amount) {
payload.data = {
attributes: {
amount
}
amount,
},
};
}

Expand All @@ -126,12 +125,14 @@ export class PIS {
* @returns {Promise<object>}
*/
public async getPayments(accessToken: string, sessionId: string, queryParameters?: object): Promise<object> {

const url = `${Endpoints.PIS}/payments` + (sessionId?('/'+sessionId):'') + (queryParameters ? ('?' + qs.stringify(queryParameters)) : '')
const url =
`${Endpoints.PIS}/payments` +
(sessionId ? '/' + sessionId : '') +
(queryParameters ? '?' + qs.stringify(queryParameters) : '');

const headers = apiService.getHeaders('get', url, accessToken, this.config);

const response = await this.axiosInstance.get(url, {headers});
const response = await this.axiosInstance.get(url, { headers });

return response.data;
}
Expand Down
3 changes: 1 addition & 2 deletions src/interfaces/ConfigInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
* @interface IFintectureConfig
*/

import { environment } from "../utils/Constants";

import { environment } from '../utils/Constants';

export interface IFintectureConfig {
app_id: string;
Expand Down
Loading

0 comments on commit 19dc244

Please sign in to comment.