btrz-api-client 9.25.0 → 9.27.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.js CHANGED
@@ -191,6 +191,10 @@ function createInventory({
191
191
  client,
192
192
  internalAuthTokenProvider
193
193
  }),
194
+ cloverTerminals: require("./endpoints/inventory/clover-terminals.js")({
195
+ client,
196
+ internalAuthTokenProvider
197
+ }),
194
198
  giftCertificateDefinitions: require("./endpoints/inventory/gift-certificate-definitions.js")({
195
199
  client,
196
200
  internalAuthTokenProvider
@@ -0,0 +1,181 @@
1
+ const {
2
+ authorizationHeaders
3
+ } = require("../endpoints_helpers.js");
4
+
5
+ /**
6
+ * Query params for GET /clover-terminals (btrz-api-inventory). See get-handler getSpec().
7
+ * @typedef {Object} CloverTerminalsQuery
8
+ * @property {number} [page] - The page number to retrieve
9
+ * @property {string} [stationId] - Filter terminals by station (location) ID
10
+ * @property {string} [serialNumber] - Filter terminals by serial number
11
+ */
12
+
13
+ /**
14
+ * Factory for clover-terminals API (btrz-api-inventory).
15
+ * @param {Object} deps
16
+ * @param {import("axios").AxiosInstance} deps.client
17
+ * @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
18
+ * @returns {{ all: function, get: function, create: function, remove: function, update: function }}
19
+ */
20
+ function cloverTerminalFactory({
21
+ client,
22
+ internalAuthTokenProvider
23
+ }) {
24
+ /**
25
+ * GET /clover-terminals - list Clover terminals (paginated).
26
+ * @param {Object} opts
27
+ * @param {string} [opts.token] - API key
28
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
29
+ * @param {CloverTerminalsQuery} [opts.query] - Query params (page, stationId, serialNumber)
30
+ * @param {Object} [opts.headers] - Optional headers
31
+ * @returns {Promise<import("axios").AxiosResponse<{ cloverTerminals: Array, next?: string, previous?: string, count: number }>>}
32
+ * @throws When response is 4xx/5xx (400 INVALID_PAGE, 401, 500)
33
+ */
34
+ function all({
35
+ token,
36
+ jwtToken,
37
+ query = {},
38
+ headers
39
+ }) {
40
+ return client.get("/clover-terminals", {
41
+ params: query,
42
+ headers: authorizationHeaders({
43
+ token,
44
+ jwtToken,
45
+ internalAuthTokenProvider,
46
+ headers
47
+ })
48
+ });
49
+ }
50
+
51
+ /**
52
+ * GET /clover-terminals/:cloverTerminalId - get a Clover terminal by id.
53
+ * @param {Object} opts
54
+ * @param {string} [opts.token] - API key
55
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
56
+ * @param {string} opts.cloverTerminalId - Clover terminal id (24 hex characters)
57
+ * @param {Object} [opts.headers] - Optional headers
58
+ * @returns {Promise<import("axios").AxiosResponse<{ cloverTerminal: Object }>>}
59
+ * @throws When response is 4xx/5xx (400 INVALID_CLOVER_TERMINAL_ID, 401, 404 CLOVER_TERMINAL_NOT_FOUND, 500)
60
+ */
61
+ function get({
62
+ cloverTerminalId,
63
+ token,
64
+ jwtToken,
65
+ headers
66
+ }) {
67
+ return client.get(`/clover-terminals/${cloverTerminalId}`, {
68
+ headers: authorizationHeaders({
69
+ token,
70
+ jwtToken,
71
+ internalAuthTokenProvider,
72
+ headers
73
+ })
74
+ });
75
+ }
76
+
77
+ /**
78
+ * POST /clover-terminals - create Clover terminal.
79
+ * @param {Object} opts
80
+ * @param {string} [opts.token] - API key
81
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
82
+ * @param {Object} opts.cloverTerminal - Clover terminal payload (name, serialNumber, stationId optional)
83
+ * @param {Object} [opts.headers] - Optional headers
84
+ * @returns {Promise<import("axios").AxiosResponse<{ cloverTerminal: Object }>>}
85
+ * @throws When response is 4xx/5xx (400 WRONG_DATA/INVALID_STATION_ID/STATION_NOT_FOUND, 401, 409 duplicate name/serial, 500)
86
+ */
87
+ function create({
88
+ jwtToken,
89
+ token,
90
+ cloverTerminal,
91
+ headers
92
+ }) {
93
+ return client({
94
+ url: "/clover-terminals",
95
+ method: "post",
96
+ headers: authorizationHeaders({
97
+ token,
98
+ jwtToken,
99
+ internalAuthTokenProvider,
100
+ headers
101
+ }),
102
+ data: {
103
+ cloverTerminal
104
+ }
105
+ });
106
+ }
107
+
108
+ /**
109
+ * DELETE /clover-terminals/:cloverTerminalId - remove Clover terminal.
110
+ * @param {Object} opts
111
+ * @param {string} [opts.token] - API key
112
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
113
+ * @param {string} opts.cloverTerminalId - Clover terminal id (24 hex characters)
114
+ * @param {Object} [opts.headers] - Optional headers
115
+ * @returns {Promise<import("axios").AxiosResponse<{ cloverTerminalId: string }>>}
116
+ * @throws When response is 4xx/5xx (400 INVALID_CLOVER_TERMINAL_ID, 401, 404 CLOVER_TERMINAL_NOT_FOUND, 500)
117
+ */
118
+ function remove({
119
+ jwtToken,
120
+ cloverTerminalId,
121
+ token,
122
+ headers
123
+ }) {
124
+ return client({
125
+ url: `/clover-terminals/${cloverTerminalId}`,
126
+ method: "delete",
127
+ headers: authorizationHeaders({
128
+ token,
129
+ jwtToken,
130
+ internalAuthTokenProvider,
131
+ headers
132
+ })
133
+ });
134
+ }
135
+
136
+ /**
137
+ * PUT /clover-terminals/:cloverTerminalId - update Clover terminal.
138
+ * @param {Object} opts
139
+ * @param {string} [opts.token] - API key
140
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
141
+ * @param {string} opts.cloverTerminalId - Clover terminal id (24 hex characters)
142
+ * @param {Object} opts.cloverTerminal - Clover terminal payload (name, serialNumber, stationId)
143
+ * @param {Object} [opts.headers] - Optional headers
144
+ * @returns {Promise<import("axios").AxiosResponse<{ cloverTerminal: Object }>>}
145
+ * @throws When response is 4xx/5xx (400, 401, 404 CLOVER_TERMINAL_NOT_FOUND, 409 duplicate name/serial, 500)
146
+ */
147
+ function update({
148
+ jwtToken,
149
+ token,
150
+ cloverTerminalId,
151
+ cloverTerminal,
152
+ headers
153
+ }) {
154
+ const _cloverTerminalId = cloverTerminalId || cloverTerminal._id;
155
+ return client({
156
+ url: `/clover-terminals/${_cloverTerminalId}`,
157
+ method: "put",
158
+ headers: authorizationHeaders({
159
+ token,
160
+ jwtToken,
161
+ internalAuthTokenProvider,
162
+ headers
163
+ }),
164
+ data: {
165
+ cloverTerminal: {
166
+ name: cloverTerminal.name,
167
+ serialNumber: cloverTerminal.serialNumber,
168
+ stationId: cloverTerminal.stationId
169
+ }
170
+ }
171
+ });
172
+ }
173
+ return {
174
+ all,
175
+ get,
176
+ create,
177
+ remove,
178
+ update
179
+ };
180
+ }
181
+ module.exports = cloverTerminalFactory;
@@ -15,7 +15,7 @@ const {
15
15
  * @param {Object} deps
16
16
  * @param {import("axios").AxiosInstance} deps.client
17
17
  * @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
18
- * @returns {{ create: function, all: function, remove: function }}
18
+ * @returns {{ create: function, all: function, get: function, update: function, remove: function }}
19
19
  */
20
20
  function customReportsFactory({
21
21
  client,
@@ -78,6 +78,65 @@ function customReportsFactory({
78
78
  });
79
79
  }
80
80
 
81
+ /**
82
+ * GET /custom-report/:customReportId - get one custom report.
83
+ * @param {Object} opts
84
+ * @param {string} [opts.token] - API key
85
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
86
+ * @param {string} opts.customReportId - Custom report id
87
+ * @param {Object} [opts.headers] - Optional headers
88
+ * @returns {Promise<import("axios").AxiosResponse>}
89
+ */
90
+ function get({
91
+ token,
92
+ jwtToken,
93
+ customReportId,
94
+ headers
95
+ }) {
96
+ return client({
97
+ url: `/custom-report/${customReportId}`,
98
+ headers: authorizationHeaders({
99
+ token,
100
+ jwtToken,
101
+ internalAuthTokenProvider,
102
+ headers
103
+ })
104
+ });
105
+ }
106
+
107
+ /**
108
+ * PUT /custom-reports/:customReportId - update a custom report.
109
+ * Today the API only accepts deliveryMethod inside customReport.
110
+ * @param {Object} opts
111
+ * @param {string} [opts.token] - API key
112
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
113
+ * @param {string} opts.customReportId - Custom report id
114
+ * @param {Object} opts.customReport - Fields to update
115
+ * @param {Object} [opts.headers] - Optional headers
116
+ * @returns {Promise<import("axios").AxiosResponse>}
117
+ */
118
+ function update({
119
+ token,
120
+ jwtToken,
121
+ customReportId,
122
+ customReport,
123
+ headers
124
+ }) {
125
+ return client({
126
+ url: `/custom-reports/${customReportId}`,
127
+ method: "put",
128
+ headers: authorizationHeaders({
129
+ token,
130
+ jwtToken,
131
+ internalAuthTokenProvider,
132
+ headers
133
+ }),
134
+ data: {
135
+ customReport
136
+ }
137
+ });
138
+ }
139
+
81
140
  /**
82
141
  * DELETE /custom-reports/:customReportId - remove custom report.
83
142
  * @param {Object} opts
@@ -107,6 +166,8 @@ function customReportsFactory({
107
166
  return {
108
167
  create,
109
168
  all,
169
+ get,
170
+ update,
110
171
  remove
111
172
  };
112
173
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "btrz-api-client",
3
- "version": "9.25.0",
3
+ "version": "9.27.0",
4
4
  "description": "Api client for Betterez endpoints",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/client.js CHANGED
@@ -86,6 +86,7 @@ function createInventory({baseURL, headers, timeout, overrideFn, internalAuthTok
86
86
  garages: require("./endpoints/inventory/garages.js")({client, internalAuthTokenProvider}),
87
87
  banorteTerminals: require("./endpoints/inventory/banorte-terminals.js")({client, internalAuthTokenProvider}),
88
88
  getnetTerminals: require("./endpoints/inventory/getnet-terminals.js")({client, internalAuthTokenProvider}),
89
+ cloverTerminals: require("./endpoints/inventory/clover-terminals.js")({client, internalAuthTokenProvider}),
89
90
  giftCertificateDefinitions: require("./endpoints/inventory/gift-certificate-definitions.js")({client, internalAuthTokenProvider}),
90
91
  healthCheck: require("./endpoints/inventory/healthcheck.js")({client, internalAuthTokenProvider}),
91
92
  holidays: require("./endpoints/inventory/holidays.js")({client, internalAuthTokenProvider}),
@@ -0,0 +1,156 @@
1
+ const {
2
+ authorizationHeaders
3
+ } = require("../endpoints_helpers.js");
4
+
5
+ /**
6
+ * Query params for GET /clover-terminals (btrz-api-inventory). See get-handler getSpec().
7
+ * @typedef {Object} CloverTerminalsQuery
8
+ * @property {number} [page] - The page number to retrieve
9
+ * @property {string} [stationId] - Filter terminals by station (location) ID
10
+ * @property {string} [serialNumber] - Filter terminals by serial number
11
+ */
12
+
13
+ /**
14
+ * Factory for clover-terminals API (btrz-api-inventory).
15
+ * @param {Object} deps
16
+ * @param {import("axios").AxiosInstance} deps.client
17
+ * @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
18
+ * @returns {{ all: function, get: function, create: function, remove: function, update: function }}
19
+ */
20
+ function cloverTerminalFactory({client, internalAuthTokenProvider}) {
21
+ /**
22
+ * GET /clover-terminals - list Clover terminals (paginated).
23
+ * @param {Object} opts
24
+ * @param {string} [opts.token] - API key
25
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
26
+ * @param {CloverTerminalsQuery} [opts.query] - Query params (page, stationId, serialNumber)
27
+ * @param {Object} [opts.headers] - Optional headers
28
+ * @returns {Promise<import("axios").AxiosResponse<{ cloverTerminals: Array, next?: string, previous?: string, count: number }>>}
29
+ * @throws When response is 4xx/5xx (400 INVALID_PAGE, 401, 500)
30
+ */
31
+ function all({
32
+ token,
33
+ jwtToken,
34
+ query = {},
35
+ headers
36
+ }) {
37
+ return client.get("/clover-terminals", {
38
+ params: query,
39
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
40
+ });
41
+ }
42
+
43
+ /**
44
+ * GET /clover-terminals/:cloverTerminalId - get a Clover terminal by id.
45
+ * @param {Object} opts
46
+ * @param {string} [opts.token] - API key
47
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
48
+ * @param {string} opts.cloverTerminalId - Clover terminal id (24 hex characters)
49
+ * @param {Object} [opts.headers] - Optional headers
50
+ * @returns {Promise<import("axios").AxiosResponse<{ cloverTerminal: Object }>>}
51
+ * @throws When response is 4xx/5xx (400 INVALID_CLOVER_TERMINAL_ID, 401, 404 CLOVER_TERMINAL_NOT_FOUND, 500)
52
+ */
53
+ function get({
54
+ cloverTerminalId,
55
+ token,
56
+ jwtToken,
57
+ headers
58
+ }) {
59
+ return client.get(`/clover-terminals/${cloverTerminalId}`, {
60
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
61
+ });
62
+ }
63
+
64
+ /**
65
+ * POST /clover-terminals - create Clover terminal.
66
+ * @param {Object} opts
67
+ * @param {string} [opts.token] - API key
68
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
69
+ * @param {Object} opts.cloverTerminal - Clover terminal payload (name, serialNumber, stationId optional)
70
+ * @param {Object} [opts.headers] - Optional headers
71
+ * @returns {Promise<import("axios").AxiosResponse<{ cloverTerminal: Object }>>}
72
+ * @throws When response is 4xx/5xx (400 WRONG_DATA/INVALID_STATION_ID/STATION_NOT_FOUND, 401, 409 duplicate name/serial, 500)
73
+ */
74
+ function create({
75
+ jwtToken,
76
+ token,
77
+ cloverTerminal,
78
+ headers
79
+ }) {
80
+ return client({
81
+ url: "/clover-terminals",
82
+ method: "post",
83
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
84
+ data: {
85
+ cloverTerminal
86
+ }
87
+ });
88
+ }
89
+
90
+ /**
91
+ * DELETE /clover-terminals/:cloverTerminalId - remove Clover terminal.
92
+ * @param {Object} opts
93
+ * @param {string} [opts.token] - API key
94
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
95
+ * @param {string} opts.cloverTerminalId - Clover terminal id (24 hex characters)
96
+ * @param {Object} [opts.headers] - Optional headers
97
+ * @returns {Promise<import("axios").AxiosResponse<{ cloverTerminalId: string }>>}
98
+ * @throws When response is 4xx/5xx (400 INVALID_CLOVER_TERMINAL_ID, 401, 404 CLOVER_TERMINAL_NOT_FOUND, 500)
99
+ */
100
+ function remove({
101
+ jwtToken,
102
+ cloverTerminalId,
103
+ token,
104
+ headers
105
+ }) {
106
+ return client({
107
+ url: `/clover-terminals/${cloverTerminalId}`,
108
+ method: "delete",
109
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
110
+ });
111
+ }
112
+
113
+ /**
114
+ * PUT /clover-terminals/:cloverTerminalId - update Clover terminal.
115
+ * @param {Object} opts
116
+ * @param {string} [opts.token] - API key
117
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
118
+ * @param {string} opts.cloverTerminalId - Clover terminal id (24 hex characters)
119
+ * @param {Object} opts.cloverTerminal - Clover terminal payload (name, serialNumber, stationId)
120
+ * @param {Object} [opts.headers] - Optional headers
121
+ * @returns {Promise<import("axios").AxiosResponse<{ cloverTerminal: Object }>>}
122
+ * @throws When response is 4xx/5xx (400, 401, 404 CLOVER_TERMINAL_NOT_FOUND, 409 duplicate name/serial, 500)
123
+ */
124
+ function update({
125
+ jwtToken,
126
+ token,
127
+ cloverTerminalId,
128
+ cloverTerminal,
129
+ headers
130
+ }) {
131
+ const _cloverTerminalId = cloverTerminalId || cloverTerminal._id;
132
+
133
+ return client({
134
+ url: `/clover-terminals/${_cloverTerminalId}`,
135
+ method: "put",
136
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
137
+ data: {
138
+ cloverTerminal: {
139
+ name: cloverTerminal.name,
140
+ serialNumber: cloverTerminal.serialNumber,
141
+ stationId: cloverTerminal.stationId
142
+ }
143
+ }
144
+ });
145
+ }
146
+
147
+ return {
148
+ all,
149
+ get,
150
+ create,
151
+ remove,
152
+ update
153
+ };
154
+ }
155
+
156
+ module.exports = cloverTerminalFactory;
@@ -13,7 +13,7 @@ const {authorizationHeaders} = require("./../endpoints_helpers.js");
13
13
  * @param {Object} deps
14
14
  * @param {import("axios").AxiosInstance} deps.client
15
15
  * @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
16
- * @returns {{ create: function, all: function, remove: function }}
16
+ * @returns {{ create: function, all: function, get: function, update: function, remove: function }}
17
17
  */
18
18
  function customReportsFactory({client, internalAuthTokenProvider}) {
19
19
  /**
@@ -51,6 +51,42 @@ function customReportsFactory({client, internalAuthTokenProvider}) {
51
51
  });
52
52
  }
53
53
 
54
+ /**
55
+ * GET /custom-report/:customReportId - get one custom report.
56
+ * @param {Object} opts
57
+ * @param {string} [opts.token] - API key
58
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
59
+ * @param {string} opts.customReportId - Custom report id
60
+ * @param {Object} [opts.headers] - Optional headers
61
+ * @returns {Promise<import("axios").AxiosResponse>}
62
+ */
63
+ function get({token, jwtToken, customReportId, headers}) {
64
+ return client({
65
+ url: `/custom-report/${customReportId}`,
66
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
67
+ });
68
+ }
69
+
70
+ /**
71
+ * PUT /custom-reports/:customReportId - update a custom report.
72
+ * Today the API only accepts deliveryMethod inside customReport.
73
+ * @param {Object} opts
74
+ * @param {string} [opts.token] - API key
75
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
76
+ * @param {string} opts.customReportId - Custom report id
77
+ * @param {Object} opts.customReport - Fields to update
78
+ * @param {Object} [opts.headers] - Optional headers
79
+ * @returns {Promise<import("axios").AxiosResponse>}
80
+ */
81
+ function update({token, jwtToken, customReportId, customReport, headers}) {
82
+ return client({
83
+ url: `/custom-reports/${customReportId}`,
84
+ method: "put",
85
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
86
+ data: {customReport}
87
+ });
88
+ }
89
+
54
90
  /**
55
91
  * DELETE /custom-reports/:customReportId - remove custom report.
56
92
  * @param {Object} opts
@@ -71,6 +107,8 @@ function customReportsFactory({client, internalAuthTokenProvider}) {
71
107
  return {
72
108
  create,
73
109
  all,
110
+ get,
111
+ update,
74
112
  remove
75
113
  };
76
114
  }
package/test/all.test.js CHANGED
@@ -98,6 +98,7 @@ require("./endpoints/inventory/filtered-trips.test.js");
98
98
  require("./endpoints/inventory/financing-costs.test.js");
99
99
  require("./endpoints/inventory/garages.test.js");
100
100
  require("./endpoints/inventory/banorte-terminals.test.js");
101
+ require("./endpoints/inventory/clover-terminals.test.js");
101
102
  require("./endpoints/inventory/getnet-terminals.test.js");
102
103
  require("./endpoints/inventory/gift-certificate-definitions.test.js");
103
104
  require("./endpoints/inventory/holidays.test.js");