Skip to content
This repository was archived by the owner on May 28, 2024. It is now read-only.

Commit 383d3d1

Browse files
Merge pull request #41 from deskbookers/ft-DSK-stayed-bookings-pure
feat: new bookings endpoint for stayed bookings
2 parents 102cf84 + ee8c019 commit 383d3d1

File tree

7 files changed

+129
-4
lines changed

7 files changed

+129
-4
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,6 @@ for (let workplace of workplaces) {
6868
* [`delete(featureName)`](docs/features.md#deletefeaturename)
6969
* [`listByVenue(venueId)`](docs/features.md#listbyvenuevenueid)
7070
* [`checkFeatureByVenue(venueId, featureName)`](docs/features.md#checkfeaturebyvenuevenueid-featureName)
71-
* [`updateFeatureByVenue(venueId, featureName, feature)`](docs/features.md#updatefeaturebyvenuevenueid-featurename-feature)
71+
* [`updateFeatureByVenue(venueId, featureName, feature)`](docs/features.md#updatefeaturebyvenuevenueid-featurename-feature)
72+
* bookings
73+
* [`month(date, venueId)`](docs/bookings.md#monthdate-venueid)

docs/bookings.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Bookings
2+
3+
## `month(date, venueId)`
4+
Retrieve month bookings for a given venueId and date (only month & year used)
5+
6+
```js
7+
await deskbookers.bookings.month(
8+
date,
9+
venueId
10+
)
11+
```
12+
#### Example response
13+
```json
14+
[
15+
{
16+
"bookingId": 262655,
17+
"bookerId": 21403,
18+
"bookerName": "Bureau Voorlichting Binnenvaart",
19+
"resellerId": 10000,
20+
"resellerName": "Deskbookers.com",
21+
"bookerGroupId": null,
22+
"bookerGroupName": null,
23+
"start": "2017-06-13T10:30:00+02:00",
24+
"end": "2017-06-13T12:30:00+02:00",
25+
"items": [
26+
{
27+
"name": "Vergaderruimte E1",
28+
"price": 0,
29+
"vat": 21,
30+
"quantity": 1
31+
},
32+
{
33+
"name": "Waterkan en glazen",
34+
"price": 0,
35+
"vat": 0,
36+
"quantity": 1
37+
},
38+
{
39+
"name": "Theekan",
40+
"price": 5.66,
41+
"vat": 6,
42+
"quantity": 1
43+
},
44+
{
45+
"name": "Koffiekan",
46+
"price": 14.16,
47+
"vat": 6,
48+
"quantity": 2
49+
}
50+
]
51+
},
52+
{
53+
"bookingId": 264346,
54+
"bookerId": 28106,
55+
"bookerName": "Mevr. Wendela Andreae",
56+
"resellerId": 10000,
57+
"resellerName": "Deskbookers.com",
58+
"bookerGroupId": null,
59+
"bookerGroupName": null,
60+
"start": "2017-06-09T12:00:00+02:00",
61+
"end": "2017-06-09T15:00:00+02:00",
62+
"items": [
63+
{
64+
"name": "Vergaderruimte E1",
65+
"price": 0,
66+
"vat": 21,
67+
"quantity": 1
68+
}
69+
]
70+
}
71+
]
72+
```

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "deskbookers",
3-
"version": "3.1.5",
3+
"version": "3.2.5",
44
"description": "Deskbookers API JavaScript SDK",
55
"main": "dist/index.js",
66
"scripts": {

src/resources/Bookings.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import Resource from './Resource'
2+
import { DeskbookersError } from '../errors'
3+
4+
export default class Bookings extends Resource {
5+
constructor (api) {
6+
super(api)
7+
}
8+
9+
async month (date, venueId) {
10+
return await this.request({
11+
method: 'GET',
12+
path: `/booking/month`,
13+
params: {
14+
date,
15+
venueId
16+
}
17+
})
18+
}
19+
20+
}

src/resources/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Cart from './Cart'
55
import Events from './Events'
66
import Features from './Features'
77
import Spaces from './Spaces'
8+
import Bookings from './Bookings'
89

910
export default {
1011
account: Account,
@@ -13,5 +14,6 @@ export default {
1314
cart: Cart,
1415
events: Events,
1516
features: Features,
16-
spaces: Spaces
17+
spaces: Spaces,
18+
bookings: Bookings
1719
}

src/utils/requests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { hmac, sha512 } from 'hash.js'
22
import { parse } from 'url'
33
import { stringify } from 'qs'
44
import jsonEncode from 'json_encode'
5-
import urlencode from 'phpurlencode'
5+
import urlencode from 'deskbookers-phpurlencode'
66
import { includes, isEmpty } from 'lodash'
77

88
export const signer = ({ publicKey, privateKey }, url, options, args) => {

test/bookings.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import dotenv from 'dotenv'
2+
import 'fetch-everywhere'
3+
import test from 'ava'
4+
import moment from 'moment'
5+
import Deskbookers from '../src'
6+
7+
import util from 'util'
8+
9+
dotenv.load()
10+
11+
async function client (login = false) {
12+
const deskbookers = new Deskbookers({
13+
https: process.env.API_HTTPS === 'true',
14+
host: process.env.API_HOST
15+
})
16+
17+
if (login) {
18+
await deskbookers.account.login(process.env.LOGIN_EMAIL, process.env.LOGIN_PASSWORD)
19+
}
20+
return deskbookers
21+
}
22+
23+
test('Get booking', async t => {
24+
const deskbookers = await client(true)
25+
const date = moment().subtract(2, 'months').calendar();
26+
27+
let booking = await deskbookers.bookings.month(date, 12686)
28+
console.dir(booking)
29+
})

0 commit comments

Comments
 (0)