Skip to content

Commit

Permalink
Add new route to Sales API connector
Browse files Browse the repository at this point in the history
https://eaflood.atlassian.net/browse/IWTF-4017

This is required for IWTF-4017 as we will need a new function within the Sales API to prepare data for a recurring payment. The recurring payment job needs to be able to conenct to this new feature so this PR updates the connector. See #1957 for further implementation.
  • Loading branch information
irisfaraway committed Jun 6, 2024
1 parent 2299bec commit 685a0f2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/connectors-lib/src/__tests__/sales-api-connector.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -643,4 +643,17 @@ describe('sales-api-connector', () => {
})
})
})

describe('preparePermissionDataForRenewal', () => {
it('retrieves all items using .getAll()', async () => {
const expectedResponse = { foo: 'bar' }
fetch.mockReturnValue({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify(expectedResponse) })
await expect(salesApi.preparePermissionDataForRenewal('AAAAAA')).resolves.toEqual(expectedResponse)
expect(fetch).toHaveBeenCalledWith('http://0.0.0.0:4000/permissionRenewalData/AAAAAA', {
method: 'get',
headers: expect.any(Object),
timeout: 20000
})
})
})
})
10 changes: 10 additions & 0 deletions packages/connectors-lib/src/sales-api-connector.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,3 +285,13 @@ export const isSystemError = statusCode => Math.floor(statusCode / 100) === 5
* @throws on a non-2xx response
*/
export const getDueRecurringPayments = async date => exec2xxOrThrow(call(new URL(`/dueRecurringPayments/${date}`, urlBase), 'get'))

/**
* Prepare permission data for renewal
*
* @param referenceNumber
* @returns {Promise<*>}
* @throws on a non-2xx response
*/
export const preparePermissionDataForRenewal = async referenceNumber =>
exec2xxOrThrow(call(new URL(`/permissionRenewalData/${referenceNumber}`, urlBase), 'get'))

0 comments on commit 685a0f2

Please sign in to comment.