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

Commit c244082

Browse files
authored
Merge pull request #19 from deskbookers/develop
v1.3.1
2 parents 49e9711 + 03352a1 commit c244082

File tree

9 files changed

+19
-23
lines changed

9 files changed

+19
-23
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/)
55
and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
## 1.3.1 - 2017-04-25
8+
### Fixed
9+
- `POST` request bug
10+
711
## 1.3.0 - 2017-04-19
812
### Changed
913
- Added `backoffice` parameter to `account.login`

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": "1.3.0",
3+
"version": "1.3.1",
44
"description": "Deskbookers API JavaScript SDK",
55
"main": "dist/index.js",
66
"scripts": {

src/resources/Account.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ import Resource from './Resource'
22
import bcrypt from 'bcryptjs'
33

44
export default class Account extends Resource {
5-
constructor (api) {
6-
super(api)
7-
}
8-
95
async retrieveSalt (email) {
106
return await this.request({
117
method: 'GET',
@@ -86,7 +82,7 @@ export default class Account extends Resource {
8682
email,
8783
name: fullName,
8884
first_name: firstName,
89-
lastName,
85+
lastName
9086
} = result.user
9187

9288
return {

src/resources/Cart.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ export default class Cart extends Resource {
102102
params: {
103103
group: this.getGroup(),
104104
voucherCode: this.getVoucherCode(),
105-
ignoreBooking: ignoreBooking && ignoreBooking.id || null,
106-
action: ignoreBooking && ignoreBooking.action || null,
105+
ignoreBooking: (ignoreBooking && ignoreBooking.id) || null,
106+
action: (ignoreBooking && ignoreBooking.action) || null,
107107
batch
108108
}
109109
})
@@ -341,5 +341,5 @@ export const normalizeDate = (date) => date ? moment(date) : null
341341

342342
export const unix = (date) => {
343343
const normalized = normalizeDate(date)
344-
return normalized && normalized.unix() || null
344+
return (normalized && normalized.unix()) || null
345345
}

src/resources/Resource.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export default class Resource {
1919
mode = 'cors',
2020
credentials = 'include'
2121
}) {
22+
method = method.toUpperCase()
2223
const options = {
2324
mode,
2425
credentials,
@@ -31,11 +32,11 @@ export default class Resource {
3132
__fields: fields,
3233
...params
3334
}
34-
const queryStr = formatArgs(args, options.method === 'post')
35+
const queryStr = formatArgs(args, options.method === 'POST')
3536
const pathFixed = path.replace(/^\/+|\/+$/, '')
3637

3738
let url
38-
if (options.method === 'post') {
39+
if (options.method === 'POST') {
3940
options.headers['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8'
4041
options.body = queryStr
4142
url = `${this.apiUrl}/${pathFixed}`
@@ -69,27 +70,24 @@ export default class Resource {
6970
// If "data" exists in response
7071
if (dataProp) {
7172
return dataProp
72-
}
7373

7474
// If "result" exists in response
75-
else if (result) {
75+
} else if (result) {
7676
const { errors } = result
7777
if (errors) {
7878
for (let error in errors) {
7979
throw new Error(errors[error])
8080
}
8181
}
8282
return result
83-
}
8483

8584
// If "error" exists in response
86-
else if (error) {
85+
} else if (error) {
8786
const msg = data.errorMessage || 'An error occurred'
8887
throw new Error(msg)
89-
}
9088

9189
// If "errors" exists in response
92-
else if (errors) {
90+
} else if (errors) {
9391
for (let error in errors) {
9492
const msg = errors[error].title || errors[error].detail
9593
throw new Error(msg)

test/account.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,6 @@ test('Logout', async t => {
5252

5353
test('Retrieve', async t => {
5454
t.throws(deskbookers.account.retrieve())
55-
const login = await deskbookers.account.login(LOGIN_EMAIL, LOGIN_PASSWORD)
55+
await deskbookers.account.login(LOGIN_EMAIL, LOGIN_PASSWORD)
5656
t.notThrows(deskbookers.account.retrieve())
5757
})

test/cart.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const deskbookers = new Deskbookers({
1414
test('Test cart availability', async t => {
1515
const cart = await prepareCart(t)
1616

17-
t.true(deskbookers.cart.available())
17+
t.true(cart.available())
1818

1919
// TODO: test more
2020
})
@@ -39,7 +39,7 @@ const prepareCart = async (t) => {
3939

4040
return deskbookers.cart
4141
} catch (e) {
42-
t.fail(`Error while preparing cart: ${e && e.message || 'Exception occurred'}`)
42+
t.fail(`Error while preparing cart: ${(e && e.message) || 'Exception occurred'}`)
4343
return deskbookers.cart
4444
}
4545
}

test/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ import dotenv from 'dotenv'
22
import 'fetch-everywhere'
33
import test from 'ava'
44
import Deskbookers from '../src'
5-
import moment from 'moment'
65
dotenv.load()
76

8-
97
// Shopping cart
108
test('Initialise', async t => {
119
const deskbookers = new Deskbookers({

test/workplaces.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ test('Urgency', async t => {
1919
const request = [
2020
{ type: 'bookings', start, end },
2121
{ type: 'visitors', start, end },
22-
{ type: 'visitors', city: 'amsterdam', start, end },
22+
{ type: 'visitors', city: 'amsterdam', start, end }
2323
]
2424

2525
const response = await deskbookers.workplaces.urgency(17657, request)

0 commit comments

Comments
 (0)