Skip to content

Commit

Permalink
order module update
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitdas13 committed Oct 21, 2021
1 parent 8f7c807 commit 09a8452
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
17 changes: 17 additions & 0 deletions dist/resources/orders.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,23 @@ module.exports = function (api) {
data: data
}, callback);
},
edit: function edit(orderId) {
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var callback = arguments[2];
var notes = params.notes;


if (!orderId) {
throw new Error('`order_id` is mandatory');
}

var data = Object.assign(normalizeNotes(notes));

return api.patch({
url: '/orders/' + orderId,
data: data
}, callback);
},
fetchPayments: function fetchPayments(orderId, callback) {
if (!orderId) {
throw new Error('`order_id` is mandatory');
Expand Down
15 changes: 15 additions & 0 deletions lib/resources/orders.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,21 @@ module.exports = function (api) {
data
}, callback)
},

edit(orderId, params = {}, callback) {
let { notes } = params

if (!orderId) {
throw new Error('`order_id` is mandatory')
}

let data = Object.assign(normalizeNotes(notes))

return api.patch({
url: `/orders/${orderId}`,
data
}, callback)
},

fetchPayments(orderId, callback) {
if (!orderId) {
Expand Down
27 changes: 27 additions & 0 deletions test/resources/orders.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,31 @@ describe('ORDERS', () => {
})
})
})

describe('edit order', () => {
it('edit order', (done) => {
let orderId = 'order_sometestId'

let params = {
notes: {
note1: 'This is note1',
note2: 'This is note2'
}
}

mocker.mock({
url: `/orders/${orderId}`,
method : 'PATCH'
})

rzpInstance.orders.edit(orderId, params).then((response) => {
assert.equal(
response.__JUST_FOR_TESTS__.url,
`/v1/orders/${orderId}`,
'Request url formed correctly'
)
done()
})
})
})
})

0 comments on commit 09a8452

Please sign in to comment.