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

Commit 8e5e3a2

Browse files
Merge pull request #56 from deskbookers/develop
Payments SetDefaultSource bug
2 parents 0c1dd7f + e6715fd commit 8e5e3a2

File tree

9 files changed

+23
-337
lines changed

9 files changed

+23
-337
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+
## 5.2.1 - 2017-08-21
8+
### Changes
9+
- Fixed `changeDefaultSource` with no body bug.
10+
711
## 5.2.0 - 2017-08-07
812
### Changes
913
- Added `payments` resource.

docs/payments.md

Lines changed: 0 additions & 166 deletions
Original file line numberDiff line numberDiff line change
@@ -1,109 +1,5 @@
11
# Payments
22

3-
## `invoices.list({limit, lastId})`
4-
List all avaiable invoices for a given `limit`, `lastId`
5-
6-
#### Params
7-
8-
| Name | Type | Required | Description |
9-
| ------- | ------ | -------- | ------------------------- |
10-
| limit | int | No | Limit results per request |
11-
| lastId | string | No | Used for Pagination |
12-
13-
```js
14-
const data = await deskbookers.payments.invoices.list({})
15-
```
16-
17-
## `invoices.get({invoiceId})`
18-
List all avaiable invoices for a given `invoiceId`
19-
20-
#### Params
21-
22-
| Name | Type | Required | Description |
23-
| --------- | ------ | -------- | ----------------------- |
24-
| invoiceId | int | Yes | Invoice Id |
25-
26-
```js
27-
const data = await deskbookers.payments.invoices.get(
28-
{invoiceId: 'in_1AmlLiGAwNnYLy52pW4WN9p1'}
29-
)
30-
```
31-
32-
## `plans.list({limit, lastId})`
33-
List all avaiable plans for a given `limit`, `lastId`
34-
35-
#### Params
36-
37-
| Name | Type | Required | Description |
38-
| ------- | ------ | -------- | ------------------------- |
39-
| limit | int | No | Limit results per request |
40-
| lastId | string | No | Used for Pagination |
41-
42-
```js
43-
const data = await deskbookers.payments.plans.list({})
44-
```
45-
46-
## `plans.get({planId})`
47-
List all avaiable plans for a given `planId`
48-
49-
#### Params
50-
51-
| Name | Type | Required | Description |
52-
| --------- | ------ | -------- | ----------------------- |
53-
| planId | int | Yes | Plan Id |
54-
55-
```js
56-
const data = await deskbookers.payments.plans.get(
57-
{planId: 'bookingTool-9900-1x-month-0'}
58-
)
59-
```
60-
61-
## `plans.subscriptions({planId})`
62-
List all avaiable subscriptions for a given `planId`
63-
64-
#### Params
65-
66-
| Name | Type | Required | Description |
67-
| --------- | ------ | -------- | ----------------------- |
68-
| planId | int | Yes | Plan Id |
69-
70-
```js
71-
const data = await deskbookers.payments.plans.get(
72-
{planId: 'bookingTool-9900-1x-month-0'}
73-
)
74-
```
75-
76-
## `subscriptions.list({limit, lastId, status})`
77-
List all avaiable subscriptions for a given `limit`, `lastId` and `status`
78-
79-
#### Params
80-
81-
| Name | Type | Required | Description |
82-
| ------- | ------ | -------- | ------------------------- |
83-
| limit | int | No | Limit results per request |
84-
| lastId | string | No | Used for Pagination |
85-
| status | string | No | Used for filtering |
86-
87-
```js
88-
const data = await deskbookers.payments.subscriptions.list(
89-
{limit: 1, status: 'active'}
90-
)
91-
```
92-
93-
## `subscriptions.get({subscriptionId})`
94-
Get subscription for a given `subscriptionId`
95-
96-
#### Params
97-
98-
| Name | Type | Required | Description |
99-
| -------------- | ------ | -------- | ------------------- |
100-
| subscriptionId | int | Yes | Subscription Id |
101-
102-
```js
103-
const data = await deskbookers.payments.subscriptions.get(
104-
{subscriptionId: 'sub_B93SRrYAV6KF7V'}
105-
)
106-
```
1073

1084
## `users.get({userId})`
1095
Get user for a given `userId`
@@ -211,68 +107,6 @@ const data = await deskbookers.payments.users.createSource({
211107
})
212108
```
213109

214-
## `users.createSubscription({userId, subscription})`
215-
Create subscriptions for a given `userId`
216-
217-
#### Params
218-
219-
| Name | Type | Required | Description |
220-
| -------------- | ------ | -------- | ------------------- |
221-
| userId | string | Yes | User Id |
222-
| subscription | object | Yes | Subscription Object |
223-
224-
#### Subscription
225-
226-
| Name | Type | Required | Description |
227-
| ------------- | ------ | -------- | --------------------- |
228-
| currency | string | Yes | Subscription currency |
229-
| userUid | string | Yes | Origin of 'features' |
230-
| interval | object | Yes | Subscription interval |
231-
| email | string | Yes | Subscription email |
232-
| vat | int | Yes | Subscription vat |
233-
| plans | object | Yes | Subscription Plans |
234-
235-
#### Interval
236-
237-
| Name | Type | Required | Description |
238-
| ----------- | ------ | -------- | ----------------------- |
239-
| period | string | Yes | Interval period |
240-
| count | int | Yes | Interval count |
241-
242-
#### plans
243-
244-
| Name | Type | Required | Description |
245-
| ----------- | ------ | -------- | ----------------------- |
246-
| feature | string | Yes | Plans feature |
247-
| name | string | Yes | Plans name |
248-
| amount | float | Yes | Plans amount |
249-
250-
251-
```js
252-
const data = await deskbookers.payments.users.createSubscription({
253-
userId: 'rb6',
254-
subscription: {
255-
currency: 'eur',
256-
userUid: 'features',
257-
interval: { period: 'month', count: 1 },
258-
259-
vat: 21,
260-
plans: [
261-
{
262-
feature: 'basic',
263-
name: 'Deskbookers for Partners Basic',
264-
amount: 10.0
265-
},
266-
{
267-
feature: 'bookingTool',
268-
name: 'Booking tool',
269-
amount: 99.0
270-
}
271-
]
272-
}
273-
})
274-
```
275-
276110
## `users.createCharge({userId, charge})`
277111
Create a charge for a given `userId` and `charge`
278112

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

src/resources/payments/Invoices.js

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

src/resources/payments/Plans.js

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

src/resources/payments/Subscriptions.js

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

src/resources/payments/Users.js

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -110,23 +110,6 @@ export default class Users extends Resource {
110110
})
111111
}
112112

113-
/**
114-
* Create subscription for users
115-
*
116-
* @param {int} userId - User Id.
117-
* @param {string} token - Source token.
118-
* @param {string} email - Email Source token.
119-
* @param {bool} setDefault - Default flag token.
120-
* @return {Object[]} - sources.
121-
*/
122-
async createSubscription ({userId, subscription} = {}) {
123-
return await this.request({
124-
method: 'POST',
125-
path: `${this.endpoint}/${userId}/subscriptions`,
126-
body: subscription || {}
127-
})
128-
}
129-
130113
/**
131114
* Get user souces
132115
*
@@ -169,7 +152,8 @@ export default class Users extends Resource {
169152
async setDefaultSource ({userId, sourceId} = {}) {
170153
return await this.request({
171154
method: 'PUT',
172-
path: `${this.endpoint}/${userId}/defaultsource/${sourceId}`
155+
path: `${this.endpoint}/${userId}/defaultsource/${sourceId}`,
156+
body: { sourceId }
173157
})
174158
}
175159

src/resources/payments/index.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
import Resource from '../Resource'
22
import Users from './Users'
3-
import Plans from './Plans'
4-
import Subscriptions from './Subscriptions'
5-
import Invoices from './Invoices'
63

74
export default class Payments extends Resource {
85
constructor (api) {
96
super(api)
107
// Create sub-resources
118
this.users = new Users(api)
12-
this.plans = new Plans(api)
13-
this.subscriptions = new Subscriptions(api)
14-
this.invoices = new Invoices(api)
159
}
1610
}

0 commit comments

Comments
 (0)