Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(aggregator): modify response type of GET /accounts_ownerships #414

Merged
merged 1 commit into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ describe('BudgetInsightClient', () => {
});

it('should get the account ownerships', async () => {
result.data = mockAccountOwnerships;
result.data = { account_ownerships: mockAccountOwnerships };
const token = 'token';
const spy = jest.spyOn(httpService, 'get').mockImplementationOnce(() => of(result));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@
* Also parse the provided URL
* @param serviceAccountConfig Configurations optionally defined in the SA
*/
public getClientConfig = (serviceAccountConfig?: ClientConfig): ClientConfig => {

Check warning on line 246 in src/aggregator/services/budget-insight/budget-insight.client.ts

View workflow job for this annotation

GitHub Actions / test

Expected 'this' to be used by class method 'getClientConfig'
const clientConfig: ClientConfig =
serviceAccountConfig?.baseUrl !== undefined &&
!isNil(serviceAccountConfig?.clientSecret) &&
Expand Down Expand Up @@ -343,11 +343,11 @@
public async fetchAccountOwnerships(token: string, clientConfig?: ClientConfig): Promise<AccountOwnership[]> {
const baseUrl: string = this.getClientConfig(clientConfig).baseUrl;
const url: string = `${baseUrl}/users/me/account_ownerships`;
const response: AxiosResponse<AccountOwnership[]> = await this.toPromise(
const response: AxiosResponse<{ account_ownerships: AccountOwnership[] }> = await this.toPromise(
this.httpService.get(url, this.setHeaders(token)),
);

return response.data;
return response.data.account_ownerships;
}

/**
Expand All @@ -368,7 +368,7 @@
* @param response Axios observable response
* @returns Promisify observable
*/
private async toPromise<T>(response: Observable<T>): Promise<T> {

Check warning on line 371 in src/aggregator/services/budget-insight/budget-insight.client.ts

View workflow job for this annotation

GitHub Actions / test

Expected 'this' to be used by class async method 'toPromise'
return lastValueFrom(response);
}

Expand All @@ -376,7 +376,7 @@
* Returns Budget Insight request headers
* @param token access token to add in the Authorization field
*/
private readonly setHeaders = (

Check warning on line 379 in src/aggregator/services/budget-insight/budget-insight.client.ts

View workflow job for this annotation

GitHub Actions / test

Expected 'this' to be used by class method 'setHeaders'
token: string,
): {
headers: { 'Content-Type': string; Accept: string; Authorization: string };
Expand Down
Loading