btrz-api-client 8.33.0 → 8.35.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 (160) hide show
  1. package/lib/client-standalone-min.js +3 -3
  2. package/lib/client.js +10 -2
  3. package/lib/endpoints/btrzpay/adyen.js +58 -0
  4. package/lib/endpoints/btrzpay/cardpointe.js +6 -3
  5. package/lib/endpoints/btrzpay/customerCards.js +19 -19
  6. package/lib/endpoints/btrzpay/customers.js +13 -13
  7. package/lib/endpoints/btrzpay/cybersource3ds.js +142 -0
  8. package/lib/endpoints/btrzpay/datalogic.js +64 -28
  9. package/lib/endpoints/btrzpay/oxxo.js +54 -28
  10. package/lib/endpoints/btrzpay/prismaTerminals.js +24 -15
  11. package/lib/endpoints/btrzpay/referenced-payments.js +4 -4
  12. package/lib/endpoints/btrzpay/square.js +8 -8
  13. package/lib/endpoints/btrzpay/stripe-terminals.js +16 -11
  14. package/lib/endpoints/btrzpay/stripe3ds.js +54 -0
  15. package/lib/endpoints/btrzpay/terminalPayments.js +19 -19
  16. package/lib/endpoints/inventory/banks.js +39 -21
  17. package/lib/endpoints/inventory/change-requests.js +59 -31
  18. package/lib/endpoints/inventory/control-classes.js +39 -20
  19. package/lib/endpoints/inventory/countries.js +25 -9
  20. package/lib/endpoints/inventory/custom-content.js +39 -21
  21. package/lib/endpoints/inventory/custom-fields.js +25 -17
  22. package/lib/endpoints/inventory/document-types.js +33 -42
  23. package/lib/endpoints/inventory/external-wallets.js +26 -20
  24. package/lib/endpoints/inventory/fees.js +19 -13
  25. package/lib/endpoints/inventory/filtered-trips.js +34 -8
  26. package/lib/endpoints/inventory/financing-costs.js +19 -14
  27. package/lib/endpoints/inventory/garages.js +19 -14
  28. package/lib/endpoints/inventory/getnet-terminals.js +20 -15
  29. package/lib/endpoints/inventory/gift-certificate-definitions.js +10 -5
  30. package/lib/endpoints/inventory/holidays.js +158 -0
  31. package/lib/endpoints/inventory/insurances.js +17 -13
  32. package/lib/endpoints/inventory/items.js +13 -9
  33. package/lib/endpoints/inventory/labels.js +16 -11
  34. package/lib/endpoints/inventory/marital-status.js +16 -11
  35. package/lib/endpoints/inventory/marketplace-modifiers.js +16 -11
  36. package/lib/endpoints/inventory/mit-terminal-settings.js +15 -10
  37. package/lib/endpoints/inventory/mit-terminals.js +16 -11
  38. package/lib/endpoints/inventory/operation-messages.js +18 -12
  39. package/lib/endpoints/inventory/operation-reasons.js +15 -10
  40. package/lib/endpoints/inventory/pay-on-accounts.js +5 -4
  41. package/lib/endpoints/inventory/payment-terminals.js +15 -10
  42. package/lib/endpoints/inventory/products.js +22 -10
  43. package/lib/endpoints/inventory/promos.js +27 -18
  44. package/lib/endpoints/inventory/segments-information-tables.js +13 -7
  45. package/lib/endpoints/inventory/station-groups.js +2 -4
  46. package/lib/endpoints/inventory/taxes.js +11 -2
  47. package/lib/endpoints/inventory/traveller-card-providers-types.js +6 -6
  48. package/lib/endpoints/inventory/trip-ids.js +67 -0
  49. package/lib/endpoints/inventory/trips.js +60 -13
  50. package/lib/endpoints/inventory/vehicle-types.js +2 -5
  51. package/lib/endpoints/inventory/vehicles.js +4 -2
  52. package/lib/endpoints/invoices/emails.js +15 -5
  53. package/lib/endpoints/invoices/invoices.js +46 -25
  54. package/lib/endpoints/invoices/pdfs.js +15 -8
  55. package/lib/endpoints/invoices/providers.js +42 -25
  56. package/lib/endpoints/invoices/tax-ids.js +11 -7
  57. package/lib/endpoints/notifications/customers.js +1 -1
  58. package/lib/endpoints/notifications/external-customers.js +54 -0
  59. package/lib/endpoints/notifications/pdfs.js +0 -3
  60. package/lib/endpoints/operations/accounting_items.js +7 -1
  61. package/lib/endpoints/operations/flexpasses.js +9 -7
  62. package/lib/endpoints/operations/gift-certificates.js +53 -0
  63. package/lib/endpoints/operations/loans.js +16 -10
  64. package/lib/endpoints/operations/movements.js +17 -6
  65. package/lib/endpoints/operations/pago-express.js +96 -0
  66. package/lib/endpoints/operations/parcels.js +11 -11
  67. package/lib/endpoints/operations/parcels_manifests.js +7 -4
  68. package/lib/endpoints/sales/cancellations.js +43 -31
  69. package/lib/endpoints/sales/cart.js +21 -18
  70. package/lib/endpoints/sales/flexpasses.js +2 -5
  71. package/lib/endpoints/sales/order.js +41 -7
  72. package/lib/endpoints/sales/parcel-quotes.js +2 -2
  73. package/package.json +1 -1
  74. package/src/client.js +10 -2
  75. package/src/endpoints/btrzpay/adyen.js +44 -0
  76. package/src/endpoints/btrzpay/cardpointe.js +6 -4
  77. package/src/endpoints/btrzpay/customerCards.js +19 -19
  78. package/src/endpoints/btrzpay/customers.js +13 -13
  79. package/src/endpoints/btrzpay/cybersource3ds.js +114 -0
  80. package/src/endpoints/btrzpay/datalogic.js +63 -28
  81. package/src/endpoints/btrzpay/oxxo.js +53 -26
  82. package/src/endpoints/btrzpay/prismaTerminals.js +24 -15
  83. package/src/endpoints/btrzpay/referenced-payments.js +4 -4
  84. package/src/endpoints/btrzpay/square.js +8 -8
  85. package/src/endpoints/btrzpay/stripe-terminals.js +17 -10
  86. package/src/endpoints/btrzpay/stripe3ds.js +40 -0
  87. package/src/endpoints/btrzpay/terminalPayments.js +19 -19
  88. package/src/endpoints/inventory/banks.js +39 -21
  89. package/src/endpoints/inventory/change-requests.js +59 -31
  90. package/src/endpoints/inventory/control-classes.js +39 -20
  91. package/src/endpoints/inventory/countries.js +25 -10
  92. package/src/endpoints/inventory/custom-content.js +39 -22
  93. package/src/endpoints/inventory/custom-fields.js +25 -19
  94. package/src/endpoints/inventory/document-types.js +34 -33
  95. package/src/endpoints/inventory/external-wallets.js +25 -20
  96. package/src/endpoints/inventory/fees.js +19 -14
  97. package/src/endpoints/inventory/filtered-trips.js +29 -8
  98. package/src/endpoints/inventory/financing-costs.js +19 -14
  99. package/src/endpoints/inventory/garages.js +19 -14
  100. package/src/endpoints/inventory/getnet-terminals.js +20 -15
  101. package/src/endpoints/inventory/gift-certificate-definitions.js +10 -5
  102. package/src/endpoints/inventory/holidays.js +121 -0
  103. package/src/endpoints/inventory/insurances.js +17 -13
  104. package/src/endpoints/inventory/items.js +13 -9
  105. package/src/endpoints/inventory/labels.js +16 -11
  106. package/src/endpoints/inventory/marital-status.js +16 -11
  107. package/src/endpoints/inventory/marketplace-modifiers.js +16 -11
  108. package/src/endpoints/inventory/mit-terminal-settings.js +15 -10
  109. package/src/endpoints/inventory/mit-terminals.js +16 -11
  110. package/src/endpoints/inventory/operation-messages.js +18 -12
  111. package/src/endpoints/inventory/operation-reasons.js +15 -10
  112. package/src/endpoints/inventory/pay-on-accounts.js +5 -4
  113. package/src/endpoints/inventory/payment-terminals.js +15 -10
  114. package/src/endpoints/inventory/products.js +22 -10
  115. package/src/endpoints/inventory/promos.js +27 -18
  116. package/src/endpoints/inventory/segments-information-tables.js +13 -7
  117. package/src/endpoints/inventory/station-groups.js +2 -4
  118. package/src/endpoints/inventory/taxes.js +11 -2
  119. package/src/endpoints/inventory/traveller-card-providers-types.js +6 -5
  120. package/src/endpoints/inventory/trip-ids.js +54 -0
  121. package/src/endpoints/inventory/trips.js +52 -14
  122. package/src/endpoints/inventory/vehicle-types.js +3 -4
  123. package/src/endpoints/inventory/vehicles.js +4 -3
  124. package/src/endpoints/invoices/emails.js +15 -5
  125. package/src/endpoints/invoices/invoices.js +46 -25
  126. package/src/endpoints/invoices/pdfs.js +15 -8
  127. package/src/endpoints/invoices/providers.js +42 -25
  128. package/src/endpoints/invoices/tax-ids.js +11 -7
  129. package/src/endpoints/notifications/customers.js +1 -1
  130. package/src/endpoints/notifications/external-customers.js +41 -0
  131. package/src/endpoints/notifications/pdfs.js +0 -3
  132. package/src/endpoints/operations/accounting_items.js +7 -2
  133. package/src/endpoints/operations/flexpasses.js +9 -7
  134. package/src/endpoints/operations/gift-certificates.js +39 -0
  135. package/src/endpoints/operations/loans.js +16 -11
  136. package/src/endpoints/operations/movements.js +17 -6
  137. package/src/endpoints/operations/pago-express.js +73 -0
  138. package/src/endpoints/operations/parcels.js +11 -11
  139. package/src/endpoints/operations/parcels_manifests.js +7 -5
  140. package/src/endpoints/sales/cancellations.js +43 -31
  141. package/src/endpoints/sales/cart.js +20 -18
  142. package/src/endpoints/sales/flexpasses.js +3 -4
  143. package/src/endpoints/sales/order.js +34 -7
  144. package/src/endpoints/sales/parcel-quotes.js +2 -2
  145. package/test/endpoints/btrzpay/adyen.tests.js +27 -0
  146. package/test/endpoints/btrzpay/carpointe.tests.js +14 -0
  147. package/test/endpoints/btrzpay/customerCards.test.js +9 -6
  148. package/test/endpoints/btrzpay/cybersource3ds.tests.js +55 -0
  149. package/test/endpoints/btrzpay/stripe-terminals.tests.js +5 -6
  150. package/test/endpoints/btrzpay/stripe3ds.tests.js +31 -0
  151. package/test/endpoints/inventory/banks.test.js +8 -10
  152. package/test/endpoints/inventory/filtered-trips.test.js +6 -0
  153. package/test/endpoints/inventory/holidays.test.js +52 -0
  154. package/test/endpoints/inventory/traveller-card-providers-types.test.js +3 -2
  155. package/test/endpoints/inventory/trip-ids.test.js +27 -0
  156. package/test/endpoints/inventory/trips.test.js +19 -14
  157. package/test/endpoints/notifications/external-customers.test.js +30 -0
  158. package/test/endpoints/operations/gift_certificates.test.js +37 -0
  159. package/test/endpoints/operations/operations.test.js +30 -0
  160. package/test/endpoints/sales/order.test.js +7 -1
@@ -25,13 +25,16 @@ const {authorizationHeaders} = require("./../endpoints_helpers.js");
25
25
  */
26
26
  function changeRequestsFactory({client, internalAuthTokenProvider}) {
27
27
  /**
28
- * GET /change-requests - list change requests.
28
+ * GET /change-requests List change requests with optional filters and pagination.
29
29
  * @param {Object} opts
30
- * @param {string} [opts.token] - API key
31
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
32
- * @param {ChangeRequestsListQuery} [opts.query] - Query params
30
+ * @param {string} [opts.token] - API key (X-API-KEY)
31
+ * @param {string} [opts.jwtToken] - JWT or internal auth (Authorization: Bearer)
32
+ * @param {ChangeRequestsListQuery} [opts.query] - Query params (type, status, createdBy, from, to, etc.)
33
33
  * @param {Object} [opts.headers] - Optional headers
34
- * @returns {Promise<import("axios").AxiosResponse>}
34
+ * @returns {Promise<import("axios").AxiosResponse<{ changeRequests: Object[], count: number, next: string, previous: string }>>}
35
+ * @throws 400 INVALID_PAGE, INVALID_TYPE_PARAMETER, INVALID_STATUS_PARAMETER, etc.
36
+ * @throws 401 Unauthorized
37
+ * @throws 500 Internal server error
35
38
  */
36
39
  function all({token, jwtToken, query = {}, headers}) {
37
40
  return client.get("/change-requests", {
@@ -41,13 +44,18 @@ function changeRequestsFactory({client, internalAuthTokenProvider}) {
41
44
  }
42
45
 
43
46
  /**
44
- * GET /change-requests/:changerequestId/manifests - get change request manifests. API does not accept query params.
47
+ * GET /change-requests/:changerequestId/manifests Get manifest change request by ID. Requires multipleManifestEditing.
45
48
  * @param {Object} opts
46
49
  * @param {string} [opts.token] - API key
47
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
48
- * @param {string} opts.changerequestId - Change request id
50
+ * @param {string} [opts.jwtToken] - JWT or internal auth
51
+ * @param {string} opts.changerequestId - Change request id (24 hex characters)
49
52
  * @param {Object} [opts.headers] - Optional headers
50
- * @returns {Promise<import("axios").AxiosResponse>}
53
+ * @returns {Promise<import("axios").AxiosResponse<{ changeRequest: Object }>>}
54
+ * @throws 400 INVALID_CHANGEREQUEST_ID, FAILED_TO_FETCH_OPERATION_SETTINGS
55
+ * @throws 401 Unauthorized
56
+ * @throws 403 MULTIPLE_MANIFEST_EDIT_NOT_ALLOWED
57
+ * @throws 404 CHANGEREQUEST_NOT_FOUND
58
+ * @throws 500 Internal server error
51
59
  */
52
60
  function get({changerequestId, token, jwtToken, query = {}, headers}) {
53
61
  return client({
@@ -58,13 +66,17 @@ function changeRequestsFactory({client, internalAuthTokenProvider}) {
58
66
  }
59
67
 
60
68
  /**
61
- * POST /change-requests/manifests - create change request manifest. API does not accept query params.
69
+ * POST /change-requests/manifests Create manifest change request. Emits changeRequests.manifests.created.
62
70
  * @param {Object} opts
63
71
  * @param {string} [opts.token] - API key
64
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
65
- * @param {Object} opts.data - Manifest payload
72
+ * @param {string} [opts.jwtToken] - JWT or internal auth
73
+ * @param {Object} opts.data - Manifest change request payload (manifestId, request, routeId, scheduleId, date, etc.)
66
74
  * @param {Object} [opts.headers] - Optional headers
67
- * @returns {Promise<import("axios").AxiosResponse>}
75
+ * @returns {Promise<import("axios").AxiosResponse<{ changeRequest: Object }>>}
76
+ * @throws 400 WRONG_DATA, FAILED_TO_FETCH_OPERATION_SETTINGS, MANIFEST_NOT_FOUND, etc.
77
+ * @throws 401 Unauthorized
78
+ * @throws 403 MULTIPLE_MANIFEST_EDIT_NOT_ALLOWED
79
+ * @throws 500 Internal server error
68
80
  */
69
81
  function create({data, token, jwtToken, headers}) {
70
82
  return client({
@@ -76,14 +88,19 @@ function changeRequestsFactory({client, internalAuthTokenProvider}) {
76
88
  }
77
89
 
78
90
  /**
79
- * PUT /change-requests/:changerequestId/manifests - update change request manifest. API does not accept query params.
91
+ * PUT /change-requests/:changerequestId/manifests Update manifest change request. Emits changeRequests.manifests.updated.
80
92
  * @param {Object} opts
81
93
  * @param {string} [opts.token] - API key
82
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
83
- * @param {string} opts.changerequestId - Change request id
84
- * @param {Object} opts.data - Manifest payload
94
+ * @param {string} [opts.jwtToken] - JWT or internal auth
95
+ * @param {string} opts.changerequestId - Change request id (24 hex characters)
96
+ * @param {Object} opts.data - Update payload (status: 'approved' or 'rejected')
85
97
  * @param {Object} [opts.headers] - Optional headers
86
- * @returns {Promise<import("axios").AxiosResponse>}
98
+ * @returns {Promise<import("axios").AxiosResponse<{ changeRequest: Object }>>}
99
+ * @throws 400 WRONG_DATA, CHANGEREQUEST_STATUS_NOT_PENDING, etc.
100
+ * @throws 401 Unauthorized
101
+ * @throws 403 MULTIPLE_MANIFEST_EDIT_NOT_ALLOWED
102
+ * @throws 404 CHANGEREQUEST_NOT_FOUND
103
+ * @throws 500 Internal server error
87
104
  */
88
105
  function update({changerequestId, data, token, jwtToken, headers}) {
89
106
  return client({
@@ -97,13 +114,17 @@ function changeRequestsFactory({client, internalAuthTokenProvider}) {
97
114
  /** @type {{ get: function, create: function, update: function }} */
98
115
  const schedules = {
99
116
  /**
100
- * GET /change-requests/:changeRequestId/schedules - get change request schedules. API does not accept query params.
117
+ * GET /change-requests/:changeRequestId/schedules Get schedule change request by ID.
101
118
  * @param {Object} opts
102
119
  * @param {string} [opts.token] - API key
103
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
104
- * @param {string} opts.changeRequestId - Change request id
120
+ * @param {string} [opts.jwtToken] - JWT or internal auth
121
+ * @param {string} opts.changeRequestId - Change request id (24 hex characters)
105
122
  * @param {Object} [opts.headers] - Optional headers
106
- * @returns {Promise<import("axios").AxiosResponse>}
123
+ * @returns {Promise<import("axios").AxiosResponse<{ changeRequest: Object }>>}
124
+ * @throws 400 INVALID_CHANGEREQUEST_ID, FAILED_TO_FETCH_OPERATION_SETTINGS, etc.
125
+ * @throws 401 Unauthorized
126
+ * @throws 404 CHANGEREQUEST_NOT_FOUND
127
+ * @throws 500 Internal server error
107
128
  */
108
129
  get({changeRequestId, token, jwtToken, query = {}, headers}) {
109
130
  return client({
@@ -114,13 +135,16 @@ function changeRequestsFactory({client, internalAuthTokenProvider}) {
114
135
  },
115
136
 
116
137
  /**
117
- * POST /change-requests/schedules - create change request schedule. API does not accept query params.
138
+ * POST /change-requests/schedules Create a schedule change request. Emits webhook changeRequests.schedules.created.
118
139
  * @param {Object} opts
119
140
  * @param {string} [opts.token] - API key
120
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
121
- * @param {Object} opts.data - Schedule payload
141
+ * @param {string} [opts.jwtToken] - JWT or internal auth
142
+ * @param {Object} opts.data - Schedule change request payload (request, routeId, scheduleId, legs, etc.)
122
143
  * @param {Object} [opts.headers] - Optional headers
123
- * @returns {Promise<import("axios").AxiosResponse>}
144
+ * @returns {Promise<import("axios").AxiosResponse<{ changeRequest: Object }>>}
145
+ * @throws 400 WRONG_DATA, FAILED_TO_FETCH_OPERATION_SETTINGS, etc.
146
+ * @throws 401 Unauthorized
147
+ * @throws 500 Internal server error
124
148
  */
125
149
  create({data, token, jwtToken, headers}) {
126
150
  return client({
@@ -132,14 +156,18 @@ function changeRequestsFactory({client, internalAuthTokenProvider}) {
132
156
  },
133
157
 
134
158
  /**
135
- * PUT /change-requests/:changeRequestId/schedules - update change request schedule. API does not accept query params.
159
+ * PUT .../schedules Update schedule change request (approve/reject). Emits changeRequests.schedules.updated.
136
160
  * @param {Object} opts
137
161
  * @param {string} [opts.token] - API key
138
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
139
- * @param {string} opts.changeRequestId - Change request id
140
- * @param {Object} opts.data - Schedule payload
162
+ * @param {string} [opts.jwtToken] - JWT or internal auth
163
+ * @param {string} opts.changeRequestId - Change request id (24 hex characters)
164
+ * @param {Object} opts.data - Update payload (status: 'approved' or 'rejected')
141
165
  * @param {Object} [opts.headers] - Optional headers
142
- * @returns {Promise<import("axios").AxiosResponse>}
166
+ * @returns {Promise<import("axios").AxiosResponse<{ changeRequest: Object }>>}
167
+ * @throws 400 WRONG_DATA, CHANGEREQUEST_STATUS_NOT_PENDING, etc.
168
+ * @throws 401 Unauthorized
169
+ * @throws 404 CHANGEREQUEST_NOT_FOUND
170
+ * @throws 500 Internal server error
143
171
  */
144
172
  update({changeRequestId, data, token, jwtToken, headers}) {
145
173
  return client({
@@ -41,13 +41,17 @@ const {
41
41
  */
42
42
  function controlClassesFactory({client, internalAuthTokenProvider}) {
43
43
  /**
44
- * GET /control-classes - list control classes.
44
+ * GET /control-classes List control class roots (paginated). Emits no webhooks.
45
45
  * @param {Object} opts
46
46
  * @param {string} [opts.token] - API key
47
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
47
+ * @param {string} [opts.jwtToken] - JWT or internal auth
48
48
  * @param {ControlClassesListQuery} [opts.query] - Query params
49
49
  * @param {Object} [opts.headers] - Optional headers
50
- * @returns {Promise<import("axios").AxiosResponse>}
50
+ * @returns {Promise<import("axios").AxiosResponse<{ controlClasses: Object[], authorizationsEnabled?: boolean }>>}
51
+ * @throws 400 INVALID_PAGE, INVALID_SCHEDULE_ID, INVALID_ASSIGNED_SCHEDULE_ID
52
+ * @throws 401 Unauthorized
53
+ * @throws 404 SCHEDULE_NOT_FOUND
54
+ * @throws 500 Internal server error
51
55
  */
52
56
  function all({
53
57
  token,
@@ -62,14 +66,18 @@ function controlClassesFactory({client, internalAuthTokenProvider}) {
62
66
  }
63
67
 
64
68
  /**
65
- * GET /control-classes/:controlClassId - get control class by id.
69
+ * GET /control-classes/:controlClassId Get one control class (optional tree, schedules).
66
70
  * @param {Object} opts
67
71
  * @param {string} [opts.token] - API key
68
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
69
- * @param {string} opts.controlClassId - Control class id
72
+ * @param {string} [opts.jwtToken] - JWT or internal auth
73
+ * @param {string} opts.controlClassId - Control class id (24 hex)
70
74
  * @param {ControlClassGetQuery} [opts.query] - Query params (tree, scheduleId, etc.)
71
75
  * @param {Object} [opts.headers] - Optional headers
72
- * @returns {Promise<import("axios").AxiosResponse>}
76
+ * @returns {Promise<import("axios").AxiosResponse<{ controlClass, root?, parent?, siblings?, children?, schedules?, tree? }>>}
77
+ * @throws 400 INVALID_CONTROLCLASS_ID
78
+ * @throws 401 Unauthorized
79
+ * @throws 404 CONTROLCLASS_NOT_FOUND
80
+ * @throws 500 Internal server error
73
81
  */
74
82
  function get({controlClassId, token, headers, jwtToken, query = {}}) {
75
83
  return client.get(`/control-classes/${controlClassId}`, {
@@ -79,13 +87,16 @@ function controlClassesFactory({client, internalAuthTokenProvider}) {
79
87
  }
80
88
 
81
89
  /**
82
- * POST /control-classes - create control class. API does not accept query params.
90
+ * POST /control-classes Create control class. Body: { controlClass }. Emits controlclasses.created.
83
91
  * @param {Object} opts
84
92
  * @param {string} [opts.token] - API key
85
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
86
- * @param {Object} opts.controlClass - Control class payload
93
+ * @param {string} [opts.jwtToken] - JWT or internal auth
94
+ * @param {Object} opts.controlClass - ControlClassData (name, props required)
87
95
  * @param {Object} [opts.headers] - Optional headers
88
- * @returns {Promise<import("axios").AxiosResponse>}
96
+ * @returns {Promise<import("axios").AxiosResponse<{ controlClass: Object }>>}
97
+ * @throws 400 WRONG_DATA, DUPLICATE_CLASS_NAME, NO_ROOT_PROPS, PARENT_CLASS_NOT_FOUND, etc.
98
+ * @throws 401 Unauthorized
99
+ * @throws 500 Internal server error
89
100
  */
90
101
  function create({jwtToken, token, controlClass, headers}) {
91
102
  return client({
@@ -99,13 +110,17 @@ function controlClassesFactory({client, internalAuthTokenProvider}) {
99
110
  }
100
111
 
101
112
  /**
102
- * DELETE /control-classes/:controlClassId - remove control class.
113
+ * DELETE /control-classes/:controlClassId Delete control class. Emits controlclasses.deleted.
103
114
  * @param {Object} opts
104
115
  * @param {string} [opts.token] - API key
105
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
106
- * @param {string} opts.controlClassId - Control class id
116
+ * @param {string} [opts.jwtToken] - JWT or internal auth
117
+ * @param {string} opts.controlClassId - Control class id (24 hex)
107
118
  * @param {Object} [opts.headers] - Optional headers
108
- * @returns {Promise<import("axios").AxiosResponse>}
119
+ * @returns {Promise<import("axios").AxiosResponse<{ controlClassId: string }>>}
120
+ * @throws 400 INVALID_CONTROLCLASS_ID, CANNOT_DELETE_CLASS_WITH_CHILDREN
121
+ * @throws 401 Unauthorized
122
+ * @throws 404 CONTROLCLASS_NOT_FOUND
123
+ * @throws 500 Internal server error
109
124
  */
110
125
  function remove({jwtToken, controlClassId, token, headers}) {
111
126
  return client({
@@ -116,14 +131,18 @@ function controlClassesFactory({client, internalAuthTokenProvider}) {
116
131
  }
117
132
 
118
133
  /**
119
- * PUT /control-classes/:controlClassId - update control class. API does not accept query params.
134
+ * PUT /control-classes/:controlClassId Update control class. Body: { controlClass }. Emits controlclasses.updated.
120
135
  * @param {Object} opts
121
136
  * @param {string} [opts.token] - API key
122
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
123
- * @param {string} opts.controlClassId - Control class id
124
- * @param {Object} opts.controlClass - Control class payload
137
+ * @param {string} [opts.jwtToken] - JWT or internal auth
138
+ * @param {string} opts.controlClassId - Control class id (24 hex)
139
+ * @param {Object} opts.controlClass - ControlClassData (name, props required)
125
140
  * @param {Object} [opts.headers] - Optional headers
126
- * @returns {Promise<import("axios").AxiosResponse>}
141
+ * @returns {Promise<import("axios").AxiosResponse<{ controlClass: Object }>>}
142
+ * @throws 400 WRONG_DATA, INVALID_CONTROLCLASS_ID, DUPLICATE_CLASS_NAME, etc.
143
+ * @throws 401 Unauthorized
144
+ * @throws 404 CONTROLCLASS_NOT_FOUND
145
+ * @throws 500 Internal server error
127
146
  */
128
147
  function update({jwtToken, token, controlClassId, controlClass, headers}) {
129
148
  return client({
@@ -3,7 +3,14 @@ const {authorizationHeaders} = require("./../endpoints_helpers.js");
3
3
  /**
4
4
  * Query params for GET /countries (btrz-api-inventory). See get-countries getSpec().
5
5
  * @typedef {Object} CountriesListQuery
6
- * @property {string} [isoCode] - Country 2 or 3 letter ISO code
6
+ * @property {string} [isoCode] - Country 2- or 3-letter ISO code (must be 2 or 3 chars if provided)
7
+ */
8
+
9
+ /**
10
+ * Query params for GET /countries/:countryId (btrz-api-inventory). See getCountryById getSpec().
11
+ * @typedef {Object} CountryGetQuery
12
+ * @property {string} [include] - Address level to include: "provinces" (default), "counties", "cities", "neighborhoods"
13
+ * @property {string} [parentKey] - Parent address level to filter by when include is not provinces
7
14
  */
8
15
 
9
16
  /**
@@ -15,30 +22,38 @@ const {authorizationHeaders} = require("./../endpoints_helpers.js");
15
22
  */
16
23
  function countriesFactory({client, internalAuthTokenProvider}) {
17
24
  /**
18
- * GET /countries - list countries.
25
+ * GET /countries List countries. Optional filter by isoCode (2 or 3 characters).
19
26
  * @param {Object} opts
20
27
  * @param {string} [opts.token] - API key
21
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
28
+ * @param {string} [opts.jwtToken] - JWT or internal auth
22
29
  * @param {CountriesListQuery} [opts.query] - Query params (isoCode)
23
30
  * @param {Object} [opts.headers] - Optional headers
24
- * @returns {Promise<import("axios").AxiosResponse>}
31
+ * @returns {Promise<import("axios").AxiosResponse<{ countries: Object[] }>>}
32
+ * @throws 400 Validation failure (e.g. invalid isoCode length)
33
+ * @throws 401 Unauthorized
34
+ * @throws 500 Internal server error
25
35
  */
26
- function all({token, query = {}, headers}) {
36
+ function all({token, jwtToken, query = {}, headers}) {
27
37
  return client({
28
38
  url: "/countries",
29
39
  params: query,
30
- headers: authorizationHeaders({token, internalAuthTokenProvider, headers})
40
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
31
41
  });
32
42
  }
33
43
 
34
44
  /**
35
- * GET /countries/:id - get country by id. API does not accept query params.
45
+ * GET /countries/:id Get country by id. Optional include (provinces/counties/cities/neighborhoods) and parentKey.
36
46
  * @param {Object} opts
37
47
  * @param {string} [opts.token] - API key
38
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
39
- * @param {string} opts.id - Country id
48
+ * @param {string} [opts.jwtToken] - JWT or internal auth
49
+ * @param {string} opts.id - Country id (24 hex)
50
+ * @param {CountryGetQuery} [opts.query] - Query params (include, parentKey)
40
51
  * @param {Object} [opts.headers] - Optional headers
41
- * @returns {Promise<import("axios").AxiosResponse>}
52
+ * @returns {Promise<import("axios").AxiosResponse<{ country: Object }>>}
53
+ * @throws 400 INVALID_COUNTRY_ID
54
+ * @throws 401 Unauthorized
55
+ * @throws 404 COUNTRY_NOT_FOUND
56
+ * @throws 500 Internal server error
42
57
  */
43
58
  function get({token, jwtToken, id, query = {}, headers}) {
44
59
  return client({
@@ -18,13 +18,15 @@ const {
18
18
  */
19
19
  function customContentFactory({client, internalAuthTokenProvider}) {
20
20
  /**
21
- * GET /custom-content - list custom content.
21
+ * GET /custom-content List custom content (paginated). Query: enabled, pageId.
22
22
  * @param {Object} opts
23
23
  * @param {string} [opts.token] - API key
24
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
24
+ * @param {string} [opts.jwtToken] - JWT or internal auth
25
25
  * @param {InventoryCustomContentQuery} [opts.query] - Query params (enabled, pageId)
26
26
  * @param {Object} [opts.headers] - Optional headers
27
- * @returns {Promise<import("axios").AxiosResponse>}
27
+ * @returns {Promise<import("axios").AxiosResponse<{ customContent: Object[] }>>}
28
+ * @throws 401 Unauthorized
29
+ * @throws 500 Internal server error
28
30
  */
29
31
  function all({
30
32
  token,
@@ -38,28 +40,35 @@ function customContentFactory({client, internalAuthTokenProvider}) {
38
40
  }
39
41
 
40
42
  /**
41
- * GET /custom-content/:customContentId - get custom content by id. API does not accept query params.
43
+ * GET /custom-content/:customContentId Get custom content by id.
42
44
  * @param {Object} opts
43
45
  * @param {string} [opts.token] - API key
44
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
45
- * @param {string} opts.customContentId - Custom content id
46
+ * @param {string} [opts.jwtToken] - JWT or internal auth
47
+ * @param {string} opts.customContentId - Custom content id (24 hex)
46
48
  * @param {Object} [opts.headers] - Optional headers
47
- * @returns {Promise<import("axios").AxiosResponse>}
49
+ * @returns {Promise<import("axios").AxiosResponse<{ customContent: Object }>>}
50
+ * @throws 400 INVALID_CUSTOMCONTENT_ID
51
+ * @throws 401 Unauthorized
52
+ * @throws 404 CUSTOMCONTENT_NOT_FOUND
53
+ * @throws 500 Internal server error
48
54
  */
49
- function get({customContentId, token, headers}) {
55
+ function get({customContentId, token, jwtToken, headers}) {
50
56
  return client.get(`/custom-content/${customContentId}`, {
51
- headers: authorizationHeaders({token, internalAuthTokenProvider, headers})
57
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
52
58
  });
53
59
  }
54
60
 
55
61
  /**
56
- * POST /custom-content - create custom content. API does not accept query params.
62
+ * POST /custom-content Create custom content. Body: { customContent }. Emits customContent.created.
57
63
  * @param {Object} opts
58
64
  * @param {string} [opts.token] - API key
59
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
60
- * @param {Object} opts.customContent - Custom content payload
65
+ * @param {string} [opts.jwtToken] - JWT or internal auth
66
+ * @param {Object} opts.customContent - CustomContentPost (name, pageId, lang required; at least one of title, text, imgUrl, mainUrl)
61
67
  * @param {Object} [opts.headers] - Optional headers
62
- * @returns {Promise<import("axios").AxiosResponse>}
68
+ * @returns {Promise<import("axios").AxiosResponse<{ customContent: Object }>>}
69
+ * @throws 400 WRONG_DATA, INVALID_CUSTOMCONTENT
70
+ * @throws 401 Unauthorized
71
+ * @throws 500 Internal server error
63
72
  */
64
73
  function create({jwtToken, token, customContent, headers}) {
65
74
  return client({
@@ -73,13 +82,17 @@ function customContentFactory({client, internalAuthTokenProvider}) {
73
82
  }
74
83
 
75
84
  /**
76
- * DELETE /custom-content/:customContentId - remove custom content. API does not accept query params.
85
+ * DELETE /custom-content/:customContentId Delete custom content. Emits customContent.deleted.
77
86
  * @param {Object} opts
78
87
  * @param {string} [opts.token] - API key
79
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
80
- * @param {string} opts.customContentId - Custom content id
88
+ * @param {string} [opts.jwtToken] - JWT or internal auth
89
+ * @param {string} opts.customContentId - Custom content id (24 hex)
81
90
  * @param {Object} [opts.headers] - Optional headers
82
- * @returns {Promise<import("axios").AxiosResponse>}
91
+ * @returns {Promise<import("axios").AxiosResponse<{ customContentId: string }>>}
92
+ * @throws 400 CUSTOMCONTENT_TERMINAL_ID, WRONG_DATA
93
+ * @throws 401 Unauthorized
94
+ * @throws 404 CUSTOMCONTENT_NOT_FOUND
95
+ * @throws 500 Internal server error
83
96
  */
84
97
  function remove({jwtToken, customContentId, token, headers}) {
85
98
  return client({
@@ -90,14 +103,18 @@ function customContentFactory({client, internalAuthTokenProvider}) {
90
103
  }
91
104
 
92
105
  /**
93
- * PUT /custom-content/:customContentId - update custom content. API does not accept query params.
106
+ * PUT /custom-content/:customContentId Update custom content. Body: { customContent }. Emits customContent.updated.
94
107
  * @param {Object} opts
95
108
  * @param {string} [opts.token] - API key
96
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
97
- * @param {string} opts.customContentId - Custom content id
98
- * @param {Object} opts.customContent - Custom content payload
109
+ * @param {string} [opts.jwtToken] - JWT or internal auth
110
+ * @param {string} opts.customContentId - Custom content id (24 hex)
111
+ * @param {Object} opts.customContent - CustomContentPost (at least one of title, text, imgUrl for update)
99
112
  * @param {Object} [opts.headers] - Optional headers
100
- * @returns {Promise<import("axios").AxiosResponse>}
113
+ * @returns {Promise<import("axios").AxiosResponse<{ customContent: Object }>>}
114
+ * @throws 400 WRONG_DATA, INVALID_CUSTOMCONTENT_UPDATE
115
+ * @throws 401 Unauthorized
116
+ * @throws 404 CUSTOMCONTENT_NOT_FOUND
117
+ * @throws 500 Internal server error
101
118
  */
102
119
  function update({jwtToken, token, customContentId, customContent, headers}) {
103
120
  return client({
@@ -13,34 +13,36 @@ const {authorizationHeaders} = require("./../endpoints_helpers.js");
13
13
  * @param {Object} deps
14
14
  * @param {import("axios").AxiosInstance} deps.client
15
15
  * @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
16
- * @returns {{ all: function, get: function, create: function, update: function, types: object }}
16
+ * @returns {{ all: function, get: function, create: function, update: function, types: { all: function } }}
17
17
  */
18
18
  function customFieldsFactory({client, internalAuthTokenProvider}) {
19
19
  /**
20
- * GET /custom-fields - list custom fields.
20
+ * GET /custom-fields - list custom fields (btrz-api-inventory).
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 {InventoryCustomFieldsQuery} [opts.query] - Query params (enabled, required, modelName)
25
25
  * @param {Object} [opts.headers] - Optional headers
26
- * @returns {Promise<import("axios").AxiosResponse>}
26
+ * @returns {Promise<import("axios").AxiosResponse<{ customfields: Array }>>}
27
+ * @throws When response is 4xx/5xx (e.g. 400 INVALID_MODEL_NAME, 401 Unauthorized, 500)
27
28
  */
28
- function all({token, query = {}, headers}) {
29
+ function all({token, jwtToken, query = {}, headers}) {
29
30
  return client({
30
31
  url: "/custom-fields",
31
32
  params: query,
32
- headers: authorizationHeaders({token, internalAuthTokenProvider, headers})
33
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
33
34
  });
34
35
  }
35
36
 
36
37
  /**
37
- * GET /custom-fields/:fieldId - get custom field by id. API does not accept query params.
38
+ * GET /custom-fields/:customfieldId - get custom field by id (btrz-api-inventory). No query params.
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
- * @param {string} opts.fieldId - Field id
42
+ * @param {string} opts.fieldId - Custom field id (24 hex chars; must start with accountId)
42
43
  * @param {Object} [opts.headers] - Optional headers
43
- * @returns {Promise<import("axios").AxiosResponse>}
44
+ * @returns {Promise<import("axios").AxiosResponse<{ customfield: Object }>>}
45
+ * @throws When response is 4xx/5xx (400, 401, 404 CUSTOMFIELD_NOT_FOUND, 500)
44
46
  */
45
47
  function get({fieldId, token, jwtToken, query = {}, headers}) {
46
48
  return client({
@@ -51,13 +53,14 @@ function customFieldsFactory({client, internalAuthTokenProvider}) {
51
53
  }
52
54
 
53
55
  /**
54
- * POST /custom-fields - create custom field. API does not accept query params.
56
+ * POST /custom-fields - create custom field (btrz-api-inventory). No query params.
55
57
  * @param {Object} opts
56
58
  * @param {string} [opts.token] - API key
57
59
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
58
- * @param {Object} opts.field - Field payload
60
+ * @param {Object} opts.field - Field payload (FieldPutData: text, type, required, disabled, options when type List)
59
61
  * @param {Object} [opts.headers] - Optional headers
60
- * @returns {Promise<import("axios").AxiosResponse>}
62
+ * @returns {Promise<import("axios").AxiosResponse<{ customfield: Object }>>}
63
+ * @throws When response is 4xx/5xx (400, 401, 404 CUSTOMFIELD_NOT_FOUND/FIELD_NOT_FOUND, 500)
61
64
  */
62
65
  function create({token, jwtToken, field, headers}) {
63
66
  return client({
@@ -69,14 +72,15 @@ function customFieldsFactory({client, internalAuthTokenProvider}) {
69
72
  }
70
73
 
71
74
  /**
72
- * PUT /custom-fields/:fieldId - update custom field. API does not accept query params.
75
+ * PUT /custom-fields/:fieldId - update custom field (btrz-api-inventory). No query params.
73
76
  * @param {Object} opts
74
77
  * @param {string} [opts.token] - API key
75
78
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
76
- * @param {string} opts.fieldId - Field id
77
- * @param {Object} opts.field - Field payload
79
+ * @param {string} opts.fieldId - Field id (24 hex chars)
80
+ * @param {Object} opts.field - Field payload (FieldPutData)
78
81
  * @param {Object} [opts.headers] - Optional headers
79
- * @returns {Promise<import("axios").AxiosResponse>}
82
+ * @returns {Promise<import("axios").AxiosResponse<{ customfield: Object }>>}
83
+ * @throws When response is 4xx/5xx (400, 401, 404 CUSTOMFIELD_NOT_FOUND/FIELD_NOT_FOUND/WRONG_DATA_OPTIONS, 500)
80
84
  */
81
85
  function update({token, jwtToken, fieldId, field, headers}) {
82
86
  return client({
@@ -90,16 +94,18 @@ function customFieldsFactory({client, internalAuthTokenProvider}) {
90
94
  /** @type {{ all: function }} */
91
95
  const types = {
92
96
  /**
93
- * GET /custom-fields/types - list custom field types. API does not accept query params.
97
+ * GET /custom-fields/types - list custom field types (btrz-api-inventory). No query params.
94
98
  * @param {Object} opts
95
99
  * @param {string} [opts.token] - API key
100
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
96
101
  * @param {Object} [opts.headers] - Optional headers
97
- * @returns {Promise<import("axios").AxiosResponse>}
102
+ * @returns {Promise<import("axios").AxiosResponse<{ types: Array }>>}
103
+ * @throws When response is 4xx/5xx (e.g. 401 Unauthorized, 500)
98
104
  */
99
- all({token, headers}) {
105
+ all({token, jwtToken, headers}) {
100
106
  return client({
101
107
  url: "/custom-fields/types",
102
- headers: authorizationHeaders({token, internalAuthTokenProvider, headers})
108
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
103
109
  });
104
110
  }
105
111
  };