Skip to content

Commit

Permalink
style: run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
amarlankri committed Aug 6, 2021
1 parent 0faa939 commit 9b7048d
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/algoan/dto/customer.enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
export enum AggregationDetailsMode {
redirect = 'REDIRECT',
api = 'API',
iframe = 'IFRAME'
iframe = 'IFRAME',
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/algoan/dto/customer.objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface AggregationDetails {
mode?: AggregationDetailsMode;
redirectUrl?: string;
apiUrl?: string;
iframeUrl?: string
iframeUrl?: string;
userId?: string;
clientId?: string;
}
Expand Down
8 changes: 4 additions & 4 deletions src/hooks/services/hooks.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import { TINK_LINK_ACTOR_CLIENT_ID } from '../../tink/contstants/tink.constants'

import { bankDetailsRequiredMock } from '../dto/bank-details-required-payload.dto.mock';
import { mapTinkDataToAlgoanAnalysis } from '../mappers/analysis.mapper';
import { AggregationDetailsMode } from '../../algoan/dto/customer.enums'
import { AggregationDetailsMode } from '../../algoan/dto/customer.enums';
import { HooksService } from './hooks.service';

describe('HookService', () => {
Expand Down Expand Up @@ -286,7 +286,7 @@ describe('HookService', () => {
...customerMock,
aggregationDetails: {
...customerMock.aggregationDetails,
mode: AggregationDetailsMode.iframe
mode: AggregationDetailsMode.iframe,
},
});
await hookService.handleAggregatorLinkRequiredEvent(aggregatorLinkRequiredMock);
Expand All @@ -298,7 +298,7 @@ describe('HookService', () => {
scope: 'accounts:read,transactions:read,credentials:read',
test: config.tink.test,
authorization_code: createAuthorizationObjectMock.code,
iframe: true
iframe: true,
});

// update
Expand Down Expand Up @@ -404,7 +404,7 @@ describe('HookService', () => {
expect(tinkAuthenticateWithRefreshTokenSpy).toHaveBeenCalledWith(
serviceAccountConfigMock.clientId,
serviceAccountConfigMock.clientSecret,
'mockRefreshToken'
'mockRefreshToken',
);
expect(tinkAuthenticateAsUserWithCodesSpy).not.toHaveBeenCalled();

Expand Down
30 changes: 19 additions & 11 deletions src/hooks/services/hooks.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { ServiceAccount } from '@algoan/rest';
import { Injectable, Inject } from '@nestjs/common';
import { Config } from 'node-config-ts';

import { AggregationDetailsMode } from '../../algoan/dto/customer.enums'
import { CustomerUpdateInput } from '../../algoan/dto/customer.inputs'
import { AggregationDetailsMode } from '../../algoan/dto/customer.enums';
import { CustomerUpdateInput } from '../../algoan/dto/customer.inputs';
import { assertsTypeValidation } from '../../shared/utils/common.utils';
import { TinkAccountObject } from '../../tink/dto/account.objects';
import { TinkAccountService } from '../../tink/services/tink-account.service';
Expand All @@ -29,7 +29,7 @@ import { AlgoanHttpService } from '../../algoan/services/algoan-http.service';
import { AggregatorLinkRequiredDTO } from '../dto/aggregator-link-required-payload.dto';
import { BankDetailsRequiredDTO } from '../dto/bank-details-required-payload.dto';
import { mapTinkDataToAlgoanAnalysis } from '../mappers/analysis.mapper';
import { AccountCheckArgs } from '../../tink/dto/account-check.args'
import { AccountCheckArgs } from '../../tink/dto/account-check.args';

/**
* Hook service
Expand Down Expand Up @@ -109,7 +109,10 @@ export class HooksService {
});
}

const linkData: CustomerUpdateInput["aggregationDetails"] = this.generateLinkDataFromAggregationMode(customer.aggregationDetails.mode, { clientConfig, callbackUrl, authorizationCode})
const linkData: CustomerUpdateInput['aggregationDetails'] = this.generateLinkDataFromAggregationMode(
customer.aggregationDetails.mode,
{ clientConfig, callbackUrl, authorizationCode },
);

// Update user with redirect link information and userId if provided
await this.algoanCustomerService.updateCustomer(payload.customerId, {
Expand All @@ -128,8 +131,11 @@ export class HooksService {
* @param data the input data used for to generate the link data
* @returns
*/
private generateLinkDataFromAggregationMode(mode: AggregationDetailsMode | undefined, data: { clientConfig: ClientConfig, callbackUrl: string, authorizationCode?: string}): CustomerUpdateInput["aggregationDetails"] {
const { clientConfig, callbackUrl, authorizationCode} = data
private generateLinkDataFromAggregationMode(
mode: AggregationDetailsMode | undefined,
data: { clientConfig: ClientConfig; callbackUrl: string; authorizationCode?: string },
): CustomerUpdateInput['aggregationDetails'] {
const { clientConfig, callbackUrl, authorizationCode } = data;
const sharedLinkParameters: AccountCheckArgs = {
client_id: clientConfig.clientId,
redirect_uri: callbackUrl,
Expand All @@ -142,18 +148,20 @@ export class HooksService {
'credentials:read', // To list providers: https://docs.tink.com/api#provider-list-providers-required-scopes-
].join(','),
authorization_code: authorizationCode,
}

};

switch (mode) {
case AggregationDetailsMode.redirect:
const redirectUrl: string | undefined = this.tinkLinkService.getAuthorizeLink(sharedLinkParameters);

return { redirectUrl }
return { redirectUrl };
case AggregationDetailsMode.iframe:
const iframeUrl: string | undefined = this.tinkLinkService.getAuthorizeLink({...sharedLinkParameters, iframe: true});
const iframeUrl: string | undefined = this.tinkLinkService.getAuthorizeLink({
...sharedLinkParameters,
iframe: true,
});

return { iframeUrl }
return { iframeUrl };

default:
throw new Error(`Invalid bank connection mode ${mode}`);
Expand Down
2 changes: 1 addition & 1 deletion src/tink/dto/account-check.args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ export interface AccountCheckArgs {
scope?: string;
test: boolean;
authorization_code?: string;
iframe?: boolean
iframe?: boolean;
}

0 comments on commit 9b7048d

Please sign in to comment.