Skip to content

Commit

Permalink
f-account-info - Update GET Consumer Details route
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugo Woodiwiss authored and hwoodiwiss committed Nov 27, 2024
1 parent ccb1ed4 commit 1d669d7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
4 changes: 3 additions & 1 deletion packages/components/pages/f-account-info/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 1d669d7

Please sign in to comment.