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

Commit 6a212bd

Browse files
committed
fix: attach Actions resource to global class
1 parent a606e4a commit 6a212bd

File tree

10 files changed

+31
-23
lines changed

10 files changed

+31
-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+
## 2.1.1 - 2017-05-23
8+
### Fixed
9+
- Attached `Actions` resource to global class
10+
711
## 2.1.0 - 2017-05-23
812
### Added
913
- `setTimezone`, `setLanguage` and `preferences` methods to `Account` resource

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

src/DeskbookersError.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/InvalidResponseError.js renamed to src/errors.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
import DeskbookersError from './DeskbookersError'
2-
31
const MAX_ERROR_LENGTH = 100
42

5-
export default class InvalidResponseError extends DeskbookersError {
3+
export class DeskbookersError extends Error {
4+
constructor (message) {
5+
super(message)
6+
this.name = 'DeskbookersError'
7+
}
8+
}
9+
10+
export class InvalidResponseError extends DeskbookersError {
611
constructor (text) {
712
// Prepare text
813
text = `${text || ''}`
14+
915
if (text.length > MAX_ERROR_LENGTH) {
1016
text = `${text.substr(0, MAX_ERROR_LENGTH)}...`
1117
}

src/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Account from './resources/account'
2+
import Actions from './resources/actions'
23
import Cart from './resources/Cart'
34
import Events from './resources/Events'
45
import Workplaces from './resources/Workplaces'
@@ -10,6 +11,7 @@ const API_RESELLER_ID = 10000
1011

1112
const resources = {
1213
account: Account,
14+
actions: Actions,
1315
cart: Cart,
1416
events: Events,
1517
workplaces: Workplaces
@@ -32,8 +34,8 @@ export default class Deskbookers {
3234
this.session = null
3335

3436
// Init resources
35-
for (let name in resources) {
36-
this[name] = new resources[name](this)
37+
for (const resource in resources) {
38+
this[resource] = new resources[resource](this)
3739
}
3840
}
3941
}

src/resources/Events.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Resource from './Resource'
2-
import DeskbookersError from '../DeskbookersError'
2+
import { DeskbookersError } from '../errors'
33

44
export default class Events extends Resource {
55
constructor (api) {

src/resources/Resource.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { signer, formatArgs } from '../utils/requests'
2-
import DeskbookersError from '../DeskbookersError'
3-
import InvalidResponseError from '../InvalidResponseError'
2+
import {
3+
DeskbookersError,
4+
InvalidResponseError
5+
} from '../errors'
46

57
export default class Resource {
68
constructor (api) {

src/resources/Workplaces.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Resource from './Resource'
2-
import DeskbookersError from '../DeskbookersError'
2+
import { DeskbookersError } from '../errors'
33

44
export default class Workplaces extends Resource {
55
constructor (api) {

src/resources/account/Preferences.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import DeskbookersError from '../../DeskbookersError'
1+
import { DeskbookersError } from '../../errors'
22
import Resource from '../Resource'
33
import { pickAll } from 'ramda'
44

test/actions.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ test('Reporting a problem', async t => {
1919
process.env.LOGIN_PASSWORD
2020
)
2121

22-
const res = await deskbookers.actions.report(
22+
const res = await deskbookers.actions.report({
2323
message: 'This function aint working!',
2424
category: 'Bugs',
2525
browser: 'IE6',
2626
page: '/home',
2727
context: 'Provider mode',
28-
extras: [
29-
'day' => 'It was on a sunday',
30-
'weather' => 'It was rainy'
31-
]
32-
)
28+
extras: {
29+
day: 'It was on a sunday',
30+
weather: 'It was rainy'
31+
}
32+
})
3333

3434
t.truthy(res)
3535
})

0 commit comments

Comments
 (0)