From 275b93397879a4ee24800c629970091de042feac Mon Sep 17 00:00:00 2001 From: Daniel Amaral Date: Thu, 3 Oct 2019 12:52:14 -0300 Subject: [PATCH 1/5] Add method to create notification for App --- dist/resources/notification.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dist/resources/notification.js b/dist/resources/notification.js index 7739dec..adcfeac 100644 --- a/dist/resources/notification.js +++ b/dist/resources/notification.js @@ -22,6 +22,10 @@ var create = function create(opts, preferences) { return _api2.default.post(opts, '/preferences/notifications', preferences); }; +var createForApp = function createForApp(opts, appId, preferences) { + return _api2.default.post(opts, '/preferences/' + appId + 'notifications', preferences); +}; + var remove = function remove(opts, _id) { return _api2.default.remove(opts, '/preferences/notifications/' + _id); }; @@ -30,5 +34,6 @@ exports.default = { getOne: getOne, getAll: getAll, create: create, + createForApp: createForApp, remove: remove }; \ No newline at end of file From 0ff9fd7578a581e27273d32f2cbe88de0149a7b7 Mon Sep 17 00:00:00 2001 From: Daniel Amaral Date: Thu, 3 Oct 2019 13:15:51 -0300 Subject: [PATCH 2/5] Fix url path passed in createForApp method in notification.js --- dist/resources/notification.js | 2 +- test/refund.spec.js | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/dist/resources/notification.js b/dist/resources/notification.js index adcfeac..ddae1a7 100644 --- a/dist/resources/notification.js +++ b/dist/resources/notification.js @@ -23,7 +23,7 @@ var create = function create(opts, preferences) { }; var createForApp = function createForApp(opts, appId, preferences) { - return _api2.default.post(opts, '/preferences/' + appId + 'notifications', preferences); + return _api2.default.post(opts, '/preferences/' + appId + '/notifications', preferences); }; var remove = function remove(opts, _id) { diff --git a/test/refund.spec.js b/test/refund.spec.js index fdef148..7cae51f 100644 --- a/test/refund.spec.js +++ b/test/refund.spec.js @@ -23,7 +23,7 @@ describe('Moip Payment Refunds', () => { it('Should successfully create an order', (done) => { moip.order.create(orderModel) - .then(({body}) => { + .then(({ body }) => { orderId = body.id done() }) @@ -32,7 +32,7 @@ describe('Moip Payment Refunds', () => { it('Should successfully create a payment for an order', (done) => { moip.payment.create(orderId, paymentModel) - .then(({body}) => { + .then(({ body }) => { // Verify and add to schema body.should.have.property('id') paymentModel.id = body.id @@ -43,7 +43,7 @@ describe('Moip Payment Refunds', () => { it('Should successfully refund the payment', (done) => { moip.payment.refunds.create(paymentModel.id) - .then(({body}) => { + .then(({ body }) => { body.should.have.property('id') body.should.have.property('status') body.status.should.be.eql('COMPLETED') @@ -77,7 +77,7 @@ describe('Moip Order Refunds', () => { it('Should successfully create an order', (done) => { moip.order.create(orderModel) - .then(({body}) => { + .then(({ body }) => { orderId = body.id done() }) @@ -86,7 +86,7 @@ describe('Moip Order Refunds', () => { it('Should successfully create a payment for an order', (done) => { moip.payment.create(orderId, paymentModel) - .then(({body}) => { + .then(({ body }) => { // Verify and add to schema body.should.have.property('id') paymentModel.id = body.id @@ -97,7 +97,7 @@ describe('Moip Order Refunds', () => { it('Should successfully refund the order', (done) => { moip.order.refunds.create(orderId) - .then(({body}) => { + .then(({ body }) => { refundId = body.id body.should.have.property('id') body.should.have.property('status') @@ -109,7 +109,7 @@ describe('Moip Order Refunds', () => { it('Should successfully get the refund', (done) => { moip.refund.get(refundId) - .then(({body}) => { + .then(({ body }) => { body.should.have.property('id') done() }) @@ -123,4 +123,4 @@ describe('Moip Order Refunds', () => { }) .catch(done) }) -}) +}) \ No newline at end of file From 58f6361c80581dc98b5ae1d0f0da01d9e0655972 Mon Sep 17 00:00:00 2001 From: Daniel Amaral Date: Thu, 3 Oct 2019 13:27:57 -0300 Subject: [PATCH 3/5] Adjust indentation spaces in refund.spec.js --- test/refund.spec.js | 202 ++++++++++++++++++++++---------------------- 1 file changed, 101 insertions(+), 101 deletions(-) diff --git a/test/refund.spec.js b/test/refund.spec.js index 7cae51f..42a2e84 100644 --- a/test/refund.spec.js +++ b/test/refund.spec.js @@ -9,118 +9,118 @@ chai.should() chai.use(require('chai-json-schema')) describe('Moip Payment Refunds', () => { - beforeEach((done) => { - setTimeout(done, 2000) - }) - - before((done) => { - orderModel.ownId = shortid.generate() - orderModel.customer.ownId = shortid.generate() - done() - }) - - let orderId - - it('Should successfully create an order', (done) => { - moip.order.create(orderModel) - .then(({ body }) => { - orderId = body.id - done() + beforeEach((done) => { + setTimeout(done, 2000) }) - .catch(done) - }) - - it('Should successfully create a payment for an order', (done) => { - moip.payment.create(orderId, paymentModel) - .then(({ body }) => { - // Verify and add to schema - body.should.have.property('id') - paymentModel.id = body.id - done() + + before((done) => { + orderModel.ownId = shortid.generate() + orderModel.customer.ownId = shortid.generate() + done() + }) + + let orderId + + it('Should successfully create an order', (done) => { + moip.order.create(orderModel) + .then(({ body }) => { + orderId = body.id + done() + }) + .catch(done) }) - .catch(done) - }) - - it('Should successfully refund the payment', (done) => { - moip.payment.refunds.create(paymentModel.id) - .then(({ body }) => { - body.should.have.property('id') - body.should.have.property('status') - body.status.should.be.eql('COMPLETED') - done() + + it('Should successfully create a payment for an order', (done) => { + moip.payment.create(orderId, paymentModel) + .then(({ body }) => { + // Verify and add to schema + body.should.have.property('id') + paymentModel.id = body.id + done() + }) + .catch(done) + }) + + it('Should successfully refund the payment', (done) => { + moip.payment.refunds.create(paymentModel.id) + .then(({ body }) => { + body.should.have.property('id') + body.should.have.property('status') + body.status.should.be.eql('COMPLETED') + done() + }) + .catch(done) }) - .catch(done) - }) - it('Should successfully get all the payment refunds', (done) => { - moip.payment.refunds.get(paymentModel.id) - .then(() => { - done() + it('Should successfully get all the payment refunds', (done) => { + moip.payment.refunds.get(paymentModel.id) + .then(() => { + done() + }) + .catch(done) }) - .catch(done) - }) }) describe('Moip Order Refunds', () => { - beforeEach((done) => { - setTimeout(done, 2000) - }) - - before((done) => { - orderModel.ownId = shortid.generate() - orderModel.customer.ownId = shortid.generate() - done() - }) - - let orderId - let refundId - - it('Should successfully create an order', (done) => { - moip.order.create(orderModel) - .then(({ body }) => { - orderId = body.id - done() + beforeEach((done) => { + setTimeout(done, 2000) + }) + + before((done) => { + orderModel.ownId = shortid.generate() + orderModel.customer.ownId = shortid.generate() + done() + }) + + let orderId + let refundId + + it('Should successfully create an order', (done) => { + moip.order.create(orderModel) + .then(({ body }) => { + orderId = body.id + done() + }) + .catch(done) }) - .catch(done) - }) - - it('Should successfully create a payment for an order', (done) => { - moip.payment.create(orderId, paymentModel) - .then(({ body }) => { - // Verify and add to schema - body.should.have.property('id') - paymentModel.id = body.id - done() + + it('Should successfully create a payment for an order', (done) => { + moip.payment.create(orderId, paymentModel) + .then(({ body }) => { + // Verify and add to schema + body.should.have.property('id') + paymentModel.id = body.id + done() + }) + .catch(done) }) - .catch(done) - }) - - it('Should successfully refund the order', (done) => { - moip.order.refunds.create(orderId) - .then(({ body }) => { - refundId = body.id - body.should.have.property('id') - body.should.have.property('status') - body.status.should.be.eql('COMPLETED') - done() + + it('Should successfully refund the order', (done) => { + moip.order.refunds.create(orderId) + .then(({ body }) => { + refundId = body.id + body.should.have.property('id') + body.should.have.property('status') + body.status.should.be.eql('COMPLETED') + done() + }) + .catch(done) }) - .catch(done) - }) - - it('Should successfully get the refund', (done) => { - moip.refund.get(refundId) - .then(({ body }) => { - body.should.have.property('id') - done() + + it('Should successfully get the refund', (done) => { + moip.refund.get(refundId) + .then(({ body }) => { + body.should.have.property('id') + done() + }) + .catch(done) }) - .catch(done) - }) - it('Should successfully get all the order refunds', (done) => { - moip.order.refunds.get(orderId) - .then(() => { - done() + it('Should successfully get all the order refunds', (done) => { + moip.order.refunds.get(orderId) + .then(() => { + done() + }) + .catch(done) }) - .catch(done) - }) -}) \ No newline at end of file +}) From ead6cd73fbc8b4a32df98ffbf64afc080ee8a4a1 Mon Sep 17 00:00:00 2001 From: Daniel Amaral Date: Thu, 3 Oct 2019 13:38:33 -0300 Subject: [PATCH 4/5] Adjust indentation spaces in refund.spec.js --- test/refund.spec.js | 200 ++++++++++++++++++++++---------------------- 1 file changed, 100 insertions(+), 100 deletions(-) diff --git a/test/refund.spec.js b/test/refund.spec.js index 42a2e84..089145a 100644 --- a/test/refund.spec.js +++ b/test/refund.spec.js @@ -9,118 +9,118 @@ chai.should() chai.use(require('chai-json-schema')) describe('Moip Payment Refunds', () => { - beforeEach((done) => { - setTimeout(done, 2000) + beforeEach((done) => { + setTimeout(done, 2000) + }) + + before((done) => { + orderModel.ownId = shortid.generate() + orderModel.customer.ownId = shortid.generate() + done() + }) + + let orderId + + it('Should successfully create an order', (done) => { + moip.order.create(orderModel) + .then(({ body }) => { + orderId = body.id + done() }) - - before((done) => { - orderModel.ownId = shortid.generate() - orderModel.customer.ownId = shortid.generate() - done() - }) - - let orderId - - it('Should successfully create an order', (done) => { - moip.order.create(orderModel) - .then(({ body }) => { - orderId = body.id - done() - }) - .catch(done) + .catch(done) + }) + + it('Should successfully create a payment for an order', (done) => { + moip.payment.create(orderId, paymentModel) + .then(({ body }) => { + // Verify and add to schema + body.should.have.property('id') + paymentModel.id = body.id + done() }) - - it('Should successfully create a payment for an order', (done) => { - moip.payment.create(orderId, paymentModel) - .then(({ body }) => { - // Verify and add to schema - body.should.have.property('id') - paymentModel.id = body.id - done() - }) - .catch(done) - }) - - it('Should successfully refund the payment', (done) => { - moip.payment.refunds.create(paymentModel.id) - .then(({ body }) => { - body.should.have.property('id') - body.should.have.property('status') - body.status.should.be.eql('COMPLETED') - done() - }) - .catch(done) + .catch(done) + }) + + it('Should successfully refund the payment', (done) => { + moip.payment.refunds.create(paymentModel.id) + .then(({ body }) => { + body.should.have.property('id') + body.should.have.property('status') + body.status.should.be.eql('COMPLETED') + done() }) + .catch(done) + }) - it('Should successfully get all the payment refunds', (done) => { - moip.payment.refunds.get(paymentModel.id) - .then(() => { - done() - }) - .catch(done) + it('Should successfully get all the payment refunds', (done) => { + moip.payment.refunds.get(paymentModel.id) + .then(() => { + done() }) + .catch(done) + }) }) describe('Moip Order Refunds', () => { - beforeEach((done) => { - setTimeout(done, 2000) + beforeEach((done) => { + setTimeout(done, 2000) + }) + + before((done) => { + orderModel.ownId = shortid.generate() + orderModel.customer.ownId = shortid.generate() + done() + }) + + let orderId + let refundId + + it('Should successfully create an order', (done) => { + moip.order.create(orderModel) + .then(({ body }) => { + orderId = body.id + done() }) - - before((done) => { - orderModel.ownId = shortid.generate() - orderModel.customer.ownId = shortid.generate() - done() + .catch(done) + }) + + it('Should successfully create a payment for an order', (done) => { + moip.payment.create(orderId, paymentModel) + .then(({ body }) => { + // Verify and add to schema + body.should.have.property('id') + paymentModel.id = body.id + done() }) - - let orderId - let refundId - - it('Should successfully create an order', (done) => { - moip.order.create(orderModel) - .then(({ body }) => { - orderId = body.id - done() - }) - .catch(done) - }) - - it('Should successfully create a payment for an order', (done) => { - moip.payment.create(orderId, paymentModel) - .then(({ body }) => { - // Verify and add to schema - body.should.have.property('id') - paymentModel.id = body.id - done() - }) - .catch(done) + .catch(done) + }) + + it('Should successfully refund the order', (done) => { + moip.order.refunds.create(orderId) + .then(({ body }) => { + refundId = body.id + body.should.have.property('id') + body.should.have.property('status') + body.status.should.be.eql('COMPLETED') + done() }) - - it('Should successfully refund the order', (done) => { - moip.order.refunds.create(orderId) - .then(({ body }) => { - refundId = body.id - body.should.have.property('id') - body.should.have.property('status') - body.status.should.be.eql('COMPLETED') - done() - }) - .catch(done) - }) - - it('Should successfully get the refund', (done) => { - moip.refund.get(refundId) - .then(({ body }) => { - body.should.have.property('id') - done() - }) - .catch(done) + .catch(done) + }) + + it('Should successfully get the refund', (done) => { + moip.refund.get(refundId) + .then(({ body }) => { + body.should.have.property('id') + done() }) + .catch(done) + }) - it('Should successfully get all the order refunds', (done) => { - moip.order.refunds.get(orderId) - .then(() => { - done() - }) - .catch(done) + it('Should successfully get all the order refunds', (done) => { + moip.order.refunds.get(orderId) + .then(() => { + done() }) + .catch(done) + }) }) From a6b924b689fa9899656bb1289cf96d9ad9e66c0d Mon Sep 17 00:00:00 2001 From: Daniel Amaral Date: Thu, 3 Oct 2019 13:42:36 -0300 Subject: [PATCH 5/5] Adjust indentation spaces in refund.spec.js --- test/refund.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/refund.spec.js b/test/refund.spec.js index 089145a..d9b4086 100644 --- a/test/refund.spec.js +++ b/test/refund.spec.js @@ -103,7 +103,7 @@ describe('Moip Order Refunds', () => { body.should.have.property('status') body.status.should.be.eql('COMPLETED') done() - }) + }) .catch(done) })