deskbookers
Advanced tools
Comparing version 5.4.1 to 5.5.0
(function (global, factory) { | ||
if (typeof define === "function" && define.amd) { | ||
define(['module', 'exports', '../Resource', './Bookings'], factory); | ||
define(['module', 'exports', '../Resource', './Bookings', './BookingReferrers'], factory); | ||
} else if (typeof exports !== "undefined") { | ||
factory(module, exports, require('../Resource'), require('./Bookings')); | ||
factory(module, exports, require('../Resource'), require('./Bookings'), require('./BookingReferrers')); | ||
} else { | ||
@@ -10,6 +10,6 @@ var mod = { | ||
}; | ||
factory(mod, mod.exports, global.Resource, global.Bookings); | ||
factory(mod, mod.exports, global.Resource, global.Bookings, global.BookingReferrers); | ||
global.index = mod.exports; | ||
} | ||
})(this, function (module, exports, _Resource2, _Bookings) { | ||
})(this, function (module, exports, _Resource2, _Bookings, _BookingReferrers) { | ||
'use strict'; | ||
@@ -25,2 +25,4 @@ | ||
var _BookingReferrers2 = _interopRequireDefault(_BookingReferrers); | ||
function _interopRequireDefault(obj) { | ||
@@ -74,2 +76,3 @@ return obj && obj.__esModule ? obj : { | ||
_this.bookings = new _Bookings2.default(api); | ||
_this.bookingReferrers = new _BookingReferrers2.default(api); | ||
return _this; | ||
@@ -76,0 +79,0 @@ } |
@@ -148,3 +148,3 @@ (function (global, factory) { | ||
url = void 0; | ||
pathFixed = path.replace(/^\/+|\/+$/, ''); | ||
pathFixed = ('' + (path || '')).replace(/^\/+|\/+$/, ''); | ||
@@ -258,3 +258,3 @@ | ||
_error = _context2.t2.value; | ||
throw new _errors2.DeskbookersError(_errors[_error]); | ||
throw new _errors2.DeskbookersError(_errors[_error] + ' (' + url + ')'); | ||
@@ -270,3 +270,3 @@ case 25: | ||
msg = data.errorMessage || 'An error occurred'; | ||
msg = (data.errorMessage || 'An error occurred') + ' (' + url + ')'; | ||
throw new _errors2.DeskbookersError(msg); | ||
@@ -277,3 +277,3 @@ | ||
errors.map(function (error) { | ||
throw new _errors2.DeskbookersError(error.title + ': ' + error.detail); | ||
throw new _errors2.DeskbookersError(error.title + ': ' + error.detail + ' (' + url + ')'); | ||
}); | ||
@@ -283,3 +283,3 @@ } | ||
case 34: | ||
throw new _errors2.DeskbookersError('Invalid response received'); | ||
throw new _errors2.DeskbookersError('Invalid response received (' + url + ')'); | ||
@@ -286,0 +286,0 @@ case 35: |
@@ -5,3 +5,4 @@ # Reports | ||
## `bookings.enquire({venueId, type, start, end, task})` | ||
### `bookings.enquire({venueId, type, start, end, task})` | ||
Get booking reports for a given `venueId` | ||
@@ -29,7 +30,8 @@ | ||
## `bookings.retrieve({venueId, type, jobId})` | ||
Get async booking reports for a given `venueId` and `jobId`, | ||
if `task` was sent as `true` on `booking.enquire`, an `jobId` | ||
### `bookings.retrieve({venueId, type, jobId})` | ||
Get async booking reports for a given `venueId` and `jobId`, | ||
if `task` was sent as `true` on `booking.enquire`, an `jobId` | ||
is returned and when passed to `retrieve` it will get the actual | ||
processing state and return the percentage, status and the actual | ||
processing state and return the percentage, status and the actual | ||
data if available. | ||
@@ -52,1 +54,46 @@ | ||
``` | ||
## Booking referrers | ||
### `bookingReferrers.enquire({start, end, autoRetrieve})` | ||
Get booking referrers report for a given date range. | ||
#### Params | ||
| Name | Type | Required | Description | | ||
| ------------ | ------ | -------- | ---------------------------------------- | | ||
| start | string | No | Only consider data after this start date | | ||
| end | string | No | Only consider data untul this end date | | ||
| autoRetrieve | bool | No | Auto retrieve the result of the report and return everything as a promise (enabled by default) | | ||
```js | ||
const data = await deskbookers.reports.bookingReferrers.enquire({ | ||
start: '2017-09-01' | ||
}) | ||
console.log(data.url) // URL to download the report | ||
``` | ||
### `bookingReferrers.retrieve({jobId})` | ||
Get async booking referrers reports for a given `jobId`. | ||
#### Params | ||
| Name | Type | Required | Description | | ||
| -------------- | ------ | -------- | ------------------- | | ||
| jobId | int | Yes | Async job id | | ||
```js | ||
const { jobInfo } = await deskbookers.reports.bookingReferrers.enquire({ | ||
start: '2017-09-01', | ||
autoRetrieve: false | ||
}) | ||
let data | ||
do { | ||
data = await deskbookers.reports.bookingReferrers.retrieve({ | ||
jobId: jobInfo.id | ||
}) | ||
} while (data.jobInfo.state !== 'complete' && data.jobInfo.state !== 'failed'); | ||
console.log(data.url) | ||
``` |
{ | ||
"name": "deskbookers", | ||
"version": "5.4.1", | ||
"version": "5.5.0", | ||
"description": "Deskbookers API JavaScript SDK", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -99,1 +99,3 @@ # Deskbookers JavaScript SDK | ||
* [`reports.bookings.retrieve({venueId, type, jobId})`](docs/reports.md#bookingsretrievevenueid-type-jobid) | ||
* [`bookingReferrers.enquire({start, end, autoResolve})`](docs/reports.md#bookingreferrersenquirestart-end-autoresolve) | ||
* [`bookingReferrers.retrieve({jobId})`](docs/reports.md#bookingreferrersretrievejobid) |
@@ -35,6 +35,7 @@ import dotenv from 'dotenv' | ||
test('enquire and booking report', async t => { | ||
test('enquire a booking report', async t => { | ||
// Prepare API | ||
const deskbookers = await client(true) | ||
t.truthy(deskbookers.session) | ||
const data = await deskbookers.reports.bookings.enquire({ | ||
@@ -50,6 +51,7 @@ venueId: 39418, | ||
test('request and booking report', async t => { | ||
test('request a booking report', async t => { | ||
// Prepare API | ||
const deskbookers = await client(true) | ||
t.truthy(deskbookers.session) | ||
const data = await deskbookers.reports.bookings.retrieve({ | ||
@@ -63,1 +65,47 @@ venueId: 39418, | ||
test('enquire an auto resolving booking referrers report', async t => { | ||
// Prepare API | ||
const deskbookers = await client(true) | ||
t.truthy(deskbookers.session) | ||
const data = await deskbookers.reports.bookingReferrers.enquire({ | ||
start: '2017-09-01', | ||
end: '2017-09-02' | ||
}) | ||
t.truthy(data.url) | ||
t.truthy(data.jobInfo) | ||
t.truthy(data.jobInfo.id) | ||
}) | ||
test('enquire an non auto resolving booking referrers report', async t => { | ||
// Prepare API | ||
const deskbookers = await client(true) | ||
t.truthy(deskbookers.session) | ||
const data = await deskbookers.reports.bookingReferrers.enquire({ | ||
start: '2017-09-01', | ||
end: '2017-09-02', | ||
autoRetrieve: false | ||
}) | ||
t.falsy(data.url) | ||
t.truthy(data.jobInfo) | ||
t.truthy(data.jobInfo.id) | ||
}) | ||
test('retrieve a booking referrers report', async t => { | ||
// Prepare API | ||
const deskbookers = await client(true) | ||
t.truthy(deskbookers.session) | ||
const data = await deskbookers.reports.bookingReferrers.enquire({ | ||
start: '2017-09-01', | ||
end: '2017-09-02', | ||
autoRetrieve: false | ||
}) | ||
const data2 = await deskbookers.reports.bookingReferrers.retrieve({ | ||
jobId: get(data, 'jobInfo.id') | ||
}) | ||
t.truthy(data2) | ||
t.truthy(data2.jobInfo) | ||
t.truthy(data2.jobInfo.id) | ||
}) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
368398
54
5886
101