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
@@ -1,7 +1,8 @@
1
+ /* eslint-disable max-len */
1
2
  const {authorizationHeaders} = require("./../endpoints_helpers.js");
2
3
 
3
4
  /**
4
- * Factory for applications (by id/name) API (btrz-api-accounts).
5
+ * Factory for applications API (btrz-api-accounts): get by id or by name. Requires BETTEREZ_APP or MOBILE_SCANNER (get by id); get by name requires authentication.
5
6
  * @param {Object} deps
6
7
  * @param {import("axios").AxiosInstance} deps.client
7
8
  * @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
@@ -9,13 +10,13 @@ const {authorizationHeaders} = require("./../endpoints_helpers.js");
9
10
  */
10
11
  function applicationsFactory({client, internalAuthTokenProvider}) {
11
12
  /**
12
- * GET /applications/:id - get an application by id.
13
+ * GET /applications/:id - get an application by id. Application must belong to the authenticated account.
13
14
  * @param {Object} opts
14
15
  * @param {string} [opts.token] - API key
15
16
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
16
- * @param {string} opts.id - Application id (ObjectId)
17
+ * @param {string} opts.id - Application id (24-char hex ObjectId)
17
18
  * @param {Object} [opts.headers] - Optional headers
18
- * @returns {Promise<import("axios").AxiosResponse>}
19
+ * @returns {Promise<import("axios").AxiosResponse>} Response data: { application } (full application document including privateKey)
19
20
  */
20
21
  function get({token, id, jwtToken, headers}) {
21
22
  return client.get(`/applications/${id}`, {
@@ -23,13 +24,13 @@ function applicationsFactory({client, internalAuthTokenProvider}) {
23
24
  });
24
25
  }
25
26
  /**
26
- * GET /applications/name/:appName - get an application by name.
27
+ * GET /applications/name/:appName - get an application by name. Returns non-internal, non-deleted application for the account; response excludes privateKey.
27
28
  * @param {Object} opts
28
29
  * @param {string} [opts.token] - API key
29
30
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
30
- * @param {string} opts.appName - Application name
31
+ * @param {string} opts.appName - Application name (exact match)
31
32
  * @param {Object} [opts.headers] - Optional headers
32
- * @returns {Promise<import("axios").AxiosResponse>}
33
+ * @returns {Promise<import("axios").AxiosResponse>} Response data: { application } (application document without privateKey)
33
34
  */
34
35
  function getByName({token, appName, jwtToken, headers}) {
35
36
  return client.get(`/applications/name/${appName}`, {
@@ -1,15 +1,16 @@
1
+ /* eslint-disable max-len */
1
2
  const base64 = require("base-64");
2
3
  const {
3
4
  authorizationHeaders
4
5
  } = require("./../endpoints_helpers.js");
5
6
 
6
7
  /**
7
- * Query params for GET /customers (btrz-api-accounts). See get-customers getSpec().
8
+ * Query params for GET /customers (btrz-api-accounts). Response is paginated (customers array + pagination).
8
9
  * @typedef {Object} CustomersQuery
9
- * @property {string} [customerNumber] - A particular customer number; only that customer will be listed
10
- * @property {string} [externalId] - A particular externalId (same format as when creating the customer)
11
- * @property {string} [providerIds] - Provider ids to get customers from (comma-separated if more than one)
12
- * @property {string} [lookupSearchParams] - Lookup search data in format "documentTypeId|DNI,documentNumber|1234567"
10
+ * @property {string} [customerNumber] - Filter: only that customer will be listed
11
+ * @property {string} [externalId] - Filter: same format as when creating the customer; only that customer listed
12
+ * @property {string} [providerIds] - Filter: provider ids to get customers from (comma-separated)
13
+ * @property {string} [lookupSearchParams] - Lookup search in format "documentTypeId|DNI,documentNumber|1234567" (documentNumber required)
13
14
  */
14
15
 
15
16
  /**
@@ -21,14 +22,14 @@ const {
21
22
  */
22
23
  function customersFactory({client, internalAuthTokenProvider}) {
23
24
  /**
24
- * PUT /customers/:customerId - update a customer (full replace).
25
+ * PUT /customers/:customerId - update a customer (full replace). Requires BETTEREZ_APP or CUSTOMER audience; customer token may only update own record. Side effect: may emit customer.updated webhook.
25
26
  * @param {Object} opts
26
27
  * @param {string} [opts.token] - API key
27
28
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
28
- * @param {string} opts.customerId - Customer id (ObjectId)
29
- * @param {Object} opts.customer - Customer payload
29
+ * @param {string} opts.customerId - Customer id (24-char hex ObjectId)
30
+ * @param {Object} opts.customer - Customer payload (CustomerData)
30
31
  * @param {Object} [opts.headers] - Optional headers
31
- * @returns {Promise<import("axios").AxiosResponse>}
32
+ * @returns {Promise<import("axios").AxiosResponse<{ _id: string, customerNumber: string, ... }>>}
32
33
  */
33
34
  function put({customerId, customer, token, jwtToken, headers}) {
34
35
  return client({
@@ -40,14 +41,14 @@ function customersFactory({client, internalAuthTokenProvider}) {
40
41
  }
41
42
 
42
43
  /**
43
- * GET /customers - list customers.
44
+ * GET /customers - list customers (paginated). Optional filters: customerNumber, externalId, providerIds, lookupSearchParams.
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
- * @param {CustomersQuery} [opts.query] - Query params (customerNumber, externalId, providerIds, lookupSearchParams)
48
- * @param {string} [opts.providerId] - Provider id; if set, added to query (convenience for single provider)
48
+ * @param {CustomersQuery} [opts.query] - Query params; API expects providerIds (comma-separated). Use providerId to send a single id.
49
+ * @param {string} [opts.providerId] - Convenience: added to query as providerId (single provider)
49
50
  * @param {Object} [opts.headers] - Optional headers
50
- * @returns {Promise<import("axios").AxiosResponse>}
51
+ * @returns {Promise<import("axios").AxiosResponse<{ customers: Array<object>, total: number, ... }>>}
51
52
  */
52
53
  function all({token, jwtToken, query = {}, headers, providerId}) {
53
54
  const query_ = providerId ? {...query, providerId} : query;
@@ -59,13 +60,14 @@ function customersFactory({client, internalAuthTokenProvider}) {
59
60
  }
60
61
 
61
62
  /**
62
- * POST /customer - create a customer.
63
+ * POST /customer - create a customer. Body: { customer }. If password is included, activation token is created and activation email sent. Side effect: may emit customer.created webhook.
63
64
  * @param {Object} opts
64
65
  * @param {string} [opts.token] - API key
65
66
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
66
- * @param {Object} opts.customer - Customer payload
67
+ * @param {Object} opts.customer - Customer payload (CustomerPost); email, firstName, lastName required
68
+ * @param {Object} [opts.query] - Optional: uniqueEmail, lang, channel, platform, appVersion, appName, activateIfExists
67
69
  * @param {Object} [opts.headers] - Optional headers
68
- * @returns {Promise<import("axios").AxiosResponse>}
70
+ * @returns {Promise<import("axios").AxiosResponse<{ _id: string, customerNumber: string, ... }>>}
69
71
  */
70
72
  function create({customer, token, jwtToken, query, headers}) {
71
73
  return client({
@@ -125,14 +127,15 @@ function customersFactory({client, internalAuthTokenProvider}) {
125
127
  }
126
128
 
127
129
  /**
128
- * PATCH /customers/:customerId - partial update a customer.
130
+ * PATCH /customers/:customerId - apply operations (activate, reset password, activateEmailAndPwd). Body: { operations } array of PatchCustomerOperation. Returns Customer and auth tokens. Side effect: may emit customer.updated webhook.
129
131
  * @param {Object} opts
130
132
  * @param {string} [opts.token] - API key
131
133
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
132
- * @param {string} opts.customerId - Customer id (ObjectId)
133
- * @param {Object} opts.data - Partial customer payload
134
+ * @param {string} opts.customerId - Customer id (24-char hex ObjectId)
135
+ * @param {Object} opts.data - Body: { operations } or array of { op, path, value }
136
+ * @param {Object} [opts.query] - Optional query
134
137
  * @param {Object} [opts.headers] - Optional headers
135
- * @returns {Promise<import("axios").AxiosResponse>}
138
+ * @returns {Promise<import("axios").AxiosResponse<CustomerWithAuthToken>>}
136
139
  */
137
140
  function update({customerId, token, jwtToken, data, query, headers}) {
138
141
  return client({
@@ -145,13 +148,13 @@ function customersFactory({client, internalAuthTokenProvider}) {
145
148
  }
146
149
 
147
150
  /**
148
- * POST /customers/merge - merge source customers into destination.
151
+ * POST /customers/merge - merge source customers into destination. Requires BETTEREZ_APP. Side effect: emits customers.merged webhook.
149
152
  * @param {Object} opts
150
153
  * @param {string} [opts.token] - API key
151
154
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
152
- * @param {string} opts.destinationCustomerId - Destination customer id (ObjectId)
153
- * @param {Array<string>} opts.sourceCustomerIds - Source customer ids (ObjectIds)
154
- * @returns {Promise<import("axios").AxiosResponse>}
155
+ * @param {string} opts.destinationCustomerId - Destination customer id (24-char hex ObjectId)
156
+ * @param {Array<string>} opts.sourceCustomerIds - Source customer ids (24-char hex ObjectIds)
157
+ * @returns {Promise<import("axios").AxiosResponse<{ customerMerge: object }>>}
155
158
  */
156
159
  function merge({destinationCustomerId, sourceCustomerIds, jwtToken, token}) {
157
160
  return client({
@@ -4,6 +4,7 @@ const {
4
4
 
5
5
  /**
6
6
  * Factory for domains API (btrz-api-accounts).
7
+ * Endpoints manage subdomains for the account: list, create (with DNS and websales config), and delete.
7
8
  * @param {Object} deps
8
9
  * @param {import("axios").AxiosInstance} deps.client
9
10
  * @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
@@ -11,11 +12,12 @@ const {
11
12
  */
12
13
  function domainsFactory({client, internalAuthTokenProvider}) {
13
14
  /**
14
- * GET /domains - list domains. API does not accept query params.
15
+ * GET /domains List all domain names for the current account.
16
+ * Response body is an array of strings (primary domain first, then secondary domains). No query parameters.
15
17
  * @param {Object} opts
16
- * @param {string} [opts.token] - API key
18
+ * @param {string} [opts.token] - API key (X-API-KEY)
17
19
  * @param {Object} [opts.headers] - Optional headers
18
- * @returns {Promise<import("axios").AxiosResponse>}
20
+ * @returns {Promise<import("axios").AxiosResponse<string[]>>} response.data is string[]
19
21
  */
20
22
  function all({token, query = {}, headers}) {
21
23
  return client({
@@ -26,13 +28,14 @@ function domainsFactory({client, internalAuthTokenProvider}) {
26
28
  }
27
29
 
28
30
  /**
29
- * POST /domains - create a domain.
31
+ * POST /domains Create a new subdomain for the account.
32
+ * Adds DNS CNAME and default websales config. Requires BETTEREZ_APP JWT. Emits domains.created (and websalesConfig.created) webhooks.
30
33
  * @param {Object} opts
31
34
  * @param {string} [opts.token] - API key
32
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
33
- * @param {Object} opts.data - Domain payload
35
+ * @param {string} [opts.jwtToken] - JWT (required for BETTEREZ_APP audience)
36
+ * @param {Object} opts.data - Body: { domain } or { domainInfo: { domain } }. domain must match pattern (no dots, no underscores).
34
37
  * @param {Object} [opts.headers] - Optional headers
35
- * @returns {Promise<import("axios").AxiosResponse>}
38
+ * @returns {Promise<import("axios").AxiosResponse<{ domain: string }>>} response.data is AddedDomainResponse
36
39
  */
37
40
  function create({data, token, jwtToken, headers}) {
38
41
  return client({
@@ -44,13 +47,15 @@ function domainsFactory({client, internalAuthTokenProvider}) {
44
47
  }
45
48
 
46
49
  /**
47
- * DELETE /domains/:domain - remove a domain.
50
+ * DELETE /domains/:domain Remove a subdomain from the account.
51
+ * Removes DNS entry, websales config, and domain from payment methods and inventory products.
52
+ * Primary domain cannot be deleted. Emits domains.deleted and websalesConfig.deleted.
48
53
  * @param {Object} opts
49
54
  * @param {string} [opts.token] - API key
50
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
51
- * @param {string} opts.domain - Domain name
55
+ * @param {string} [opts.jwtToken] - JWT (required for BETTEREZ_APP audience)
56
+ * @param {string} opts.domain - Domain name (path parameter)
52
57
  * @param {Object} [opts.headers] - Optional headers
53
- * @returns {Promise<import("axios").AxiosResponse>}
58
+ * @returns {Promise<import("axios").AxiosResponse<{ domain: string }>>} response.data is DeletedDomainResponse
54
59
  */
55
60
  function remove({domain, token, jwtToken, headers}) {
56
61
  return client({
@@ -3,6 +3,7 @@ const {authorizationHeaders} = require("./../endpoints_helpers.js");
3
3
 
4
4
  /**
5
5
  * Factory for email-settings API (btrz-api-accounts).
6
+ * Manage account email settings (identity/verified senders). Path parameter is email address.
6
7
  * @param {Object} deps
7
8
  * @param {import("axios").AxiosInstance} deps.client
8
9
  * @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
@@ -10,12 +11,13 @@ const {authorizationHeaders} = require("./../endpoints_helpers.js");
10
11
  */
11
12
  function emailSettingsFactory({client, internalAuthTokenProvider}) {
12
13
  /**
13
- * GET /email-settings - list email settings. API does not accept query params.
14
+ * GET /email-settings List all email settings for the account.
15
+ * Response may trigger AWS verification and commIdentity updates. No query params.
14
16
  * @param {Object} opts
15
17
  * @param {string} [opts.token] - API key
16
18
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
17
19
  * @param {Object} [opts.headers] - Optional headers
18
- * @returns {Promise<import("axios").AxiosResponse>}
20
+ * @returns {Promise<import("axios").AxiosResponse<{ emailSettings: object[] }>>}
19
21
  */
20
22
  function all({token, jwtToken, query = {}, headers}) {
21
23
  return client({
@@ -25,13 +27,13 @@ function emailSettingsFactory({client, internalAuthTokenProvider}) {
25
27
  });
26
28
  }
27
29
  /**
28
- * GET /email-settings/:email - get email settings by email. API does not accept query params.
30
+ * GET /email-settings/:email Get one email setting by email address (path param).
29
31
  * @param {Object} opts
30
32
  * @param {string} [opts.token] - API key
31
33
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
32
- * @param {string} opts.email - Email address
34
+ * @param {string} opts.email - Email address (path parameter; must match email pattern)
33
35
  * @param {Object} [opts.headers] - Optional headers
34
- * @returns {Promise<import("axios").AxiosResponse>}
36
+ * @returns {Promise<import("axios").AxiosResponse<object>>} response.data is EmailSetting
35
37
  */
36
38
  function getByEmail({token, jwtToken, email, query = {}, headers}) {
37
39
  return client({
@@ -42,13 +44,14 @@ function emailSettingsFactory({client, internalAuthTokenProvider}) {
42
44
  }
43
45
 
44
46
  /**
45
- * POST /email-settings - create email settings.
47
+ * POST /email-settings Create an email setting. Requires BETTEREZ_APP JWT. Emits emailSetting.created.
48
+ * Body: { emailSetting } or { name, email, active }. Email and domain are verified in AWS.
46
49
  * @param {Object} opts
47
50
  * @param {string} [opts.token] - API key
48
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
49
- * @param {Object} opts.data - Email settings payload
51
+ * @param {string} [opts.jwtToken] - JWT (required for BETTEREZ_APP audience)
52
+ * @param {Object} opts.data - Body: { name, email, active? } or { emailSetting: { name, email, active? } }
50
53
  * @param {Object} [opts.headers] - Optional headers
51
- * @returns {Promise<import("axios").AxiosResponse>}
54
+ * @returns {Promise<import("axios").AxiosResponse<{ emailSetting: object }>>}
52
55
  */
53
56
  function create({data, token, jwtToken, headers}) {
54
57
  return client({
@@ -60,14 +63,14 @@ function emailSettingsFactory({client, internalAuthTokenProvider}) {
60
63
  }
61
64
 
62
65
  /**
63
- * PUT /email-settings/:email - update email settings.
66
+ * PUT /email-settings/:email Update an email setting. Requires BETTEREZ_APP JWT. Emits emailSetting.updated.
64
67
  * @param {Object} opts
65
68
  * @param {string} [opts.token] - API key
66
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
67
- * @param {string} opts.email - Email address
68
- * @param {Object} opts.data - Email settings payload
69
+ * @param {string} [opts.jwtToken] - JWT (required for BETTEREZ_APP audience)
70
+ * @param {string} opts.email - Email address (path parameter)
71
+ * @param {Object} opts.data - Body: { name, email, active?, ... } or { emailSetting: { ... } }
69
72
  * @param {Object} [opts.headers] - Optional headers
70
- * @returns {Promise<import("axios").AxiosResponse>}
73
+ * @returns {Promise<import("axios").AxiosResponse<{ emailSetting: object }>>}
71
74
  */
72
75
  function update({token, jwtToken, email, data, headers}) {
73
76
  return client({
@@ -79,13 +82,14 @@ function emailSettingsFactory({client, internalAuthTokenProvider}) {
79
82
  }
80
83
 
81
84
  /**
82
- * DELETE /email-settings/:email - remove email settings.
85
+ * DELETE /email-settings/:email Remove an email setting. Requires BETTEREZ_APP JWT. Emits emailSetting.deleted.
86
+ * Fails with 400 if the email is currently active.
83
87
  * @param {Object} opts
84
88
  * @param {string} [opts.token] - API key
85
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
86
- * @param {string} opts.email - Email address
89
+ * @param {string} [opts.jwtToken] - JWT (required for BETTEREZ_APP audience)
90
+ * @param {string} opts.email - Email address (path parameter)
87
91
  * @param {Object} [opts.headers] - Optional headers
88
- * @returns {Promise<import("axios").AxiosResponse>}
92
+ * @returns {Promise<import("axios").AxiosResponse<{ emailSetting: object }>>}
89
93
  */
90
94
  function remove({email, token, jwtToken, headers}) {
91
95
  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
@@ -159,7 +160,8 @@ function emailTemplatesFactory({client, internalAuthTokenProvider}) {
159
160
  * @param {string} opts.mainTemplateId - Main template id (ObjectId)
160
161
  * @param {string} opts.agencyId - Agency id (ObjectId)
161
162
  * @param {Object} [opts.headers] - Optional headers
162
- * @returns {Promise<import("axios").AxiosResponse>}
163
+ * @returns {Promise<import("axios").AxiosResponse<{ emailTemplate: object }>>}
164
+ * @throws {import("axios").AxiosError} 400 validation (WRONG_DATA, MAIN_TEMPLATE_IS_NOT_CUSTOM), 401 (MAIN_TEMPLATE_ACCOUNT_MISMATCH, MAIN_TEMPLATE_NOT_FROM_PROVIDER), 404 MAIN_TEMPLATE_NOT_FOUND, 500
163
165
  */
164
166
  function createSub({token, jwtToken, mainTemplateId, agencyId, headers}) {
165
167
  return client({
@@ -172,14 +174,16 @@ function emailTemplatesFactory({client, internalAuthTokenProvider}) {
172
174
 
173
175
  const versions = {
174
176
  /**
175
- * PUT /email-templates/:emailTemplateId/versions/:versionId - update a template version.
177
+ * PUT /email-templates/:emailTemplateId/versions/:versionId - roll back template to a saved version (versionId is zero-based index in versions array).
176
178
  * @param {Object} opts
177
179
  * @param {string} [opts.token] - API key
178
180
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
179
181
  * @param {string} opts.emailTemplateId - Template id (ObjectId)
180
- * @param {string} opts.versionId - Version id (ObjectId)
182
+ * @param {string} opts.versionId - Zero-based version index (e.g. "0", "1")
183
+ * @param {Object} [opts.query] - Optional query (superUserId, superUserHash for default templates)
181
184
  * @param {Object} [opts.headers] - Optional headers
182
- * @returns {Promise<import("axios").AxiosResponse>}
185
+ * @returns {Promise<import("axios").AxiosResponse<{ emailTemplate: object }>>}
186
+ * @throws {import("axios").AxiosError} 400 WRONG_DATA, 401 NOT_SUPER_USER, 404 EMAIL_TEMPLATE_NOT_FOUND / EMAIL_TEMPLATE_VERSION_NOT_FOUND, 500
183
187
  */
184
188
  update({token, jwtToken, emailTemplateId, versionId, query = {}, headers}) {
185
189
  return client({
@@ -4,6 +4,7 @@ const {authorizationHeaders} = require("./../endpoints_helpers");
4
4
 
5
5
  /**
6
6
  * Factory for exchange-rates API (btrz-api-accounts).
7
+ * Manage account exchange rates by currency ISO code. GET returns paginated list; POST creates a rate and updates account preferences.
7
8
  * @param {Object} deps
8
9
  * @param {import("axios").AxiosInstance} deps.client
9
10
  * @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
@@ -11,13 +12,15 @@ const {authorizationHeaders} = require("./../endpoints_helpers");
11
12
  */
12
13
  function exchangeRatesFactory({client, internalAuthTokenProvider}) {
13
14
  /**
14
- * GET /exchange-rates/:isoCode - get exchange rates by ISO code. API does not define query params in getSpec().
15
+ * GET /exchange-rates/:isoCode List exchange rates for the account filtered by currency ISO code (3 letters).
16
+ * Response is paginated (exchangeRates array + totalRecords, page, etc.).
15
17
  * @param {Object} opts
16
18
  * @param {string} [opts.token] - API key
17
19
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
18
- * @param {string} opts.isoCode - Currency ISO code (3 characters)
20
+ * @param {string} opts.isoCode - Currency ISO code (3 uppercase letters, e.g. USD, MXN)
21
+ * @param {Object} [opts.query] - Optional query (e.g. page for pagination)
19
22
  * @param {Object} [opts.headers] - Optional headers
20
- * @returns {Promise<import("axios").AxiosResponse>}
23
+ * @returns {Promise<import("axios").AxiosResponse<{ exchangeRates: object[], totalRecords: number, ... }>>}
21
24
  */
22
25
  function allByIsoCode({token, jwtToken, isoCode, query = {}, headers}) {
23
26
  return client({
@@ -28,13 +31,15 @@ function exchangeRatesFactory({client, internalAuthTokenProvider}) {
28
31
  }
29
32
 
30
33
  /**
31
- * POST /exchange-rates - create an exchange rate.
34
+ * POST /exchange-rates Create an exchange rate. Requires BETTEREZ_APP JWT. Currency must be in account preferences and enabled.
35
+ * Updates account preferences.supportedCurrencies for that currency. Emits exchangeRates.created.
36
+ * Body: { exchangeRate } or { isoCode, buy, sell }. buy and sell must be > 0.
32
37
  * @param {Object} opts
33
38
  * @param {string} [opts.token] - API key
34
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
35
- * @param {Object} opts.data - Exchange rate payload
39
+ * @param {string} [opts.jwtToken] - JWT (required for BETTEREZ_APP audience)
40
+ * @param {Object} opts.data - Body: { isoCode, buy, sell } or { exchangeRate: { isoCode, buy, sell } }
36
41
  * @param {Object} [opts.headers] - Optional headers
37
- * @returns {Promise<import("axios").AxiosResponse>}
42
+ * @returns {Promise<import("axios").AxiosResponse<{ exchangeRate: object }>>}
38
43
  */
39
44
  function create({data, token, jwtToken, headers}) {
40
45
  return client({
@@ -3,6 +3,7 @@ const {authorizationHeaders} = require("../endpoints_helpers");
3
3
 
4
4
  /**
5
5
  * Factory for exchange-receipt-settings API (btrz-api-accounts).
6
+ * Get or update account exchange receipt settings (CNBV-related fields). Requires BETTEREZ_APP audience.
6
7
  * @param {Object} deps
7
8
  * @param {import("axios").AxiosInstance} deps.client
8
9
  * @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
@@ -10,13 +11,15 @@ const {authorizationHeaders} = require("../endpoints_helpers");
10
11
  */
11
12
  function exchangeReceiptsFactory({client, internalAuthTokenProvider}) {
12
13
  /**
13
- * PUT /exchange-receipt-settings - update exchange receipt settings. API does not accept query params.
14
+ * PUT /exchange-receipt-settings Update exchange receipt settings. Requires BETTEREZ_APP JWT.
15
+ * Body: { exchangeReceipt } or ExchangeReceipt fields at root. All fields must be strings.
16
+ * Emits exchangeReceipt.updated.
14
17
  * @param {Object} opts
15
18
  * @param {string} [opts.token] - API key
16
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
17
- * @param {Object} opts.data - Settings payload
19
+ * @param {string} [opts.jwtToken] - JWT (BETTEREZ_APP audience)
20
+ * @param {Object} opts.data - Body: { exchangeReceipt } or required ExchangeReceipt fields
18
21
  * @param {Object} [opts.headers] - Optional headers
19
- * @returns {Promise<import("axios").AxiosResponse>}
22
+ * @returns {Promise<import("axios").AxiosResponse<{ exchangeReceipt: object }>>}
20
23
  */
21
24
  function update({data, token, jwtToken, headers}) {
22
25
  return client({
@@ -28,12 +31,13 @@ function exchangeReceiptsFactory({client, internalAuthTokenProvider}) {
28
31
  }
29
32
 
30
33
  /**
31
- * GET /exchange-receipt-settings - get exchange receipt settings. API does not accept query params.
34
+ * GET /exchange-receipt-settings Get exchange receipt settings. Requires BETTEREZ_APP JWT.
35
+ * Returns empty object if not set.
32
36
  * @param {Object} opts
33
37
  * @param {string} [opts.token] - API key
34
38
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
35
39
  * @param {Object} [opts.headers] - Optional headers
36
- * @returns {Promise<import("axios").AxiosResponse>}
40
+ * @returns {Promise<import("axios").AxiosResponse<{ exchangeReceipt: object }>>}
37
41
  */
38
42
  function get({token, jwtToken, headers}) {
39
43
  return client({
@@ -0,0 +1,37 @@
1
+ /* eslint-disable import/extensions */
2
+ const {authorizationHeaders} = require("../endpoints_helpers");
3
+
4
+ /**
5
+ * Factory for external-customers API (btrz-api-accounts). Saldo Max (ADO) registration proxy.
6
+ * @param {Object} deps
7
+ * @param {import("axios").AxiosInstance} deps.client
8
+ * @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
9
+ * @returns {{ registerSaldoMax: function }}
10
+ */
11
+ function externalCustomersFactory({client, internalAuthTokenProvider}) {
12
+ /**
13
+ * POST /external-customers/ado – Register a user with Saldo Max (ADO). Requires BETTEREZ_APP JWT.
14
+ * Body: SaldoMaxRegistrationRequest at root or { body: SaldoMaxRegistrationRequest }.
15
+ * Required: firstName, lastName, email, password (Base64), verificationCode, isoCode (2-letter).
16
+ * @param {Object} opts
17
+ * @param {string} [opts.token] - API key
18
+ * @param {string} [opts.jwtToken] - JWT (BETTEREZ_APP audience)
19
+ * @param {Object} opts.data - Request body (or { body: SaldoMaxRegistrationRequest })
20
+ * @param {Object} [opts.headers] - Optional headers
21
+ * @returns {Promise<import("axios").AxiosResponse<{ code: string }>>}
22
+ */
23
+ function registerSaldoMax({data, token, jwtToken, headers}) {
24
+ return client({
25
+ url: "/external-customers/ado",
26
+ method: "post",
27
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
28
+ data
29
+ });
30
+ }
31
+
32
+ return {
33
+ registerSaldoMax
34
+ };
35
+ }
36
+
37
+ module.exports = externalCustomersFactory;
@@ -3,7 +3,7 @@ const {
3
3
  } = require("./../endpoints_helpers.js");
4
4
 
5
5
  /**
6
- * Factory for goal-settings API (btrz-api-accounts).
6
+ * Factory for goal-settings API (btrz-api-accounts). Goal API integration settings.
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 goalSettingsFactory({client, internalAuthTokenProvider}) {
13
13
  /**
14
- * GET /goal-settings - get goal settings. API does not accept query params.
14
+ * GET /goal-settings Get goal settings for the account. Requires BETTEREZ_APP JWT.
15
+ * If user lacks read permission for /admin/integrations/goal, returns 200 with empty goalSettings.
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<{ goalSettings: object }>>}
20
21
  */
21
22
  function get({token, jwtToken, query, headers}) {
22
23
  return client({
@@ -27,13 +28,14 @@ function goalSettingsFactory({client, internalAuthTokenProvider}) {
27
28
  }
28
29
 
29
30
  /**
30
- * PUT /goal-settings - update goal settings. API does not accept query params.
31
+ * PUT /goal-settings Update goal settings. Requires BETTEREZ_APP and update permission for
32
+ * /admin/integrations/goal. Emits goalsettings.updated. Body: { goalSettings }.
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.goalSettings - Settings payload
36
+ * @param {Object} opts.goalSettings - Required: baseUrl, clientId, clientSecret, pushOnManifestStatus
35
37
  * @param {Object} [opts.headers] - Optional headers
36
- * @returns {Promise<import("axios").AxiosResponse>}
38
+ * @returns {Promise<import("axios").AxiosResponse<{ goalSettings: object }>>}
37
39
  */
38
40
  function update({jwtToken, token, goalSettings, headers}) {
39
41
  return client({
@@ -2,7 +2,7 @@
2
2
  const {authorizationHeaders} = require("./../endpoints_helpers");
3
3
 
4
4
  /**
5
- * Factory for images API (btrz-api-accounts).
5
+ * Factory for images API (btrz-api-accounts). Account images (url-based). POST/DELETE require BETTEREZ_APP.
6
6
  * @param {Object} deps
7
7
  * @param {import("axios").AxiosInstance} deps.client
8
8
  * @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
@@ -10,12 +10,13 @@ const {authorizationHeaders} = require("./../endpoints_helpers");
10
10
  */
11
11
  function ImagesFactory({client, internalAuthTokenProvider}) {
12
12
  /**
13
- * GET /images - list images. API getSpec() does not define query params.
13
+ * GET /images List images for the account (paginated). Query: page.
14
14
  * @param {Object} opts
15
15
  * @param {string} [opts.token] - API key
16
16
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
17
+ * @param {Object} [opts.query] - Optional query (e.g. page for pagination)
17
18
  * @param {Object} [opts.headers] - Optional headers
18
- * @returns {Promise<import("axios").AxiosResponse>}
19
+ * @returns {Promise<import("axios").AxiosResponse<{ images: object[], totalRecords: number, ... }>>}
19
20
  */
20
21
  function all({token, jwtToken, query = {}, headers}) {
21
22
  return client({
@@ -26,13 +27,13 @@ function ImagesFactory({client, internalAuthTokenProvider}) {
26
27
  }
27
28
 
28
29
  /**
29
- * GET /images/:imageId - get an image. API does not accept query params.
30
+ * GET /images/:imageId Get a single image by id (24 hex ObjectId).
30
31
  * @param {Object} opts
31
32
  * @param {string} [opts.token] - API key
32
33
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
33
- * @param {string} opts.imageId - Image id (ObjectId)
34
+ * @param {string} opts.imageId - Image id (24 hex characters)
34
35
  * @param {Object} [opts.headers] - Optional headers
35
- * @returns {Promise<import("axios").AxiosResponse>}
36
+ * @returns {Promise<import("axios").AxiosResponse<{ image: object }>>}
36
37
  */
37
38
  function get({token, jwtToken, query = {}, headers, imageId}) {
38
39
  return client({
@@ -43,13 +44,13 @@ function ImagesFactory({client, internalAuthTokenProvider}) {
43
44
  }
44
45
 
45
46
  /**
46
- * POST /images - create an image.
47
+ * POST /images Create an image. Requires BETTEREZ_APP JWT. Body: { image } with url required. Emits images.created.
47
48
  * @param {Object} opts
48
49
  * @param {string} [opts.token] - API key
49
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
50
- * @param {Object} opts.image - Image payload
50
+ * @param {string} [opts.jwtToken] - JWT (BETTEREZ_APP audience)
51
+ * @param {Object} opts.image - { url } (required)
51
52
  * @param {Object} [opts.headers] - Optional headers
52
- * @returns {Promise<import("axios").AxiosResponse>}
53
+ * @returns {Promise<import("axios").AxiosResponse<{ image: object }>>}
53
54
  */
54
55
  function create({jwtToken, token, image, headers}) {
55
56
  return client({
@@ -65,13 +66,13 @@ function ImagesFactory({client, internalAuthTokenProvider}) {
65
66
  }
66
67
 
67
68
  /**
68
- * DELETE /images/:imageId - remove an image.
69
+ * DELETE /images/:imageId Delete an image. Requires BETTEREZ_APP JWT. Emits images.deleted (data: { imageId }).
69
70
  * @param {Object} opts
70
71
  * @param {string} [opts.token] - API key
71
72
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
72
- * @param {string} opts.imageId - Image id (ObjectId)
73
+ * @param {string} opts.imageId - Image id (24 hex ObjectId)
73
74
  * @param {Object} [opts.headers] - Optional headers
74
- * @returns {Promise<import("axios").AxiosResponse>}
75
+ * @returns {Promise<import("axios").AxiosResponse<{ imageId: string }>>}
75
76
  */
76
77
  function remove({imageId, token, jwtToken, headers}) {
77
78
  return client({