Skip to content

Commit 31b6b0b

Browse files
author
Hugo Woodiwiss
committed
f-account-info - Update GET Consumer Details route
1 parent ccb1ed4 commit 31b6b0b

File tree

3 files changed

+23
-13
lines changed

3 files changed

+23
-13
lines changed

packages/components/pages/f-account-info/src/constants.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ export const UPDATE_CONSUMER_DETAIL = 'updateConsumerDetail';
33

44
export const EVENT_SPINNER_STOP_LOADING = 'stop-spinner';
55

6-
export const CONSUMER_DETAILS_URL = 'consumer';
6+
export const GET_CONSUMER_DETAILS_URL = 'applications/uk/consumer/me';
7+
export const PATCH_CONSUMER_DETAILS_URL = 'consumer';
78
export const CONSUMER_ADDRESSES_URL = 'consumer/addresses';
89

910
export const AUTHORISATION_HEADER_NAME = 'Authorization';
11+
export const ACCEPT_TENANT_HEADER_NAME = 'Accept-Tenant';

packages/components/pages/f-account-info/src/services/providers/Consumer.api.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import {
2-
CONSUMER_DETAILS_URL,
2+
GET_CONSUMER_DETAILS_URL,
3+
PATCH_CONSUMER_DETAILS_URL,
34
CONSUMER_ADDRESSES_URL,
4-
AUTHORISATION_HEADER_NAME
5+
AUTHORISATION_HEADER_NAME,
6+
ACCEPT_TENANT_HEADER_NAME
57
} from '../../constants';
68

79
const BuildHeaders = authToken => {
810
const headers = {
9-
[AUTHORISATION_HEADER_NAME]: authToken ? `Bearer ${authToken}` : ''
11+
[AUTHORISATION_HEADER_NAME]: authToken ? `Bearer ${authToken}` : '',
12+
[ACCEPT_TENANT_HEADER_NAME]: 'uk',
1013
};
1114

1215
return headers;
@@ -24,7 +27,7 @@ export default class ConsumerApi {
2427
async getConsumerDetails (authToken) {
2528
const headers = BuildHeaders(authToken);
2629

27-
const response = await this.#httpClient.get(`${this.#baseUrl}/${CONSUMER_DETAILS_URL}`, headers);
30+
const response = await this.#httpClient.get(`${this.#baseUrl}/${GET_CONSUMER_DETAILS_URL}`, headers);
2831

2932
return response;
3033
}
@@ -40,7 +43,7 @@ export default class ConsumerApi {
4043
async patchConsumer (authToken, body) {
4144
const headers = BuildHeaders(authToken);
4245

43-
const response = await this.#httpClient.patch(`${this.#baseUrl}/${CONSUMER_DETAILS_URL}`, body, headers);
46+
const response = await this.#httpClient.patch(`${this.#baseUrl}/${PATCH_CONSUMER_DETAILS_URL}`, body, headers);
4447

4548
return response;
4649
}

packages/components/pages/f-account-info/src/services/providers/_tests/Consumer.api.test.js

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import ConsumerApi from '../Consumer.api';
22

33
import {
4-
CONSUMER_DETAILS_URL,
4+
GET_CONSUMER_DETAILS_URL,
5+
PATCH_CONSUMER_DETAILS_URL,
56
CONSUMER_ADDRESSES_URL,
6-
AUTHORISATION_HEADER_NAME
7+
AUTHORISATION_HEADER_NAME,
8+
ACCEPT_TENANT_HEADER_NAME
79
} from '../../../constants';
810
import {
911
baseUrl,
@@ -52,9 +54,10 @@ describe('ConsumerApi Provider', () => {
5254
describe('When calling `getConsumerDetails`', () => {
5355
it('should send the correct parameters', async () => {
5456
// Arrange
55-
const expectedUri = `${baseUrl}/${CONSUMER_DETAILS_URL}`;
57+
const expectedUri = `${baseUrl}/${GET_CONSUMER_DETAILS_URL}`;
5658
const expectedHeaders = {
57-
[AUTHORISATION_HEADER_NAME]: `Bearer ${token}`
59+
[AUTHORISATION_HEADER_NAME]: `Bearer ${token}`,
60+
[ACCEPT_TENANT_HEADER_NAME]: 'uk'
5861
};
5962

6063
// Act
@@ -70,7 +73,8 @@ describe('ConsumerApi Provider', () => {
7073
// Arrange
7174
const expectedUri = `${baseUrl}/${CONSUMER_ADDRESSES_URL}`;
7275
const expectedHeaders = {
73-
[AUTHORISATION_HEADER_NAME]: `Bearer ${token}`
76+
[AUTHORISATION_HEADER_NAME]: `Bearer ${token}`,
77+
[ACCEPT_TENANT_HEADER_NAME]: 'uk'
7478
};
7579

7680
// Act
@@ -84,10 +88,11 @@ describe('ConsumerApi Provider', () => {
8488
describe('When calling `patchConsumer`', () => {
8589
it('should send the correct parameters', async () => {
8690
// Arrange
87-
const expectedUri = `${baseUrl}/${CONSUMER_DETAILS_URL}`;
91+
const expectedUri = `${baseUrl}/${PATCH_CONSUMER_DETAILS_URL}`;
8892
const expectedBody = consumerUpdateBody;
8993
const expectedHeaders = {
90-
[AUTHORISATION_HEADER_NAME]: `Bearer ${token}`
94+
[AUTHORISATION_HEADER_NAME]: `Bearer ${token}`,
95+
[ACCEPT_TENANT_HEADER_NAME]: 'uk'
9196
};
9297

9398
// Act

0 commit comments

Comments
 (0)