btrz-api-client 9.2.0 → 9.3.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.
|
@@ -23,7 +23,7 @@ const {
|
|
|
23
23
|
* @param {Object} deps
|
|
24
24
|
* @param {import("axios").AxiosInstance} deps.client
|
|
25
25
|
* @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
|
|
26
|
-
* @returns {{ put: function, all: function, create: function, signIn: function, signInCas: function, update: function, merge: function }}
|
|
26
|
+
* @returns {{ put: function, all: function, get: function, create: function, signIn: function, signInCas: function, update: function, merge: function }}
|
|
27
27
|
*/
|
|
28
28
|
function customersFactory({
|
|
29
29
|
client,
|
|
@@ -91,6 +91,32 @@ function customersFactory({
|
|
|
91
91
|
});
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
/**
|
|
95
|
+
* GET /customers/:customerId - get a customer by id.
|
|
96
|
+
* @param {Object} opts
|
|
97
|
+
* @param {string} [opts.token] - API key
|
|
98
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
99
|
+
* @param {string} opts.customerId - Customer id (24-char hex ObjectId)
|
|
100
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
101
|
+
* @returns {Promise<import("axios").AxiosResponse<{ _id: string, customerNumber: string, ... }>>}
|
|
102
|
+
*/
|
|
103
|
+
function get({
|
|
104
|
+
customerId,
|
|
105
|
+
token,
|
|
106
|
+
jwtToken,
|
|
107
|
+
headers
|
|
108
|
+
}) {
|
|
109
|
+
return client({
|
|
110
|
+
url: `/customers/${customerId}`,
|
|
111
|
+
headers: authorizationHeaders({
|
|
112
|
+
token,
|
|
113
|
+
jwtToken,
|
|
114
|
+
internalAuthTokenProvider,
|
|
115
|
+
headers
|
|
116
|
+
})
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
94
120
|
/**
|
|
95
121
|
* POST /customer - create a customer. Body: { customer }. If password is included, activation token is created and activation email sent. Side effect: may emit customer.created webhook.
|
|
96
122
|
* @param {Object} opts
|
|
@@ -247,6 +273,7 @@ function customersFactory({
|
|
|
247
273
|
return {
|
|
248
274
|
put,
|
|
249
275
|
all,
|
|
276
|
+
get,
|
|
250
277
|
create,
|
|
251
278
|
signIn,
|
|
252
279
|
signInCas,
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@ const {
|
|
|
18
18
|
* @param {Object} deps
|
|
19
19
|
* @param {import("axios").AxiosInstance} deps.client
|
|
20
20
|
* @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
|
|
21
|
-
* @returns {{ put: function, all: function, create: function, signIn: function, signInCas: function, update: function, merge: function }}
|
|
21
|
+
* @returns {{ put: function, all: function, get: function, create: function, signIn: function, signInCas: function, update: function, merge: function }}
|
|
22
22
|
*/
|
|
23
23
|
function customersFactory({client, internalAuthTokenProvider}) {
|
|
24
24
|
/**
|
|
@@ -59,6 +59,22 @@ function customersFactory({client, internalAuthTokenProvider}) {
|
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
/**
|
|
63
|
+
* GET /customers/:customerId - get a customer by id.
|
|
64
|
+
* @param {Object} opts
|
|
65
|
+
* @param {string} [opts.token] - API key
|
|
66
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
67
|
+
* @param {string} opts.customerId - Customer id (24-char hex ObjectId)
|
|
68
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
69
|
+
* @returns {Promise<import("axios").AxiosResponse<{ _id: string, customerNumber: string, ... }>>}
|
|
70
|
+
*/
|
|
71
|
+
function get({customerId, token, jwtToken, headers}) {
|
|
72
|
+
return client({
|
|
73
|
+
url: `/customers/${customerId}`,
|
|
74
|
+
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
62
78
|
/**
|
|
63
79
|
* POST /customer - create a customer. Body: { customer }. If password is included, activation token is created and activation email sent. Side effect: may emit customer.created webhook.
|
|
64
80
|
* @param {Object} opts
|
|
@@ -168,6 +184,7 @@ function customersFactory({client, internalAuthTokenProvider}) {
|
|
|
168
184
|
return {
|
|
169
185
|
put,
|
|
170
186
|
all,
|
|
187
|
+
get,
|
|
171
188
|
create,
|
|
172
189
|
signIn,
|
|
173
190
|
signInCas,
|
|
@@ -29,6 +29,12 @@ describe("accounts/customers", () => {
|
|
|
29
29
|
return api.accounts.customers.all({jwtToken, token, query});
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
+
it("should GET a customer by id", () => {
|
|
33
|
+
const customerId = "66f6d6d5f57d8b6eb95a1122";
|
|
34
|
+
axiosMock.onGet(`/customers/${customerId}`).reply(expectRequest({statusCode: 200, token, jwtToken}));
|
|
35
|
+
return api.accounts.customers.get({jwtToken, token, customerId});
|
|
36
|
+
});
|
|
37
|
+
|
|
32
38
|
it("should POST a customer", () => {
|
|
33
39
|
const customer = {
|
|
34
40
|
firstName: "someFirstName",
|