Skip to content

Commit

Permalink
fix(bridge.client): update the delete users API call
Browse files Browse the repository at this point in the history
  • Loading branch information
ccoeurderoy committed Jul 4, 2022
1 parent b7b4fb8 commit cb2a845
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 7 deletions.
33 changes: 33 additions & 0 deletions src/aggregator/services/bridge/bridge.client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -528,4 +528,37 @@ describe('BridgeClient', () => {
},
});
});

it('delete a user', async () => {
const result: AxiosResponse = {
data: {},
status: 204,
statusText: '',
headers: {},
config: {},
};

const spy = jest.spyOn(httpService, 'post').mockImplementationOnce(() => of(result));

const resp = await service.deleteUser('mockAccessToken', {
userId: 'userId',
password: 'password',
});
expect(resp).toBeUndefined();

expect(spy).toHaveBeenCalledWith(
'https://api.bridgeapi.io/v2/users/userId/delete',
{
password: 'password',
},
{
headers: {
Authorization: 'Bearer mockAccessToken',
'Client-Id': config.bridge.clientId,
'Client-Secret': config.bridge.clientSecret,
'Bankin-Version': config.bridge.bankinVersion,
},
},
);
});
});
19 changes: 12 additions & 7 deletions src/aggregator/services/bridge/bridge.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,17 +296,22 @@ export class BridgeClient {
params: { userId: string; password: string },
clientConfig?: ClientConfig,
): Promise<void> {
const uri: string = `/v2/users/${params.userId}?password=${params.password}`;
const uri: string = `/v2/users/${params.userId}/delete`;
const url: string = `${config.bridge.baseUrl}${uri}`;

await BridgeClient.toPromise(
this.httpService.delete(url, {
headers: {
Authorization: `Bearer ${accessToken}`,
...BridgeClient.getHeaders(clientConfig),
'Content-Type': 'application/json',
this.httpService.post(
url,
{
password: params.password,
},
}),
{
headers: {
Authorization: `Bearer ${accessToken}`,
...BridgeClient.getHeaders(clientConfig),
},
},
),
);
}

Expand Down

0 comments on commit cb2a845

Please sign in to comment.