rejoiner 2.11.1 → 2.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/endpoints/sessions.js +29 -0
- package/lib/helpers.js +3 -1
- package/package.json +1 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const { dateString, withClient } = require('../helpers')
|
|
2
|
+
|
|
3
|
+
const sessionsEndpoint = (client) => {
|
|
4
|
+
const endpoint = 'sessions'
|
|
5
|
+
|
|
6
|
+
const { dispatchReturnData } = withClient(client)
|
|
7
|
+
|
|
8
|
+
return {
|
|
9
|
+
path: endpoint,
|
|
10
|
+
update: (sessionId, data = {}) => {
|
|
11
|
+
const {
|
|
12
|
+
paymentDate,
|
|
13
|
+
fulfillmentDate,
|
|
14
|
+
deliveryDate,
|
|
15
|
+
metadata,
|
|
16
|
+
} = data
|
|
17
|
+
|
|
18
|
+
const payload = { metadata }
|
|
19
|
+
|
|
20
|
+
if (paymentDate) payload.payment_date = dateString(paymentDate)
|
|
21
|
+
if (fulfillmentDate) payload.fulfillment_date = dateString(fulfillmentDate)
|
|
22
|
+
if (deliveryDate) payload.delivery_date = dateString(deliveryDate)
|
|
23
|
+
|
|
24
|
+
return dispatchReturnData('put')(`/${endpoint}/${sessionId}/`, payload)
|
|
25
|
+
},
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
module.exports = sessionsEndpoint
|
package/lib/helpers.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
const dateString = (date) => new Date(date).toISOString()
|
|
2
|
+
|
|
1
3
|
const withClient = (client) => {
|
|
2
4
|
const dispatchReturnData = (method) => (...args) => client.dispatch[method](...args)
|
|
3
5
|
.then((res) => res.data)
|
|
@@ -28,4 +30,4 @@ const withClient = (client) => {
|
|
|
28
30
|
}
|
|
29
31
|
}
|
|
30
32
|
|
|
31
|
-
module.exports = { withClient }
|
|
33
|
+
module.exports = { dateString, withClient }
|
package/package.json
CHANGED