From d161873fa7ef7dc76d318f8e9ac0ee211a71da15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armando=20Rodr=C3=ADguez?= <127134616+armando-rodriguez-cko@users.noreply.github.com> Date: Mon, 25 Mar 2024 14:08:26 +0100 Subject: [PATCH] Add compiled submitted evidence endpoint to disputes --- src/api/disputes/disputes.js | 23 +++++++++++++++++++++++ test/disputes/disputes.js | 18 ++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/src/api/disputes/disputes.js b/src/api/disputes/disputes.js index 187b428..a8b9eae 100644 --- a/src/api/disputes/disputes.js +++ b/src/api/disputes/disputes.js @@ -165,6 +165,29 @@ export default class Disputes { } } + /** + * Returns all of the scheme files of a dispute using the dispute identifier. + * Currently available only for VISA disputes. + * + * @memberof Disputes + * @param {string} disputeId Dispute id. + * @return {Promise} A promise to the dispute scheme files response. + */ + async getCompiledSubmittedEvidence(disputeId) { + try { + const response = await get( + this.config.httpClient, + `${this.config.host}/disputes/${disputeId}/evidence/submitted`, + this.config, + this.config.sk + ); + return await response.json; + } catch (err) { + const error = await determineError(err); + throw error; + } + } + /** * Returns all of the scheme files of a dispute using the dispute identifier. * Currently available only for VISA disputes. diff --git a/test/disputes/disputes.js b/test/disputes/disputes.js index 14d1f85..43df0ff 100644 --- a/test/disputes/disputes.js +++ b/test/disputes/disputes.js @@ -708,6 +708,24 @@ describe('Disputes', () => { } }); + it('should get compiled submitted evidence', async () => { + nock('https://api.sandbox.checkout.com') + .get('/disputes/dsp_3dc29c89ce075g46136d/evidence/submitted') + .reply(200, { + file_id: 'file_iweu3nxyt6zund3gwhg7wo4fhq', + _links: { + self: { + href: 'https://api.checkout.com/disputes/dsp_3dc29c89ce075g46136d/evidence/submitted', + }, + }, + }); + + const cko = new Checkout(SK); + + const compiledSubmittedEvidence = await cko.disputes.getCompiledSubmittedEvidence('dsp_3dc29c89ce075g46136d'); + expect(compiledSubmittedEvidence.file_id).to.equal('file_iweu3nxyt6zund3gwhg7wo4fhq'); + }); + it('should get dispute scheme files', async () => { nock('https://api.sandbox.checkout.com') .get('/disputes/dsp_3dc29c89ce075g46136d/schemefiles')