btrz-api-client 9.10.1 → 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.js CHANGED
@@ -497,6 +497,10 @@ function createAccounts({
497
497
  client,
498
498
  internalAuthTokenProvider
499
499
  }),
500
+ authorizedExternalMessaging: require("./endpoints/accounts/authorized-external-messaging.js")({
501
+ client,
502
+ internalAuthTokenProvider
503
+ }),
500
504
  application: require("./endpoints/accounts/application.js")({
501
505
  client,
502
506
  internalAuthTokenProvider
@@ -0,0 +1,171 @@
1
+ const {
2
+ authorizationHeaders
3
+ } = require("../endpoints_helpers.js");
4
+
5
+ /**
6
+ * Query params for GET /authorized-external-messaging (btrz-api-accounts).
7
+ * @typedef {Object} AuthorizedExternalMessagingListQuery
8
+ * @property {number} [page] - The page number to retrieve (positive integer)
9
+ * @property {string} [email] - Filter by email prefix (starts with), case-insensitive
10
+ */
11
+
12
+ /**
13
+ * Factory for authorized-external-messaging API (btrz-api-accounts).
14
+ * @param {Object} deps
15
+ * @param {import("axios").AxiosInstance} deps.client
16
+ * @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
17
+ * @returns {{ all: function, get: function, create: function, update: function, remove: function }}
18
+ */
19
+ function authorizedExternalMessagingFactory({
20
+ client,
21
+ internalAuthTokenProvider
22
+ }) {
23
+ /**
24
+ * GET /authorized-external-messaging - list authorized external messaging entries for the account.
25
+ * @param {Object} opts
26
+ * @param {string} [opts.token] - API key
27
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
28
+ * @param {AuthorizedExternalMessagingListQuery} [opts.query] - Query params (page, email)
29
+ * @param {Object} [opts.headers] - Optional headers
30
+ * @returns {Promise<import("axios").AxiosResponse>}
31
+ */
32
+ function all({
33
+ token,
34
+ jwtToken,
35
+ query = {},
36
+ headers
37
+ }) {
38
+ return client.get("/authorized-external-messaging", {
39
+ params: query,
40
+ headers: authorizationHeaders({
41
+ token,
42
+ jwtToken,
43
+ internalAuthTokenProvider,
44
+ headers
45
+ })
46
+ });
47
+ }
48
+
49
+ /**
50
+ * GET /authorized-external-messaging/:authorizedExternalMessagingId - get an entry by id.
51
+ * @param {Object} opts
52
+ * @param {string} [opts.token] - API key
53
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
54
+ * @param {string} opts.authorizedExternalMessagingId - Entry id (ObjectId)
55
+ * @param {Object} [opts.headers] - Optional headers
56
+ * @returns {Promise<import("axios").AxiosResponse>}
57
+ */
58
+ function get({
59
+ token,
60
+ jwtToken,
61
+ authorizedExternalMessagingId,
62
+ headers
63
+ }) {
64
+ return client({
65
+ url: `/authorized-external-messaging/${authorizedExternalMessagingId}`,
66
+ headers: authorizationHeaders({
67
+ token,
68
+ jwtToken,
69
+ internalAuthTokenProvider,
70
+ headers
71
+ })
72
+ });
73
+ }
74
+
75
+ /**
76
+ * POST /authorized-external-messaging - create an authorized external messaging entry.
77
+ * @param {Object} opts
78
+ * @param {string} [opts.token] - API key
79
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
80
+ * @param {Object} opts.authorizedExternalMessaging - Entry payload (email required)
81
+ * @param {Object} [opts.headers] - Optional headers
82
+ * @returns {Promise<import("axios").AxiosResponse>}
83
+ */
84
+ function create({
85
+ token,
86
+ jwtToken,
87
+ authorizedExternalMessaging,
88
+ headers
89
+ }) {
90
+ return client({
91
+ url: "/authorized-external-messaging",
92
+ method: "post",
93
+ headers: authorizationHeaders({
94
+ token,
95
+ jwtToken,
96
+ internalAuthTokenProvider,
97
+ headers
98
+ }),
99
+ data: {
100
+ authorizedExternalMessaging
101
+ }
102
+ });
103
+ }
104
+
105
+ /**
106
+ * PUT /authorized-external-messaging/:authorizedExternalMessagingId - update an entry.
107
+ * @param {Object} opts
108
+ * @param {string} [opts.token] - API key
109
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
110
+ * @param {string} opts.authorizedExternalMessagingId - Entry id (24-char hex ObjectId)
111
+ * @param {Object} opts.authorizedExternalMessaging - Entry payload (email required)
112
+ * @param {Object} [opts.headers] - Optional headers
113
+ * @returns {Promise<import("axios").AxiosResponse>}
114
+ */
115
+ function update({
116
+ token,
117
+ jwtToken,
118
+ authorizedExternalMessagingId,
119
+ authorizedExternalMessaging,
120
+ headers
121
+ }) {
122
+ return client({
123
+ url: `/authorized-external-messaging/${authorizedExternalMessagingId}`,
124
+ method: "put",
125
+ headers: authorizationHeaders({
126
+ token,
127
+ jwtToken,
128
+ internalAuthTokenProvider,
129
+ headers
130
+ }),
131
+ data: {
132
+ authorizedExternalMessaging
133
+ }
134
+ });
135
+ }
136
+
137
+ /**
138
+ * DELETE /authorized-external-messaging/:authorizedExternalMessagingId - delete an entry.
139
+ * @param {Object} opts
140
+ * @param {string} [opts.token] - API key
141
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
142
+ * @param {string} opts.authorizedExternalMessagingId - Entry id (24-char hex ObjectId)
143
+ * @param {Object} [opts.headers] - Optional headers
144
+ * @returns {Promise<import("axios").AxiosResponse>}
145
+ */
146
+ function remove({
147
+ token,
148
+ jwtToken,
149
+ authorizedExternalMessagingId,
150
+ headers
151
+ }) {
152
+ return client({
153
+ url: `/authorized-external-messaging/${authorizedExternalMessagingId}`,
154
+ method: "delete",
155
+ headers: authorizationHeaders({
156
+ token,
157
+ jwtToken,
158
+ internalAuthTokenProvider,
159
+ headers
160
+ })
161
+ });
162
+ }
163
+ return {
164
+ all,
165
+ get,
166
+ create,
167
+ update,
168
+ remove
169
+ };
170
+ }
171
+ module.exports = authorizedExternalMessagingFactory;
@@ -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: {
@@ -7,6 +7,7 @@ const {
7
7
  * Query params for GET /network/agencies (btrz-api-accounts). See get-agencies-handler getSpec().
8
8
  * @typedef {Object} NetworkAgenciesListQuery
9
9
  * @property {string} [name] - Filter by agency/seller name (prefix, case-insensitive)
10
+ * @property {string} [createdBy] - Filter by creating provider user ObjectId
10
11
  * @property {number} [page] - Page number (1-based)
11
12
  */
12
13
 
@@ -23,11 +24,11 @@ function networkFactory({
23
24
  }) {
24
25
  const agencies = {
25
26
  /**
26
- * GET /network/agencies - list agencies (paginated). Query: name, page.
27
+ * GET /network/agencies - list agencies (paginated). Query: name, createdBy, page.
27
28
  * @param {Object} opts
28
29
  * @param {string} [opts.token] - API key
29
30
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
30
- * @param {NetworkAgenciesListQuery} [opts.query] - Query params (name, page)
31
+ * @param {NetworkAgenciesListQuery} [opts.query] - Query params (name, createdBy, page)
31
32
  * @param {Object} [opts.headers] - Optional headers
32
33
  * @returns {Promise<import("axios").AxiosResponse<{ agencies: Array, next?: string, previous?: string, count?: number }>>}
33
34
  * Errors: 401, 500
@@ -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 {Object} [opts.query] - Query params (productId, originId, destinationId, fareIds, departureDate, returnDate, etc.)
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "btrz-api-client",
3
- "version": "9.10.1",
3
+ "version": "9.12.0",
4
4
  "description": "Api client for Betterez endpoints",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/client.js CHANGED
@@ -188,6 +188,7 @@ function createAccounts({baseURL, headers, timeout, overrideFn, internalAuthToke
188
188
  accounts: require("./endpoints/accounts/accounts.js")({client, internalAuthTokenProvider}),
189
189
  agencies: require("./endpoints/accounts/agencies.js")({client, internalAuthTokenProvider}),
190
190
  agencyTypes: require("./endpoints/accounts/agency-types.js")({client, internalAuthTokenProvider}),
191
+ authorizedExternalMessaging: require("./endpoints/accounts/authorized-external-messaging.js")({client, internalAuthTokenProvider}),
191
192
  application: require("./endpoints/accounts/application.js")({client, internalAuthTokenProvider}),
192
193
  applications: require("./endpoints/accounts/applications.js")({client, internalAuthTokenProvider}),
193
194
  applicationSettings: require("./endpoints/accounts/application-settings.js")({client, internalAuthTokenProvider}),
@@ -0,0 +1,119 @@
1
+ const {
2
+ authorizationHeaders
3
+ } = require("../endpoints_helpers.js");
4
+
5
+ /**
6
+ * Query params for GET /authorized-external-messaging (btrz-api-accounts).
7
+ * @typedef {Object} AuthorizedExternalMessagingListQuery
8
+ * @property {number} [page] - The page number to retrieve (positive integer)
9
+ * @property {string} [email] - Filter by email prefix (starts with), case-insensitive
10
+ */
11
+
12
+ /**
13
+ * Factory for authorized-external-messaging API (btrz-api-accounts).
14
+ * @param {Object} deps
15
+ * @param {import("axios").AxiosInstance} deps.client
16
+ * @param {{ getToken: function(): string }} [deps.internalAuthTokenProvider]
17
+ * @returns {{ all: function, get: function, create: function, update: function, remove: function }}
18
+ */
19
+ function authorizedExternalMessagingFactory({client, internalAuthTokenProvider}) {
20
+ /**
21
+ * GET /authorized-external-messaging - list authorized external messaging entries for the account.
22
+ * @param {Object} opts
23
+ * @param {string} [opts.token] - API key
24
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
25
+ * @param {AuthorizedExternalMessagingListQuery} [opts.query] - Query params (page, email)
26
+ * @param {Object} [opts.headers] - Optional headers
27
+ * @returns {Promise<import("axios").AxiosResponse>}
28
+ */
29
+ function all({token, jwtToken, query = {}, headers}) {
30
+ return client.get("/authorized-external-messaging", {
31
+ params: query,
32
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
33
+ });
34
+ }
35
+
36
+ /**
37
+ * GET /authorized-external-messaging/:authorizedExternalMessagingId - get an entry by id.
38
+ * @param {Object} opts
39
+ * @param {string} [opts.token] - API key
40
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
41
+ * @param {string} opts.authorizedExternalMessagingId - Entry id (ObjectId)
42
+ * @param {Object} [opts.headers] - Optional headers
43
+ * @returns {Promise<import("axios").AxiosResponse>}
44
+ */
45
+ function get({token, jwtToken, authorizedExternalMessagingId, headers}) {
46
+ return client({
47
+ url: `/authorized-external-messaging/${authorizedExternalMessagingId}`,
48
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
49
+ });
50
+ }
51
+
52
+ /**
53
+ * POST /authorized-external-messaging - create an authorized external messaging entry.
54
+ * @param {Object} opts
55
+ * @param {string} [opts.token] - API key
56
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
57
+ * @param {Object} opts.authorizedExternalMessaging - Entry payload (email required)
58
+ * @param {Object} [opts.headers] - Optional headers
59
+ * @returns {Promise<import("axios").AxiosResponse>}
60
+ */
61
+ function create({token, jwtToken, authorizedExternalMessaging, headers}) {
62
+ return client({
63
+ url: "/authorized-external-messaging",
64
+ method: "post",
65
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
66
+ data: {
67
+ authorizedExternalMessaging
68
+ }
69
+ });
70
+ }
71
+
72
+ /**
73
+ * PUT /authorized-external-messaging/:authorizedExternalMessagingId - update an entry.
74
+ * @param {Object} opts
75
+ * @param {string} [opts.token] - API key
76
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
77
+ * @param {string} opts.authorizedExternalMessagingId - Entry id (24-char hex ObjectId)
78
+ * @param {Object} opts.authorizedExternalMessaging - Entry payload (email required)
79
+ * @param {Object} [opts.headers] - Optional headers
80
+ * @returns {Promise<import("axios").AxiosResponse>}
81
+ */
82
+ function update({token, jwtToken, authorizedExternalMessagingId, authorizedExternalMessaging, headers}) {
83
+ return client({
84
+ url: `/authorized-external-messaging/${authorizedExternalMessagingId}`,
85
+ method: "put",
86
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers}),
87
+ data: {
88
+ authorizedExternalMessaging
89
+ }
90
+ });
91
+ }
92
+
93
+ /**
94
+ * DELETE /authorized-external-messaging/:authorizedExternalMessagingId - delete an entry.
95
+ * @param {Object} opts
96
+ * @param {string} [opts.token] - API key
97
+ * @param {string} [opts.jwtToken] - JWT or internal auth symbol
98
+ * @param {string} opts.authorizedExternalMessagingId - Entry id (24-char hex ObjectId)
99
+ * @param {Object} [opts.headers] - Optional headers
100
+ * @returns {Promise<import("axios").AxiosResponse>}
101
+ */
102
+ function remove({token, jwtToken, authorizedExternalMessagingId, headers}) {
103
+ return client({
104
+ url: `/authorized-external-messaging/${authorizedExternalMessagingId}`,
105
+ method: "delete",
106
+ headers: authorizationHeaders({token, jwtToken, internalAuthTokenProvider, headers})
107
+ });
108
+ }
109
+
110
+ return {
111
+ all,
112
+ get,
113
+ create,
114
+ update,
115
+ remove
116
+ };
117
+ }
118
+
119
+ module.exports = authorizedExternalMessagingFactory;
@@ -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: {
@@ -7,6 +7,7 @@ const {
7
7
  * Query params for GET /network/agencies (btrz-api-accounts). See get-agencies-handler getSpec().
8
8
  * @typedef {Object} NetworkAgenciesListQuery
9
9
  * @property {string} [name] - Filter by agency/seller name (prefix, case-insensitive)
10
+ * @property {string} [createdBy] - Filter by creating provider user ObjectId
10
11
  * @property {number} [page] - Page number (1-based)
11
12
  */
12
13
 
@@ -20,11 +21,11 @@ const {
20
21
  function networkFactory({client, internalAuthTokenProvider}) {
21
22
  const agencies = {
22
23
  /**
23
- * GET /network/agencies - list agencies (paginated). Query: name, page.
24
+ * GET /network/agencies - list agencies (paginated). Query: name, createdBy, page.
24
25
  * @param {Object} opts
25
26
  * @param {string} [opts.token] - API key
26
27
  * @param {string} [opts.jwtToken] - JWT or internal auth symbol
27
- * @param {NetworkAgenciesListQuery} [opts.query] - Query params (name, page)
28
+ * @param {NetworkAgenciesListQuery} [opts.query] - Query params (name, createdBy, page)
28
29
  * @param {Object} [opts.headers] - Optional headers
29
30
  * @returns {Promise<import("axios").AxiosResponse<{ agencies: Array, next?: string, previous?: string, count?: number }>>}
30
31
  * Errors: 401, 500
@@ -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 {Object} [opts.query] - Query params (productId, originId, destinationId, fareIds, departureDate, returnDate, etc.)
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
@@ -0,0 +1,98 @@
1
+ const {
2
+ axiosMock,
3
+ expectRequest
4
+ } = require("./../../test-helpers.js");
5
+ const api = require("./../../../src/client.js").createApiClient({
6
+ baseURL: "http://test.com"
7
+ });
8
+
9
+ describe("accounts/authorized-external-messaging", () => {
10
+ const token = "I owe you a token";
11
+ const jwtToken = "I owe you a JWT token";
12
+
13
+ afterEach(() => {
14
+ axiosMock.reset();
15
+ });
16
+
17
+ it("should GET a list of authorized external messaging entries", () => {
18
+ axiosMock.onGet("/authorized-external-messaging").reply(expectRequest({
19
+ statusCode: 200,
20
+ token,
21
+ jwtToken
22
+ }));
23
+ return api.accounts.authorizedExternalMessaging.all({
24
+ token,
25
+ jwtToken,
26
+ query: {
27
+ page: 1,
28
+ email: "user@"
29
+ }
30
+ });
31
+ });
32
+
33
+ it("should GET an authorized external messaging entry by id", () => {
34
+ const authorizedExternalMessagingId = "507f1f77bcf86cd799439011";
35
+ axiosMock.onGet(`/authorized-external-messaging/${authorizedExternalMessagingId}`).reply(expectRequest({
36
+ statusCode: 200,
37
+ token,
38
+ jwtToken
39
+ }));
40
+ return api.accounts.authorizedExternalMessaging.get({
41
+ token,
42
+ jwtToken,
43
+ authorizedExternalMessagingId
44
+ });
45
+ });
46
+
47
+ it("should POST an authorized external messaging entry", () => {
48
+ const authorizedExternalMessaging = {
49
+ email: "reports@example.com",
50
+ reports: true
51
+ };
52
+ axiosMock.onPost("/authorized-external-messaging").reply(expectRequest({
53
+ statusCode: 200,
54
+ token,
55
+ jwtToken,
56
+ body: {authorizedExternalMessaging}
57
+ }));
58
+ return api.accounts.authorizedExternalMessaging.create({
59
+ token,
60
+ jwtToken,
61
+ authorizedExternalMessaging
62
+ });
63
+ });
64
+
65
+ it("should PUT an authorized external messaging entry", () => {
66
+ const authorizedExternalMessagingId = "507f1f77bcf86cd799439011";
67
+ const authorizedExternalMessaging = {
68
+ email: "reports@example.com",
69
+ reports: true
70
+ };
71
+ axiosMock.onPut(`/authorized-external-messaging/${authorizedExternalMessagingId}`).reply(expectRequest({
72
+ statusCode: 200,
73
+ token,
74
+ jwtToken,
75
+ body: {authorizedExternalMessaging}
76
+ }));
77
+ return api.accounts.authorizedExternalMessaging.update({
78
+ token,
79
+ jwtToken,
80
+ authorizedExternalMessagingId,
81
+ authorizedExternalMessaging
82
+ });
83
+ });
84
+
85
+ it("should DELETE an authorized external messaging entry", () => {
86
+ const authorizedExternalMessagingId = "507f1f77bcf86cd799439011";
87
+ axiosMock.onDelete(`/authorized-external-messaging/${authorizedExternalMessagingId}`).reply(expectRequest({
88
+ statusCode: 200,
89
+ token,
90
+ jwtToken
91
+ }));
92
+ return api.accounts.authorizedExternalMessaging.remove({
93
+ token,
94
+ jwtToken,
95
+ authorizedExternalMessagingId
96
+ });
97
+ });
98
+ });