btrz-api-client 8.33.0 → 8.34.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 (65) hide show
  1. package/lib/client-standalone-min.js +3 -3
  2. package/lib/client.js +6 -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/segments-information-tables.js +13 -7
  17. package/lib/endpoints/inventory/trip-ids.js +67 -0
  18. package/lib/endpoints/inventory/trips.js +60 -13
  19. package/lib/endpoints/invoices/emails.js +15 -5
  20. package/lib/endpoints/invoices/invoices.js +46 -25
  21. package/lib/endpoints/invoices/pdfs.js +15 -8
  22. package/lib/endpoints/invoices/providers.js +42 -25
  23. package/lib/endpoints/invoices/tax-ids.js +11 -7
  24. package/lib/endpoints/sales/cancellations.js +43 -31
  25. package/lib/endpoints/sales/cart.js +21 -18
  26. package/lib/endpoints/sales/flexpasses.js +2 -5
  27. package/lib/endpoints/sales/order.js +41 -7
  28. package/lib/endpoints/sales/parcel-quotes.js +2 -2
  29. package/package.json +1 -1
  30. package/src/client.js +6 -2
  31. package/src/endpoints/btrzpay/adyen.js +44 -0
  32. package/src/endpoints/btrzpay/cardpointe.js +6 -4
  33. package/src/endpoints/btrzpay/customerCards.js +19 -19
  34. package/src/endpoints/btrzpay/customers.js +13 -13
  35. package/src/endpoints/btrzpay/cybersource3ds.js +114 -0
  36. package/src/endpoints/btrzpay/datalogic.js +63 -28
  37. package/src/endpoints/btrzpay/oxxo.js +53 -26
  38. package/src/endpoints/btrzpay/prismaTerminals.js +24 -15
  39. package/src/endpoints/btrzpay/referenced-payments.js +4 -4
  40. package/src/endpoints/btrzpay/square.js +8 -8
  41. package/src/endpoints/btrzpay/stripe-terminals.js +17 -10
  42. package/src/endpoints/btrzpay/stripe3ds.js +40 -0
  43. package/src/endpoints/btrzpay/terminalPayments.js +19 -19
  44. package/src/endpoints/inventory/segments-information-tables.js +13 -7
  45. package/src/endpoints/inventory/trip-ids.js +54 -0
  46. package/src/endpoints/inventory/trips.js +52 -14
  47. package/src/endpoints/invoices/emails.js +15 -5
  48. package/src/endpoints/invoices/invoices.js +46 -25
  49. package/src/endpoints/invoices/pdfs.js +15 -8
  50. package/src/endpoints/invoices/providers.js +42 -25
  51. package/src/endpoints/invoices/tax-ids.js +11 -7
  52. package/src/endpoints/sales/cancellations.js +43 -31
  53. package/src/endpoints/sales/cart.js +20 -18
  54. package/src/endpoints/sales/flexpasses.js +3 -4
  55. package/src/endpoints/sales/order.js +34 -7
  56. package/src/endpoints/sales/parcel-quotes.js +2 -2
  57. package/test/endpoints/btrzpay/adyen.tests.js +27 -0
  58. package/test/endpoints/btrzpay/carpointe.tests.js +14 -0
  59. package/test/endpoints/btrzpay/customerCards.test.js +9 -6
  60. package/test/endpoints/btrzpay/cybersource3ds.tests.js +55 -0
  61. package/test/endpoints/btrzpay/stripe-terminals.tests.js +5 -6
  62. package/test/endpoints/btrzpay/stripe3ds.tests.js +31 -0
  63. package/test/endpoints/inventory/trip-ids.test.js +27 -0
  64. package/test/endpoints/inventory/trips.test.js +19 -14
  65. package/test/endpoints/sales/order.test.js +7 -1
@@ -5,10 +5,10 @@ const {
5
5
  /**
6
6
  * Query params for GET /terminal-payments/mit/:id (btrz-api-payments). See get-mit-by-id-handler getSpec().
7
7
  * @typedef {Object} TerminalPaymentsMitGetQuery
8
- * @property {string} [providerId] - Account provider (operator) ID; used by agencies/sellers
9
- * @property {string} [branchId] - Branch id where payment started (required for GET)
10
- * @property {string} [companyId] - Company id where payment started (required for GET)
11
- * @property {string} [date] - Date when payment started; format dd/mm/yyyy (required for GET)
8
+ * @property {string} [providerId] - Account provider (operator) ID; used by agencies/sellers; when omitted, authenticated account is used
9
+ * @property {string} branchId - Branch id where payment started (required). Example: 00676
10
+ * @property {string} companyId - Company id where payment started (required). Example: Z890
11
+ * @property {string} date - Date when payment started; format dd/mm/yyyy (required)
12
12
  */
13
13
 
14
14
  /**
@@ -27,15 +27,15 @@ const {
27
27
  function terminalPaymentsFactory({client, internalAuthTokenProvider}) {
28
28
  const mit = {
29
29
  /**
30
- * PUT /terminal-payments/mit/:id - update MIT terminal payment.
30
+ * PUT /terminal-payments/mit/:terminalPaymentId - complete MIT terminal payment with result from terminal.
31
31
  * @param {Object} opts
32
32
  * @param {string} [opts.token] - API key
33
33
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
34
- * @param {string} opts.id - Terminal payment id
35
- * @param {Object} opts.terminalPayment - Terminal payment payload
36
- * @param {TerminalPaymentsMitPutQuery} [opts.query] - Query params (providerId)
34
+ * @param {string} opts.id - Terminal payment ID (UUID)
35
+ * @param {{ result?: Object, paymentRequest: Object, orderId: string }} opts.terminalPayment - Terminal payment data (result, paymentRequest, orderId)
36
+ * @param {TerminalPaymentsMitPutQuery} [opts.query] - Optional providerId
37
37
  * @param {Object} [opts.headers] - Optional headers
38
- * @returns {Promise<import("axios").AxiosResponse>}
38
+ * @returns {Promise<import("axios").AxiosResponse<{ terminalPayment: Object }>>} Rejects with 400 (WRONG_DATA, INVALID_TERMINALPAYMENT_ID, INVALID_RESULT_OBJECT, MIT_*), 401, 404 (TERMINALPAYMENT_NOT_FOUND, MIT_PAYMENT_NOT_FOUND), 409 (CANT_UPDATE_ORDER), 500.
39
39
  */
40
40
  update({token, jwtToken, id, terminalPayment, query = {}, headers}) {
41
41
  return client({
@@ -47,14 +47,14 @@ function terminalPaymentsFactory({client, internalAuthTokenProvider}) {
47
47
  });
48
48
  },
49
49
  /**
50
- * GET /terminal-payments/mit/:id - get MIT terminal payment.
50
+ * GET /terminal-payments/mit/:terminalPaymentId - get MIT terminal payment result from MIT servers.
51
51
  * @param {Object} opts
52
52
  * @param {string} [opts.token] - API key
53
53
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
54
- * @param {string} opts.id - Terminal payment id
55
- * @param {TerminalPaymentsMitGetQuery} [opts.query] - Query params (providerId, branchId, companyId, date)
54
+ * @param {string} opts.id - Terminal payment ID (UUID)
55
+ * @param {TerminalPaymentsMitGetQuery} opts.query - branchId, companyId, date (required); optional providerId
56
56
  * @param {Object} [opts.headers] - Optional headers
57
- * @returns {Promise<import("axios").AxiosResponse>}
57
+ * @returns {Promise<import("axios").AxiosResponse<{ terminalPayment: Object }>>} Rejects with 400 (WRONG_DATA, INVALID_TERMINALPAYMENT_ID, INVALID_DATE, MIT_*), 401, 404 (TERMINALPAYMENT_NOT_FOUND, MIT_PAYMENT_NOT_FOUND), 500.
58
58
  */
59
59
  get({token, jwtToken, id, query = {}, headers}) {
60
60
  return client.get(`/terminal-payments/mit/${id}`, {
@@ -66,14 +66,14 @@ function terminalPaymentsFactory({client, internalAuthTokenProvider}) {
66
66
 
67
67
  const webhooks = {
68
68
  /**
69
- * POST /terminal-payments/webhooks/getnet/:providerId - Getnet webhook. API does not accept query params.
69
+ * POST /terminal-payments/webhooks/getnet/:providerId - Getnet Terminal webhook (inbound). API does not accept query params.
70
70
  * @param {Object} opts
71
- * @param {Object} opts.data - Request body
72
- * @param {string} opts.providerId - Provider id
71
+ * @param {Object} opts.data - Getnet webhook payload (e.g. TrxResult, TrxReference, userId)
72
+ * @param {string} opts.providerId - Provider (account) ID for getnet_terminal payment method
73
73
  * @param {Object} [opts.headers] - Optional headers
74
- * @param {string} [opts.token] - API key
75
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
76
- * @returns {Promise<import("axios").AxiosResponse>}
74
+ * @param {string} [opts.token] - API key (optional when no userId in payload)
75
+ * @param {string} [opts.jwtToken] - JWT or internal auth (required when userId is in payload)
76
+ * @returns {Promise<import("axios").AxiosResponse<{ status: string }>>} Rejects with 400 (INVALID_WEBHOOK_PAYLOAD), 401 (when userId present but not authenticated), 404 (PAYMENT_NOT_FOUND_FOR_WEBHOOK_EVENT, PAYMENT_METHOD_NOT_FOUND, USER_NOT_FOUND), 409 (CANT_UPDATE_ORDER), 500.
77
77
  */
78
78
  getnet({data, providerId, headers = {}, token, jwtToken}) {
79
79
  const _headers = token && jwtToken ?
@@ -1,3 +1,4 @@
1
+ /* eslint-disable max-len */
1
2
  const {
2
3
  authorizationHeaders
3
4
  } = require("./../endpoints_helpers.js");
@@ -5,7 +6,7 @@ const {
5
6
  /**
6
7
  * Query params for GET /segments-information-tables/:routeId (btrz-api-inventory-trips). See get-by-id-handler getSpec().
7
8
  * @typedef {Object} SegmentsInformationTablesQuery
8
- * @property {string} [providerId] - Provider id of the route if not the same as the user making the request (ObjectId format)
9
+ * @property {string} [providerId] - Provider/account id of the route when different from the authenticated user (24-char hex ObjectId)
9
10
  */
10
11
 
11
12
  /**
@@ -17,18 +18,23 @@ const {
17
18
  */
18
19
  function segmentInformationTableFactory({client, internalAuthTokenProvider}) {
19
20
  /**
20
- * GET /segments-information-tables/:routeId - get segments information table by route id.
21
+ * GET /segments-information-tables/:routeId Returns segment information tables for the route (distances, durations, durationsHHMM between stops). Requires BETTEREZ_APP audience.
21
22
  * @param {Object} opts
22
- * @param {string} [opts.token] - API key
23
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
24
- * @param {string} opts.routeId - Route id (ObjectId format)
25
- * @param {SegmentsInformationTablesQuery} [opts.query] - Query params (providerId)
23
+ * @param {string} [opts.token] - API key (X-API-KEY)
24
+ * @param {string} [opts.jwtToken] - JWT or internal auth (Authorization: Bearer)
25
+ * @param {string} opts.routeId - Route id (24-char hex ObjectId)
26
+ * @param {SegmentsInformationTablesQuery} [opts.query] - Optional providerId
26
27
  * @param {Object} [opts.headers] - Optional headers
27
- * @returns {Promise<import("axios").AxiosResponse>}
28
+ * @returns {Promise<import("axios").AxiosResponse<{ segmentInformationTables: { distances: Object, durations: Object, durationsHHMM: Object } }>>}
29
+ * @throws 400 INVALID_ROUTE_ID — routeId not 24 hex characters
30
+ * @throws 401 Unauthorized
31
+ * @throws 404 ROUTE_NOT_FOUND
32
+ * @throws 500 Internal server error
28
33
  */
29
34
  function get({token, jwtToken, routeId, query = {}, headers}) {
30
35
  return client({
31
36
  url: `/segments-information-tables/${routeId}`,
37
+ method: "get",
32
38
  params: query,
33
39
  headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
34
40
  });
@@ -0,0 +1,54 @@
1
+ /* eslint-disable max-len */
2
+ const {authorizationHeaders} = require("./../endpoints_helpers.js");
3
+
4
+ /**
5
+ * Body for POST /direct-trip-ids (btrz-api-inventory-trips). See TripIdPostData in post-handler getSpec().
6
+ * @typedef {Object} TripIdPostData
7
+ * @property {string} providerId - Provider id (24-char hex ObjectId)
8
+ * @property {string} routeId - Route id (24-char hex ObjectId)
9
+ * @property {string} scheduleId - Schedule id
10
+ * @property {string} departureDate - Departure date (yyyy-mm-dd)
11
+ * @property {string} fareIds - Fare ids and quantities (e.g. fareId:qty)
12
+ * @property {string} channel - One of: backoffice, agency-backoffice, websales, agency-websales
13
+ * @property {string} productId - Product id (24-char hex ObjectId)
14
+ * @property {string} originId - Origin station id (24-char hex ObjectId)
15
+ * @property {string} destinationId - Destination station id (24-char hex ObjectId)
16
+ * @property {string} [currency] - ISO currency code (optional, for multicurrency)
17
+ */
18
+
19
+ /**
20
+ * Factory for trip-ids API (btrz-api-inventory-trips).
21
+ * @param {Object} deps
22
+ * @param {import("axios").AxiosInstance} deps.client
23
+ * @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
24
+ * @returns {{ create: function }}
25
+ */
26
+ function tripIdsFactory({client, internalAuthTokenProvider}) {
27
+ /**
28
+ * POST /direct-trip-ids — Resolve trip parameters to a trip id. Runs trip search internally and returns the matching trip's base64 id (or null). Body can be TripIdPostData or { tripId: TripIdPostData }.
29
+ * @param {Object} opts
30
+ * @param {string} [opts.token] - API key (X-API-KEY)
31
+ * @param {string} [opts.jwtToken] - JWT or internal auth (Authorization: Bearer)
32
+ * @param {TripIdPostData|{ tripId: TripIdPostData }} opts.data - Trip parameters (or wrapped in tripId key)
33
+ * @param {Object} [opts.headers] - Optional headers
34
+ * @returns {Promise<import("axios").AxiosResponse<{ tripId: { tripId: string|null } }>>}
35
+ * @throws 400 WRONG_DATA — tripId required or required fields missing
36
+ * @throws 401 Unauthorized
37
+ * @throws 404 TRIP_IDS_NOT_FOUND
38
+ * @throws 500 Internal server error
39
+ */
40
+ function create({token, jwtToken, data, headers}) {
41
+ return client({
42
+ url: "/direct-trip-ids",
43
+ method: "post",
44
+ data,
45
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
46
+ });
47
+ }
48
+
49
+ return {
50
+ create
51
+ };
52
+ }
53
+
54
+ module.exports = tripIdsFactory;
@@ -1,46 +1,84 @@
1
+ /* eslint-disable max-len */
1
2
  const {authorizationHeaders} = require("./../endpoints_helpers.js");
2
3
 
3
4
  /**
4
- * Factory for trips API (btrz-api-inventory).
5
+ * Factory for trips API (btrz-api-inventory-trips).
5
6
  * @param {Object} deps
6
7
  * @param {import("axios").AxiosInstance} deps.client
7
8
  * @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
8
- * @returns {{ all: function, get: function }}
9
+ * @returns {{ all: function, get: function, getPricingSimulation: function }}
9
10
  */
10
11
  function tripsFactory({client, internalAuthTokenProvider}) {
11
12
  /**
12
- * GET /trips - list trips. API source of truth in btrz-api-inventory-trips; query not documented here.
13
+ * GET /trips Search for available trips by date, origin, destination, fare, product, channel, and price. Rate limited (e.g. 8000 req/10 min). See get-trips getSpec() for full query params (productId, originId, destinationId, fareIds, departureDate, returnDate, channel, currency, etc.).
13
14
  * @param {Object} opts
14
- * @param {string} [opts.token] - API key
15
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
15
+ * @param {string} [opts.token] - API key (X-API-KEY)
16
+ * @param {string} [opts.jwtToken] - JWT or internal auth (Authorization: Bearer)
17
+ * @param {Object} [opts.query] - Query params (productId, originId, destinationId, fareIds, departureDate, returnDate, etc.)
16
18
  * @param {Object} [opts.headers] - Optional headers
17
- * @returns {Promise<import("axios").AxiosResponse>}
19
+ * @returns {Promise<import("axios").AxiosResponse<{ trips: { departures: Object[], returns: Object[] } }>>}
20
+ * @throws 400 INVALID_DATE, INVALID_DATE_FORMAT, INVALID_PRODUCTID, INVALID_ORIGIN, INVALID_DESTINATION, INVALID_CHANNEL, INVALID_FARE, INVALID_FAREID, INVALID_MANIFEST_STATUS, WRONG_DATA
21
+ * @throws 401 Unauthorized
22
+ * @throws 409 NO_HIGHER_OR_EQL_PRICE
23
+ * @throws 500 Internal server error
18
24
  */
19
25
  function all({token, jwtToken, query = {}, headers}) {
20
26
  return client({
21
27
  url: "/trips",
28
+ method: "get",
22
29
  params: query,
23
30
  headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
24
31
  });
25
32
  }
26
33
 
27
34
  /**
28
- * GET /trip/:id - get trip by id. API does not accept query params.
35
+ * GET /trip/:id — Get up-to-date information for a trip by its ID (base64-encoded trip summary from a search). Optional query: extraCapacityImpact, ignoreCutoffs, currency, ignoreOmitByAvailability, includeMoveToTrips.
29
36
  * @param {Object} opts
30
- * @param {string} [opts.token] - API key
31
- * @param {string} opts.id - Trip id
37
+ * @param {string} [opts.token] - API key (X-API-KEY)
38
+ * @param {string} [opts.jwtToken] - JWT or internal auth (Authorization: Bearer)
39
+ * @param {string} opts.id - Trip id (base64-encoded)
40
+ * @param {Object} [opts.query] - Optional: extraCapacityImpact, ignoreCutoffs, currency, ignoreOmitByAvailability, includeMoveToTrips
32
41
  * @param {Object} [opts.headers] - Optional headers
33
- * @returns {Promise<import("axios").AxiosResponse>}
42
+ * @returns {Promise<import("axios").AxiosResponse<{ trip: Object }>>}
43
+ * @throws 400 INVALID_TRIP — tripId is invalid
44
+ * @throws 401 Unauthorized
45
+ * @throws 500 Internal server error
34
46
  */
35
- function get({token, id, headers}) {
36
- return client.get(`/trip/${id}`, {
37
- headers: authorizationHeaders({token, internalAuthTokenProvider, headers})
47
+ function get({token, jwtToken, id, query = {}, headers}) {
48
+ return client({
49
+ url: `/trip/${id}`,
50
+ method: "get",
51
+ params: query,
52
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
53
+ });
54
+ }
55
+
56
+ /**
57
+ * GET /trips/pricing-simulation — Get pricing simulation for all purchase combinations for a schedule. Query: scheduleId, productId (required); purchaseDate, travelDate, includeReadable, includeMetadata, minimize (optional).
58
+ * @param {Object} opts
59
+ * @param {string} [opts.token] - API key (X-API-KEY)
60
+ * @param {string} [opts.jwtToken] - JWT or internal auth (Authorization: Bearer)
61
+ * @param {Object} [opts.query] - scheduleId, productId (required); purchaseDate, travelDate, includeReadable, includeMetadata, minimize
62
+ * @param {Object} [opts.headers] - Optional headers
63
+ * @returns {Promise<import("axios").AxiosResponse<Object>>} Response shape per PricingSimulationResult definition
64
+ * @throws 400 INVALID_SCHEDULE_ID, INVALID_PRODUCT_ID, INVALID_PRODUCT, ROUTE_NOT_FOUND, ONLY_JP_SUPPORTED, INVALID_DATE
65
+ * @throws 401 Unauthorized, PRICING_SIMULATOR_DISABLED, PROVIDER_UNAUTHORIZED
66
+ * @throws 404 SCHEDULE_NOT_FOUND, NO_MANIFEST
67
+ * @throws 500 Internal server error
68
+ */
69
+ function getPricingSimulation({token, jwtToken, query = {}, headers}) {
70
+ return client({
71
+ url: "/trips/pricing-simulation",
72
+ method: "get",
73
+ params: query,
74
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
38
75
  });
39
76
  }
40
77
 
41
78
  return {
42
79
  all,
43
- get
80
+ get,
81
+ getPricingSimulation
44
82
  };
45
83
  }
46
84
 
@@ -10,13 +10,23 @@ const {authorizationHeaders} = require("./../endpoints_helpers.js");
10
10
  */
11
11
  function emailsFactory({client, internalAuthTokenProvider}) {
12
12
  /**
13
- * POST /emails - create/send invoice email. API does not accept query params.
13
+ * POST /emails Send invoice by email to the given addresses.
14
+ * Request body may be sent as root object or under key "email". On success the API emits webhook invoiceemail.created.
15
+ *
14
16
  * @param {Object} opts
15
- * @param {string} [opts.token] - API key
16
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
17
- * @param {Object} opts.data - Request body
17
+ * @param {string} [opts.token] - API key (X-API-KEY)
18
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol (Authorization: Bearer)
19
+ * @param {Object} opts.data - Request body (EmailPostData)
20
+ * @param {string} opts.data.invoiceId - Invoice ID (required, 24-char hex ObjectId)
21
+ * @param {string[]} opts.data.emails - Recipient email addresses (required)
22
+ * @param {string} [opts.data.language] - Language code for template (e.g. "en-us")
23
+ * @param {Object} [opts.query] - Query params (none used by this endpoint)
18
24
  * @param {Object} [opts.headers] - Optional headers
19
- * @returns {Promise<import("axios").AxiosResponse>}
25
+ * @returns {Promise<import("axios").AxiosResponse<{ status: "OK" }>>} Resolves with { status: "OK" } on success
26
+ * @throws 400 WRONG_DATA, ACCOUNT_CANT_SEND_EMAILS, NO_VERIFIED_OR_ACTIVE_EMAIL, INVALID_EMAIL_TO_SEND
27
+ * @throws 401 Unauthorized (missing/invalid X-API-KEY or Authorization)
28
+ * @throws 404 INVOICE_NOT_FOUND
29
+ * @throws 500 Internal server error
20
30
  */
21
31
  function create({token, jwtToken, data, query = {}, headers}) {
22
32
  return client({
@@ -22,13 +22,15 @@ const {authorizationHeaders} = require("./../endpoints_helpers.js");
22
22
  */
23
23
  function invoicesFactory({client, internalAuthTokenProvider}) {
24
24
  /**
25
- * GET /invoices - list invoices.
25
+ * GET /invoices List invoices by transaction (paginated).
26
26
  * @param {Object} opts
27
- * @param {string} [opts.token] - API key
28
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
29
- * @param {InvoicesListQuery} [opts.query] - Query params (transactionId required)
27
+ * @param {string} [opts.token] - API key (X-API-KEY)
28
+ * @param {string} [opts.jwtToken] - JWT or internal auth (Authorization: Bearer)
29
+ * @param {InvoicesListQuery} [opts.query] - Query; transactionId (required) = 24-char hex ObjectId
30
30
  * @param {Object} [opts.headers] - Optional headers
31
- * @returns {Promise<import("axios").AxiosResponse>}
31
+ * @returns {Promise<import("axios").AxiosResponse<{ invoices: Object[], total: number, page?: number, ... }>>}
32
+ * @throws 401 Unauthorized
33
+ * @throws 500 Internal server error
32
34
  */
33
35
  function all({token, jwtToken, query = {}, headers}) {
34
36
  return client({
@@ -40,13 +42,17 @@ function invoicesFactory({client, internalAuthTokenProvider}) {
40
42
  }
41
43
 
42
44
  /**
43
- * GET /invoices/:id - get invoice by id. API does not accept query params.
45
+ * GET /invoices/:id Get a single invoice by ID.
44
46
  * @param {Object} opts
45
- * @param {string} [opts.token] - API key
46
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
47
- * @param {string} opts.id - Invoice id
47
+ * @param {string} [opts.token] - API key (X-API-KEY)
48
+ * @param {string} [opts.jwtToken] - JWT or internal auth (Authorization: Bearer)
49
+ * @param {string} opts.id - Invoice ID (24-character hex ObjectId)
48
50
  * @param {Object} [opts.headers] - Optional headers
49
- * @returns {Promise<import("axios").AxiosResponse>}
51
+ * @returns {Promise<import("axios").AxiosResponse<{ invoice: Object }>>}
52
+ * @throws 400 WRONG_DATA, INVALID_INVOICE_ID
53
+ * @throws 401 Unauthorized
54
+ * @throws 404 INVOICE_NOT_FOUND
55
+ * @throws 500 Internal server error
50
56
  */
51
57
  function get({token, jwtToken, id, query = {}, headers}) {
52
58
  return client({
@@ -58,13 +64,16 @@ function invoicesFactory({client, internalAuthTokenProvider}) {
58
64
  }
59
65
 
60
66
  /**
61
- * GET /failures - list invoice failures.
67
+ * GET /failures List invoice failures (paginated). Optional transactionId filter.
62
68
  * @param {Object} opts
63
- * @param {string} [opts.token] - API key
64
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
65
- * @param {InvoicesFailuresQuery} [opts.query] - Query params (transactionId optional)
69
+ * @param {string} [opts.token] - API key (X-API-KEY)
70
+ * @param {string} [opts.jwtToken] - JWT or internal auth (Authorization: Bearer)
71
+ * @param {InvoicesFailuresQuery} [opts.query] - Query; transactionId optional (24-char hex; if present must be valid)
66
72
  * @param {Object} [opts.headers] - Optional headers
67
- * @returns {Promise<import("axios").AxiosResponse>}
73
+ * @returns {Promise<import("axios").AxiosResponse<{ invoicesFailures: Object[], total: number, ... }>>}
74
+ * @throws 400 WRONG_DATA, INVALID_TRANSACTION_ID (if transactionId provided and invalid)
75
+ * @throws 401 Unauthorized
76
+ * @throws 500 Internal server error
68
77
  */
69
78
  function getInvoicesFailures({token, jwtToken, query = {}, headers}) {
70
79
  return client({
@@ -76,13 +85,19 @@ function invoicesFactory({client, internalAuthTokenProvider}) {
76
85
  }
77
86
 
78
87
  /**
79
- * POST /retry - retry invoicing. API does not accept query params.
88
+ * POST /retry Retry invoicing from an invoice failure using saved data. Body: transactionId (required).
89
+ * On success may emit webhooks invoices.created or invoices.updated.
80
90
  * @param {Object} opts
81
- * @param {string} [opts.token] - API key
82
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
83
- * @param {Object} opts.data - Request body
91
+ * @param {string} [opts.token] - API key (X-API-KEY)
92
+ * @param {string} [opts.jwtToken] - JWT or internal auth (Authorization: Bearer)
93
+ * @param {Object} opts.data - Body: { transactionId } (transactionId = 24-char hex ObjectId)
84
94
  * @param {Object} [opts.headers] - Optional headers
85
- * @returns {Promise<import("axios").AxiosResponse>}
95
+ * @returns {Promise<import("axios").AxiosResponse<{ invoice: Object }>>}
96
+ * @throws 400 WRONG_DATA, INVOICE_NOT_CREATED, INVOICE_PROVIDER_TYPE_NOT_SUPPORTED, INVOICE_PROVIDER_NOT_FOUND, TRANSACTION_ALREADY_INVOICED
97
+ * @throws 401 Unauthorized
98
+ * @throws 404 TRANSACTION_NOT_FOUND, INVOICE_FAILURE_NOT_FOUND
99
+ * @throws 409 INFILE_SIGN_FAILED, INFILE_CERTIFICATION_FAILED
100
+ * @throws 500 Internal server error
86
101
  */
87
102
  function retryInvoicing({token, jwtToken, data, query = {}, headers}) {
88
103
  return client({
@@ -95,13 +110,19 @@ function invoicesFactory({client, internalAuthTokenProvider}) {
95
110
  }
96
111
 
97
112
  /**
98
- * PUT /retry - override buyer and retry invoicing. API does not accept query params.
113
+ * PUT /retry Override buyer and retry invoicing from an invoice failure. Body: retryData with transactionId and overrideBuyer.
114
+ * On success may emit webhooks invoices.created or invoices.updated.
99
115
  * @param {Object} opts
100
- * @param {string} [opts.token] - API key
101
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
102
- * @param {Object} opts.data - Request body
116
+ * @param {string} [opts.token] - API key (X-API-KEY)
117
+ * @param {string} [opts.jwtToken] - JWT or internal auth (Authorization: Bearer)
118
+ * @param {Object} opts.data - Body: { transactionId, overrideBuyer } (RetryPutData); overrideBuyer required when no certified invoice exists
103
119
  * @param {Object} [opts.headers] - Optional headers
104
- * @returns {Promise<import("axios").AxiosResponse>}
120
+ * @returns {Promise<import("axios").AxiosResponse<{ invoice: Object }>>}
121
+ * @throws 400 WRONG_DATA, INVOICE_NOT_CREATED, INVOICE_PROVIDER_TYPE_NOT_SUPPORTED, INVOICE_PROVIDER_NOT_FOUND, TRANSACTION_ALREADY_INVOICED, OVERRIDE_BUYER_IS_MANDATORY
122
+ * @throws 401 Unauthorized
123
+ * @throws 404 TRANSACTION_NOT_FOUND, INVOICE_FAILURE_NOT_FOUND
124
+ * @throws 409 INFILE_SIGN_FAILED, INFILE_CERTIFICATION_FAILED
125
+ * @throws 500 Internal server error
105
126
  */
106
127
  function overrideBuyerRetryInvoicing({token, jwtToken, data, query = {}, headers}) {
107
128
  return client({
@@ -3,8 +3,8 @@ const {authorizationHeaders} = require("./../endpoints_helpers.js");
3
3
 
4
4
  /**
5
5
  * Query params for GET /pdfs (btrz-api-invoices). See pdfs get-handler getSpec().
6
- * @typedef {Object} PdfsListQuery
7
- * @property {string} transactionId - Transaction id of the invoice (required)
6
+ * @typedef {Object} PdfsQuery
7
+ * @property {string} transactionId - Transaction ID of the invoice (required, 24-char hex ObjectId)
8
8
  */
9
9
 
10
10
  /**
@@ -16,14 +16,21 @@ const {authorizationHeaders} = require("./../endpoints_helpers.js");
16
16
  */
17
17
  function pdfsFactory({client, internalAuthTokenProvider}) {
18
18
  /**
19
- * GET /pdfs - list invoice PDFs.
19
+ * GET /pdfs Returns the invoice PDF for the invoice associated with the given transaction.
20
+ * Response is binary (application/pdf) with Content-Disposition attachment; filename=invoice-{invoiceId}.pdf.
21
+ * Use responseType "blob" or "arraybuffer" to receive binary data.
22
+ *
20
23
  * @param {Object} opts
21
- * @param {string} [opts.token] - API key
22
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
23
- * @param {PdfsListQuery} [opts.query] - Query params (transactionId required)
24
- * @param {string} [opts.responseType] - Response type (e.g. "json", "blob")
24
+ * @param {string} [opts.token] - API key (X-API-KEY)
25
+ * @param {string} [opts.jwtToken] - JWT or internal auth (Authorization: Bearer)
26
+ * @param {PdfsQuery} [opts.query] - Query; transactionId (required)
27
+ * @param {string} [opts.responseType] - Response type: "blob" or "arraybuffer" for binary PDF; "json" default
25
28
  * @param {Object} [opts.headers] - Optional headers
26
- * @returns {Promise<import("axios").AxiosResponse>}
29
+ * @returns {Promise<import("axios").AxiosResponse<ArrayBuffer|Blob|*>>} PDF binary when responseType is blob/arraybuffer
30
+ * @throws 400 WRONG_DATA — transactionId is required
31
+ * @throws 401 Unauthorized
32
+ * @throws 404 INVOICE_NOT_FOUND — Invoice not found for the transactionId
33
+ * @throws 500 Internal server error (e.g. unsupported invoice provider type)
27
34
  */
28
35
  function all({token, jwtToken, query = {}, responseType = "json", headers}) {
29
36
  return client({
@@ -20,13 +20,15 @@ const {authorizationHeaders} = require("./../endpoints_helpers.js");
20
20
  */
21
21
  function providersFactory({client, internalAuthTokenProvider}) {
22
22
  /**
23
- * GET /providers - list invoice providers.
23
+ * GET /providers List invoice providers (paginated). Optional filters: enabled, invoiceProviderType, channel, country, operatingCompany.
24
24
  * @param {Object} opts
25
- * @param {string} [opts.token] - API key
26
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
25
+ * @param {string} [opts.token] - API key (X-API-KEY)
26
+ * @param {string} [opts.jwtToken] - JWT or internal auth (Authorization: Bearer)
27
27
  * @param {ProvidersListQuery} [opts.query] - Query params (all optional)
28
28
  * @param {Object} [opts.headers] - Optional headers
29
- * @returns {Promise<import("axios").AxiosResponse>}
29
+ * @returns {Promise<import("axios").AxiosResponse<{ providers: Object[], total?: number, ... }>>}
30
+ * @throws 401 Unauthorized
31
+ * @throws 500 Internal server error
30
32
  */
31
33
  function all({token, jwtToken, query = {}, headers}) {
32
34
  return client({
@@ -38,13 +40,17 @@ function providersFactory({client, internalAuthTokenProvider}) {
38
40
  }
39
41
 
40
42
  /**
41
- * GET /providers/:id - get invoice provider by id. API does not accept query params.
43
+ * GET /providers/:id Get a single invoice provider by ID.
42
44
  * @param {Object} opts
43
- * @param {string} [opts.token] - API key
44
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
45
- * @param {string} opts.id - Provider id
45
+ * @param {string} [opts.token] - API key (X-API-KEY)
46
+ * @param {string} [opts.jwtToken] - JWT or internal auth (Authorization: Bearer)
47
+ * @param {string} opts.id - Provider ID (24-character hex ObjectId)
46
48
  * @param {Object} [opts.headers] - Optional headers
47
- * @returns {Promise<import("axios").AxiosResponse>}
49
+ * @returns {Promise<import("axios").AxiosResponse<{ provider: Object }>>}
50
+ * @throws 400 WRONG_DATA, INVALID_PROVIDER_ID
51
+ * @throws 401 Unauthorized
52
+ * @throws 404 PROVIDER_NOT_FOUND
53
+ * @throws 500 Internal server error
48
54
  */
49
55
  function get({token, jwtToken, id, query = {}, headers}) {
50
56
  return client({
@@ -56,14 +62,18 @@ function providersFactory({client, internalAuthTokenProvider}) {
56
62
  }
57
63
 
58
64
  /**
59
- * PUT /providers/:id - update invoice provider. API does not accept query params.
65
+ * PUT /providers/:id Update invoice provider. Body may be provider or body.provider. Emits webhook invoice_providers.updated on success.
60
66
  * @param {Object} opts
61
- * @param {string} [opts.token] - API key
62
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
63
- * @param {string} opts.id - Provider id
64
- * @param {Object} opts.data - Request body
67
+ * @param {string} [opts.token] - API key (X-API-KEY)
68
+ * @param {string} [opts.jwtToken] - JWT or internal auth (Authorization: Bearer)
69
+ * @param {string} opts.id - Provider ID (24-character hex ObjectId)
70
+ * @param {Object} opts.data - Request body (ProviderPutData)
65
71
  * @param {Object} [opts.headers] - Optional headers
66
- * @returns {Promise<import("axios").AxiosResponse>}
72
+ * @returns {Promise<import("axios").AxiosResponse<{ provider: Object }>>}
73
+ * @throws 400 INVALID_PHRASES, OPERATING_COMPANY_NOT_FOUND, CANNOT_CHANGE_PROVIDER, INVALID_IVA_AFFILIATION, CANT_REMOVE_*, INVALID_PARAM_VALUE, CANT_DELETE_DOCUMENT_TYPE_*
74
+ * @throws 401 Unauthorized
75
+ * @throws 404 PROVIDER_NOT_FOUND
76
+ * @throws 500 Internal server error
67
77
  */
68
78
  function update({token, jwtToken, id, data, query = {}, headers}) {
69
79
  return client({
@@ -76,13 +86,17 @@ function providersFactory({client, internalAuthTokenProvider}) {
76
86
  }
77
87
 
78
88
  /**
79
- * DELETE /providers/:id - remove invoice provider. API does not accept query params.
89
+ * DELETE /providers/:id Remove invoice provider. Emits webhook invoice_providers.deleted on success.
80
90
  * @param {Object} opts
81
- * @param {string} [opts.token] - API key
82
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
83
- * @param {string} opts.id - Provider id
91
+ * @param {string} [opts.token] - API key (X-API-KEY)
92
+ * @param {string} [opts.jwtToken] - JWT or internal auth (Authorization: Bearer)
93
+ * @param {string} opts.id - Provider ID (24-character hex ObjectId)
84
94
  * @param {Object} [opts.headers] - Optional headers
85
- * @returns {Promise<import("axios").AxiosResponse>}
95
+ * @returns {Promise<import("axios").AxiosResponse<{ providerId: string }>>}
96
+ * @throws 400 WRONG_DATA, INVALID_PROVIDER_ID
97
+ * @throws 401 Unauthorized
98
+ * @throws 404 PROVIDER_NOT_FOUND
99
+ * @throws 500 Internal server error
86
100
  */
87
101
  function remove({token, jwtToken, id, query = {}, headers}) {
88
102
  return client({
@@ -94,13 +108,16 @@ function providersFactory({client, internalAuthTokenProvider}) {
94
108
  }
95
109
 
96
110
  /**
97
- * POST /providers - create invoice provider. API does not accept query params.
111
+ * POST /providers Create invoice provider. Body may be provider or body.provider (ProviderPostData). Emits webhook invoice_providers.created on success.
98
112
  * @param {Object} opts
99
- * @param {string} [opts.token] - API key
100
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
101
- * @param {Object} opts.data - Request body
113
+ * @param {string} [opts.token] - API key (X-API-KEY)
114
+ * @param {string} [opts.jwtToken] - JWT or internal auth (Authorization: Bearer)
115
+ * @param {Object} opts.data - Request body (ProviderPostData: invoiceProviderType, currencies, params required)
102
116
  * @param {Object} [opts.headers] - Optional headers
103
- * @returns {Promise<import("axios").AxiosResponse>}
117
+ * @returns {Promise<import("axios").AxiosResponse<{ provider: Object }>>}
118
+ * @throws 400 WRONG_DATA, INVALID_PHRASES, REQUIRED_PARAM_MISSING, INVALID_PARAM_VALUE, OPERATING_COMPANY_NOT_FOUND, INVALID_IVA_AFFILIATION
119
+ * @throws 401 Unauthorized
120
+ * @throws 500 Internal server error
104
121
  */
105
122
  function create({token, jwtToken, data, query = {}, headers}) {
106
123
  return client({
@@ -6,8 +6,8 @@ const {authorizationHeaders} = require("./../endpoints_helpers.js");
6
6
  * @typedef {Object} TaxIdsListQuery
7
7
  * @property {string} taxNumber - Tax number to look up (required)
8
8
  * @property {string} country - ISO code of the country of the tax information (required)
9
- * @property {string} [invoiceProviderId] - Invoice provider id (24 hex chars)
10
- * @property {string} [documentType] - Tax identification type to check against validation service
9
+ * @property {string} [invoiceProviderId] - Invoice provider id (24-char hex ObjectId); optional, for external validation
10
+ * @property {string} [documentType] - Tax identification type for validation (e.g. NIT, DPI for infile)
11
11
  */
12
12
 
13
13
  /**
@@ -19,13 +19,17 @@ const {authorizationHeaders} = require("./../endpoints_helpers.js");
19
19
  */
20
20
  function taxIdsFactory({client, internalAuthTokenProvider}) {
21
21
  /**
22
- * GET /tax-ids - list tax IDs.
22
+ * GET /tax-ids List tax ID information (paginated). Merges internal tax IDs with external provider validation when invoiceProviderId is provided.
23
23
  * @param {Object} opts
24
- * @param {string} [opts.token] - API key
25
- * @param {string} [opts.jwtToken] - JWT or internal auth symbol
26
- * @param {TaxIdsListQuery} opts.query - taxNumber, country; optional invoiceProviderId, documentType
24
+ * @param {string} [opts.token] - API key (X-API-KEY)
25
+ * @param {string} [opts.jwtToken] - JWT or internal auth (Authorization: Bearer)
26
+ * @param {TaxIdsListQuery} [opts.query] - taxNumber and country (required); optional invoiceProviderId, documentType
27
27
  * @param {Object} [opts.headers] - Optional headers
28
- * @returns {Promise<import("axios").AxiosResponse>} 400 WRONG_DATA, INVALID_PROVIDER_ID; 404 TAXID_NOT_FOUND
28
+ * @returns {Promise<import("axios").AxiosResponse<{ taxIds: Object[], total?: number, ... }>>}
29
+ * @throws 400 WRONG_DATA, INVALID_PROVIDER_ID, INVALID_TAX_NUMBER, INVALID_PROVIDER_CREDENTIALS
30
+ * @throws 401 Unauthorized
31
+ * @throws 404 TAXID_NOT_FOUND, PROVIDER_NOT_FOUND
32
+ * @throws 500 Internal server error
29
33
  */
30
34
  function all({token, jwtToken, query = {}, headers}) {
31
35
  return client({