btrz-api-client 8.34.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.
- package/lib/client-standalone-min.js +3 -3
- package/lib/client.js +4 -0
- package/lib/endpoints/inventory/banks.js +39 -21
- package/lib/endpoints/inventory/change-requests.js +59 -31
- package/lib/endpoints/inventory/control-classes.js +39 -20
- package/lib/endpoints/inventory/countries.js +25 -9
- package/lib/endpoints/inventory/custom-content.js +39 -21
- package/lib/endpoints/inventory/custom-fields.js +25 -17
- package/lib/endpoints/inventory/document-types.js +33 -42
- package/lib/endpoints/inventory/external-wallets.js +26 -20
- package/lib/endpoints/inventory/fees.js +19 -13
- package/lib/endpoints/inventory/filtered-trips.js +34 -8
- package/lib/endpoints/inventory/financing-costs.js +19 -14
- package/lib/endpoints/inventory/garages.js +19 -14
- package/lib/endpoints/inventory/getnet-terminals.js +20 -15
- package/lib/endpoints/inventory/gift-certificate-definitions.js +10 -5
- package/lib/endpoints/inventory/holidays.js +158 -0
- package/lib/endpoints/inventory/insurances.js +17 -13
- package/lib/endpoints/inventory/items.js +13 -9
- package/lib/endpoints/inventory/labels.js +16 -11
- package/lib/endpoints/inventory/marital-status.js +16 -11
- package/lib/endpoints/inventory/marketplace-modifiers.js +16 -11
- package/lib/endpoints/inventory/mit-terminal-settings.js +15 -10
- package/lib/endpoints/inventory/mit-terminals.js +16 -11
- package/lib/endpoints/inventory/operation-messages.js +18 -12
- package/lib/endpoints/inventory/operation-reasons.js +15 -10
- package/lib/endpoints/inventory/pay-on-accounts.js +5 -4
- package/lib/endpoints/inventory/payment-terminals.js +15 -10
- package/lib/endpoints/inventory/products.js +22 -10
- package/lib/endpoints/inventory/promos.js +27 -18
- package/lib/endpoints/inventory/station-groups.js +2 -4
- package/lib/endpoints/inventory/taxes.js +11 -2
- package/lib/endpoints/inventory/traveller-card-providers-types.js +6 -6
- package/lib/endpoints/inventory/vehicle-types.js +2 -5
- package/lib/endpoints/inventory/vehicles.js +4 -2
- package/lib/endpoints/notifications/customers.js +1 -1
- package/lib/endpoints/notifications/external-customers.js +54 -0
- package/lib/endpoints/notifications/pdfs.js +0 -3
- package/lib/endpoints/operations/accounting_items.js +7 -1
- package/lib/endpoints/operations/flexpasses.js +9 -7
- package/lib/endpoints/operations/gift-certificates.js +53 -0
- package/lib/endpoints/operations/loans.js +16 -10
- package/lib/endpoints/operations/movements.js +17 -6
- package/lib/endpoints/operations/pago-express.js +96 -0
- package/lib/endpoints/operations/parcels.js +11 -11
- package/lib/endpoints/operations/parcels_manifests.js +7 -4
- package/package.json +1 -1
- package/src/client.js +4 -0
- package/src/endpoints/inventory/banks.js +39 -21
- package/src/endpoints/inventory/change-requests.js +59 -31
- package/src/endpoints/inventory/control-classes.js +39 -20
- package/src/endpoints/inventory/countries.js +25 -10
- package/src/endpoints/inventory/custom-content.js +39 -22
- package/src/endpoints/inventory/custom-fields.js +25 -19
- package/src/endpoints/inventory/document-types.js +34 -33
- package/src/endpoints/inventory/external-wallets.js +25 -20
- package/src/endpoints/inventory/fees.js +19 -14
- package/src/endpoints/inventory/filtered-trips.js +29 -8
- package/src/endpoints/inventory/financing-costs.js +19 -14
- package/src/endpoints/inventory/garages.js +19 -14
- package/src/endpoints/inventory/getnet-terminals.js +20 -15
- package/src/endpoints/inventory/gift-certificate-definitions.js +10 -5
- package/src/endpoints/inventory/holidays.js +121 -0
- package/src/endpoints/inventory/insurances.js +17 -13
- package/src/endpoints/inventory/items.js +13 -9
- package/src/endpoints/inventory/labels.js +16 -11
- package/src/endpoints/inventory/marital-status.js +16 -11
- package/src/endpoints/inventory/marketplace-modifiers.js +16 -11
- package/src/endpoints/inventory/mit-terminal-settings.js +15 -10
- package/src/endpoints/inventory/mit-terminals.js +16 -11
- package/src/endpoints/inventory/operation-messages.js +18 -12
- package/src/endpoints/inventory/operation-reasons.js +15 -10
- package/src/endpoints/inventory/pay-on-accounts.js +5 -4
- package/src/endpoints/inventory/payment-terminals.js +15 -10
- package/src/endpoints/inventory/products.js +22 -10
- package/src/endpoints/inventory/promos.js +27 -18
- package/src/endpoints/inventory/station-groups.js +2 -4
- package/src/endpoints/inventory/taxes.js +11 -2
- package/src/endpoints/inventory/traveller-card-providers-types.js +6 -5
- package/src/endpoints/inventory/vehicle-types.js +3 -4
- package/src/endpoints/inventory/vehicles.js +4 -3
- package/src/endpoints/notifications/customers.js +1 -1
- package/src/endpoints/notifications/external-customers.js +41 -0
- package/src/endpoints/notifications/pdfs.js +0 -3
- package/src/endpoints/operations/accounting_items.js +7 -2
- package/src/endpoints/operations/flexpasses.js +9 -7
- package/src/endpoints/operations/gift-certificates.js +39 -0
- package/src/endpoints/operations/loans.js +16 -11
- package/src/endpoints/operations/movements.js +17 -6
- package/src/endpoints/operations/pago-express.js +73 -0
- package/src/endpoints/operations/parcels.js +11 -11
- package/src/endpoints/operations/parcels_manifests.js +7 -5
- package/test/endpoints/inventory/banks.test.js +8 -10
- package/test/endpoints/inventory/filtered-trips.test.js +6 -0
- package/test/endpoints/inventory/holidays.test.js +52 -0
- package/test/endpoints/inventory/traveller-card-providers-types.test.js +3 -2
- package/test/endpoints/notifications/external-customers.test.js +30 -0
- package/test/endpoints/operations/gift_certificates.test.js +37 -0
- package/test/endpoints/operations/operations.test.js +30 -0
|
@@ -40,7 +40,9 @@ function productsFactory({client, internalAuthTokenProvider}) {
|
|
|
40
40
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
41
41
|
* @param {ProductsListQuery} [opts.query] - Query params
|
|
42
42
|
* @param {Object} [opts.headers] - Optional headers
|
|
43
|
-
* @returns {Promise<import("axios").AxiosResponse>}
|
|
43
|
+
* @returns {Promise<import("axios").AxiosResponse<{ products: Array<object> }>>}
|
|
44
|
+
* Resolves with list of products; response.data has Products shape.
|
|
45
|
+
* @throws When the request fails (400 invalid channels, 401 unauthorized, 500). ErrorResponse body.
|
|
44
46
|
*/
|
|
45
47
|
function all({token, query = {}, headers}) {
|
|
46
48
|
return client({
|
|
@@ -58,7 +60,9 @@ function productsFactory({client, internalAuthTokenProvider}) {
|
|
|
58
60
|
* @param {string} opts.productId - Product id
|
|
59
61
|
* @param {ProductGetQuery} [opts.query] - Query params (providerIds, channels, enabled)
|
|
60
62
|
* @param {Object} [opts.headers] - Optional headers
|
|
61
|
-
* @returns {Promise<import("axios").AxiosResponse
|
|
63
|
+
* @returns {Promise<import("axios").AxiosResponse<{ product: object }>>}
|
|
64
|
+
* Resolves with single product; response.data.product is the Product.
|
|
65
|
+
* @throws When the request fails (400/401/404/500). Body: INVALID_PRODUCTID, WRONG_DATA, PRODUCT_NOTFOUND.
|
|
62
66
|
*/
|
|
63
67
|
function get({productId, token, jwtToken, query = {}, headers}) {
|
|
64
68
|
return client({
|
|
@@ -69,13 +73,16 @@ function productsFactory({client, internalAuthTokenProvider}) {
|
|
|
69
73
|
}
|
|
70
74
|
|
|
71
75
|
/**
|
|
72
|
-
* POST /products - create product.
|
|
76
|
+
* POST /products - create product. No query params. Requires BETTEREZ_APP JWT or API key.
|
|
73
77
|
* @param {Object} opts
|
|
74
78
|
* @param {string} [opts.token] - API key
|
|
75
79
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
76
|
-
* @param {Object} opts.data - Product payload
|
|
80
|
+
* @param {Object} opts.data - Product payload (PostedProduct); must not include _id.
|
|
77
81
|
* @param {Object} [opts.headers] - Optional headers
|
|
78
|
-
* @returns {Promise<import("axios").AxiosResponse
|
|
82
|
+
* @returns {Promise<import("axios").AxiosResponse<{ product: object }>>}
|
|
83
|
+
* Resolves with the created product.
|
|
84
|
+
* @throws When the request fails (400/401/500). Body: DUPLICATE_PRODUCT, CANNOT_CREATE_PRODUCT_WITH_ID,
|
|
85
|
+
* INVALID_PAYMENT_METHODS, INVALID_PARENT_PRODUCT_ID, INVALID_JOURNEY_RESTRICTIONS, INVALID_PRODUCT_NAME, etc.
|
|
79
86
|
*/
|
|
80
87
|
function create({data, token, jwtToken, headers}) {
|
|
81
88
|
return client({
|
|
@@ -87,14 +94,17 @@ function productsFactory({client, internalAuthTokenProvider}) {
|
|
|
87
94
|
}
|
|
88
95
|
|
|
89
96
|
/**
|
|
90
|
-
* PUT /products/:productId - update product.
|
|
97
|
+
* PUT /products/:productId - update product. No query params. Requires BETTEREZ_APP JWT or API key.
|
|
91
98
|
* @param {Object} opts
|
|
92
99
|
* @param {string} [opts.token] - API key
|
|
93
100
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
94
101
|
* @param {string} opts.productId - Product id
|
|
95
|
-
* @param {Object} opts.data - Product payload
|
|
102
|
+
* @param {Object} opts.data - Product payload (PostedProduct).
|
|
96
103
|
* @param {Object} [opts.headers] - Optional headers
|
|
97
|
-
* @returns {Promise<import("axios").AxiosResponse
|
|
104
|
+
* @returns {Promise<import("axios").AxiosResponse<{ product: object }>>}
|
|
105
|
+
* Resolves with the updated product. Emits product.updated webhook.
|
|
106
|
+
* @throws When the request fails (400/401/404/500). Body: NOT_FOUND, INVALID_PAYMENT_METHODS,
|
|
107
|
+
* CANNOT_SET_PARENT_AS_CHILD, INVALID_JOURNEY_RESTRICTIONS, INVALID_PRODUCT_NAME, etc.
|
|
98
108
|
*/
|
|
99
109
|
function update({productId, data, token, jwtToken, headers}) {
|
|
100
110
|
return client({
|
|
@@ -114,7 +124,8 @@ function productsFactory({client, internalAuthTokenProvider}) {
|
|
|
114
124
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
115
125
|
* @param {string} opts.domain - Domain
|
|
116
126
|
* @param {Object} [opts.headers] - Optional headers
|
|
117
|
-
* @returns {Promise<import("axios").AxiosResponse>}
|
|
127
|
+
* @returns {Promise<import("axios").AxiosResponse>} Resolves on success. May emit product.updated.
|
|
128
|
+
* @throws When the request fails (401, 404, 500).
|
|
118
129
|
*/
|
|
119
130
|
remove: ({token, jwtToken, domain, headers}) => {
|
|
120
131
|
return client({
|
|
@@ -133,7 +144,8 @@ function productsFactory({client, internalAuthTokenProvider}) {
|
|
|
133
144
|
* @param {string} [opts.token] - API key
|
|
134
145
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
135
146
|
* @param {Object} [opts.headers] - Optional headers
|
|
136
|
-
* @returns {Promise<import("axios").AxiosResponse>}
|
|
147
|
+
* @returns {Promise<import("axios").AxiosResponse>} Resolves with list of product families.
|
|
148
|
+
* @throws When the request fails (401, 500).
|
|
137
149
|
*/
|
|
138
150
|
all: ({token, query = {}, headers}) => {
|
|
139
151
|
return client({
|
|
@@ -40,7 +40,9 @@ function promosFactory({client, internalAuthTokenProvider}) {
|
|
|
40
40
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
41
41
|
* @param {PromosListQuery} [opts.query] - Query params
|
|
42
42
|
* @param {Object} [opts.headers] - Optional headers
|
|
43
|
-
* @returns {Promise<import("axios").AxiosResponse
|
|
43
|
+
* @returns {Promise<import("axios").AxiosResponse<{ promos: Array<object>, total: number }>>}
|
|
44
|
+
* Resolves with paginated promos; response.data has Promos shape.
|
|
45
|
+
* @throws When the request fails (400/401/404/500). Body: WRONG_DATA, PROMO_NOT_FOUND.
|
|
44
46
|
*/
|
|
45
47
|
function all({token, query = {}, headers}) {
|
|
46
48
|
return client.get("/promos", {
|
|
@@ -66,13 +68,15 @@ function promosFactory({client, internalAuthTokenProvider}) {
|
|
|
66
68
|
}
|
|
67
69
|
|
|
68
70
|
/**
|
|
69
|
-
* POST /promos - create promo.
|
|
71
|
+
* POST /promos - create promo. No query params. Requires BETTEREZ_APP JWT or API key. Emits promo.created.
|
|
70
72
|
* @param {Object} opts
|
|
71
73
|
* @param {string} [opts.token] - API key
|
|
72
74
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
73
|
-
* @param {Object} opts.promo - Promo payload
|
|
75
|
+
* @param {Object} opts.promo - Promo payload (PromoUpdateRequest); must not include _id.
|
|
74
76
|
* @param {Object} [opts.headers] - Optional headers
|
|
75
|
-
* @returns {Promise<import("axios").AxiosResponse
|
|
77
|
+
* @returns {Promise<import("axios").AxiosResponse<object>>} Resolves with created Promo.
|
|
78
|
+
* @throws When the request fails (400/401/500). Body: WRONG_DATA, INTERNALID_USED,
|
|
79
|
+
* CANNOT_CREATE_PROMO_WITH_ID, INVALID_PAYMENT_METHOD_TYPE, etc.
|
|
76
80
|
*/
|
|
77
81
|
function create({jwtToken, promo, token, headers}) {
|
|
78
82
|
return client({
|
|
@@ -84,13 +88,14 @@ function promosFactory({client, internalAuthTokenProvider}) {
|
|
|
84
88
|
}
|
|
85
89
|
|
|
86
90
|
/**
|
|
87
|
-
* DELETE /promos/:promoId -
|
|
91
|
+
* DELETE /promos/:promoId - disable promo (soft delete). No query params. Requires BETTEREZ_APP. Emits promo.deleted.
|
|
88
92
|
* @param {Object} opts
|
|
89
93
|
* @param {string} [opts.token] - API key
|
|
90
94
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
91
95
|
* @param {string} opts.promoId - Promo id
|
|
92
96
|
* @param {Object} [opts.headers] - Optional headers
|
|
93
|
-
* @returns {Promise<import("axios").AxiosResponse>}
|
|
97
|
+
* @returns {Promise<import("axios").AxiosResponse>} Resolves with disabled promo.
|
|
98
|
+
* @throws When the request fails (400/401/404/500). Body: WRONG_DATA, INVALID_PROMO_ID, PROMO_NOT_FOUND.
|
|
94
99
|
*/
|
|
95
100
|
function remove({jwtToken, promoId, token, headers}) {
|
|
96
101
|
return client({
|
|
@@ -101,14 +106,15 @@ function promosFactory({client, internalAuthTokenProvider}) {
|
|
|
101
106
|
}
|
|
102
107
|
|
|
103
108
|
/**
|
|
104
|
-
* PATCH /promos/:promoId - update promo.
|
|
109
|
+
* PATCH /promos/:promoId - update promo (partial). No query params. Requires BETTEREZ_APP. Emits promo.updated.
|
|
105
110
|
* @param {Object} opts
|
|
106
111
|
* @param {string} [opts.token] - API key
|
|
107
112
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
108
113
|
* @param {string} opts.promoId - Promo id
|
|
109
|
-
* @param {Object} opts.update -
|
|
114
|
+
* @param {Object} opts.update - Partial update (PromoUpdateRequest).
|
|
110
115
|
* @param {Object} [opts.headers] - Optional headers
|
|
111
|
-
* @returns {Promise<import("axios").AxiosResponse
|
|
116
|
+
* @returns {Promise<import("axios").AxiosResponse<object>>} Resolves with updated Promo.
|
|
117
|
+
* @throws When the request fails (400/401/404/500). Body: WRONG_DATA, INTERNALID_USED, PROMO_NOT_FOUND, etc.
|
|
112
118
|
*/
|
|
113
119
|
// eslint-disable-next-line no-shadow
|
|
114
120
|
function update({jwtToken, token, promoId, update, headers}) {
|
|
@@ -121,14 +127,15 @@ function promosFactory({client, internalAuthTokenProvider}) {
|
|
|
121
127
|
}
|
|
122
128
|
|
|
123
129
|
/**
|
|
124
|
-
* PATCH /promo/:promoId -
|
|
130
|
+
* PATCH /promo/:promoId - update rule availability (add/subtract). No query params. Emits promo.updated.
|
|
125
131
|
* @param {Object} opts
|
|
126
132
|
* @param {string} [opts.token] - API key
|
|
127
133
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
128
134
|
* @param {string} opts.promoId - Promo id
|
|
129
|
-
* @param {Object} opts.operations -
|
|
135
|
+
* @param {Object} opts.operations - Array of PromoUpdateOperation (op, path, value).
|
|
130
136
|
* @param {Object} [opts.headers] - Optional headers
|
|
131
|
-
* @returns {Promise<import("axios").AxiosResponse
|
|
137
|
+
* @returns {Promise<import("axios").AxiosResponse<object>>} Resolves with PatchedPromos.
|
|
138
|
+
* @throws When the request fails (400/401/404/500).
|
|
132
139
|
*/
|
|
133
140
|
function patch({jwtToken, token, promoId, operations, headers}) {
|
|
134
141
|
return client({
|
|
@@ -140,14 +147,15 @@ function promosFactory({client, internalAuthTokenProvider}) {
|
|
|
140
147
|
}
|
|
141
148
|
|
|
142
149
|
/**
|
|
143
|
-
* POST /promos/:promoId/rules - add promo rule.
|
|
150
|
+
* POST /promos/:promoId/rules - add promo rule. No query params. Requires BETTEREZ_APP. May emit promo.updated.
|
|
144
151
|
* @param {Object} opts
|
|
145
152
|
* @param {string} [opts.token] - API key
|
|
146
153
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
147
154
|
* @param {string} opts.promoId - Promo id
|
|
148
|
-
* @param {Object} opts.rule - Rule payload
|
|
155
|
+
* @param {Object} opts.rule - Rule payload (PromoRule).
|
|
149
156
|
* @param {Object} [opts.headers] - Optional headers
|
|
150
|
-
* @returns {Promise<import("axios").AxiosResponse
|
|
157
|
+
* @returns {Promise<import("axios").AxiosResponse<object>>} Resolves with Promo including new rule.
|
|
158
|
+
* @throws When the request fails (400/401/404/500). Body: WRONG_DATA, INVALID_PRODUCT_ID, INVALID_FARE_ID, etc.
|
|
151
159
|
*/
|
|
152
160
|
function addRule({jwtToken, token, promoId, rule, headers}) {
|
|
153
161
|
return client({
|
|
@@ -159,15 +167,16 @@ function promosFactory({client, internalAuthTokenProvider}) {
|
|
|
159
167
|
}
|
|
160
168
|
|
|
161
169
|
/**
|
|
162
|
-
* PUT /promos/:promoId/rules/:ruleId - update promo rule.
|
|
170
|
+
* PUT /promos/:promoId/rules/:ruleId - update promo rule. No query params. Requires BETTEREZ_APP. Emits promo.updated.
|
|
163
171
|
* @param {Object} opts
|
|
164
172
|
* @param {string} [opts.token] - API key
|
|
165
173
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
166
174
|
* @param {string} opts.promoId - Promo id
|
|
167
175
|
* @param {string} opts.ruleId - Rule id
|
|
168
|
-
* @param {Object} opts.rule -
|
|
176
|
+
* @param {Object} opts.rule - Full rule payload (PromoRule).
|
|
169
177
|
* @param {Object} [opts.headers] - Optional headers
|
|
170
|
-
* @returns {Promise<import("axios").AxiosResponse
|
|
178
|
+
* @returns {Promise<import("axios").AxiosResponse<object>>} Resolves with updated Promo.
|
|
179
|
+
* @throws When the request fails (400/401/404/500). Body: WRONG_DATA, INVALID_PRODUCT_ID, INVALID_FARE_ID, etc.
|
|
171
180
|
*/
|
|
172
181
|
function updateRule({jwtToken, token, promoId, ruleId, rule, headers}) {
|
|
173
182
|
return client({
|
|
@@ -20,14 +20,12 @@ function stationGroupsFactory({client, internalAuthTokenProvider}) {
|
|
|
20
20
|
* GET /station-groups - list station groups.
|
|
21
21
|
* @param {Object} opts
|
|
22
22
|
* @param {string} [opts.token] - API key
|
|
23
|
-
* @param {
|
|
24
|
-
* @param {StationGroupsListQuery} [opts.query] - Query params
|
|
23
|
+
* @param {StationGroupsListQuery} [opts.query] - Query params (e.g. providerIds)
|
|
25
24
|
* @param {Object} [opts.headers] - Optional headers
|
|
26
25
|
* @returns {Promise<import("axios").AxiosResponse>}
|
|
27
26
|
*/
|
|
28
27
|
function all({token, query = {}, headers}) {
|
|
29
|
-
return client({
|
|
30
|
-
url: "/station-groups",
|
|
28
|
+
return client.get("/station-groups", {
|
|
31
29
|
params: query,
|
|
32
30
|
headers: authorizationHeaders({token, internalAuthTokenProvider, headers})
|
|
33
31
|
});
|
|
@@ -6,6 +6,15 @@ const {authorizationHeaders} = require("../endpoints_helpers.js");
|
|
|
6
6
|
* @property {string} [providerIds] - The id of the providers to get taxes for
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Query params for GET /taxes/exceptions (btrz-api-inventory). See get-tax-exceptions-handler getSpec().
|
|
11
|
+
* @typedef {Object} TaxExceptionsListQuery
|
|
12
|
+
* @property {string} [originId] - Origin station id (24 hex characters)
|
|
13
|
+
* @property {string} [destinationId] - Destination station id (24 hex characters)
|
|
14
|
+
* @property {number} [page] - Page to return
|
|
15
|
+
* @property {number} [recordsPerPage] - Records per page
|
|
16
|
+
*/
|
|
17
|
+
|
|
9
18
|
/**
|
|
10
19
|
* Factory for taxes API (btrz-api-inventory).
|
|
11
20
|
* @param {Object} deps
|
|
@@ -99,7 +108,7 @@ function taxesFactory({client, internalAuthTokenProvider}) {
|
|
|
99
108
|
url: "/taxes/exceptions",
|
|
100
109
|
method: "post",
|
|
101
110
|
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
|
|
102
|
-
data: taxException
|
|
111
|
+
data: {taxException}
|
|
103
112
|
});
|
|
104
113
|
},
|
|
105
114
|
/**
|
|
@@ -117,7 +126,7 @@ function taxesFactory({client, internalAuthTokenProvider}) {
|
|
|
117
126
|
url: `/taxes/exceptions/${taxExceptionId}`,
|
|
118
127
|
method: "put",
|
|
119
128
|
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
|
|
120
|
-
data: taxException
|
|
129
|
+
data: {taxException}
|
|
121
130
|
});
|
|
122
131
|
},
|
|
123
132
|
/**
|
|
@@ -2,6 +2,7 @@ const {authorizationHeaders} = require("./../endpoints_helpers.js");
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Factory for traveller-card-providers types API (btrz-api-inventory).
|
|
5
|
+
* Returns the list of supported traveller card provider types (e.g. "custom", "caa").
|
|
5
6
|
* @param {Object} deps
|
|
6
7
|
* @param {import("axios").AxiosInstance} deps.client
|
|
7
8
|
* @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
|
|
@@ -9,16 +10,16 @@ const {authorizationHeaders} = require("./../endpoints_helpers.js");
|
|
|
9
10
|
*/
|
|
10
11
|
function travellerCardProvidersTypesFactory({client, internalAuthTokenProvider}) {
|
|
11
12
|
/**
|
|
12
|
-
* GET /traveller-card-providers/types - list traveller card provider types.
|
|
13
|
+
* GET /traveller-card-providers/types - list traveller card provider types (e.g. "custom", "caa"). No query or path params.
|
|
13
14
|
* @param {Object} opts
|
|
14
15
|
* @param {string} [opts.token] - API key
|
|
16
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
15
17
|
* @param {Object} [opts.headers] - Optional headers
|
|
16
|
-
* @returns {Promise<import("axios").AxiosResponse>}
|
|
18
|
+
* @returns {Promise<import("axios").AxiosResponse<{ travellerCardProviderTypes: Array<{ type: string, properties: Object }> }>>}
|
|
17
19
|
*/
|
|
18
|
-
function all({token,
|
|
20
|
+
function all({token, jwtToken, headers}) {
|
|
19
21
|
return client.get("/traveller-card-providers/types", {
|
|
20
|
-
|
|
21
|
-
headers: authorizationHeaders({token, internalAuthTokenProvider, headers})
|
|
22
|
+
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
|
|
22
23
|
});
|
|
23
24
|
}
|
|
24
25
|
|
|
@@ -11,16 +11,15 @@ const {
|
|
|
11
11
|
*/
|
|
12
12
|
function vehicleTypesFactory({client, internalAuthTokenProvider}) {
|
|
13
13
|
/**
|
|
14
|
-
* GET /vehicle-types - list vehicle types (e.g. Bus, Shuttle, Van, Train, Ferry, Tram).
|
|
14
|
+
* GET /vehicle-types - list vehicle types (e.g. Bus, Shuttle, Van, Train, Ferry, Tram). No query or path params.
|
|
15
15
|
* @param {Object} opts
|
|
16
16
|
* @param {string} [opts.token] - API key
|
|
17
17
|
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
18
18
|
* @param {Object} [opts.headers] - Optional headers
|
|
19
|
-
* @returns {Promise<import("axios").AxiosResponse>}
|
|
19
|
+
* @returns {Promise<import("axios").AxiosResponse<{ vehicleTypes: Array<{ _id: string, name: string }> }>>}
|
|
20
20
|
*/
|
|
21
|
-
function all({token, jwtToken,
|
|
21
|
+
function all({token, jwtToken, headers}) {
|
|
22
22
|
return client.get("/vehicle-types", {
|
|
23
|
-
params: query,
|
|
24
23
|
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
|
|
25
24
|
});
|
|
26
25
|
}
|
|
@@ -41,12 +41,13 @@ function vehiclesFactory({client, internalAuthTokenProvider}) {
|
|
|
41
41
|
*/
|
|
42
42
|
function all({
|
|
43
43
|
token,
|
|
44
|
+
jwtToken,
|
|
44
45
|
query = {},
|
|
45
46
|
headers
|
|
46
47
|
}) {
|
|
47
48
|
return client.get("/vehicles", {
|
|
48
49
|
params: query,
|
|
49
|
-
headers: authorizationHeaders({token, internalAuthTokenProvider, headers})
|
|
50
|
+
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
|
|
50
51
|
});
|
|
51
52
|
}
|
|
52
53
|
|
|
@@ -59,9 +60,9 @@ function vehiclesFactory({client, internalAuthTokenProvider}) {
|
|
|
59
60
|
* @param {Object} [opts.headers] - Optional headers
|
|
60
61
|
* @returns {Promise<import("axios").AxiosResponse>}
|
|
61
62
|
*/
|
|
62
|
-
function get({vehicleId, token, headers}) {
|
|
63
|
+
function get({vehicleId, token, jwtToken, headers}) {
|
|
63
64
|
return client.get(`/vehicles/${vehicleId}`, {
|
|
64
|
-
headers: authorizationHeaders({token, internalAuthTokenProvider, headers})
|
|
65
|
+
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
|
|
65
66
|
});
|
|
66
67
|
}
|
|
67
68
|
|
|
@@ -62,7 +62,7 @@ function customersFactory({
|
|
|
62
62
|
* @param {Object} opts
|
|
63
63
|
* @param {string} [opts.token] - API key
|
|
64
64
|
* @param {CustomersActivationPostQuery} [opts.query] - Query params (providerId required)
|
|
65
|
-
* @param {Object}
|
|
65
|
+
* @param {Object} opts.data - Body: CustomerForActivation (firstName, lastName, email; optional activateCustomerEmailLoginToken)
|
|
66
66
|
* @param {Object} [opts.headers] - Optional headers
|
|
67
67
|
* @returns {Promise<import("axios").AxiosResponse>}
|
|
68
68
|
*/
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const {authorizationHeaders} = require("../endpoints_helpers.js");
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Request body for POST /external-customers/ado/registration (btrz-api-notifications).
|
|
5
|
+
* @typedef {Object} SaldoMaxRegistrationRequest
|
|
6
|
+
* @property {string} email - User email to register in Saldo Max (verification code is sent to this email).
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Factory for external-customers API (btrz-api-notifications). Saldo Max (ADO) verification-code registration.
|
|
11
|
+
* @param {Object} deps
|
|
12
|
+
* @param {import("axios").AxiosInstance} deps.client
|
|
13
|
+
* @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
|
|
14
|
+
* @returns {{ requestSaldoMaxVerificationCode: function }}
|
|
15
|
+
*/
|
|
16
|
+
function externalCustomersFactory({client, internalAuthTokenProvider}) {
|
|
17
|
+
/**
|
|
18
|
+
* POST /external-customers/ado/registration – Request a Saldo Max (ADO) verification code for the given email.
|
|
19
|
+
* Requires BETTEREZ_APP JWT. Forwards to Saldo Max; sends verification code to the email.
|
|
20
|
+
* @param {Object} opts
|
|
21
|
+
* @param {string} [opts.token] - API key
|
|
22
|
+
* @param {string} [opts.jwtToken] - JWT (BETTEREZ_APP audience)
|
|
23
|
+
* @param {SaldoMaxRegistrationRequest} opts.data - Body: { email } (or { body: { email } })
|
|
24
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
25
|
+
* @returns {Promise<import("axios").AxiosResponse<{ code: string, message: string }>>}
|
|
26
|
+
*/
|
|
27
|
+
function requestSaldoMaxVerificationCode({data, token, jwtToken, headers}) {
|
|
28
|
+
return client({
|
|
29
|
+
url: "/external-customers/ado/registration",
|
|
30
|
+
method: "post",
|
|
31
|
+
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
|
|
32
|
+
data
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
requestSaldoMaxVerificationCode
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
module.exports = externalCustomersFactory;
|
|
@@ -26,12 +26,14 @@ function accountingItemsFactory({
|
|
|
26
26
|
* GET /accounting-items - list accounting items.
|
|
27
27
|
* @param {Object} opts
|
|
28
28
|
* @param {string} [opts.token] - API key
|
|
29
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
29
30
|
* @param {AccountingItemsListQuery} [opts.query] - Query params (all optional)
|
|
30
31
|
* @param {Object} [opts.headers] - Optional headers
|
|
31
32
|
* @returns {Promise<import("axios").AxiosResponse>}
|
|
32
33
|
*/
|
|
33
34
|
function all({
|
|
34
35
|
token,
|
|
36
|
+
jwtToken,
|
|
35
37
|
query = {},
|
|
36
38
|
headers
|
|
37
39
|
}) {
|
|
@@ -39,6 +41,7 @@ function accountingItemsFactory({
|
|
|
39
41
|
params: query,
|
|
40
42
|
headers: authorizationHeaders({
|
|
41
43
|
token,
|
|
44
|
+
jwtToken,
|
|
42
45
|
internalAuthTokenProvider,
|
|
43
46
|
headers
|
|
44
47
|
})
|
|
@@ -49,16 +52,18 @@ function accountingItemsFactory({
|
|
|
49
52
|
* GET /accounting-items/:accountingItemId - get accounting item by id. API does not accept query params.
|
|
50
53
|
* @param {Object} opts
|
|
51
54
|
* @param {string} [opts.token] - API key
|
|
52
|
-
* @param {string} opts.
|
|
55
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth symbol
|
|
56
|
+
* @param {string} opts.accountingItemId - Accounting item id (ObjectId format)
|
|
53
57
|
* @param {Object} [opts.headers] - Optional headers
|
|
54
58
|
* @returns {Promise<import("axios").AxiosResponse>}
|
|
55
59
|
*/
|
|
56
60
|
function get({
|
|
57
|
-
accountingItemId, token, headers
|
|
61
|
+
accountingItemId, token, jwtToken, headers
|
|
58
62
|
}) {
|
|
59
63
|
return client.get(`/accounting-items/${accountingItemId}`, {
|
|
60
64
|
headers: authorizationHeaders({
|
|
61
65
|
token,
|
|
66
|
+
jwtToken,
|
|
62
67
|
internalAuthTokenProvider,
|
|
63
68
|
headers
|
|
64
69
|
})
|
|
@@ -9,14 +9,16 @@ const {authorizationHeaders} = require("./../endpoints_helpers.js");
|
|
|
9
9
|
*/
|
|
10
10
|
function flexpassesFactory({client, internalAuthTokenProvider}) {
|
|
11
11
|
/**
|
|
12
|
-
* DELETE /flexpasses/:flexpassId/scannings/:tripId -
|
|
12
|
+
* DELETE /flexpasses/:flexpassId/scannings/:tripId - deletes one flexpass scanning for the given trip ID.
|
|
13
|
+
* Removes the scan matching tripId from the flexpass's scans; if multiple scans exist for the same tripId, only one is removed.
|
|
14
|
+
* Requires operations API base URL (e.g. .../operations). No query parameters.
|
|
13
15
|
* @param {Object} opts
|
|
14
|
-
* @param {string} [opts.token] - API key
|
|
15
|
-
* @param {string} [opts.jwtToken] - JWT or internal auth
|
|
16
|
-
* @param {string} opts.flexpassId - Flexpass
|
|
17
|
-
* @param {string} opts.tripId - Trip
|
|
18
|
-
* @param {Object} [opts.headers] - Optional headers
|
|
19
|
-
* @returns {Promise<import("axios").AxiosResponse
|
|
16
|
+
* @param {string} [opts.token] - API key (X-API-KEY)
|
|
17
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth (Authorization Bearer)
|
|
18
|
+
* @param {string} opts.flexpassId - Flexpass document ID (Mongo ObjectId string)
|
|
19
|
+
* @param {string} opts.tripId - Trip identifier of the scan to remove (e.g. routeId_scheduleName_date)
|
|
20
|
+
* @param {Object} [opts.headers] - Optional request headers
|
|
21
|
+
* @returns {Promise<import("axios").AxiosResponse<{ flexpassDeleted?: string }>>}
|
|
20
22
|
*/
|
|
21
23
|
function deleteScanBytripId({jwtToken, token, flexpassId, tripId, headers}) {
|
|
22
24
|
return client({
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
const {authorizationHeaders} = require("../endpoints_helpers.js");
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Factory for gift-certificates API (btrz-api-operations).
|
|
5
|
+
* @param {Object} deps
|
|
6
|
+
* @param {import("axios").AxiosInstance} deps.client
|
|
7
|
+
* @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
|
|
8
|
+
* @returns {Object} gift-certificates API methods
|
|
9
|
+
*/
|
|
10
|
+
function giftCertificatesFactory({client, internalAuthTokenProvider}) {
|
|
11
|
+
/**
|
|
12
|
+
* GET /gift-certificates - list paid gift certificates for a customer. Paginated; requires customer JWT when used with JwtAuth.
|
|
13
|
+
* @param {Object} opts
|
|
14
|
+
* @param {string} [opts.token] - API key (X-API-KEY)
|
|
15
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth (Authorization Bearer); when using customer JWT, must match customer param
|
|
16
|
+
* @param {string} opts.customer - Customer number to filter by (required)
|
|
17
|
+
* @param {number} [opts.page] - 1-based page number; page size is 20
|
|
18
|
+
* @param {Object} [opts.headers] - Optional request headers
|
|
19
|
+
* @returns {Promise<import("axios").AxiosResponse<{ giftCertificates: Array<object>, count: number, next?: string, previous?: string }>>}
|
|
20
|
+
*/
|
|
21
|
+
function list({jwtToken, token, customer, page, headers}) {
|
|
22
|
+
const params = {customer};
|
|
23
|
+
if (page != null) {
|
|
24
|
+
params.page = page;
|
|
25
|
+
}
|
|
26
|
+
return client({
|
|
27
|
+
url: "/gift-certificates",
|
|
28
|
+
method: "get",
|
|
29
|
+
params,
|
|
30
|
+
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
list
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
module.exports = giftCertificatesFactory;
|
|
@@ -24,15 +24,17 @@ function loansFactory({
|
|
|
24
24
|
client, internalAuthTokenProvider
|
|
25
25
|
}) {
|
|
26
26
|
/**
|
|
27
|
-
* GET /loans - list loans.
|
|
27
|
+
* GET /loans - list loans for the account or provider. Paginated (20 per page). Requires operations API base URL.
|
|
28
28
|
* @param {Object} opts
|
|
29
|
-
* @param {string} [opts.token] - API key
|
|
30
|
-
* @param {
|
|
31
|
-
* @param {
|
|
32
|
-
* @
|
|
29
|
+
* @param {string} [opts.token] - API key (X-API-KEY)
|
|
30
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth (Authorization Bearer)
|
|
31
|
+
* @param {LoansListQuery} [opts.query] - Query params (all optional): page, shiftId, type, trxId, status, providerId
|
|
32
|
+
* @param {Object} [opts.headers] - Optional request headers
|
|
33
|
+
* @returns {Promise<import("axios").AxiosResponse<{ loans: Array<object>, count: number, next?: string, previous?: string }>>}
|
|
33
34
|
*/
|
|
34
35
|
function all({
|
|
35
36
|
token,
|
|
37
|
+
jwtToken,
|
|
36
38
|
query = {},
|
|
37
39
|
headers
|
|
38
40
|
}) {
|
|
@@ -40,6 +42,7 @@ function loansFactory({
|
|
|
40
42
|
params: query,
|
|
41
43
|
headers: authorizationHeaders({
|
|
42
44
|
token,
|
|
45
|
+
jwtToken,
|
|
43
46
|
internalAuthTokenProvider,
|
|
44
47
|
headers
|
|
45
48
|
})
|
|
@@ -47,19 +50,21 @@ function loansFactory({
|
|
|
47
50
|
}
|
|
48
51
|
|
|
49
52
|
/**
|
|
50
|
-
* GET /loans/:loanId - get loan by
|
|
53
|
+
* GET /loans/:loanId - get a single loan by ID. Requires operations API base URL.
|
|
51
54
|
* @param {Object} opts
|
|
52
|
-
* @param {string} [opts.token] - API key
|
|
53
|
-
* @param {string} opts.
|
|
54
|
-
* @param {
|
|
55
|
-
* @
|
|
55
|
+
* @param {string} [opts.token] - API key (X-API-KEY)
|
|
56
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth (Authorization Bearer)
|
|
57
|
+
* @param {string} opts.loanId - Loan document ID (24 hex characters)
|
|
58
|
+
* @param {Object} [opts.headers] - Optional request headers
|
|
59
|
+
* @returns {Promise<import("axios").AxiosResponse<{ loan: object }>>}
|
|
56
60
|
*/
|
|
57
61
|
function get({
|
|
58
|
-
loanId, token, headers
|
|
62
|
+
loanId, token, jwtToken, headers
|
|
59
63
|
}) {
|
|
60
64
|
return client.get(`/loans/${loanId}`, {
|
|
61
65
|
headers: authorizationHeaders({
|
|
62
66
|
token,
|
|
67
|
+
jwtToken,
|
|
63
68
|
internalAuthTokenProvider,
|
|
64
69
|
headers
|
|
65
70
|
})
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
const {authorizationHeaders} = require("./../endpoints_helpers.js");
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Request body for POST /movements (btrz-api-operations). See MovementPostData in movements models.
|
|
5
|
+
* @typedef {Object} MovementPostData
|
|
6
|
+
* @property {Array<{ _id: string, section?: string, sectionName?: string, seat?: string, row?: string, seatId?: string }>} tickets - Tickets to move (same transaction if more than one). Each must have _id; optional seat fields for destination seatmap.
|
|
7
|
+
* @property {{ routeId: string, scheduleId: string, date: string }} newManifest - Destination manifest: routeId (ObjectId), scheduleId (UUID), date (YYYY-MM-DD).
|
|
8
|
+
* @property {string} channel - Channel of the movement (e.g. backoffice). Must be a valid backoffice channel.
|
|
9
|
+
* @property {boolean} [allowsDifferentTrx] - If true, allows moving tickets from different transactions.
|
|
10
|
+
* @property {boolean} [newdesign] - If true, uses new seatmap design for accommodation.
|
|
11
|
+
*/
|
|
12
|
+
|
|
3
13
|
/**
|
|
4
14
|
* Factory for movements API (btrz-api-operations).
|
|
5
15
|
* @param {Object} deps
|
|
@@ -9,13 +19,14 @@ const {authorizationHeaders} = require("./../endpoints_helpers.js");
|
|
|
9
19
|
*/
|
|
10
20
|
function movementsFactory({client, internalAuthTokenProvider}) {
|
|
11
21
|
/**
|
|
12
|
-
* POST /movements - create movement
|
|
22
|
+
* POST /movements - create a movement (move tickets to another manifest). No query params.
|
|
13
23
|
* @param {Object} opts
|
|
14
|
-
* @param {string} [opts.token] - API key
|
|
15
|
-
* @param {string} [opts.jwtToken] - JWT or internal auth
|
|
16
|
-
* @param {
|
|
17
|
-
* @param {Object} [opts.
|
|
18
|
-
* @
|
|
24
|
+
* @param {string} [opts.token] - API key (X-API-KEY)
|
|
25
|
+
* @param {string} [opts.jwtToken] - JWT or internal auth (Authorization Bearer)
|
|
26
|
+
* @param {MovementPostData} opts.movement - Request body: tickets, newManifest, channel; optional allowsDifferentTrx, newdesign
|
|
27
|
+
* @param {Object} [opts.query] - Optional query params (API accepts none)
|
|
28
|
+
* @param {Object} [opts.headers] - Optional request headers
|
|
29
|
+
* @returns {Promise<import("axios").AxiosResponse<{}>>}
|
|
19
30
|
*/
|
|
20
31
|
function create({token, jwtToken, movement, query = {}, headers}) {
|
|
21
32
|
return client({
|