btrz-api-client 9.22.0 → 9.26.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.
@@ -0,0 +1,256 @@
1
+ describe("inventory/clover-terminals", () => {
2
+ const assert = require("node:assert/strict");
3
+ const {
4
+ axiosMock,
5
+ expectRequest
6
+ } = require("../../test-helpers.js");
7
+ const api = require("../../../src/client.js").createApiClient({
8
+ baseURL: "http://test.com"
9
+ });
10
+
11
+ const token = "I owe you a token";
12
+ const jwtToken = "I owe you a JWT token";
13
+
14
+ afterEach(() => {
15
+ axiosMock.restore();
16
+ });
17
+
18
+ it("should retrieve a list of Clover terminals", () => {
19
+ const query = {page: 2, stationId: "5f243d100617680712e78dd7", serialNumber: "DEV-001"};
20
+
21
+ axiosMock.onGet("/clover-terminals", {params: query}).reply(expectRequest({
22
+ statusCode: 200, token, jwtToken
23
+ }));
24
+
25
+ return api.inventory.cloverTerminals.all({
26
+ jwtToken,
27
+ token,
28
+ query
29
+ });
30
+ });
31
+
32
+ it("should retrieve an existing Clover terminal by id", () => {
33
+ const cloverTerminalId = "1234123412341234";
34
+
35
+ axiosMock.onGet(`/clover-terminals/${cloverTerminalId}`).reply(expectRequest({
36
+ statusCode: 200, token, jwtToken
37
+ }));
38
+
39
+ return api.inventory.cloverTerminals.get({
40
+ jwtToken,
41
+ token,
42
+ cloverTerminalId
43
+ });
44
+ });
45
+
46
+ it("should create a new Clover terminal", async () => {
47
+ const cloverTerminal = {
48
+ name: "New Clover Terminal",
49
+ serialNumber: "Test Serial Number"
50
+ };
51
+
52
+ axiosMock.onPost("/clover-terminals").reply(expectRequest({
53
+ statusCode: 200, token, jwtToken, body: {cloverTerminal}
54
+ }));
55
+
56
+ return api.inventory.cloverTerminals.create({
57
+ jwtToken,
58
+ token,
59
+ cloverTerminal
60
+ });
61
+ });
62
+
63
+ it("should create a new Clover terminal with stationId (location)", async () => {
64
+ const cloverTerminal = {
65
+ name: "Clover Terminal at Station",
66
+ serialNumber: "SN-001",
67
+ stationId: "5f243d100617680712e78dd7"
68
+ };
69
+
70
+ axiosMock.onPost("/clover-terminals").reply(expectRequest({
71
+ statusCode: 200, token, jwtToken, body: {cloverTerminal}
72
+ }));
73
+
74
+ return api.inventory.cloverTerminals.create({
75
+ jwtToken,
76
+ token,
77
+ cloverTerminal
78
+ });
79
+ });
80
+
81
+ it("should delete a Clover terminal", () => {
82
+ const cloverTerminalId = "1234";
83
+
84
+ axiosMock.onDelete(`/clover-terminals/${cloverTerminalId}`).reply(expectRequest({
85
+ statusCode: 200, token, jwtToken
86
+ }));
87
+
88
+ return api.inventory.cloverTerminals.remove({
89
+ jwtToken,
90
+ token,
91
+ cloverTerminalId
92
+ });
93
+ });
94
+
95
+ it("should update an existing Clover terminal", async () => {
96
+ const cloverTerminal = {
97
+ _id: "terminal-id-123",
98
+ name: "Updated Clover Terminal",
99
+ serialNumber: "Updated Serial Number"
100
+ };
101
+
102
+ const cloverTerminalFieldsToUpdate = {
103
+ name: cloverTerminal.name,
104
+ serialNumber: cloverTerminal.serialNumber,
105
+ stationId: cloverTerminal.stationId
106
+ };
107
+
108
+ axiosMock.onPut(`/clover-terminals/${cloverTerminal._id}`).reply(expectRequest({
109
+ statusCode: 200, token, jwtToken, body: {cloverTerminal: cloverTerminalFieldsToUpdate}
110
+ }));
111
+
112
+ return api.inventory.cloverTerminals.update({
113
+ jwtToken,
114
+ token,
115
+ cloverTerminal
116
+ });
117
+ });
118
+
119
+ it("should update an existing Clover terminal with stationId (location)", async () => {
120
+ const cloverTerminalId = "terminal-id-456";
121
+ const cloverTerminal = {
122
+ _id: cloverTerminalId,
123
+ name: "Terminal at Station",
124
+ serialNumber: "SN-789",
125
+ stationId: "5f243d100617680712e78dd7"
126
+ };
127
+
128
+ const expectedBody = {
129
+ cloverTerminal: {
130
+ name: cloverTerminal.name,
131
+ serialNumber: cloverTerminal.serialNumber,
132
+ stationId: cloverTerminal.stationId
133
+ }
134
+ };
135
+
136
+ axiosMock.onPut(`/clover-terminals/${cloverTerminalId}`).reply(expectRequest({
137
+ statusCode: 200, token, jwtToken, body: expectedBody
138
+ }));
139
+
140
+ return api.inventory.cloverTerminals.update({
141
+ jwtToken,
142
+ token,
143
+ cloverTerminalId,
144
+ cloverTerminal
145
+ });
146
+ });
147
+
148
+ it("should update an existing Clover terminal with empty stationId", async () => {
149
+ const cloverTerminal = {
150
+ _id: "terminal-id-999",
151
+ name: "Terminal No Location",
152
+ serialNumber: "SN-999",
153
+ stationId: ""
154
+ };
155
+
156
+ const expectedBody = {
157
+ cloverTerminal: {
158
+ name: cloverTerminal.name,
159
+ serialNumber: cloverTerminal.serialNumber,
160
+ stationId: ""
161
+ }
162
+ };
163
+
164
+ axiosMock.onPut(`/clover-terminals/${cloverTerminal._id}`).reply(expectRequest({
165
+ statusCode: 200, token, jwtToken, body: expectedBody
166
+ }));
167
+
168
+ return api.inventory.cloverTerminals.update({
169
+ jwtToken,
170
+ token,
171
+ cloverTerminal
172
+ });
173
+ });
174
+
175
+ it("should reject when Clover terminal is not found", async () => {
176
+ const cloverTerminalId = "5f243d100617680712e78dd7";
177
+
178
+ axiosMock.onGet(`/clover-terminals/${cloverTerminalId}`).reply(404, {
179
+ code: "CLOVER_TERMINAL_NOT_FOUND"
180
+ });
181
+
182
+ await assert.rejects(
183
+ () => {
184
+ return api.inventory.cloverTerminals.get({jwtToken, token, cloverTerminalId});
185
+ },
186
+ (err) => {
187
+ assert.equal(err.response.status, 404);
188
+ assert.equal(err.response.data.code, "CLOVER_TERMINAL_NOT_FOUND");
189
+ return true;
190
+ }
191
+ );
192
+ });
193
+
194
+ it("should reject when Clover terminal id is invalid", async () => {
195
+ const cloverTerminalId = "not-an-object-id";
196
+
197
+ axiosMock.onGet(`/clover-terminals/${cloverTerminalId}`).reply(400, {
198
+ code: "INVALID_CLOVER_TERMINAL_ID"
199
+ });
200
+
201
+ await assert.rejects(
202
+ () => {
203
+ return api.inventory.cloverTerminals.get({jwtToken, token, cloverTerminalId});
204
+ },
205
+ (err) => {
206
+ assert.equal(err.response.status, 400);
207
+ assert.equal(err.response.data.code, "INVALID_CLOVER_TERMINAL_ID");
208
+ return true;
209
+ }
210
+ );
211
+ });
212
+
213
+ it("should reject when Clover terminal name is duplicated", async () => {
214
+ const cloverTerminal = {
215
+ name: "Duplicate Name",
216
+ serialNumber: "SN-UNIQUE"
217
+ };
218
+
219
+ axiosMock.onPost("/clover-terminals").reply(409, {
220
+ code: "DUPLICATED_CLOVER_TERMINAL_NAME"
221
+ });
222
+
223
+ await assert.rejects(
224
+ () => {
225
+ return api.inventory.cloverTerminals.create({jwtToken, token, cloverTerminal});
226
+ },
227
+ (err) => {
228
+ assert.equal(err.response.status, 409);
229
+ assert.equal(err.response.data.code, "DUPLICATED_CLOVER_TERMINAL_NAME");
230
+ return true;
231
+ }
232
+ );
233
+ });
234
+
235
+ it("should reject when Clover terminal serial number is duplicated", async () => {
236
+ const cloverTerminal = {
237
+ name: "Unique Name",
238
+ serialNumber: "SN-DUPLICATE"
239
+ };
240
+
241
+ axiosMock.onPost("/clover-terminals").reply(409, {
242
+ code: "DUPLICATE_CLOVER_TERMINAL_SERIAL_NUMBER"
243
+ });
244
+
245
+ await assert.rejects(
246
+ () => {
247
+ return api.inventory.cloverTerminals.create({jwtToken, token, cloverTerminal});
248
+ },
249
+ (err) => {
250
+ assert.equal(err.response.status, 409);
251
+ assert.equal(err.response.data.code, "DUPLICATE_CLOVER_TERMINAL_SERIAL_NUMBER");
252
+ return true;
253
+ }
254
+ );
255
+ });
256
+ });
@@ -4,7 +4,7 @@ export = accountsFactory;
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, defaultUsers: { create: function }, configurationReplication: { create: function } }}
7
+ * @returns {{ get: function, defaultUsers: { create: function }, configurationReplication: { create: function }, sessionRecordingSettings: { update: function } }}
8
8
  */
9
9
  declare function accountsFactory({ client, internalAuthTokenProvider }: {
10
10
  client: import("axios").AxiosInstance;
@@ -19,4 +19,7 @@ declare function accountsFactory({ client, internalAuthTokenProvider }: {
19
19
  configurationReplication: {
20
20
  create: Function;
21
21
  };
22
+ sessionRecordingSettings: {
23
+ update: Function;
24
+ };
22
25
  };