@defra-fish/connectors-lib 1.64.0-rc.13 → 1.64.0-rc.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defra-fish/connectors-lib",
3
- "version": "1.64.0-rc.13",
3
+ "version": "1.64.0-rc.14",
4
4
  "description": "Shared connectors",
5
5
  "type": "module",
6
6
  "engines": {
@@ -46,5 +46,5 @@
46
46
  "node-fetch": "2.7.0",
47
47
  "redlock": "4.2.0"
48
48
  },
49
- "gitHead": "ad1e6150b116fd892371168e1ad8ed857c8db3d8"
49
+ "gitHead": "556cb2d08393657c9f205695bbc00fac6d401f94"
50
50
  }
@@ -821,103 +821,4 @@ describe('sales-api-connector', () => {
821
821
  await expect(salesApi.retrieveStagedTransaction('id')).rejects.toThrow('Internal Server Error')
822
822
  })
823
823
  })
824
-
825
- describe('retrieveRecurringPaymentAgreement', () => {
826
- describe.each([['id'], ['abc-123']])("Retrieving recurring payment agreement id '%s'", agreementId => {
827
- beforeEach(() => {
828
- fetch.mockReturnValueOnce({
829
- ok: true,
830
- status: 200,
831
- statusText: 'OK',
832
- text: async () => JSON.stringify({ agreementId })
833
- })
834
- })
835
-
836
- it('calls the endpoint with the correct parameters', async () => {
837
- await salesApi.retrieveRecurringPaymentAgreement(agreementId)
838
-
839
- expect(fetch).toHaveBeenCalledWith(`http://0.0.0.0:4000/retrieveRecurringPaymentAgreement/${agreementId}`, {
840
- method: 'get',
841
- headers: expect.any(Object),
842
- timeout: 20000
843
- })
844
- })
845
-
846
- it('returns the expected response data', async () => {
847
- const processedResult = await salesApi.retrieveRecurringPaymentAgreement(agreementId)
848
-
849
- expect(processedResult).toEqual({ agreementId })
850
- })
851
- })
852
-
853
- it('throws an error on non-2xx response', async () => {
854
- fetch.mockReturnValueOnce({
855
- ok: false,
856
- status: 500,
857
- statusText: 'Internal Server Error',
858
- text: async () => 'Server Error'
859
- })
860
-
861
- await expect(salesApi.retrieveRecurringPaymentAgreement('agreementId')).rejects.toThrow('Internal Server Error')
862
- })
863
- })
864
-
865
- describe('updateRecurringTransaction', () => {
866
- it.each([['Debit card'], ['Credit card']])('updates the transaction with payment method "%s"', async method => {
867
- const transactionId = 'transaction-id'
868
- const payload = {
869
- payment: {
870
- source: 'Gov Pay',
871
- method
872
- }
873
- }
874
- const expectedResponse = { id: transactionId, ...payload }
875
-
876
- fetch.mockReturnValueOnce({
877
- ok: true,
878
- status: 200,
879
- statusText: 'OK',
880
- text: async () => JSON.stringify(expectedResponse)
881
- })
882
-
883
- await expect(salesApi.updateRecurringTransaction(transactionId, payload)).resolves.toEqual(expectedResponse)
884
-
885
- expect(fetch).toHaveBeenCalledWith(
886
- `http://0.0.0.0:4000/update-recurring-transactions/${transactionId}`,
887
- expect.objectContaining({
888
- method: 'patch',
889
- body: JSON.stringify(payload)
890
- })
891
- )
892
- })
893
-
894
- it('throws on a non-ok response', async () => {
895
- const transactionId = 'transaction-id'
896
- const payload = {
897
- payment: {
898
- source: 'Gov Pay',
899
- method: 'Debit card'
900
- }
901
- }
902
-
903
- fetch.mockReturnValueOnce({
904
- ok: false,
905
- status: 422,
906
- statusText: 'Unprocessable Entity',
907
- text: async () => JSON.stringify({ error: 'Description' })
908
- })
909
-
910
- await expect(salesApi.updateRecurringTransaction(transactionId, payload)).rejects.toThrow(
911
- /Unexpected response from the Sales API:.*"status": 422.*"statusText": "Unprocessable Entity"/s
912
- )
913
-
914
- expect(fetch).toHaveBeenCalledWith(
915
- `http://0.0.0.0:4000/update-recurring-transactions/${transactionId}`,
916
- expect.objectContaining({
917
- method: 'patch',
918
- body: JSON.stringify(payload)
919
- })
920
- )
921
- })
922
- })
923
824
  })
@@ -100,17 +100,6 @@ export const createTransactions = async transactionArr =>
100
100
  */
101
101
  export const finaliseTransaction = async (id, payload) => exec2xxOrThrow(call(new URL(`/transactions/${id}`, urlBase), 'patch', payload))
102
102
 
103
- /**
104
- * Update a transaction in the sales API
105
- *
106
- * @param id the transaction id to finalise
107
- * @param payload the update-transaction payload to supply on the request
108
- * @returns {Promise<*>}
109
- * @throws on a non-2xx response
110
- */
111
- export const updateRecurringTransaction = async (id, payload) =>
112
- exec2xxOrThrow(call(new URL(`/update-recurring-transactions/${id}`, urlBase), 'patch', payload))
113
-
114
103
  /**
115
104
  * Retrieve the details of a transaction file. Returns null if not found.
116
105
  *
@@ -341,13 +330,3 @@ export const cancelRecurringPayment = async id => {
341
330
  export const retrieveStagedTransaction = async id => {
342
331
  return exec2xxOrThrow(call(new URL(`/retrieveStagedTransaction/${id}`, urlBase), 'get'))
343
332
  }
344
-
345
- /**
346
- * Retrieve recurring payment agreement details
347
- *
348
- * @param {string} agreementId
349
- * @returns {Promise<*>}
350
- * @throws on a non-2xx response
351
- */
352
- export const retrieveRecurringPaymentAgreement = async agreementId =>
353
- exec2xxOrThrow(call(new URL(`/retrieveRecurringPaymentAgreement/${agreementId}`, urlBase), 'get'))