btrz-api-client 8.31.0 → 8.32.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.
Files changed (85) hide show
  1. package/.cursor/rules/jsdoc-endpoints.mdc +1 -1
  2. package/lib/client-standalone-min.js +3 -3
  3. package/lib/client.js +3 -0
  4. package/lib/endpoints/accounts/agencies.js +52 -0
  5. package/lib/endpoints/accounts/application-settings.js +19 -18
  6. package/lib/endpoints/accounts/applications.js +8 -7
  7. package/lib/endpoints/accounts/customers.js +27 -24
  8. package/lib/endpoints/accounts/domains.js +16 -11
  9. package/lib/endpoints/accounts/email-settings.js +22 -18
  10. package/lib/endpoints/accounts/email-templates.js +8 -4
  11. package/lib/endpoints/accounts/exchange-rates.js +12 -7
  12. package/lib/endpoints/accounts/exchange-receipts.js +10 -6
  13. package/lib/endpoints/accounts/external-customers.js +50 -0
  14. package/lib/endpoints/accounts/goal-settings.js +8 -6
  15. package/lib/endpoints/accounts/images.js +14 -13
  16. package/lib/endpoints/accounts/interline.js +35 -27
  17. package/lib/endpoints/accounts/journey-prices-settings.js +8 -6
  18. package/lib/endpoints/accounts/lexicons.js +13 -13
  19. package/lib/endpoints/accounts/market-pricing-settings.js +7 -6
  20. package/lib/endpoints/accounts/multiproduct-sales-settings.js +7 -6
  21. package/lib/endpoints/accounts/network.js +28 -13
  22. package/lib/endpoints/accounts/operation-settings.js +8 -6
  23. package/lib/endpoints/accounts/people-lookups.js +17 -17
  24. package/lib/endpoints/accounts/point-to-point-settings.js +6 -6
  25. package/lib/endpoints/accounts/print-settings.js +9 -6
  26. package/lib/endpoints/accounts/print-templates.js +37 -21
  27. package/lib/endpoints/accounts/printers.js +10 -4
  28. package/lib/endpoints/accounts/rms-settings.js +19 -11
  29. package/lib/endpoints/accounts/salesforce-settings.js +8 -6
  30. package/lib/endpoints/accounts/shift-settings.js +7 -6
  31. package/lib/endpoints/accounts/shifts.js +13 -9
  32. package/lib/endpoints/accounts/sms-templates.js +28 -19
  33. package/lib/endpoints/accounts/sub-print-templates.js +5 -3
  34. package/lib/endpoints/accounts/ticket-movement-settings.js +8 -5
  35. package/lib/endpoints/accounts/travellers.js +18 -12
  36. package/lib/endpoints/accounts/trusted-machines.js +11 -8
  37. package/lib/endpoints/accounts/twilio-settings.js +8 -5
  38. package/lib/endpoints/accounts/users.js +105 -63
  39. package/lib/endpoints/accounts/verified-emails.js +130 -0
  40. package/lib/endpoints/accounts/websales-config.js +7 -5
  41. package/package.json +1 -1
  42. package/src/client.js +3 -0
  43. package/src/endpoints/accounts/agencies.js +40 -0
  44. package/src/endpoints/accounts/application-settings.js +19 -18
  45. package/src/endpoints/accounts/applications.js +8 -7
  46. package/src/endpoints/accounts/customers.js +27 -24
  47. package/src/endpoints/accounts/domains.js +16 -11
  48. package/src/endpoints/accounts/email-settings.js +22 -18
  49. package/src/endpoints/accounts/email-templates.js +8 -4
  50. package/src/endpoints/accounts/exchange-rates.js +12 -7
  51. package/src/endpoints/accounts/exchange-receipts.js +10 -6
  52. package/src/endpoints/accounts/external-customers.js +37 -0
  53. package/src/endpoints/accounts/goal-settings.js +8 -6
  54. package/src/endpoints/accounts/images.js +14 -13
  55. package/src/endpoints/accounts/interline.js +35 -28
  56. package/src/endpoints/accounts/journey-prices-settings.js +8 -6
  57. package/src/endpoints/accounts/lexicons.js +13 -13
  58. package/src/endpoints/accounts/market-pricing-settings.js +7 -6
  59. package/src/endpoints/accounts/multiproduct-sales-settings.js +7 -6
  60. package/src/endpoints/accounts/network.js +28 -14
  61. package/src/endpoints/accounts/operation-settings.js +8 -6
  62. package/src/endpoints/accounts/people-lookups.js +17 -17
  63. package/src/endpoints/accounts/point-to-point-settings.js +6 -6
  64. package/src/endpoints/accounts/print-settings.js +9 -7
  65. package/src/endpoints/accounts/print-templates.js +31 -19
  66. package/src/endpoints/accounts/printers.js +10 -5
  67. package/src/endpoints/accounts/rms-settings.js +19 -11
  68. package/src/endpoints/accounts/salesforce-settings.js +8 -6
  69. package/src/endpoints/accounts/shift-settings.js +7 -6
  70. package/src/endpoints/accounts/shifts.js +13 -9
  71. package/src/endpoints/accounts/sms-templates.js +28 -19
  72. package/src/endpoints/accounts/sub-print-templates.js +5 -3
  73. package/src/endpoints/accounts/ticket-movement-settings.js +8 -5
  74. package/src/endpoints/accounts/travellers.js +18 -12
  75. package/src/endpoints/accounts/trusted-machines.js +11 -8
  76. package/src/endpoints/accounts/twilio-settings.js +8 -5
  77. package/src/endpoints/accounts/users.js +42 -5
  78. package/src/endpoints/accounts/verified-emails.js +100 -0
  79. package/src/endpoints/accounts/websales-config.js +7 -5
  80. package/test/endpoints/accounts/agencies.test.js +58 -0
  81. package/test/endpoints/accounts/external-customers.test.js +62 -0
  82. package/test/endpoints/accounts/users.js +10 -0
  83. package/test/endpoints/accounts/verified-emails.test.js +35 -0
  84. package/types/endpoints/accounts/users.d.ts +2 -1
  85. package/types/endpoints/accounts/verified-emails.d.ts +19 -0
@@ -3,7 +3,7 @@ const {
3
3
  } = require("../endpoints_helpers.js");
4
4
 
5
5
  /**
6
- * Factory for point-to-point-settings API (btrz-api-accounts).
6
+ * Factory for point-to-point-settings API (btrz-api-accounts). Requires user logged in to backoffice app.
7
7
  * @param {Object} deps
8
8
  * @param {import("axios").AxiosInstance} deps.client
9
9
  * @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
@@ -11,12 +11,12 @@ const {
11
11
  */
12
12
  function pointToPointSettingsFactory({client, internalAuthTokenProvider}) {
13
13
  /**
14
- * GET /point-to-point-settings - get point-to-point settings. API does not accept query params.
14
+ * GET /point-to-point-settings get point-to-point settings for the current account. No query params.
15
15
  * @param {Object} opts
16
16
  * @param {string} [opts.token] - API key
17
17
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
18
18
  * @param {Object} [opts.headers] - Optional headers
19
- * @returns {Promise<import("axios").AxiosResponse>}
19
+ * @returns {Promise<import("axios").AxiosResponse<{ pointToPointSettings: object }>>}
20
20
  */
21
21
  function get({token, jwtToken, headers}) {
22
22
  return client({
@@ -26,13 +26,13 @@ function pointToPointSettingsFactory({client, internalAuthTokenProvider}) {
26
26
  }
27
27
 
28
28
  /**
29
- * PUT /point-to-point-settings - update point-to-point settings. API does not accept query params.
29
+ * PUT /point-to-point-settings update settings. Body: useOnlySpecificFareTable (boolean) required.
30
30
  * @param {Object} opts
31
31
  * @param {string} [opts.token] - API key
32
32
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
33
- * @param {Object} opts.pointToPointSettings - Settings payload
33
+ * @param {{ useOnlySpecificFareTable: boolean }} opts.pointToPointSettings - Settings payload (useOnlySpecificFareTable required)
34
34
  * @param {Object} [opts.headers] - Optional headers
35
- * @returns {Promise<import("axios").AxiosResponse>}
35
+ * @returns {Promise<import("axios").AxiosResponse<{ pointToPointSettings: object }>>}
36
36
  */
37
37
  function update({token, jwtToken, pointToPointSettings, headers}) {
38
38
  return client({
@@ -11,28 +11,30 @@ const {
11
11
  */
12
12
  function printSettingsFactory({client, internalAuthTokenProvider}) {
13
13
  /**
14
- * GET /print-settings - list/get print settings. API does not accept query params.
14
+ * GET /print-settings get print settings for the current account. No query params.
15
15
  * @param {Object} opts
16
16
  * @param {string} [opts.token] - API key
17
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
18
+ * @param {Object} [opts.query] - Optional query params
17
19
  * @param {Object} [opts.headers] - Optional headers
18
- * @returns {Promise<import("axios").AxiosResponse>}
20
+ * @returns {Promise<import("axios").AxiosResponse<{ printSettings: object }>>}
19
21
  */
20
- function all({token, query, headers}) {
22
+ function all({token, jwtToken, query, headers}) {
21
23
  return client({
22
24
  url: "/print-settings",
23
25
  params: query,
24
- headers: authorizationHeaders({token, internalAuthTokenProvider, headers})
26
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
25
27
  });
26
28
  }
27
29
 
28
30
  /**
29
- * PUT /print-settings - update print settings. API does not accept query params.
31
+ * PUT /print-settings update print settings. Emits printsettings.updated webhook. Requires BETTEREZ_APP.
30
32
  * @param {Object} opts
31
33
  * @param {string} [opts.token] - API key
32
34
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
33
- * @param {Object} opts.printSettings - Print settings payload
35
+ * @param {Object} opts.printSettings - Print settings payload (PrintSettingsPutData)
34
36
  * @param {Object} [opts.headers] - Optional headers
35
- * @returns {Promise<import("axios").AxiosResponse>}
37
+ * @returns {Promise<import("axios").AxiosResponse<{ printSettings: object }>>}
36
38
  */
37
39
  function update({jwtToken, token, printSettings, headers}) {
38
40
  return client({
@@ -1,3 +1,4 @@
1
+ /* eslint-disable max-len */
1
2
  const {
2
3
  authorizationHeaders
3
4
  } = require("./../endpoints_helpers.js");
@@ -15,6 +16,7 @@ const {
15
16
  * @property {string} [sort] - relevance | natural | createdAsc | createdDesc | updatedAsc | updatedDesc
16
17
  * @property {string} [templateCollectionId] - default | epsontmt88v | zebralp2844 | zebragx420t
17
18
  * @property {string} [status] - draft | published
19
+ * @property {string} [agencyId] - Filter sub-templates for this agency (ObjectId)
18
20
  * @property {string} [mainTemplateAccountId] - Filter by source provider (ObjectId)
19
21
  * @property {number} [page] - 1-based page for pagination
20
22
  */
@@ -43,47 +45,54 @@ const {
43
45
  */
44
46
  function printSettingsFactory({client, internalAuthTokenProvider}) {
45
47
  /**
46
- * GET /print-templates - list print templates.
48
+ * GET /print-templates - list print templates (paginated when page is provided).
47
49
  * @param {Object} opts
48
50
  * @param {string} [opts.token] - API key
49
- * @param {PrintTemplatesListQuery} [opts.query] - Query params (providerId, type, channel, consumer, format, etc.)
51
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
52
+ * @param {PrintTemplatesListQuery} [opts.query] - Query params (providerId, type, channel, agencyId, etc.)
50
53
  * @param {Object} [opts.headers] - Optional headers
51
- * @returns {Promise<import("axios").AxiosResponse>}
54
+ * @returns {Promise<import("axios").AxiosResponse<{ printTemplates: object[], next?: string, previous?: string, totalRecords?: number, page?: number }>>}
55
+ * When page is used, response includes next, previous, totalRecords, page.
56
+ * @throws {import("axios").AxiosError} 400 WRONG_DATA, INVALID_PRODUCT_ID; 401; 500
52
57
  */
53
- function all({token, query, headers}) {
58
+ function all({token, jwtToken, query = {}, headers}) {
54
59
  return client({
55
60
  url: "/print-templates",
56
61
  params: query,
57
- headers: authorizationHeaders({token, internalAuthTokenProvider, headers})
62
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
58
63
  });
59
64
  }
60
65
 
61
66
  /**
62
- * GET /print-templates/:printTemplateId - get a print template.
67
+ * GET /print-templates/:printTemplateId - get a single print template.
63
68
  * @param {Object} opts
64
69
  * @param {string} [opts.token] - API key
70
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
65
71
  * @param {string} opts.printTemplateId - Print template id (ObjectId)
66
72
  * @param {PrintTemplateGetByIdQuery} [opts.query] - Query params (providerId, superUserId, superUserHash)
67
73
  * @param {Object} [opts.headers] - Optional headers
68
- * @returns {Promise<import("axios").AxiosResponse>}
74
+ * @returns {Promise<import("axios").AxiosResponse<{ printTemplate: object }>>}
75
+ * @throws {import("axios").AxiosError} 400 INVALID_PRINT_TEMPLATE_ID / INVALID_PROVIDER_ID, 401, 404 PRINT_TEMPLATE_NOT_FOUND, 500
69
76
  */
70
- function get({token, query, headers, printTemplateId}) {
77
+ function get({token, jwtToken, printTemplateId, query = {}, headers}) {
71
78
  return client({
72
79
  url: `/print-templates/${printTemplateId}`,
73
80
  params: query,
74
- headers: authorizationHeaders({token, internalAuthTokenProvider, headers})
81
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
75
82
  });
76
83
  }
77
84
 
78
85
  /**
79
- * PUT /print-templates/:printTemplateId - update a print template. API getSpec() does not define query params.
86
+ * PUT /print-templates/:printTemplateId - update a print template.
80
87
  * @param {Object} opts
81
88
  * @param {string} [opts.token] - API key
82
89
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
83
90
  * @param {string} opts.printTemplateId - Print template id (ObjectId)
84
- * @param {Object} opts.printTemplate - Print template payload
91
+ * @param {Object} opts.printTemplate - Print template payload (name, type; type-specific fields)
92
+ * @param {Object} [opts.query] - Optional (superUserId, superUserHash)
85
93
  * @param {Object} [opts.headers] - Optional headers
86
- * @returns {Promise<import("axios").AxiosResponse>}
94
+ * @returns {Promise<import("axios").AxiosResponse<{ printTemplate: object }>>}
95
+ * @throws {import("axios").AxiosError} 400 WRONG_DATA, type-specific; 401 NOT_SUPER_USER; 404; 500
87
96
  */
88
97
  function update({jwtToken, token, printTemplateId, printTemplate, headers, query}) {
89
98
  return client({
@@ -100,13 +109,14 @@ function printSettingsFactory({client, internalAuthTokenProvider}) {
100
109
  }
101
110
 
102
111
  /**
103
- * POST /print-templates - create a print template. API does not accept query params.
112
+ * POST /print-templates - create a print template. Body: printTemplate (name, type required; type-specific fields).
104
113
  * @param {Object} opts
105
114
  * @param {string} [opts.token] - API key
106
115
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
107
- * @param {Object} opts.printTemplate - Print template payload
116
+ * @param {Object} opts.printTemplate - Print template payload (see PrintTemplatePostData)
108
117
  * @param {Object} [opts.headers] - Optional headers
109
- * @returns {Promise<import("axios").AxiosResponse>}
118
+ * @returns {Promise<import("axios").AxiosResponse<{ printTemplate: object }>>}
119
+ * @throws {import("axios").AxiosError} 400 WRONG_DATA / PRODUCT_* / INVOICE_* / META_* / TEMPLATE_*, 401 NOT_SUPER_USER, 500
110
120
  */
111
121
  function create({jwtToken, token, printTemplate, headers}) {
112
122
  return client({
@@ -122,13 +132,14 @@ function printSettingsFactory({client, internalAuthTokenProvider}) {
122
132
  }
123
133
 
124
134
  /**
125
- * DELETE /print-templates/:printTemplateId - remove a print template. API does not accept query params.
135
+ * DELETE /print-templates/:printTemplateId - delete a print template.
126
136
  * @param {Object} opts
127
137
  * @param {string} [opts.token] - API key
128
138
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
129
139
  * @param {string} opts.printTemplateId - Print template id (ObjectId)
130
140
  * @param {Object} [opts.headers] - Optional headers
131
- * @returns {Promise<import("axios").AxiosResponse>}
141
+ * @returns {Promise<import("axios").AxiosResponse<{ printTemplateId: string }>>}
142
+ * @throws {import("axios").AxiosError} 400 PRINT_TEMPLATE_ID, 401, 404 PRINT_TEMPLATE_NOT_FOUND, 500
132
143
  */
133
144
  function remove({printTemplateId, token, jwtToken, headers}) {
134
145
  return client({
@@ -142,7 +153,7 @@ function printSettingsFactory({client, internalAuthTokenProvider}) {
142
153
 
143
154
  const versions = {
144
155
  /**
145
- * PUT /print-templates/:printTemplateId/versions/:versionId - roll back print template to a version.
156
+ * PUT /print-templates/:printTemplateId/versions/:versionId - roll back to a saved version (versionId = zero-based index).
146
157
  * @param {Object} opts
147
158
  * @param {string} [opts.token] - API key
148
159
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
@@ -150,7 +161,8 @@ function printSettingsFactory({client, internalAuthTokenProvider}) {
150
161
  * @param {string} opts.versionId - Zero-based version index (e.g. "0", "1")
151
162
  * @param {PrintTemplateVersionUpdateQuery} [opts.query] - Query params (superUserId, superUserHash)
152
163
  * @param {Object} [opts.headers] - Optional headers
153
- * @returns {Promise<import("axios").AxiosResponse>}
164
+ * @returns {Promise<import("axios").AxiosResponse<{ printTemplate: object }>>}
165
+ * @throws {import("axios").AxiosError} 400 WRONG_DATA; 401 NOT_SUPER_USER; 404; 500
154
166
  */
155
167
  update({printTemplateId, token, jwtToken, headers, query, versionId}) {
156
168
  return client({
@@ -1,3 +1,4 @@
1
+ /* eslint-disable max-len */
1
2
  const {
2
3
  authorizationHeaders
3
4
  } = require("./../endpoints_helpers.js");
@@ -11,17 +12,21 @@ const {
11
12
  */
12
13
  function printersFactory({client, internalAuthTokenProvider}) {
13
14
  /**
14
- * GET /printers - list printers. API does not accept query params.
15
+ * GET /printers - list supported printers and their print templates. No query parameters accepted.
15
16
  * @param {Object} opts
16
17
  * @param {string} [opts.token] - API key
18
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
19
+ * @param {Object} [opts.query] - Unused; API accepts no query params
17
20
  * @param {Object} [opts.headers] - Optional headers
18
- * @returns {Promise<import("axios").AxiosResponse>}
21
+ * @returns {Promise<import("axios").AxiosResponse<{ printers: Array<object> }>>}
22
+ * Response printers array: each has id, name, itemTypes, templates (see GET /printers).
23
+ * @throws {import("axios").AxiosError} 401 Unauthorized, 500 Internal server error
19
24
  */
20
- function all({token, query, headers}) {
25
+ function all({token, jwtToken, query, headers}) {
21
26
  return client({
22
27
  url: "/printers",
23
- params: query,
24
- headers: authorizationHeaders({token, internalAuthTokenProvider, headers})
28
+ params: query || {},
29
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
25
30
  });
26
31
  }
27
32
 
@@ -1,3 +1,4 @@
1
+ /* eslint-disable max-len */
1
2
  const {
2
3
  authorizationHeaders
3
4
  } = require("./../endpoints_helpers.js");
@@ -11,12 +12,14 @@ const {
11
12
  */
12
13
  function revenueManagementSettingsFactory({client, internalAuthTokenProvider}) {
13
14
  /**
14
- * GET /rms-settings - get revenue management settings. API does not accept query params.
15
+ * GET /rms-settings get revenue management settings for the account. No query parameters.
15
16
  * @param {Object} opts
16
- * @param {string} [opts.token] - API key
17
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
18
- * @param {Object} [opts.headers] - Optional headers
19
- * @returns {Promise<import("axios").AxiosResponse>}
17
+ * @param {string} [opts.token] - API key (X-API-KEY)
18
+ * @param {string} [opts.jwtToken] - JWT or internal auth token
19
+ * @param {Object} [opts.headers] - Optional request headers
20
+ * @returns {Promise<import("axios").AxiosResponse<{ data: { revenueManagementSettings: { enabled: boolean, applicationId?: string, subscriptionId?: string, ratalityClientId?: string, userId?: string } } }>>}
21
+ * @throws {import("axios").AxiosError} 401 Unauthorized (missing or invalid API key/Authorization)
22
+ * @throws {import("axios").AxiosError} 500 Internal server error
20
23
  */
21
24
  function get({token, jwtToken, headers}) {
22
25
  return client({
@@ -26,13 +29,18 @@ function revenueManagementSettingsFactory({client, internalAuthTokenProvider}) {
26
29
  }
27
30
 
28
31
  /**
29
- * PUT /rms-settings - update revenue management settings. API does not accept query params.
32
+ * PUT /rms-settings update revenue management settings. Body is the settings object (e.g. { enabled: true }).
33
+ * When enabling, Ratality credentials must already exist on the account. Emits rms.enabled / rms.disabled webhooks.
30
34
  * @param {Object} opts
31
- * @param {string} [opts.token] - API key
32
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
33
- * @param {Object} opts.revenueManagementSettings - Settings payload
34
- * @param {Object} [opts.headers] - Optional headers
35
- * @returns {Promise<import("axios").AxiosResponse>}
35
+ * @param {string} [opts.token] - API key (X-API-KEY)
36
+ * @param {string} [opts.jwtToken] - JWT or internal auth token
37
+ * @param {{ enabled: boolean, ratalityUsername?: string, ratalityPassword?: string }} opts.revenueManagementSettings - Settings payload (at least enabled; credentials required when enabling)
38
+ * @param {Object} [opts.headers] - Optional request headers
39
+ * @returns {Promise<import("axios").AxiosResponse<{ data: { revenueManagementSettings: { enabled: boolean, applicationId?: string, subscriptionId?: string, ratalityClientId?: string, userId?: string } } }>>}
40
+ * @throws {import("axios").AxiosError} 400 ACCOUNT_ALREADY_HAS_RMS_SETTINGS_ENABLED, RATALITY_CREDENTIALS_REQUIRED, CREATE_CLIENT_*
41
+ * @throws {import("axios").AxiosError} 401 Unauthorized
42
+ * @throws {import("axios").AxiosError} 404 ACCOUNT_NOT_FOUND
43
+ * @throws {import("axios").AxiosError} 500 CREATE_USER_ERROR or internal server error
36
44
  */
37
45
  function update({token, jwtToken, revenueManagementSettings, headers}) {
38
46
  return client({
@@ -3,7 +3,7 @@ const {
3
3
  } = require("./../endpoints_helpers.js");
4
4
 
5
5
  /**
6
- * Factory for salesforce-settings API (btrz-api-accounts).
6
+ * Factory for salesforce-settings API (btrz-api-accounts). Requires BETTEREZ_APP audience.
7
7
  * @param {Object} deps
8
8
  * @param {import("axios").AxiosInstance} deps.client
9
9
  * @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
@@ -11,12 +11,13 @@ const {
11
11
  */
12
12
  function salesforceSettingsFactory({client, internalAuthTokenProvider}) {
13
13
  /**
14
- * GET /salesforce-settings - get Salesforce settings. API does not accept query params.
14
+ * GET /salesforce-settings get Salesforce settings for the current account. No query params.
15
15
  * @param {Object} opts
16
16
  * @param {string} [opts.token] - API key
17
17
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
18
+ * @param {Object} [opts.query] - Optional query params
18
19
  * @param {Object} [opts.headers] - Optional headers
19
- * @returns {Promise<import("axios").AxiosResponse>}
20
+ * @returns {Promise<import("axios").AxiosResponse<{ salesforceSettings: object }>>}
20
21
  */
21
22
  function get({jwtToken, token, query, headers}) {
22
23
  return client({
@@ -27,13 +28,14 @@ function salesforceSettingsFactory({client, internalAuthTokenProvider}) {
27
28
  }
28
29
 
29
30
  /**
30
- * PUT /salesforce-settings - update Salesforce settings. API does not accept query params.
31
+ * PUT /salesforce-settings update Salesforce settings. When enabled is true, mcInstanceId,
32
+ * messageId, clientId, clientSecret are required. Emits salesforcesettings.updated webhook.
31
33
  * @param {Object} opts
32
34
  * @param {string} [opts.token] - API key
33
35
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
34
- * @param {Object} opts.salesforceSettings - Settings payload
36
+ * @param {Object} opts.salesforceSettings - Settings payload (SalesforceSettingsPayload; enabled required)
35
37
  * @param {Object} [opts.headers] - Optional headers
36
- * @returns {Promise<import("axios").AxiosResponse>}
38
+ * @returns {Promise<import("axios").AxiosResponse<{ salesforceSettings: object }>>}
37
39
  */
38
40
  function update({jwtToken, token, salesforceSettings, headers}) {
39
41
  return client({
@@ -3,7 +3,7 @@ const {
3
3
  } = require("./../endpoints_helpers.js");
4
4
 
5
5
  /**
6
- * Factory for shift-settings API (btrz-api-accounts).
6
+ * Factory for shift-settings API (btrz-api-accounts). Requires BETTEREZ_APP audience.
7
7
  * @param {Object} deps
8
8
  * @param {import("axios").AxiosInstance} deps.client
9
9
  * @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
@@ -11,12 +11,13 @@ const {
11
11
  */
12
12
  function shiftSettingsFactory({client, internalAuthTokenProvider}) {
13
13
  /**
14
- * GET /shift-settings - get shift settings. API does not accept query params.
14
+ * GET /shift-settings get shift settings for the current account. No query params.
15
15
  * @param {Object} opts
16
16
  * @param {string} [opts.token] - API key
17
17
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
18
+ * @param {Object} [opts.query] - Optional query params
18
19
  * @param {Object} [opts.headers] - Optional headers
19
- * @returns {Promise<import("axios").AxiosResponse>}
20
+ * @returns {Promise<import("axios").AxiosResponse<{ shiftSettings: object }>>}
20
21
  */
21
22
  function get({token, jwtToken, query, headers}) {
22
23
  return client({
@@ -27,13 +28,13 @@ function shiftSettingsFactory({client, internalAuthTokenProvider}) {
27
28
  }
28
29
 
29
30
  /**
30
- * PUT /shift-settings - update shift settings. API does not accept query params.
31
+ * PUT /shift-settings update shift settings. Emits shiftsettings.updated webhook.
31
32
  * @param {Object} opts
32
33
  * @param {string} [opts.token] - API key
33
34
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
34
- * @param {Object} opts.shiftSettings - Settings payload
35
+ * @param {Object} opts.shiftSettings - Settings payload (ShiftSetting)
35
36
  * @param {Object} [opts.headers] - Optional headers
36
- * @returns {Promise<import("axios").AxiosResponse>}
37
+ * @returns {Promise<import("axios").AxiosResponse<{ shiftSettings: object }>>}
37
38
  */
38
39
  function update({jwtToken, token, shiftSettings, headers}) {
39
40
  return client({
@@ -46,13 +46,14 @@ const {authorizationHeaders} = require("./../endpoints_helpers.js");
46
46
  */
47
47
  function shiftsFactory({client, internalAuthTokenProvider}) {
48
48
  /**
49
- * GET /shifts - list shifts.
49
+ * GET /shifts - list shifts for the account. Returns shifts filtered by query params.
50
+ * See get-shifts handler getSpec() in btrz-api-accounts for full API details.
50
51
  * @param {Object} opts
51
52
  * @param {string} [opts.token] - API key
52
53
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
53
- * @param {ShiftsListQuery} [opts.query] - Query params
54
+ * @param {ShiftsListQuery} [opts.query] - Query params (includeActivity, status, pendingShiftClosure, locationId, providerId, sort, fromDate, toDate)
54
55
  * @param {Object} [opts.headers] - Optional headers
55
- * @returns {Promise<import("axios").AxiosResponse>}
56
+ * @returns {Promise<import("axios").AxiosResponse<{ shifts: Array }>>} Response body: { shifts }. Errors: 400 (validation), 401, 500
56
57
  */
57
58
  function all({jwtToken, token, query, headers}) {
58
59
  return client.get("/shifts", {
@@ -78,13 +79,14 @@ function shiftsFactory({client, internalAuthTokenProvider}) {
78
79
  }
79
80
 
80
81
  /**
81
- * POST /shifts - create a shift.
82
+ * POST /shifts - open a shift for a user. Body: PostShiftRequest (stationId, userId, counterNumber).
83
+ * See post-shift handler getSpec() in btrz-api-accounts for full API details.
82
84
  * @param {Object} opts
83
85
  * @param {string} [opts.token] - API key
84
86
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
85
- * @param {Object} opts.shiftData - Shift payload
87
+ * @param {Object} opts.shiftData - Shift payload (stationId, userId, counterNumber)
86
88
  * @param {Object} [opts.headers] - Optional headers
87
- * @returns {Promise<import("axios").AxiosResponse>}
89
+ * @returns {Promise<import("axios").AxiosResponse<{ shift: Object }>>} Response body: { shift }. Errors: 400, 401, 404 (USER_NOT_FOUND, STATION_NOT_FOUND), 409 (SHIFT_ALREADY_OPEN_FOR_USER, USER_WITHOUT_SHIFT_ENABLED), 500
88
90
  */
89
91
  function create({jwtToken, token, shiftData, headers}) {
90
92
  return client({
@@ -98,14 +100,16 @@ function shiftsFactory({client, internalAuthTokenProvider}) {
98
100
  }
99
101
 
100
102
  /**
101
- * PATCH /shifts/:shiftId - update a shift (operations). API getSpec() does not define query params.
103
+ * PATCH /shifts/:shiftId - close a shift. Body: PatchShiftRequest (operations array with comment).
104
+ * See patch-shift handler getSpec() in btrz-api-accounts for full API details.
102
105
  * @param {Object} opts
103
106
  * @param {string} [opts.token] - API key
104
107
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
105
108
  * @param {string} opts.shiftId - Shift id (ObjectId)
106
- * @param {Object} opts.operations - Operations payload
109
+ * @param {Object} opts.operations - Operations payload (e.g. [{ comment }] for close)
107
110
  * @param {Object} [opts.headers] - Optional headers
108
- * @returns {Promise<import("axios").AxiosResponse>}
111
+ * @param {Object} [opts.query] - Optional query params
112
+ * @returns {Promise<import("axios").AxiosResponse<{ shift: Object }>>} Response body: { shift }. Errors: 401, 404 (SHIFT_NOT_FOUND, USER_NOT_FOUND), 409 (SHIFT_ALREADY_CLOSED, COMMENT_IS_MANDATORY_WHEN_VARIANCE_EXISTS, TOTAL_CHANGED), 500
109
113
  */
110
114
  function update({jwtToken, token, shiftId, operations, headers, query}) {
111
115
  return client({
@@ -12,6 +12,7 @@ const {
12
12
  * @property {string} [sort] - relevance | natural | createdAsc | createdDesc | updatedAsc | updatedDesc
13
13
  * @property {string} [templateCollectionId] - default | custom
14
14
  * @property {string} [status] - draft | published
15
+ * @property {string} [agencyId] - Filter sub-templates for this agency (ObjectId)
15
16
  * @property {string} [mainTemplateAccountId] - Filter by source provider (ObjectId)
16
17
  * @property {string} [lang] - ISO language code (e.g. en-us)
17
18
  * @property {number} [page] - 1-based page for pagination
@@ -41,12 +42,13 @@ const {
41
42
  */
42
43
  function smsTemplatesFactory({client, internalAuthTokenProvider}) {
43
44
  /**
44
- * GET /sms-templates/types - returns available template types. API does not accept query params.
45
+ * GET /sms-templates/types - returns available template types.
45
46
  * @param {Object} opts
46
47
  * @param {string} [opts.token] - API key
47
48
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
48
49
  * @param {Object} [opts.headers] - Optional headers
49
- * @returns {Promise<import("axios").AxiosResponse>}
50
+ * @returns {Promise<import("axios").AxiosResponse<{ types: string[] }>>}
51
+ * @throws {import("axios").AxiosError} 401, 500
50
52
  */
51
53
  function getTypes({token, jwtToken, headers}) {
52
54
  return client({
@@ -56,13 +58,14 @@ function smsTemplatesFactory({client, internalAuthTokenProvider}) {
56
58
  }
57
59
 
58
60
  /**
59
- * GET /sms-templates - list SMS templates.
61
+ * GET /sms-templates - list SMS templates (paginated when page is provided).
60
62
  * @param {Object} opts
61
63
  * @param {string} [opts.token] - API key
62
64
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
63
- * @param {SmsTemplatesListQuery} [opts.query] - Query params (providerId, type, channel, sort, etc.)
65
+ * @param {SmsTemplatesListQuery} [opts.query] - Query params (providerId, type, channel, sort, agencyId, etc.)
64
66
  * @param {Object} [opts.headers] - Optional headers
65
- * @returns {Promise<import("axios").AxiosResponse>}
67
+ * @returns {Promise<import("axios").AxiosResponse<{ smsTemplates: object[], next?: string, previous?: string, totalRecords?: number, page?: number }>>}
68
+ * @throws {import("axios").AxiosError} 400 WRONG_DATA, 401, 500
66
69
  */
67
70
  function all({token, jwtToken, query = {}, headers}) {
68
71
  return client({
@@ -80,7 +83,8 @@ function smsTemplatesFactory({client, internalAuthTokenProvider}) {
80
83
  * @param {string} opts.smsTemplateId - Template id (ObjectId)
81
84
  * @param {SmsTemplateGetByIdQuery} [opts.query] - Query params (providerId, superUserId, superUserHash)
82
85
  * @param {Object} [opts.headers] - Optional headers
83
- * @returns {Promise<import("axios").AxiosResponse>}
86
+ * @returns {Promise<import("axios").AxiosResponse<{ smsTemplate: object }>>}
87
+ * @throws {import("axios").AxiosError} 400 INVALID_SMS_TEMPLATE_ID / INVALID_PROVIDER_ID, 401, 404 SMS_TEMPLATE_NOT_FOUND, 500
84
88
  */
85
89
  function get({token, jwtToken, smsTemplateId, query = {}, headers}) {
86
90
  return client({
@@ -91,13 +95,14 @@ function smsTemplatesFactory({client, internalAuthTokenProvider}) {
91
95
  }
92
96
 
93
97
  /**
94
- * POST /sms-templates - create an SMS template. API does not accept query params.
98
+ * POST /sms-templates - create an SMS template. Body: smsTemplate (name, type, lang, txtTemplate required).
95
99
  * @param {Object} opts
96
100
  * @param {string} [opts.token] - API key
97
101
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
98
- * @param {Object} opts.data - Request body
102
+ * @param {Object} opts.data - Request body (smsTemplate or root with name, type, lang, txtTemplate)
99
103
  * @param {Object} [opts.headers] - Optional headers
100
- * @returns {Promise<import("axios").AxiosResponse>}
104
+ * @returns {Promise<import("axios").AxiosResponse<{ smsTemplate: object }>>}
105
+ * @throws {import("axios").AxiosError} 400 WRONG_DATA / TEMPLATE_* / LANG_* / TXT_TEMPLATE_REQUIRED, 401 NOT_SUPER_USER, 500
101
106
  */
102
107
  function create({token, jwtToken, data, headers}) {
103
108
  return client({
@@ -109,14 +114,15 @@ function smsTemplatesFactory({client, internalAuthTokenProvider}) {
109
114
  }
110
115
 
111
116
  /**
112
- * PUT /sms-templates/:smsTemplateId - update an SMS template. API does not accept query params.
117
+ * PUT /sms-templates/:smsTemplateId - update an SMS template. Body: smsTemplate (name, type, txtTemplate required; lang read-only).
113
118
  * @param {Object} opts
114
119
  * @param {string} [opts.token] - API key
115
120
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
116
121
  * @param {string} opts.smsTemplateId - Template id (ObjectId)
117
- * @param {Object} opts.data - Request body
122
+ * @param {Object} opts.data - Request body (smsTemplate or root)
118
123
  * @param {Object} [opts.headers] - Optional headers
119
- * @returns {Promise<import("axios").AxiosResponse>}
124
+ * @returns {Promise<import("axios").AxiosResponse<{ smsTemplate: object }>>}
125
+ * @throws {import("axios").AxiosError} 400 WRONG_DATA / TEMPLATE_* / TXT_TEMPLATE_REQUIRED, 401 NOT_SUPER_USER, 404 SMS_TEMPLATE_NOT_FOUND, 500
120
126
  */
121
127
  function update({token, jwtToken, smsTemplateId, data, headers}) {
122
128
  return client({
@@ -128,13 +134,14 @@ function smsTemplatesFactory({client, internalAuthTokenProvider}) {
128
134
  }
129
135
 
130
136
  /**
131
- * DELETE /sms-templates/:smsTemplateId - delete an SMS template. API does not accept query params.
137
+ * DELETE /sms-templates/:smsTemplateId - delete an SMS template.
132
138
  * @param {Object} opts
133
139
  * @param {string} [opts.token] - API key
134
140
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
135
141
  * @param {string} opts.smsTemplateId - Template id (ObjectId)
136
142
  * @param {Object} [opts.headers] - Optional headers
137
- * @returns {Promise<import("axios").AxiosResponse>}
143
+ * @returns {Promise<import("axios").AxiosResponse<{ smsTemplateId: string }>>}
144
+ * @throws {import("axios").AxiosError} 400 SMS_TEMPLATE_ID, 401, 404 SMS_TEMPLATE_NOT_FOUND, 500
138
145
  */
139
146
  function remove({token, jwtToken, smsTemplateId, headers}) {
140
147
  return client({
@@ -145,14 +152,15 @@ function smsTemplatesFactory({client, internalAuthTokenProvider}) {
145
152
  }
146
153
 
147
154
  /**
148
- * POST /sub-sms-templates - create a sub SMS template from a main template. API does not accept query params.
155
+ * POST /sub-sms-templates - create a sub SMS template from a main template.
149
156
  * @param {Object} opts
150
157
  * @param {string} [opts.token] - API key
151
158
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
152
159
  * @param {string} opts.mainTemplateId - Main template id (ObjectId)
153
160
  * @param {string} opts.agencyId - Agency id (ObjectId)
154
161
  * @param {Object} [opts.headers] - Optional headers
155
- * @returns {Promise<import("axios").AxiosResponse>}
162
+ * @returns {Promise<import("axios").AxiosResponse<{ smsTemplate: object }>>}
163
+ * @throws {import("axios").AxiosError} 400 WRONG_DATA / MAIN_TEMPLATE_IS_NOT_CUSTOM, 401 MAIN_TEMPLATE_ACCOUNT_MISMATCH / MAIN_TEMPLATE_NOT_FROM_PROVIDER, 404 MAIN_TEMPLATE_NOT_FOUND, 500
156
164
  */
157
165
  function createSub({token, jwtToken, mainTemplateId, agencyId, headers}) {
158
166
  return client({
@@ -165,15 +173,16 @@ function smsTemplatesFactory({client, internalAuthTokenProvider}) {
165
173
 
166
174
  const versions = {
167
175
  /**
168
- * PUT /sms-templates/:smsTemplateId/versions/:versionId - roll back sms template to a version.
176
+ * PUT /sms-templates/:smsTemplateId/versions/:versionId - roll back SMS template to a saved version (versionId = zero-based index).
169
177
  * @param {Object} opts
170
178
  * @param {string} [opts.token] - API key
171
179
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
172
180
  * @param {string} opts.smsTemplateId - Template id (ObjectId)
173
181
  * @param {string} opts.versionId - Zero-based version index (e.g. "0", "1")
174
- * @param {SmsTemplateVersionUpdateQuery} [opts.query] - Query params (superUserId, superUserHash)
182
+ * @param {SmsTemplateVersionUpdateQuery} [opts.query] - Query params (superUserId, superUserHash for default templates)
175
183
  * @param {Object} [opts.headers] - Optional headers
176
- * @returns {Promise<import("axios").AxiosResponse>}
184
+ * @returns {Promise<import("axios").AxiosResponse<{ smsTemplate: object }>>}
185
+ * @throws {import("axios").AxiosError} 400 WRONG_DATA, 401 NOT_SUPER_USER, 404 SMS_TEMPLATE_NOT_FOUND / SMS_TEMPLATE_VERSION_NOT_FOUND, 500
177
186
  */
178
187
  update({token, jwtToken, smsTemplateId, versionId, query = {}, headers}) {
179
188
  return client({
@@ -1,3 +1,4 @@
1
+ /* eslint-disable max-len */
1
2
  const {
2
3
  authorizationHeaders
3
4
  } = require("./../endpoints_helpers.js");
@@ -11,13 +12,14 @@ const {
11
12
  */
12
13
  function subPrintTemplatesFactory({client, internalAuthTokenProvider}) {
13
14
  /**
14
- * POST /sub-print-templates - create a sub print template. API does not accept query params.
15
+ * POST /sub-print-templates - create a sub print template from a main template (body: agencyId, mainTemplateId).
15
16
  * @param {Object} opts
16
17
  * @param {string} [opts.token] - API key
17
18
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
18
- * @param {Object} opts.subPrintTemplate - Sub print template payload
19
+ * @param {Object} opts.subPrintTemplate - Payload with agencyId and mainTemplateId (both ObjectIds)
19
20
  * @param {Object} [opts.headers] - Optional headers
20
- * @returns {Promise<import("axios").AxiosResponse>}
21
+ * @returns {Promise<import("axios").AxiosResponse<{ printTemplate: object }>>}
22
+ * @throws {import("axios").AxiosError} 400 WRONG_DATA / MAIN_TEMPLATE_IS_NOT_CUSTOM, 401 MAIN_TEMPLATE_ACCOUNT_MISMATCH / MAIN_TEMPLATE_NOT_FROM_PROVIDER, 404 MAIN_TEMPLATE_NOT_FOUND, 500
21
23
  */
22
24
  function create({jwtToken, token, subPrintTemplate, headers}) {
23
25
  return client({
@@ -11,12 +11,13 @@ const {
11
11
  */
12
12
  function ticketMovementSettingsFactory({client, internalAuthTokenProvider}) {
13
13
  /**
14
- * GET /ticket-movement-settings - get ticket movement settings. API does not accept query params.
14
+ * GET /ticket-movement-settings - get ticket movement settings for the account.
15
+ * No query or path parameters. See get-handler getSpec() in btrz-api-accounts for response schema.
15
16
  * @param {Object} opts
16
17
  * @param {string} [opts.token] - API key
17
18
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
18
19
  * @param {Object} [opts.headers] - Optional headers
19
- * @returns {Promise<import("axios").AxiosResponse>}
20
+ * @returns {Promise<import("axios").AxiosResponse<Object>>} Response body: ticket movement settings object. Errors: 401, 500
20
21
  */
21
22
  function get({token, jwtToken, headers}) {
22
23
  return client({
@@ -26,13 +27,15 @@ function ticketMovementSettingsFactory({client, internalAuthTokenProvider}) {
26
27
  }
27
28
 
28
29
  /**
29
- * PUT /ticket-movement-settings - update ticket movement settings. API does not accept query params.
30
+ * PUT /ticket-movement-settings - update ticket movement settings for the account.
31
+ * Body must include all required fields (see put-handler getSpec() in btrz-api-accounts).
32
+ * Side effect: persists to account.preferences.ticketMovements.
30
33
  * @param {Object} opts
31
34
  * @param {string} [opts.token] - API key
32
35
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
33
- * @param {Object} opts.ticketMovementSettings - Settings payload
36
+ * @param {Object} opts.ticketMovementSettings - Full settings payload (see put-handler getSpec())
34
37
  * @param {Object} [opts.headers] - Optional headers
35
- * @returns {Promise<import("axios").AxiosResponse>}
38
+ * @returns {Promise<import("axios").AxiosResponse<Object>>} Updated settings. Errors: 400, 401, 500
36
39
  */
37
40
  function update({token, jwtToken, ticketMovementSettings, headers}) {
38
41
  return client({