diff --git a/packages/components/pages/f-account-info/src/constants.js b/packages/components/pages/f-account-info/src/constants.js index ff18bc8e0a..8c873fa7fb 100644 --- a/packages/components/pages/f-account-info/src/constants.js +++ b/packages/components/pages/f-account-info/src/constants.js @@ -3,7 +3,9 @@ export const UPDATE_CONSUMER_DETAIL = 'updateConsumerDetail'; export const EVENT_SPINNER_STOP_LOADING = 'stop-spinner'; -export const CONSUMER_DETAILS_URL = 'consumer'; +export const GET_CONSUMER_DETAILS_URL = 'applications/uk/consumer/me'; +export const PATCH_CONSUMER_DETAILS_URL = 'consumer'; export const CONSUMER_ADDRESSES_URL = 'consumer/addresses'; export const AUTHORISATION_HEADER_NAME = 'Authorization'; +export const ACCEPT_TENANT_HEADER_NAME = 'Accept-Tenant'; diff --git a/packages/components/pages/f-account-info/src/services/providers/Consumer.api.js b/packages/components/pages/f-account-info/src/services/providers/Consumer.api.js index e30fa3fb46..17251660df 100644 --- a/packages/components/pages/f-account-info/src/services/providers/Consumer.api.js +++ b/packages/components/pages/f-account-info/src/services/providers/Consumer.api.js @@ -1,12 +1,15 @@ import { - CONSUMER_DETAILS_URL, + GET_CONSUMER_DETAILS_URL, + PATCH_CONSUMER_DETAILS_URL, CONSUMER_ADDRESSES_URL, - AUTHORISATION_HEADER_NAME + AUTHORISATION_HEADER_NAME, + ACCEPT_TENANT_HEADER_NAME } from '../../constants'; const BuildHeaders = authToken => { const headers = { - [AUTHORISATION_HEADER_NAME]: authToken ? `Bearer ${authToken}` : '' + [AUTHORISATION_HEADER_NAME]: authToken ? `Bearer ${authToken}` : '', + [ACCEPT_TENANT_HEADER_NAME]: 'uk', }; return headers; @@ -24,7 +27,7 @@ export default class ConsumerApi { async getConsumerDetails (authToken) { const headers = BuildHeaders(authToken); - const response = await this.#httpClient.get(`${this.#baseUrl}/${CONSUMER_DETAILS_URL}`, headers); + const response = await this.#httpClient.get(`${this.#baseUrl}/${GET_CONSUMER_DETAILS_URL}`, headers); return response; } @@ -40,7 +43,7 @@ export default class ConsumerApi { async patchConsumer (authToken, body) { const headers = BuildHeaders(authToken); - const response = await this.#httpClient.patch(`${this.#baseUrl}/${CONSUMER_DETAILS_URL}`, body, headers); + const response = await this.#httpClient.patch(`${this.#baseUrl}/${PATCH_CONSUMER_DETAILS_URL}`, body, headers); return response; } diff --git a/packages/components/pages/f-account-info/src/services/providers/_tests/Consumer.api.test.js b/packages/components/pages/f-account-info/src/services/providers/_tests/Consumer.api.test.js index 4604e43a48..cdc939a279 100644 --- a/packages/components/pages/f-account-info/src/services/providers/_tests/Consumer.api.test.js +++ b/packages/components/pages/f-account-info/src/services/providers/_tests/Consumer.api.test.js @@ -1,9 +1,11 @@ import ConsumerApi from '../Consumer.api'; import { - CONSUMER_DETAILS_URL, + GET_CONSUMER_DETAILS_URL, + PATCH_CONSUMER_DETAILS_URL, CONSUMER_ADDRESSES_URL, - AUTHORISATION_HEADER_NAME + AUTHORISATION_HEADER_NAME, + ACCEPT_TENANT_HEADER_NAME } from '../../../constants'; import { baseUrl, @@ -52,9 +54,10 @@ describe('ConsumerApi Provider', () => { describe('When calling `getConsumerDetails`', () => { it('should send the correct parameters', async () => { // Arrange - const expectedUri = `${baseUrl}/${CONSUMER_DETAILS_URL}`; + const expectedUri = `${baseUrl}/${GET_CONSUMER_DETAILS_URL}`; const expectedHeaders = { - [AUTHORISATION_HEADER_NAME]: `Bearer ${token}` + [AUTHORISATION_HEADER_NAME]: `Bearer ${token}`, + [ACCEPT_TENANT_HEADER_NAME]: 'uk' }; // Act @@ -70,7 +73,8 @@ describe('ConsumerApi Provider', () => { // Arrange const expectedUri = `${baseUrl}/${CONSUMER_ADDRESSES_URL}`; const expectedHeaders = { - [AUTHORISATION_HEADER_NAME]: `Bearer ${token}` + [AUTHORISATION_HEADER_NAME]: `Bearer ${token}`, + [ACCEPT_TENANT_HEADER_NAME]: 'uk' }; // Act @@ -84,10 +88,11 @@ describe('ConsumerApi Provider', () => { describe('When calling `patchConsumer`', () => { it('should send the correct parameters', async () => { // Arrange - const expectedUri = `${baseUrl}/${CONSUMER_DETAILS_URL}`; + const expectedUri = `${baseUrl}/${PATCH_CONSUMER_DETAILS_URL}`; const expectedBody = consumerUpdateBody; const expectedHeaders = { - [AUTHORISATION_HEADER_NAME]: `Bearer ${token}` + [AUTHORISATION_HEADER_NAME]: `Bearer ${token}`, + [ACCEPT_TENANT_HEADER_NAME]: 'uk' }; // Act