deskbookers
Advanced tools
Comparing version 5.2.0 to 5.2.1
@@ -356,3 +356,3 @@ (function (global, factory) { | ||
}, { | ||
key: 'listSources', | ||
key: 'createSubscription', | ||
value: function () { | ||
@@ -362,4 +362,3 @@ var _ref13 = _asyncToGenerator(regeneratorRuntime.mark(function _callee7() { | ||
userId = _ref14.userId, | ||
limit = _ref14.limit, | ||
lastId = _ref14.lastId; | ||
subscription = _ref14.subscription; | ||
@@ -372,7 +371,5 @@ return regeneratorRuntime.wrap(function _callee7$(_context7) { | ||
return this.request({ | ||
path: this.endpoint + '/' + userId + '/sources', | ||
params: { | ||
limit: limit, | ||
lastId: lastId | ||
} | ||
method: 'POST', | ||
path: this.endpoint + '/' + userId + '/subscriptions', | ||
body: subscription || {} | ||
}); | ||
@@ -391,10 +388,10 @@ | ||
function listSources() { | ||
function createSubscription() { | ||
return _ref13.apply(this, arguments); | ||
} | ||
return listSources; | ||
return createSubscription; | ||
}() | ||
}, { | ||
key: 'deleteSource', | ||
key: 'listSources', | ||
value: function () { | ||
@@ -404,3 +401,4 @@ var _ref15 = _asyncToGenerator(regeneratorRuntime.mark(function _callee8() { | ||
userId = _ref16.userId, | ||
sourceId = _ref16.sourceId; | ||
limit = _ref16.limit, | ||
lastId = _ref16.lastId; | ||
@@ -413,4 +411,7 @@ return regeneratorRuntime.wrap(function _callee8$(_context8) { | ||
return this.request({ | ||
method: 'DELETE', | ||
path: this.endpoint + '/' + userId + '/sources/' + sourceId | ||
path: this.endpoint + '/' + userId + '/sources', | ||
params: { | ||
limit: limit, | ||
lastId: lastId | ||
} | ||
}); | ||
@@ -429,10 +430,10 @@ | ||
function deleteSource() { | ||
function listSources() { | ||
return _ref15.apply(this, arguments); | ||
} | ||
return deleteSource; | ||
return listSources; | ||
}() | ||
}, { | ||
key: 'setDefaultSource', | ||
key: 'deleteSource', | ||
value: function () { | ||
@@ -450,4 +451,4 @@ var _ref17 = _asyncToGenerator(regeneratorRuntime.mark(function _callee9() { | ||
return this.request({ | ||
method: 'PUT', | ||
path: this.endpoint + '/' + userId + '/defaultsource/' + sourceId | ||
method: 'DELETE', | ||
path: this.endpoint + '/' + userId + '/sources/' + sourceId | ||
}); | ||
@@ -466,10 +467,10 @@ | ||
function setDefaultSource() { | ||
function deleteSource() { | ||
return _ref17.apply(this, arguments); | ||
} | ||
return setDefaultSource; | ||
return deleteSource; | ||
}() | ||
}, { | ||
key: 'createCharge', | ||
key: 'setDefaultSource', | ||
value: function () { | ||
@@ -479,3 +480,3 @@ var _ref19 = _asyncToGenerator(regeneratorRuntime.mark(function _callee10() { | ||
userId = _ref20.userId, | ||
charge = _ref20.charge; | ||
sourceId = _ref20.sourceId; | ||
@@ -488,5 +489,4 @@ return regeneratorRuntime.wrap(function _callee10$(_context10) { | ||
return this.request({ | ||
method: 'POST', | ||
path: this.endpoint + '/' + userId + '/charge', | ||
body: charge | ||
method: 'PUT', | ||
path: this.endpoint + '/' + userId + '/defaultsource/' + sourceId | ||
}); | ||
@@ -505,6 +505,42 @@ | ||
function createCharge() { | ||
function setDefaultSource() { | ||
return _ref19.apply(this, arguments); | ||
} | ||
return setDefaultSource; | ||
}() | ||
}, { | ||
key: 'createCharge', | ||
value: function () { | ||
var _ref21 = _asyncToGenerator(regeneratorRuntime.mark(function _callee11() { | ||
var _ref22 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, | ||
userId = _ref22.userId, | ||
charge = _ref22.charge; | ||
return regeneratorRuntime.wrap(function _callee11$(_context11) { | ||
while (1) { | ||
switch (_context11.prev = _context11.next) { | ||
case 0: | ||
_context11.next = 2; | ||
return this.request({ | ||
method: 'POST', | ||
path: this.endpoint + '/' + userId + '/charge', | ||
body: charge | ||
}); | ||
case 2: | ||
return _context11.abrupt('return', _context11.sent); | ||
case 3: | ||
case 'end': | ||
return _context11.stop(); | ||
} | ||
} | ||
}, _callee11, this); | ||
})); | ||
function createCharge() { | ||
return _ref21.apply(this, arguments); | ||
} | ||
return createCharge; | ||
@@ -511,0 +547,0 @@ }() |
{ | ||
"name": "deskbookers", | ||
"version": "5.2.0", | ||
"version": "5.2.1", | ||
"description": "Deskbookers API JavaScript SDK", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -26,5 +26,5 @@ import dotenv from 'dotenv' | ||
const date = moment().subtract(2, 'months').calendar(); | ||
let booking = await deskbookers.bookings.month(date, 12686) | ||
console.dir(booking) | ||
t.truthy(booking) | ||
}) |
@@ -23,3 +23,4 @@ import dotenv from 'dotenv' | ||
const unread = await deskbookers.events.unread() | ||
t.truthy(unread.total) | ||
t.is(typeof unread.total, 'number') | ||
}) | ||
@@ -26,0 +27,0 @@ |
@@ -40,3 +40,2 @@ import dotenv from 'dotenv' | ||
const data = await deskbookers.notifications.list({userId: 999999999, start: 0, limit: 10, noCache: true}) | ||
console.log('list notifications', data) | ||
t.truthy(data) | ||
@@ -51,3 +50,2 @@ }) | ||
const data = await deskbookers.notifications.list({userId: 999999999, start: 0, limit: 10, type: 'corgi', noCache: true}) | ||
console.log('list notifications by type', data) | ||
t.truthy(data) | ||
@@ -62,3 +60,2 @@ }) | ||
const data = await deskbookers.notifications.list({userId: 999999999, start: 0, limit: 10, type: null, unread: true, noCache: true}) | ||
console.log('list unread notifications', data) | ||
t.truthy(data) | ||
@@ -73,3 +70,2 @@ }) | ||
const data = await deskbookers.notifications.list({userId: 999999999, start: 0, limit: 10, type: 'blue-corgi', unread: false, noCache: true}) | ||
console.log('list unread notifications by type', data) | ||
t.truthy(data) | ||
@@ -84,3 +80,2 @@ }) | ||
const data = await deskbookers.notifications.count({userId: 999999999, start: 0, limit: 10, noCache: true}) | ||
console.log('count notifications', data) | ||
t.truthy(data) | ||
@@ -95,3 +90,2 @@ }) | ||
const data = await deskbookers.notifications.count({userId: 999999999, start: 0, limit: 10, type: 'corgi', noCache: true}) | ||
console.log('count notifications by type', data) | ||
t.truthy(data) | ||
@@ -106,3 +100,2 @@ }) | ||
const data = await deskbookers.notifications.count({userId: 999999999, start: 0, limit: 10, type: null, unread: true, noCache: true}) | ||
console.log('count unread notifications', data) | ||
t.truthy(data) | ||
@@ -117,3 +110,2 @@ }) | ||
const data = await deskbookers.notifications.count({userId: 999999999, start: 0, limit: 10, type: 'blue-corgi', unread: false, noCache: true}) | ||
console.log('count read notifications by type', data) | ||
t.truthy(data) | ||
@@ -129,3 +121,3 @@ }) | ||
{ | ||
userId: 2, | ||
userId: 2, | ||
type: 'fluffycorgi', | ||
@@ -147,3 +139,3 @@ context: 'c12345', | ||
{ | ||
userId: 3, | ||
userId: 3, | ||
type: 'fluffycorgi', | ||
@@ -158,3 +150,3 @@ context: 'c12345', | ||
{ | ||
userId: 2, | ||
userId: 2, | ||
type: 'fluffycorgi', | ||
@@ -161,0 +153,0 @@ context: 'c12345', |
import dotenv from 'dotenv' | ||
import { get } from 'lodash' | ||
import 'fetch-everywhere' | ||
@@ -41,3 +42,2 @@ import test from 'ava' | ||
const data = await deskbookers.payments.invoices.list({}) | ||
console.log('list invoices', data) | ||
t.truthy(data) | ||
@@ -54,3 +54,2 @@ }) | ||
) | ||
console.log('get invoice', data) | ||
t.truthy(data) | ||
@@ -65,3 +64,2 @@ }) | ||
const data = await deskbookers.payments.plans.list({}) | ||
console.log('list plans', data) | ||
t.truthy(data) | ||
@@ -78,5 +76,4 @@ }) | ||
) | ||
console.log('get plan', data) | ||
t.truthy(data) | ||
}) | ||
}) | ||
@@ -91,3 +88,2 @@ test('payments subscriptions plan', async t => { | ||
) | ||
console.log('subscriptions plan', data) | ||
t.truthy(data) | ||
@@ -102,3 +98,2 @@ }) | ||
const data = await deskbookers.payments.subscriptions.list({limit: 1, status: 'active'}) | ||
console.log('list subscriptions', data) | ||
t.truthy(data) | ||
@@ -113,3 +108,2 @@ }) | ||
const data = await deskbookers.payments.subscriptions.get({subscriptionId: 'sub_B93SRrYAV6KF7V'}) | ||
console.log('get subscription', data) | ||
t.truthy(data) | ||
@@ -126,3 +120,2 @@ }) | ||
) | ||
console.log('get user', data) | ||
t.truthy(data) | ||
@@ -139,3 +132,2 @@ }) | ||
}) | ||
console.log('get user', data) | ||
t.truthy(data) | ||
@@ -152,3 +144,2 @@ }) | ||
}) | ||
console.log('get user', data) | ||
t.truthy(data) | ||
@@ -165,3 +156,2 @@ }) | ||
}) | ||
console.log('get user', data) | ||
t.truthy(data) | ||
@@ -179,3 +169,2 @@ }) | ||
}) | ||
console.log('create user', data) | ||
t.truthy(data) | ||
@@ -195,3 +184,2 @@ }) | ||
}) | ||
console.log('create source for user', data) | ||
t.truthy(data) | ||
@@ -227,7 +215,8 @@ }) | ||
}) | ||
console.log('create subscriptions for user', data) | ||
t.truthy(data) | ||
t.is(get(data, 'meta.userUid'), 'rb6-features') | ||
}) | ||
test('payments create subscriptions for user', async t => { | ||
test('payments create charge for user', async t => { | ||
// Prepare API | ||
@@ -248,3 +237,2 @@ const deskbookers = await client(true) | ||
}) | ||
console.log('create subscriptions for user', data) | ||
t.truthy(data) | ||
@@ -262,3 +250,2 @@ }) | ||
}) | ||
console.log('list user sources', data) | ||
t.truthy(data) | ||
@@ -272,7 +259,14 @@ }) | ||
// Create a source | ||
const source = await deskbookers.payments.users.createSource({ | ||
userId: 'rb5', | ||
token: 'tok_br', | ||
email: 'lomoa@lamao.comoa', | ||
setDefault: true | ||
}) | ||
const data = await deskbookers.payments.users.deleteSource({ | ||
userId: 'rb5', | ||
sourceId: 'src_1AmliGGAwNnYLy52m399REmA' | ||
sourceId: source.id | ||
}) | ||
console.log('delete user source', data) | ||
t.truthy(data) | ||
@@ -290,4 +284,3 @@ }) | ||
}) | ||
console.log('set user source source', data) | ||
t.truthy(data) | ||
}) |
368272
5834