btrz-api-client 9.31.0 → 9.33.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/client-standalone-min.js +5 -5
- package/lib/endpoints/accounts/current-shifts.js +24 -1
- package/lib/endpoints/btrzpay/stripe-terminals.js +4 -1
- package/package.json +1 -1
- package/src/endpoints/accounts/current-shifts.js +16 -1
- package/src/endpoints/btrzpay/stripe-terminals.js +4 -2
- package/test/endpoints/accounts/current-shifts.test.js +8 -0
- package/test/endpoints/btrzpay/stripe-terminals.tests.js +3 -2
- package/types/endpoints/accounts/current-shifts.d.ts +2 -1
|
@@ -42,8 +42,31 @@ function currentShiftsFactory({
|
|
|
42
42
|
params: query
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* GET /users/:userId/current-shift-location - location `_id`, `name`, and `zone` for the open shift.
|
|
48
|
+
* @param {Object} opts
|
|
49
|
+
* @param {string} [opts.token] - API key
|
|
50
|
+
* @param {string} opts.userId - User id (ObjectId)
|
|
51
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
52
|
+
* @returns {Promise<import("axios").AxiosResponse>}
|
|
53
|
+
*/
|
|
54
|
+
function getLocation({
|
|
55
|
+
token,
|
|
56
|
+
userId,
|
|
57
|
+
headers
|
|
58
|
+
}) {
|
|
59
|
+
return client.get(`/users/${userId}/current-shift-location`, {
|
|
60
|
+
headers: authorizationHeaders({
|
|
61
|
+
token,
|
|
62
|
+
internalAuthTokenProvider,
|
|
63
|
+
headers
|
|
64
|
+
})
|
|
65
|
+
});
|
|
66
|
+
}
|
|
45
67
|
return {
|
|
46
|
-
get
|
|
68
|
+
get,
|
|
69
|
+
getLocation
|
|
47
70
|
};
|
|
48
71
|
}
|
|
49
72
|
module.exports = currentShiftsFactory;
|
|
@@ -57,12 +57,13 @@ function stripeTerminalsFactory({
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
|
-
* POST /stripe-terminals/:terminalId/simulate - simulate a payment on a Stripe Terminal reader.
|
|
60
|
+
* POST /stripe-terminals/:terminalId/simulate - simulate a payment on a Stripe Terminal reader.
|
|
61
61
|
* @param {Object} opts
|
|
62
62
|
* @param {string} [opts.token] - API key
|
|
63
63
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
64
64
|
* @param {string} opts.id - Terminal ID (Stripe reader id, e.g. tmr_xxx)
|
|
65
65
|
* @param {{ ccNumber: string }} opts.stripePayment - Payment to simulate; ccNumber required
|
|
66
|
+
* @param {StripeTerminalsListQuery} [opts.query] - Optional providerId for agencies/sellers
|
|
66
67
|
* @param {Object} [opts.headers] - Optional headers
|
|
67
68
|
* @returns {Promise<import("axios").AxiosResponse<{ stripeTerminalPayment: Object }>>}
|
|
68
69
|
* Rejects with 400 (WRONG_DATA), 401,
|
|
@@ -74,6 +75,7 @@ function stripeTerminalsFactory({
|
|
|
74
75
|
jwtToken,
|
|
75
76
|
id,
|
|
76
77
|
stripePayment,
|
|
78
|
+
query = {},
|
|
77
79
|
headers
|
|
78
80
|
}) {
|
|
79
81
|
return client({
|
|
@@ -85,6 +87,7 @@ function stripeTerminalsFactory({
|
|
|
85
87
|
internalAuthTokenProvider,
|
|
86
88
|
headers
|
|
87
89
|
}),
|
|
90
|
+
params: query,
|
|
88
91
|
data: {
|
|
89
92
|
stripePayment
|
|
90
93
|
}
|
package/package.json
CHANGED
|
@@ -31,8 +31,23 @@ function currentShiftsFactory({client, internalAuthTokenProvider}) {
|
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
/**
|
|
35
|
+
* GET /users/:userId/current-shift-location - location `_id`, `name`, and `zone` for the open shift.
|
|
36
|
+
* @param {Object} opts
|
|
37
|
+
* @param {string} [opts.token] - API key
|
|
38
|
+
* @param {string} opts.userId - User id (ObjectId)
|
|
39
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
40
|
+
* @returns {Promise<import("axios").AxiosResponse>}
|
|
41
|
+
*/
|
|
42
|
+
function getLocation({token, userId, headers}) {
|
|
43
|
+
return client.get(`/users/${userId}/current-shift-location`, {
|
|
44
|
+
headers: authorizationHeaders({token, internalAuthTokenProvider, headers})
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
34
48
|
return {
|
|
35
|
-
get
|
|
49
|
+
get,
|
|
50
|
+
getLocation
|
|
36
51
|
};
|
|
37
52
|
}
|
|
38
53
|
|
|
@@ -46,23 +46,25 @@ function stripeTerminalsFactory({client, internalAuthTokenProvider}) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
|
-
* POST /stripe-terminals/:terminalId/simulate - simulate a payment on a Stripe Terminal reader.
|
|
49
|
+
* POST /stripe-terminals/:terminalId/simulate - simulate a payment on a Stripe Terminal reader.
|
|
50
50
|
* @param {Object} opts
|
|
51
51
|
* @param {string} [opts.token] - API key
|
|
52
52
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
53
53
|
* @param {string} opts.id - Terminal ID (Stripe reader id, e.g. tmr_xxx)
|
|
54
54
|
* @param {{ ccNumber: string }} opts.stripePayment - Payment to simulate; ccNumber required
|
|
55
|
+
* @param {StripeTerminalsListQuery} [opts.query] - Optional providerId for agencies/sellers
|
|
55
56
|
* @param {Object} [opts.headers] - Optional headers
|
|
56
57
|
* @returns {Promise<import("axios").AxiosResponse<{ stripeTerminalPayment: Object }>>}
|
|
57
58
|
* Rejects with 400 (WRONG_DATA), 401,
|
|
58
59
|
* 404 (PAYMENT_METHOD_NOT_FOUND, TRANSACTION_NOT_FOUND),
|
|
59
60
|
* 409 (errorCode/errorMessage), 500.
|
|
60
61
|
*/
|
|
61
|
-
function simulate({token, jwtToken, id, stripePayment, headers}) {
|
|
62
|
+
function simulate({token, jwtToken, id, stripePayment, query = {}, headers}) {
|
|
62
63
|
return client({
|
|
63
64
|
url: `/stripe-terminals/${id}/simulate`,
|
|
64
65
|
method: "post",
|
|
65
66
|
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
|
|
67
|
+
params: query,
|
|
66
68
|
data: {stripePayment}
|
|
67
69
|
});
|
|
68
70
|
}
|
|
@@ -16,4 +16,12 @@ describe("accounts/users/:userId/current-shift", () => {
|
|
|
16
16
|
.reply(expectRequest({statusCode: 200, token}));
|
|
17
17
|
return api.accounts.currentShifts.get({token, userId, query});
|
|
18
18
|
});
|
|
19
|
+
|
|
20
|
+
it("should get current-shift-location", () => {
|
|
21
|
+
const userId = "userId1";
|
|
22
|
+
|
|
23
|
+
axiosMock.onGet(`/users/${userId}/current-shift-location`)
|
|
24
|
+
.reply(expectRequest({statusCode: 200, token}));
|
|
25
|
+
return api.accounts.currentShifts.getLocation({token, userId});
|
|
26
|
+
});
|
|
19
27
|
});
|
|
@@ -30,13 +30,14 @@ describe("btrzpay/stripe-terminals", () => {
|
|
|
30
30
|
const terminalId = "tm_123";
|
|
31
31
|
const body = {stripePayment};
|
|
32
32
|
axiosMock.onPost(`/stripe-terminals/${terminalId}/simulate`, body).reply(expectRequest({
|
|
33
|
-
statusCode: 200, token, jwtToken
|
|
33
|
+
statusCode: 200, token, jwtToken, query
|
|
34
34
|
}));
|
|
35
35
|
return api.btrzpay.stripeTerminals.simulate({
|
|
36
36
|
id: terminalId,
|
|
37
37
|
token,
|
|
38
38
|
jwtToken,
|
|
39
|
-
stripePayment
|
|
39
|
+
stripePayment,
|
|
40
|
+
query
|
|
40
41
|
});
|
|
41
42
|
});
|
|
42
43
|
});
|
|
@@ -4,7 +4,7 @@ export = currentShiftsFactory;
|
|
|
4
4
|
* @param {Object} deps
|
|
5
5
|
* @param {import("axios").AxiosInstance} deps.client
|
|
6
6
|
* @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
|
|
7
|
-
* @returns {{ get: function }}
|
|
7
|
+
* @returns {{ get: function, getLocation: function }}
|
|
8
8
|
*/
|
|
9
9
|
declare function currentShiftsFactory({ client, internalAuthTokenProvider }: {
|
|
10
10
|
client: import("axios").AxiosInstance;
|
|
@@ -13,4 +13,5 @@ declare function currentShiftsFactory({ client, internalAuthTokenProvider }: {
|
|
|
13
13
|
};
|
|
14
14
|
}): {
|
|
15
15
|
get: Function;
|
|
16
|
+
getLocation: Function;
|
|
16
17
|
};
|