diff --git a/packages/api-axios/src/resources/filesDelivery.js b/packages/api-axios/src/resources/filesDelivery.js index 1fdc208f..11f158eb 100644 --- a/packages/api-axios/src/resources/filesDelivery.js +++ b/packages/api-axios/src/resources/filesDelivery.js @@ -26,7 +26,8 @@ export default class AvFilesDeliveryApi extends AvMicroserviceApi { getLocation(response) { const baseUrl = super.getLocation(response); - return `${baseUrl}/${response.data.id}`; + const { id } = response.data; + return !id || baseUrl.endsWith(id) ? `${baseUrl}` : `${baseUrl}/${id}`; } } diff --git a/packages/api-axios/src/resources/tests/filesDelivery.test.js b/packages/api-axios/src/resources/tests/filesDelivery.test.js index 14977f00..1ea84fa9 100644 --- a/packages/api-axios/src/resources/tests/filesDelivery.test.js +++ b/packages/api-axios/src/resources/tests/filesDelivery.test.js @@ -21,6 +21,15 @@ describe('AvFileDelivery', () => { ); }); + test('polling url should be correct', () => { + expect(api.getLocation({ headers: { Location: '/ms/api/availity/internal/platform/file-upload-delivery/v1/batch/deliveries/id123'}, data: { id: 'id123'}, config: {}})).toBe( + 'http://localhost:8080/ms/api/availity/internal/platform/file-upload-delivery/v1/batch/deliveries/id123' + ); + expect(api.getLocation({ headers: { Location: '/ms/api/availity/internal/platform/file-upload-delivery/v1/batch/deliveries/id123'}, data: {}, config: {}})).toBe( + 'http://localhost:8080/ms/api/availity/internal/platform/file-upload-delivery/v1/batch/deliveries/id123' + ); + }); + test('uploadFile() should call create for reference passed', async () => { const data = { deliveries: [