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
@@ -23,13 +23,14 @@ const {authorizationHeaders} = require("./../endpoints_helpers.js");
23
23
  */
24
24
  function travellersFactory({client, internalAuthTokenProvider}) {
25
25
  /**
26
- * GET /travellers - list travellers.
26
+ * GET /travellers - list travellers for the account. See get-handler getSpec() in btrz-api-accounts.
27
27
  * @param {Object} opts
28
28
  * @param {string} [opts.token] - API key
29
29
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
30
30
  * @param {TravellersListQuery} [opts.query] - Query params (customerId, page, providerIds)
31
31
  * @param {Object} [opts.headers] - Optional headers
32
- * @returns {Promise<import("axios").AxiosResponse>}
32
+ * @returns {Promise<import("axios").AxiosResponse<{ travellers: Array, page?: number, count?: number }>>}
33
+ * Errors: 401, 404 (CUSTOMER_NOT_FOUND), 500
33
34
  */
34
35
  function all({token, jwtToken, query, headers}) {
35
36
  return client({
@@ -40,13 +41,15 @@ function travellersFactory({client, internalAuthTokenProvider}) {
40
41
  }
41
42
 
42
43
  /**
43
- * GET /travellers/:id - get a traveller. API does not accept query params.
44
+ * GET /travellers/:id - get a traveller by id. See get-by-id-handler getSpec() in btrz-api-accounts.
44
45
  * @param {Object} opts
45
46
  * @param {string} [opts.token] - API key
46
47
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
47
48
  * @param {string} opts.id - Traveller id (ObjectId)
49
+ * @param {Object} [opts.query] - Optional query params
48
50
  * @param {Object} [opts.headers] - Optional headers
49
- * @returns {Promise<import("axios").AxiosResponse>}
51
+ * @returns {Promise<import("axios").AxiosResponse<{ traveller: Object }>>}
52
+ * Errors: 400, 401, 404 (TRAVELLER_NOT_FOUND), 500
50
53
  */
51
54
  function get({token, jwtToken, id, query = {}, headers}) {
52
55
  return client({
@@ -58,15 +61,16 @@ function travellersFactory({client, internalAuthTokenProvider}) {
58
61
  }
59
62
 
60
63
  /**
61
- * PUT /travellers/:id - update a traveller.
64
+ * PUT /travellers/:id - update a traveller. See put-handler getSpec() in btrz-api-accounts.
62
65
  * @param {Object} opts
63
66
  * @param {string} [opts.token] - API key
64
67
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
65
68
  * @param {string} opts.id - Traveller id (ObjectId)
66
- * @param {Object} opts.data - Traveller payload
69
+ * @param {Object} opts.data - Traveller payload (TravellerPutData)
67
70
  * @param {TravellerProviderIdsQuery} [opts.query] - Query params (providerIds)
68
71
  * @param {Object} [opts.headers] - Optional headers
69
- * @returns {Promise<import("axios").AxiosResponse>}
72
+ * @returns {Promise<import("axios").AxiosResponse<{ traveller: Object }>>}
73
+ * Errors: 400, 401, 404, 409, 500
70
74
  */
71
75
  function update({token, jwtToken, id, data, query = {}, headers}) {
72
76
  return client({
@@ -79,14 +83,15 @@ function travellersFactory({client, internalAuthTokenProvider}) {
79
83
  }
80
84
 
81
85
  /**
82
- * DELETE /travellers/:id - remove a traveller.
86
+ * DELETE /travellers/:id - remove a traveller. Returns 204 No Content. See delete-handler getSpec().
83
87
  * @param {Object} opts
84
88
  * @param {string} [opts.token] - API key
85
89
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
86
90
  * @param {string} opts.id - Traveller id (ObjectId)
87
91
  * @param {TravellerProviderIdsQuery} [opts.query] - Query params (providerIds)
88
92
  * @param {Object} [opts.headers] - Optional headers
89
- * @returns {Promise<import("axios").AxiosResponse>}
93
+ * @returns {Promise<import("axios").AxiosResponse<void>>}
94
+ * Errors: 400, 401, 404 (TRAVELLER_NOT_FOUND), 500
90
95
  */
91
96
  function remove({token, jwtToken, id, query = {}, headers}) {
92
97
  return client({
@@ -98,14 +103,15 @@ function travellersFactory({client, internalAuthTokenProvider}) {
98
103
  }
99
104
 
100
105
  /**
101
- * POST /travellers - create a traveller.
106
+ * POST /travellers - create a traveller. Returns 201. See post-handler getSpec() in btrz-api-accounts.
102
107
  * @param {Object} opts
103
108
  * @param {string} [opts.token] - API key
104
109
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
105
- * @param {Object} opts.data - Traveller payload
110
+ * @param {Object} opts.data - Traveller payload (TravellerPostData: customerId, fareId, cards, etc.)
106
111
  * @param {TravellerProviderIdsQuery} [opts.query] - Query params (providerIds)
107
112
  * @param {Object} [opts.headers] - Optional headers
108
- * @returns {Promise<import("axios").AxiosResponse>}
113
+ * @returns {Promise<import("axios").AxiosResponse<{ traveller: Object }>>}
114
+ * Errors: 400, 401, 404, 409, 500
109
115
  */
110
116
  function create({token, jwtToken, query = {}, data, headers}) {
111
117
  return client({
@@ -17,13 +17,14 @@ const {authorizationHeaders} = require("./../endpoints_helpers.js");
17
17
  */
18
18
  function trustedMachinesFactory({client, internalAuthTokenProvider}) {
19
19
  /**
20
- * POST /trusted-machines - create (register) a trusted machine. API does not accept query params.
20
+ * POST /trusted-machines - trust the machine (hideInDocumentation: true in API). Sets cookie via Set-Cookie.
21
21
  * @param {Object} opts
22
22
  * @param {string} [opts.token] - API key
23
23
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
24
- * @param {Object} opts.data - Trusted machine payload
24
+ * @param {Object} opts.data - Body (NewTrustedMachine: expirationDays, browserFingerprint, etc.)
25
25
  * @param {Object} [opts.headers] - Optional headers
26
- * @returns {Promise<import("axios").AxiosResponse>}
26
+ * @returns {Promise<import("axios").AxiosResponse<{ result: string, trustedMachine: Object }>>}
27
+ * Errors: 400, 401, 409, 500
27
28
  */
28
29
  function create({token, jwtToken, data, headers}) {
29
30
  return client({
@@ -36,13 +37,14 @@ function trustedMachinesFactory({client, internalAuthTokenProvider}) {
36
37
  }
37
38
 
38
39
  /**
39
- * GET /trusted-machines/:id - get a trusted machine. API does not accept query params.
40
+ * GET /trusted-machines/:id - get a trusted machine by id. See get-by-id-handler getSpec() in btrz-api-accounts.
40
41
  * @param {Object} opts
41
42
  * @param {string} [opts.token] - API key
42
43
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
43
44
  * @param {string} opts.id - Trusted machine id (ObjectId)
44
45
  * @param {Object} [opts.headers] - Optional headers
45
- * @returns {Promise<import("axios").AxiosResponse>}
46
+ * @returns {Promise<import("axios").AxiosResponse<{ trustedmachine: Object }>>}
47
+ * Errors: 400, 401, 404 (TRUSTED_MACHINE_NOT_FOUND), 500
46
48
  */
47
49
  function get({token, jwtToken, id, headers}) {
48
50
  return client({
@@ -53,13 +55,14 @@ function trustedMachinesFactory({client, internalAuthTokenProvider}) {
53
55
  }
54
56
 
55
57
  /**
56
- * GET /trusted-machines - list trusted machines.
58
+ * GET /trusted-machines - list enabled trusted machines for the account. See get-handler getSpec().
57
59
  * @param {Object} opts
58
60
  * @param {string} [opts.token] - API key
59
61
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
60
- * @param {TrustedMachinesListQuery} [opts.query] - Query params (userId, page, recordsPerPage)
62
+ * @param {TrustedMachinesListQuery} [opts.query] - Query params (userId, page, recordsPerPage max 100)
61
63
  * @param {Object} [opts.headers] - Optional headers
62
- * @returns {Promise<import("axios").AxiosResponse>}
64
+ * @returns {Promise<import("axios").AxiosResponse<{ trustedmachines: Array }>>}
65
+ * Paginated. Errors: 401, 500
63
66
  */
64
67
  function all({token, jwtToken, query = {}, headers}) {
65
68
  return client({
@@ -11,12 +11,14 @@ const {
11
11
  */
12
12
  function twilioSettingsFactory({client, internalAuthTokenProvider}) {
13
13
  /**
14
- * GET /twilio-settings - get Twilio settings. API does not accept query params.
14
+ * GET /twilio-settings - get Twilio settings for the account. See get-handler getSpec() in btrz-api-accounts.
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<{ twilioSettings: Object }>>}
21
+ * Errors: 401, 404 (TWILIO_SETTINGS_NOT_FOUND), 500
20
22
  */
21
23
  function get({jwtToken, token, query, headers}) {
22
24
  return client({
@@ -27,13 +29,14 @@ function twilioSettingsFactory({client, internalAuthTokenProvider}) {
27
29
  }
28
30
 
29
31
  /**
30
- * PUT /twilio-settings - update Twilio settings. API does not accept query params.
32
+ * PUT /twilio-settings - update Twilio settings. See put-handler getSpec() in btrz-api-accounts.
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.twilioSettings - Settings payload
36
+ * @param {Object} opts.twilioSettings - Settings payload (TwilioSettingsPayload: enabled, sendingNumber, etc.)
35
37
  * @param {Object} [opts.headers] - Optional headers
36
- * @returns {Promise<import("axios").AxiosResponse>}
38
+ * @returns {Promise<import("axios").AxiosResponse<{ twilioSettings: Object }>>}
39
+ * Errors: 401, 404, 409, 500
37
40
  */
38
41
  function update({jwtToken, token, twilioSettings, headers}) {
39
42
  return client({
@@ -1,6 +1,24 @@
1
1
  /* eslint-disable max-len */
2
2
  const {authorizationHeaders} = require("./../endpoints_helpers.js");
3
3
 
4
+ /**
5
+ * Query params for GET /users (btrz-api-accounts). See get-users getSpec().
6
+ * @typedef {Object} GetUsersListQuery
7
+ * @property {number} [page] - Page number (1-based). When provided, response is limited to pageSize items.
8
+ * @property {string} [deleted] - "true" | "false" to filter by deleted flag
9
+ * @property {string} [firstName] - Filter by first name (prefix, case-insensitive)
10
+ * @property {string} [lastName] - Filter by last name (prefix, case-insensitive)
11
+ * @property {string} [display] - Filter by display name (prefix, case-insensitive)
12
+ * @property {string} [externalId] - Filter by external ID (exact)
13
+ * @property {string} [employeeNumber] - Filter by employee number (exact)
14
+ * @property {string} [email] - Filter by email (prefix, case-insensitive)
15
+ * @property {string} [assignableToManifest] - "true" | "false"
16
+ * @property {string} [role] - Filter users that have this role (role key)
17
+ * @property {string} [excludedRoles] - Comma-separated role keys to exclude
18
+ * @property {string} [preferredLocationId] - Filter by preferred location ID
19
+ * @property {string} [preferredLocationIds] - Filter by preferred location IDs
20
+ */
21
+
4
22
  /**
5
23
  * Query params for GET /users/:userId/sequences (btrz-api-accounts). See get-user-sequences-handler getSpec().
6
24
  * @typedef {Object} UserSequencesListQuery
@@ -13,7 +31,7 @@ const {authorizationHeaders} = require("./../endpoints_helpers.js");
13
31
  * @param {Object} deps
14
32
  * @param {import("axios").AxiosInstance} deps.client
15
33
  * @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
16
- * @returns {{ get: function, getV2: function, all: function, create: function, login: function, update: function, createOrUpdateMany: function, impersonate: function, startMfa: function, confirmMfa: function, disableMfa: function, sequences: { get: function, all: function, create: function, update: function, transfer: function } }}
34
+ * @returns {{ get: function, getV2: function, all: function, create: function, login: function, update: function, delete: function, createOrUpdateMany: function, impersonate: function, startMfa: function, confirmMfa: function, disableMfa: function, sequences: { get: function, all: function, create: function, update: function, transfer: function } }}
17
35
  */
18
36
  function usersFactory({client, internalAuthTokenProvider}) {
19
37
  /**
@@ -49,10 +67,11 @@ function usersFactory({client, internalAuthTokenProvider}) {
49
67
  }
50
68
 
51
69
  /**
52
- * GET /users - list users. API getSpec() does not define query params.
70
+ * GET /users - list users with optional pagination and filters.
53
71
  * @param {Object} opts
54
72
  * @param {string} [opts.token] - API key
55
73
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
74
+ * @param {GetUsersListQuery} [opts.query] - Query params (page, deleted, firstName, lastName, display, externalId, employeeNumber, email, assignableToManifest, role, excludedRoles, preferredLocationId, preferredLocationIds)
56
75
  * @param {Object} [opts.headers] - Optional headers
57
76
  * @returns {Promise<import("axios").AxiosResponse>}
58
77
  */
@@ -97,14 +116,14 @@ function usersFactory({client, internalAuthTokenProvider}) {
97
116
  }
98
117
 
99
118
  /**
100
- * PUT /users/:userId - update a user.
119
+ * PUT /users/:userId - update a user. Emits webhook user.updated.
101
120
  * @param {Object} opts
102
121
  * @param {string} [opts.token] - API key
103
122
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
104
123
  * @param {string} opts.userId - User id (ObjectId)
105
- * @param {Object} opts.user - User payload
124
+ * @param {Object} opts.user - User payload (allowed fields per PUT /users/:userId spec)
106
125
  * @param {Object} [opts.headers] - Optional headers
107
- * @returns {Promise<import("axios").AxiosResponse>}
126
+ * @returns {Promise<import("axios").AxiosResponse<{ user: Object }>>}
108
127
  */
109
128
  function update({token, jwtToken, userId, user, headers}) {
110
129
  return client({
@@ -115,6 +134,23 @@ function usersFactory({client, internalAuthTokenProvider}) {
115
134
  });
116
135
  }
117
136
 
137
+ /**
138
+ * DELETE /users/:id - delete a user. Emits webhook user.deleted. Returns 204 on success.
139
+ * @param {Object} opts
140
+ * @param {string} [opts.token] - API key
141
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
142
+ * @param {string} opts.id - User id (ObjectId)
143
+ * @param {Object} [opts.headers] - Optional headers
144
+ * @returns {Promise<import("axios").AxiosResponse>}
145
+ */
146
+ function deleteUser({token, jwtToken, id, headers}) {
147
+ return client({
148
+ url: `/users/${id}`,
149
+ method: "delete",
150
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
151
+ });
152
+ }
153
+
118
154
  /**
119
155
  * POST /users/import - create or update many users.
120
156
  * @param {Object} opts
@@ -306,6 +342,7 @@ function usersFactory({client, internalAuthTokenProvider}) {
306
342
  create,
307
343
  login,
308
344
  update,
345
+ delete: deleteUser,
309
346
  createOrUpdateMany,
310
347
  impersonate,
311
348
  startMfa,
@@ -0,0 +1,100 @@
1
+ const {authorizationHeaders} = require("./../endpoints_helpers.js");
2
+
3
+ /**
4
+ * Query params for GET /verified-emails (btrz-api-accounts). See get-handler getSpec().
5
+ * @typedef {Object} VerifiedEmailsListQuery
6
+ * @property {number} [page] - Page number (1-based). Default 1.
7
+ * @property {number} [pageSize] - Page size. Default 20.
8
+ */
9
+
10
+ /**
11
+ * Factory for verified-emails API (btrz-api-accounts).
12
+ * @param {Object} deps
13
+ * @param {import("axios").AxiosInstance} deps.client
14
+ * @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
15
+ * @returns {{ all: function, get: function, create: function, update: function }}
16
+ */
17
+ function verifiedEmailsFactory({client, internalAuthTokenProvider}) {
18
+ /**
19
+ * GET /verified-emails - list verified emails for the account (paginated).
20
+ * @param {Object} opts
21
+ * @param {string} [opts.token] - API key
22
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
23
+ * @param {VerifiedEmailsListQuery} [opts.query] - Query params (page, pageSize)
24
+ * @param {Object} [opts.headers] - Optional headers
25
+ * @returns {Promise<import("axios").AxiosResponse<{ verifiedEmails: Array }>>}
26
+ * Errors: 401, 500
27
+ */
28
+ function all({token, jwtToken, query = {}, headers}) {
29
+ return client({
30
+ url: "/verified-emails",
31
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
32
+ params: query
33
+ });
34
+ }
35
+
36
+ /**
37
+ * GET /verified-emails/:email - get a verified email by email address.
38
+ * @param {Object} opts
39
+ * @param {string} [opts.token] - API key
40
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
41
+ * @param {string} opts.email - Email address (path parameter)
42
+ * @param {Object} [opts.headers] - Optional headers
43
+ * @returns {Promise<import("axios").AxiosResponse<{ verifiedEmail: Object }>>}
44
+ * Errors: 400 (WRONG_DATA), 401, 404 (VERIFIED_EMAIL_NOT_FOUND), 500
45
+ */
46
+ function get({token, jwtToken, email, headers}) {
47
+ return client({
48
+ url: `/verified-emails/${encodeURIComponent(email)}`,
49
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
50
+ });
51
+ }
52
+
53
+ /**
54
+ * POST /verified-emails - create a verified email. Emits webhook verifiedEmails.created.
55
+ * @param {Object} opts
56
+ * @param {string} [opts.token] - API key
57
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
58
+ * @param {Object} opts.data - Body: email (required), status (BLACKLISTED | BLOCKED | WHITELISTED), optional QEVResponse
59
+ * @param {Object} [opts.headers] - Optional headers
60
+ * @returns {Promise<import("axios").AxiosResponse<{ verifiedEmail: Object }>>}
61
+ * Errors: 400 (WRONG_DATA, INVALID_STATUS), 401, 500
62
+ */
63
+ function create({token, jwtToken, data, headers}) {
64
+ return client({
65
+ url: "/verified-emails",
66
+ method: "post",
67
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
68
+ data
69
+ });
70
+ }
71
+
72
+ /**
73
+ * PUT /verified-emails/:email - update a verified email. Emits webhook verifiedEmails.updated.
74
+ * @param {Object} opts
75
+ * @param {string} [opts.token] - API key
76
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
77
+ * @param {string} opts.email - Email address (path parameter)
78
+ * @param {Object} opts.data - Body: status (BLACKLISTED | BLOCKED | WHITELISTED), optional QEVResponse
79
+ * @param {Object} [opts.headers] - Optional headers
80
+ * @returns {Promise<import("axios").AxiosResponse<{ verifiedEmail: Object }>>}
81
+ * Errors: 400 (INVALID_STATUS, VERIFIED_EMAIL_BLOCKED), 401, 404 (VERIFIED_EMAIL_NOT_FOUND), 500
82
+ */
83
+ function update({token, jwtToken, email, data, headers}) {
84
+ return client({
85
+ url: `/verified-emails/${encodeURIComponent(email)}`,
86
+ method: "put",
87
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
88
+ data
89
+ });
90
+ }
91
+
92
+ return {
93
+ all,
94
+ get,
95
+ create,
96
+ update
97
+ };
98
+ }
99
+
100
+ module.exports = verifiedEmailsFactory;
@@ -17,13 +17,14 @@ const {authorizationHeaders} = require("./../endpoints_helpers.js");
17
17
  */
18
18
  function websalesConfigFactory({client, internalAuthTokenProvider}) {
19
19
  /**
20
- * GET /websales-config - get websales config (list).
20
+ * GET /websales-config - get websales config list (paginated). Query: domain, providerId.
21
21
  * @param {Object} opts
22
22
  * @param {string} [opts.token] - API key
23
23
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
24
24
  * @param {WebsalesConfigListQuery} [opts.query] - Query params (domain, providerId)
25
25
  * @param {Object} [opts.headers] - Optional headers
26
- * @returns {Promise<import("axios").AxiosResponse>}
26
+ * @returns {Promise<import("axios").AxiosResponse<{ websalesConfig: Array, next?: string, previous?: string, count?: number }>>}
27
+ * Errors: 401, 500
27
28
  */
28
29
  function get({token, jwtToken, query = {}, headers}) {
29
30
  return client({
@@ -34,14 +35,15 @@ function websalesConfigFactory({client, internalAuthTokenProvider}) {
34
35
  }
35
36
 
36
37
  /**
37
- * PUT /websales-config/:websalesConfigId - update websales config. API does not accept query params.
38
+ * PUT /websales-config/:websalesConfigId - update websales config. Emits webhook websalesConfig.updated.
38
39
  * @param {Object} opts
39
40
  * @param {string} [opts.token] - API key
40
41
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
41
42
  * @param {string} opts.websalesConfigId - Websales config id (ObjectId)
42
- * @param {Object} opts.websalesConfig - Config payload
43
+ * @param {Object} opts.websalesConfig - Config payload (WebsalesConfigPutData; SSO cannot be updated)
43
44
  * @param {Object} [opts.headers] - Optional headers
44
- * @returns {Promise<import("axios").AxiosResponse>}
45
+ * @returns {Promise<import("axios").AxiosResponse<{ websalesConfig: Object }>>}
46
+ * Errors: 400, 401, 404 (WEBSALESCONFIG_NOT_FOUND), 409, 500
45
47
  */
46
48
  function update({token, jwtToken, websalesConfigId, websalesConfig, headers}) {
47
49
  return client({
@@ -0,0 +1,58 @@
1
+ const {
2
+ axiosMock,
3
+ expectRequest
4
+ } = require("./../../test-helpers.js");
5
+ const api = require("./../../../src/client.js").createApiClient({
6
+ baseURL: "http://test.com"
7
+ });
8
+
9
+ describe("accounts/agencies", () => {
10
+ const jwtToken = "I owe you a JWT token";
11
+ const token = "I owe you a token";
12
+
13
+ afterEach(() => {
14
+ axiosMock.reset();
15
+ });
16
+
17
+ it("should PUT credit limit for an agency", () => {
18
+ const agencyId = "507f1f77bcf86cd799439011";
19
+ const data = {
20
+ limitAmount: 1000,
21
+ unlimited: false
22
+ };
23
+ axiosMock.onPut(`/agencies/${agencyId}/credit-limit`).reply(expectRequest({
24
+ statusCode: 200,
25
+ token,
26
+ jwtToken,
27
+ body: data
28
+ }));
29
+ return api.accounts.agencies.putCreditLimit({
30
+ token,
31
+ jwtToken,
32
+ agencyId,
33
+ data
34
+ });
35
+ });
36
+
37
+ it("should PUT credit limit with wrapped creditLimit body", () => {
38
+ const agencyId = "507f1f77bcf86cd799439012";
39
+ const data = {
40
+ creditLimit: {
41
+ limitAmount: 2000,
42
+ unlimited: true
43
+ }
44
+ };
45
+ axiosMock.onPut(`/agencies/${agencyId}/credit-limit`).reply(expectRequest({
46
+ statusCode: 200,
47
+ token,
48
+ jwtToken,
49
+ body: data
50
+ }));
51
+ return api.accounts.agencies.putCreditLimit({
52
+ token,
53
+ jwtToken,
54
+ agencyId,
55
+ data
56
+ });
57
+ });
58
+ });
@@ -0,0 +1,62 @@
1
+ const {
2
+ axiosMock,
3
+ expectRequest
4
+ } = require("./../../test-helpers.js");
5
+ const api = require("./../../../src/client.js").createApiClient({
6
+ baseURL: "http://test.com"
7
+ });
8
+
9
+ describe("accounts/external-customers", () => {
10
+ const jwtToken = "I owe you a JWT token";
11
+ const token = "I owe you a token";
12
+
13
+ afterEach(() => {
14
+ axiosMock.reset();
15
+ });
16
+
17
+ it("should POST Saldo Max registration (external-customers/ado)", () => {
18
+ const data = {
19
+ firstName: "TestName",
20
+ lastName: "TestLastName",
21
+ email: "test@betterez.com",
22
+ password: "YmFzZTY0cGFzc3dvcmQ=",
23
+ verificationCode: "689411",
24
+ isoCode: "AR"
25
+ };
26
+ axiosMock.onPost("/external-customers/ado").reply(expectRequest({
27
+ statusCode: 201,
28
+ token,
29
+ jwtToken,
30
+ body: data
31
+ }));
32
+ return api.accounts.externalCustomers.registerSaldoMax({
33
+ token,
34
+ jwtToken,
35
+ data
36
+ });
37
+ });
38
+
39
+ it("should POST with body wrapper when using body key", () => {
40
+ const data = {
41
+ body: {
42
+ firstName: "A",
43
+ lastName: "B",
44
+ email: "a@b.com",
45
+ password: "cGFzcw==",
46
+ verificationCode: "123",
47
+ isoCode: "MX"
48
+ }
49
+ };
50
+ const withoutApiKey = true;
51
+ axiosMock.onPost("/external-customers/ado").reply(expectRequest({
52
+ statusCode: 201,
53
+ jwtToken,
54
+ withoutApiKey,
55
+ body: data
56
+ }));
57
+ return api.accounts.externalCustomers.registerSaldoMax({
58
+ jwtToken,
59
+ data
60
+ });
61
+ });
62
+ });
@@ -61,6 +61,16 @@ describe("accounts/user/{id}", () => {
61
61
  });
62
62
  });
63
63
 
64
+ it("should delete a user", () => {
65
+ const userId = "627a25404a761f0fcbdbdfc1";
66
+ axiosMock.onDelete(`/users/${userId}`).reply(expectRequest({statusCode: 204, token, jwtToken}));
67
+ return api.accounts.users.delete({
68
+ jwtToken,
69
+ token,
70
+ id: userId
71
+ });
72
+ });
73
+
64
74
  it("should create a user", () => {
65
75
  const user = {
66
76
  firstName: "Jane",
@@ -0,0 +1,35 @@
1
+ const {axiosMock, expectRequest} = require("./../../test-helpers.js");
2
+ const api = require("./../../../src/client.js").createApiClient({baseURL: "http://test.com"});
3
+
4
+ describe("accounts/verified-emails", () => {
5
+ const token = "someToken";
6
+ const jwtToken = "I owe you a JWT token";
7
+
8
+ afterEach(() => {
9
+ axiosMock.restore();
10
+ });
11
+
12
+ it("should get all verified emails", () => {
13
+ const query = {page: 1, pageSize: 20};
14
+ axiosMock.onGet("/verified-emails").reply(expectRequest({statusCode: 200, token, jwtToken, query}));
15
+ return api.accounts.verifiedEmails.all({token, jwtToken, query});
16
+ });
17
+
18
+ it("should get verified email by email address", () => {
19
+ const email = "user@example.com";
20
+ axiosMock.onGet(`/verified-emails/${encodeURIComponent(email)}`).reply(expectRequest({statusCode: 200, token, jwtToken}));
21
+ return api.accounts.verifiedEmails.get({token, jwtToken, email});
22
+ });
23
+ it("should create a verified email", () => {
24
+ const data = {email: "test@example.com", status: "WHITELISTED"};
25
+ axiosMock.onPost("/verified-emails").reply(expectRequest({statusCode: 200, token, jwtToken, body: data}));
26
+ return api.accounts.verifiedEmails.create({token, jwtToken, data});
27
+ });
28
+
29
+ it("should update a verified email", () => {
30
+ const email = "user@example.com";
31
+ const data = {status: "BLACKLISTED"};
32
+ axiosMock.onPut(`/verified-emails/${encodeURIComponent(email)}`).reply(expectRequest({statusCode: 200, token, jwtToken, body: data}));
33
+ return api.accounts.verifiedEmails.update({token, jwtToken, email, data});
34
+ });
35
+ });
@@ -4,7 +4,7 @@ export = usersFactory;
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, getV2: function, all: function, create: function, login: function, update: function, createOrUpdateMany: function, impersonate: function, startMfa: function, confirmMfa: function, disableMfa: function, sequences: { get: function, all: function, create: function, update: function, transfer: function } }}
7
+ * @returns {{ get: function, getV2: function, all: function, create: function, login: function, update: function, delete: function, createOrUpdateMany: function, impersonate: function, startMfa: function, confirmMfa: function, disableMfa: function, sequences: { get: function, all: function, create: function, update: function, transfer: function } }}
8
8
  */
9
9
  declare function usersFactory({ client, internalAuthTokenProvider }: {
10
10
  client: import("axios").AxiosInstance;
@@ -18,6 +18,7 @@ declare function usersFactory({ client, internalAuthTokenProvider }: {
18
18
  create: Function;
19
19
  login: Function;
20
20
  update: Function;
21
+ delete: Function;
21
22
  createOrUpdateMany: Function;
22
23
  impersonate: Function;
23
24
  startMfa: Function;
@@ -0,0 +1,19 @@
1
+ export = verifiedEmailsFactory;
2
+ /**
3
+ * Factory for verified-emails API (btrz-api-accounts).
4
+ * @param {Object} deps
5
+ * @param {import("axios").AxiosInstance} deps.client
6
+ * @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
7
+ * @returns {{ all: function, get: function, create: function, update: function }}
8
+ */
9
+ declare function verifiedEmailsFactory({ client, internalAuthTokenProvider }: {
10
+ client: import("axios").AxiosInstance;
11
+ internalAuthTokenProvider?: {
12
+ getToken: () => string;
13
+ };
14
+ }): {
15
+ all: Function;
16
+ get: Function;
17
+ create: Function;
18
+ update: Function;
19
+ };