queue.push(function () { nock(VOICE_ENDPOINT) .put('/call-flows/id#1') .reply(204, ''); messagebird.callflows.update('id#1', {title: 'title_new'}, function (err, response) { doTest(err, 'callflows.update', []); }); });
it('should update campaign', function (done) { var server = nock('https://api.voucherify.io', reqWithBody) .put('/v1/campaigns/cust_ABCD', { description: 'test campaign' }) .reply(200, {}) client.campaigns.update('cust_ABCD', { description: 'test campaign' }) .then(function () { server.done() done() }) })
it('should update loyalty earning rule (callback)', function (done) { const server = nock('https://api.voucherify.io', reqWithBody) .put('/v1/loyalties/campaign_test-id/earning-rules/earning_rules_test-id', { loyalty: { points: 21 } }) .reply(200, {}) client.loyalties.updateEarningRule('campaign_test-id', { id: 'earning_rules_test-id', loyalty: { points: 21 } }, function (err) { expect(err).to.be.null server.done() done() }) })
// Voice webhook update queue.push(function () { var params = { 'status': 'disabled' }; nock('https://voice.messagebird.com') .put('/webhooks/webhook-id', params) .reply(200, { id: 'webhook-id', url: 'https://example.com/webhook', token: 'secret-token' }); messagebird.voice.webhooks.update('webhook-id', params, function (err, data) { doTest(err, 'voice.webhooks.update', [ ['type', data instanceof Object], ['.id', data && data.id === 'webhook-id'], ['.token', data && data.token === 'secret-token'] ]); }); });
it('should update customer consents by Source ID (when ID not provided)', function (done) { var server = nock('https://api.voucherify.io', reqWithoutBody) .put('/v1/customers/s_test-id/consents') .reply(200, {}) client.customers.updateConsents({ source_id: 's_test-id' }, { const_id: true }) .then(function () { server.done() done() }) })
it('should update reward (callback)', function (done) { const server = nock('https://api.voucherify.io', reqWithBody) .put('/v1/rewards/reward_test-id', { name: '10$ discount' }) .reply(200, {}) client.rewards.update({ id: 'reward_test-id', name: '10$ discount' }, function (err) { expect(err).to.be.null server.done() done() }) })
it('should update loyalty earning rule', function (done) { const server = nock('https://api.voucherify.io', reqWithBody) .put('/v1/loyalties/campaign_test-id/earning-rules/earning_rules_test-id', { loyalty: { points: 21 } }) .reply(200, {}) client.loyalties.updateEarningRule('campaign_test-id', { id: 'earning_rules_test-id', loyalty: { points: 21 } }) .then(function () { server.done() done() }) })
it('should update product', function (done) { var server = nock('https://api.voucherify.io', reqWithBody) .put('/v1/products/prod_test-id', { name: 'product name' }) .reply(200, {}) client.products.update({ id: 'prod_test-id', name: 'product name' }) .then(function () { server.done() done() }) })
it('should update loyalty program (callback)', function (done) { const server = nock('https://api.voucherify.io', reqWithBody) .put('/v1/loyalties/campaign_test-id', { description: 'Test program' }) .reply(200, {}) client.loyalties.update({ id: 'campaign_test-id', description: 'Test program' }, function (err) { expect(err).to.be.null server.done() done() }) })
it('should update voucher', function (done) { var server = nock('https://api.voucherify.io', reqWithBody) .put('/v1/vouchers/test-code', { code: 'test-code', type: 'DISCOUNT_VOUCHER' }) .reply(200, {}) client.vouchers.update({ code: 'test-code', type: 'DISCOUNT_VOUCHER' }) .then(function () { server.done() done() }) })
it('should update reward', function (done) { const server = nock('https://api.voucherify.io', reqWithBody) .put('/v1/rewards/reward_test-id', { name: '10$ discount' }) .reply(200, {}) client.rewards.update({ id: 'reward_test-id', name: '10$ discount' }) .then(function () { server.done() done() }) })
it('should update loyalty program', function (done) { const server = nock('https://api.voucherify.io', reqWithBody) .put('/v1/loyalties/campaign_test-id', { description: 'Test program' }) .reply(200, {}) client.loyalties.update({ id: 'campaign_test-id', description: 'Test program' }) .then(function () { server.done() done() }) })
it('should update customer by Source ID (when ID not provided)', function (done) { var server = nock('https://api.voucherify.io', reqWithBody) .put('/v1/customers/s_test-id', { source_id: 's_test-id', name: 'customer name' }) .reply(200, {}) client.customers.update({ source_id: 's_test-id', name: 'customer name' }) .then(function () { server.done() done() }) })
it('should update customer consents', function (done) { var server = nock('https://api.voucherify.io', reqWithoutBody) .put('/v1/customers/cust_test-id/consents') .reply(200, {}) client.customers.updateConsents({ id: 'cust_test-id' }, { const_id: true }) .then(function () { server.done() done() }) })
it('should update customer by ID', function (done) { var server = nock('https://api.voucherify.io', reqWithBody) .put('/v1/customers/cust_test-id', { source_id: 's_test-id', name: 'customer name' }) .reply(200, {}) client.customers.update({ id: 'cust_test-id', source_id: 's_test-id', name: 'customer name' }) .then(function () { server.done() done() }) })