btrz-api-client 9.11.0 → 9.12.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 +5 -5
- package/lib/endpoints/accounts/external-customers.js +32 -0
- package/lib/endpoints/inventory/control-classes.js +0 -2
- package/lib/endpoints/inventory/trips.js +29 -2
- package/package.json +1 -1
- package/src/endpoints/accounts/external-customers.js +21 -0
- package/src/endpoints/inventory/control-classes.js +0 -2
- package/src/endpoints/inventory/trips.js +29 -2
- package/test/endpoints/accounts/external-customers.test.js +19 -0
|
@@ -101,6 +101,37 @@ function externalCustomersFactory({
|
|
|
101
101
|
data
|
|
102
102
|
});
|
|
103
103
|
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* PUT /external-customers/ado/{externalId} – Update Saldo Max (ADO) client data (e.g. birthDate).
|
|
107
|
+
* Requires BETTEREZ_APP JWT. Maps to ADO ModificarDatosClienteMonedero.
|
|
108
|
+
* @param {Object} opts
|
|
109
|
+
* @param {string} opts.id - ADO idCustomerUnique (path externalId)
|
|
110
|
+
* @param {string} [opts.token] - API key
|
|
111
|
+
* @param {string} [opts.jwtToken] - JWT (BETTEREZ_APP audience)
|
|
112
|
+
* @param {{birthDate: string}} opts.data - Body; birthDate in DD/MM/YYYY
|
|
113
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
114
|
+
* @returns {Promise<import("axios").AxiosResponse<{ code: string, externalId: string, birthDate: string }>>}
|
|
115
|
+
*/
|
|
116
|
+
function updateSaldoMaxClientData({
|
|
117
|
+
id,
|
|
118
|
+
data,
|
|
119
|
+
token,
|
|
120
|
+
jwtToken,
|
|
121
|
+
headers
|
|
122
|
+
}) {
|
|
123
|
+
return client({
|
|
124
|
+
url: `/external-customers/ado/${encodeURIComponent(id)}`,
|
|
125
|
+
method: "put",
|
|
126
|
+
headers: authorizationHeaders({
|
|
127
|
+
token,
|
|
128
|
+
jwtToken,
|
|
129
|
+
internalAuthTokenProvider,
|
|
130
|
+
headers
|
|
131
|
+
}),
|
|
132
|
+
data
|
|
133
|
+
});
|
|
134
|
+
}
|
|
104
135
|
const saldoMax = {
|
|
105
136
|
/**
|
|
106
137
|
* GET /external-customers/ado - get SaldoMax user by email, phone or walletId.
|
|
@@ -136,6 +167,7 @@ function externalCustomersFactory({
|
|
|
136
167
|
});
|
|
137
168
|
},
|
|
138
169
|
create: registerSaldoMax,
|
|
170
|
+
update: updateSaldoMaxClientData,
|
|
139
171
|
confirmation: {
|
|
140
172
|
create: confirmSaldoMaxRegistration,
|
|
141
173
|
resend: {
|
|
@@ -18,8 +18,6 @@ const {
|
|
|
18
18
|
* @property {string} [seatClassId] - Filter by seat class ID(s), comma-separated
|
|
19
19
|
* @property {string} [operatingCompanyId] - Filter by operating company ID(s), comma-separated
|
|
20
20
|
* @property {string} [channel] - Filter by channel(s), comma-separated
|
|
21
|
-
* @property {number} [advancePurchaseFrom] - Filter by advance purchase from (hours)
|
|
22
|
-
* @property {number} [advancePurchaseTo] - Filter by advance purchase to (hours)
|
|
23
21
|
*/
|
|
24
22
|
|
|
25
23
|
/**
|
|
@@ -3,6 +3,33 @@ const {
|
|
|
3
3
|
authorizationHeaders
|
|
4
4
|
} = require("./../endpoints_helpers.js");
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {Object} MoveSegmentDemandEntry
|
|
8
|
+
* @property {string} fromId - Station ObjectId for the moved ticket origin
|
|
9
|
+
* @property {string} toId - Station ObjectId for the moved ticket destination
|
|
10
|
+
* @property {string} [fareId] - Optional fare ObjectId
|
|
11
|
+
* @property {number} [sitting] - Sitting passengers for this segment (default 0)
|
|
12
|
+
* @property {number} [standing] - Standing passengers for this segment (default 0)
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @typedef {Object} TripsSearchQuery
|
|
17
|
+
* @property {string} productId
|
|
18
|
+
* @property {string} originId
|
|
19
|
+
* @property {string} destinationId
|
|
20
|
+
* @property {string} fareIds - Format fareId:qty,fareId:qty
|
|
21
|
+
* @property {string} departureDate - YYYY-MM-DD
|
|
22
|
+
* @property {string} [returnDate] - YYYY-MM-DD
|
|
23
|
+
* @property {string} [channel]
|
|
24
|
+
* @property {string} [currency]
|
|
25
|
+
* @property {boolean|string} [isMove] - When true, includes dispatched trips and allows moveSegmentDemand
|
|
26
|
+
* @property {string} [moveSegmentDemand] - JSON stringified MoveSegmentDemandEntry[] used for IROPS/bulk-move segment-aware capacity (requires isMove=true)
|
|
27
|
+
* @property {boolean|string} [ignoreCutoffs]
|
|
28
|
+
* @property {boolean|string} [ignorePerFareCapacityLimits]
|
|
29
|
+
* @property {string} [allowedManifestStatuses]
|
|
30
|
+
* @property {boolean|string} [includeMoveToTrips]
|
|
31
|
+
*/
|
|
32
|
+
|
|
6
33
|
/**
|
|
7
34
|
* Factory for trips API (btrz-api-inventory-trips).
|
|
8
35
|
* @param {Object} deps
|
|
@@ -19,10 +46,10 @@ function tripsFactory({
|
|
|
19
46
|
* @param {Object} opts
|
|
20
47
|
* @param {string} [opts.token] - API key (X-API-KEY)
|
|
21
48
|
* @param {string} [opts.jwtToken] - JWT or internal auth (Authorization: Bearer)
|
|
22
|
-
* @param {
|
|
49
|
+
* @param {TripsSearchQuery} [opts.query] - Query params for trip search
|
|
23
50
|
* @param {Object} [opts.headers] - Optional headers
|
|
24
51
|
* @returns {Promise<import("axios").AxiosResponse<{ trips: { departures: Object[], returns: Object[] } }>>}
|
|
25
|
-
* @throws 400 INVALID_DATE, INVALID_DATE_FORMAT, INVALID_PRODUCTID, INVALID_ORIGIN, INVALID_DESTINATION, INVALID_CHANNEL, INVALID_FARE, INVALID_FAREID, INVALID_MANIFEST_STATUS, WRONG_DATA
|
|
52
|
+
* @throws 400 INVALID_DATE, INVALID_DATE_FORMAT, INVALID_PRODUCTID, INVALID_ORIGIN, INVALID_DESTINATION, INVALID_CHANNEL, INVALID_FARE, INVALID_FAREID, INVALID_MANIFEST_STATUS, INVALID_MOVE_SEGMENT_DEMAND, WRONG_DATA
|
|
26
53
|
* @throws 401 Unauthorized
|
|
27
54
|
* @throws 409 NO_HIGHER_OR_EQL_PRICE
|
|
28
55
|
* @throws 500 Internal server error
|
package/package.json
CHANGED
|
@@ -67,6 +67,26 @@ function externalCustomersFactory({client, internalAuthTokenProvider}) {
|
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
/**
|
|
71
|
+
* PUT /external-customers/ado/{externalId} – Update Saldo Max (ADO) client data (e.g. birthDate).
|
|
72
|
+
* Requires BETTEREZ_APP JWT. Maps to ADO ModificarDatosClienteMonedero.
|
|
73
|
+
* @param {Object} opts
|
|
74
|
+
* @param {string} opts.id - ADO idCustomerUnique (path externalId)
|
|
75
|
+
* @param {string} [opts.token] - API key
|
|
76
|
+
* @param {string} [opts.jwtToken] - JWT (BETTEREZ_APP audience)
|
|
77
|
+
* @param {{birthDate: string}} opts.data - Body; birthDate in DD/MM/YYYY
|
|
78
|
+
* @param {Object} [opts.headers] - Optional headers
|
|
79
|
+
* @returns {Promise<import("axios").AxiosResponse<{ code: string, externalId: string, birthDate: string }>>}
|
|
80
|
+
*/
|
|
81
|
+
function updateSaldoMaxClientData({id, data, token, jwtToken, headers}) {
|
|
82
|
+
return client({
|
|
83
|
+
url: `/external-customers/ado/${encodeURIComponent(id)}`,
|
|
84
|
+
method: "put",
|
|
85
|
+
headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
|
|
86
|
+
data
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
70
90
|
const saldoMax = {
|
|
71
91
|
/**
|
|
72
92
|
* GET /external-customers/ado - get SaldoMax user by email, phone or walletId.
|
|
@@ -92,6 +112,7 @@ function externalCustomersFactory({client, internalAuthTokenProvider}) {
|
|
|
92
112
|
});
|
|
93
113
|
},
|
|
94
114
|
create: registerSaldoMax,
|
|
115
|
+
update: updateSaldoMaxClientData,
|
|
95
116
|
confirmation: {
|
|
96
117
|
create: confirmSaldoMaxRegistration,
|
|
97
118
|
resend: {
|
|
@@ -18,8 +18,6 @@ const {
|
|
|
18
18
|
* @property {string} [seatClassId] - Filter by seat class ID(s), comma-separated
|
|
19
19
|
* @property {string} [operatingCompanyId] - Filter by operating company ID(s), comma-separated
|
|
20
20
|
* @property {string} [channel] - Filter by channel(s), comma-separated
|
|
21
|
-
* @property {number} [advancePurchaseFrom] - Filter by advance purchase from (hours)
|
|
22
|
-
* @property {number} [advancePurchaseTo] - Filter by advance purchase to (hours)
|
|
23
21
|
*/
|
|
24
22
|
|
|
25
23
|
/**
|
|
@@ -1,6 +1,33 @@
|
|
|
1
1
|
/* eslint-disable max-len */
|
|
2
2
|
const {authorizationHeaders} = require("./../endpoints_helpers.js");
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {Object} MoveSegmentDemandEntry
|
|
6
|
+
* @property {string} fromId - Station ObjectId for the moved ticket origin
|
|
7
|
+
* @property {string} toId - Station ObjectId for the moved ticket destination
|
|
8
|
+
* @property {string} [fareId] - Optional fare ObjectId
|
|
9
|
+
* @property {number} [sitting] - Sitting passengers for this segment (default 0)
|
|
10
|
+
* @property {number} [standing] - Standing passengers for this segment (default 0)
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @typedef {Object} TripsSearchQuery
|
|
15
|
+
* @property {string} productId
|
|
16
|
+
* @property {string} originId
|
|
17
|
+
* @property {string} destinationId
|
|
18
|
+
* @property {string} fareIds - Format fareId:qty,fareId:qty
|
|
19
|
+
* @property {string} departureDate - YYYY-MM-DD
|
|
20
|
+
* @property {string} [returnDate] - YYYY-MM-DD
|
|
21
|
+
* @property {string} [channel]
|
|
22
|
+
* @property {string} [currency]
|
|
23
|
+
* @property {boolean|string} [isMove] - When true, includes dispatched trips and allows moveSegmentDemand
|
|
24
|
+
* @property {string} [moveSegmentDemand] - JSON stringified MoveSegmentDemandEntry[] used for IROPS/bulk-move segment-aware capacity (requires isMove=true)
|
|
25
|
+
* @property {boolean|string} [ignoreCutoffs]
|
|
26
|
+
* @property {boolean|string} [ignorePerFareCapacityLimits]
|
|
27
|
+
* @property {string} [allowedManifestStatuses]
|
|
28
|
+
* @property {boolean|string} [includeMoveToTrips]
|
|
29
|
+
*/
|
|
30
|
+
|
|
4
31
|
/**
|
|
5
32
|
* Factory for trips API (btrz-api-inventory-trips).
|
|
6
33
|
* @param {Object} deps
|
|
@@ -14,10 +41,10 @@ function tripsFactory({client, internalAuthTokenProvider}) {
|
|
|
14
41
|
* @param {Object} opts
|
|
15
42
|
* @param {string} [opts.token] - API key (X-API-KEY)
|
|
16
43
|
* @param {string} [opts.jwtToken] - JWT or internal auth (Authorization: Bearer)
|
|
17
|
-
* @param {
|
|
44
|
+
* @param {TripsSearchQuery} [opts.query] - Query params for trip search
|
|
18
45
|
* @param {Object} [opts.headers] - Optional headers
|
|
19
46
|
* @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
|
|
47
|
+
* @throws 400 INVALID_DATE, INVALID_DATE_FORMAT, INVALID_PRODUCTID, INVALID_ORIGIN, INVALID_DESTINATION, INVALID_CHANNEL, INVALID_FARE, INVALID_FAREID, INVALID_MANIFEST_STATUS, INVALID_MOVE_SEGMENT_DEMAND, WRONG_DATA
|
|
21
48
|
* @throws 401 Unauthorized
|
|
22
49
|
* @throws 409 NO_HIGHER_OR_EQL_PRICE
|
|
23
50
|
* @throws 500 Internal server error
|
|
@@ -94,4 +94,23 @@ describe("accounts/external-customers", () => {
|
|
|
94
94
|
data
|
|
95
95
|
});
|
|
96
96
|
});
|
|
97
|
+
|
|
98
|
+
it("should PUT Saldo Max client data (birthDate) on external-customers/ado/{externalId}", () => {
|
|
99
|
+
const externalId = "01-1224-000001988";
|
|
100
|
+
const data = {
|
|
101
|
+
birthDate: "15/06/1990"
|
|
102
|
+
};
|
|
103
|
+
axiosMock.onPut(`/external-customers/ado/${encodeURIComponent(externalId)}`).reply(expectRequest({
|
|
104
|
+
statusCode: 200,
|
|
105
|
+
token,
|
|
106
|
+
jwtToken,
|
|
107
|
+
body: data
|
|
108
|
+
}));
|
|
109
|
+
return api.accounts.externalCustomers.saldoMax.update({
|
|
110
|
+
token,
|
|
111
|
+
jwtToken,
|
|
112
|
+
id: externalId,
|
|
113
|
+
data
|
|
114
|
+
});
|
|
115
|
+
});
|
|
97
116
|
});
|