@flexops/sdk 2.0.0 → 3.0.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/README.md +186 -111
- package/dist/index.d.mts +1034 -413
- package/dist/index.d.ts +1034 -413
- package/dist/index.js +787 -396
- package/dist/index.mjs +778 -393
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -21,33 +21,85 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
AnalyticsResource: () => AnalyticsResource,
|
|
24
|
-
ApiKeysResource: () => ApiKeysResource,
|
|
25
24
|
AuthResource: () => AuthResource,
|
|
25
|
+
CarbonOffsetsResource: () => CarbonOffsetsResource,
|
|
26
26
|
CarriersResource: () => CarriersResource,
|
|
27
27
|
EmailTemplatesResource: () => EmailTemplatesResource,
|
|
28
28
|
FlexOps: () => FlexOps,
|
|
29
29
|
FlexOpsAuthError: () => FlexOpsAuthError,
|
|
30
30
|
FlexOpsError: () => FlexOpsError,
|
|
31
31
|
FlexOpsRateLimitError: () => FlexOpsRateLimitError,
|
|
32
|
+
HazmatClassification: () => HazmatClassification,
|
|
32
33
|
HsCodesResource: () => HsCodesResource,
|
|
33
34
|
InsuranceResource: () => InsuranceResource,
|
|
34
35
|
InventoryResource: () => InventoryResource,
|
|
35
|
-
OffsetResource: () => OffsetResource,
|
|
36
36
|
OrdersResource: () => OrdersResource,
|
|
37
37
|
PickupsResource: () => PickupsResource,
|
|
38
|
+
RecurrenceInterval: () => RecurrenceInterval,
|
|
38
39
|
RecurringShipmentsResource: () => RecurringShipmentsResource,
|
|
39
|
-
|
|
40
|
+
ReportFormat: () => ReportFormat,
|
|
41
|
+
ReportFrequency: () => ReportFrequency,
|
|
42
|
+
ReportSchedulesResource: () => ReportSchedulesResource,
|
|
40
43
|
ReturnsResource: () => ReturnsResource,
|
|
41
44
|
RulesResource: () => RulesResource,
|
|
42
45
|
ScanFormsResource: () => ScanFormsResource,
|
|
43
46
|
ShippingResource: () => ShippingResource,
|
|
47
|
+
TrackingEmailEvent: () => TrackingEmailEvent,
|
|
44
48
|
WalletResource: () => WalletResource,
|
|
49
|
+
WebhookEventType: () => WebhookEventType,
|
|
45
50
|
WebhooksResource: () => WebhooksResource,
|
|
51
|
+
WorkspaceRole: () => WorkspaceRole,
|
|
46
52
|
WorkspacesResource: () => WorkspacesResource
|
|
47
53
|
});
|
|
48
54
|
module.exports = __toCommonJS(index_exports);
|
|
49
55
|
|
|
50
56
|
// src/types.ts
|
|
57
|
+
var WorkspaceRole = {
|
|
58
|
+
Owner: 0,
|
|
59
|
+
Admin: 1,
|
|
60
|
+
Member: 2,
|
|
61
|
+
Merchant: 3
|
|
62
|
+
};
|
|
63
|
+
var HazmatClassification = {
|
|
64
|
+
None: 0,
|
|
65
|
+
LimitedQuantity: 1,
|
|
66
|
+
LithiumBatteryContainedInEquipment: 2,
|
|
67
|
+
LithiumBatteryPackedWithEquipment: 3,
|
|
68
|
+
LithiumBatteryStandalone: 4,
|
|
69
|
+
OtherRestricted: 5,
|
|
70
|
+
LithiumBatteryUsedDevice: 6
|
|
71
|
+
};
|
|
72
|
+
var WebhookEventType = {
|
|
73
|
+
LabelCreated: "LabelCreated",
|
|
74
|
+
LabelCanceled: "LabelCanceled",
|
|
75
|
+
BatchCompleted: "BatchCompleted",
|
|
76
|
+
TrackingUpdated: "TrackingUpdated",
|
|
77
|
+
TrackingDelivered: "TrackingDelivered"
|
|
78
|
+
};
|
|
79
|
+
var RecurrenceInterval = {
|
|
80
|
+
Daily: 0,
|
|
81
|
+
Weekly: 1,
|
|
82
|
+
Biweekly: 2,
|
|
83
|
+
Monthly: 3,
|
|
84
|
+
Custom: 4
|
|
85
|
+
};
|
|
86
|
+
var ReportFormat = {
|
|
87
|
+
Csv: 0,
|
|
88
|
+
Json: 1
|
|
89
|
+
};
|
|
90
|
+
var ReportFrequency = {
|
|
91
|
+
Daily: 0,
|
|
92
|
+
Weekly: 1,
|
|
93
|
+
Monthly: 2
|
|
94
|
+
};
|
|
95
|
+
var TrackingEmailEvent = {
|
|
96
|
+
LabelCreated: 0,
|
|
97
|
+
InTransit: 1,
|
|
98
|
+
OutForDelivery: 2,
|
|
99
|
+
Delivered: 3,
|
|
100
|
+
Exception: 4,
|
|
101
|
+
ReturnToSender: 5
|
|
102
|
+
};
|
|
51
103
|
var FlexOpsError = class extends Error {
|
|
52
104
|
constructor(message, status, code, errors) {
|
|
53
105
|
super(message);
|
|
@@ -71,6 +123,20 @@ var FlexOpsAuthError = class extends FlexOpsError {
|
|
|
71
123
|
}
|
|
72
124
|
};
|
|
73
125
|
|
|
126
|
+
// src/node-crypto.ts
|
|
127
|
+
function loadNodeCrypto(purpose) {
|
|
128
|
+
const fromProcess = globalThis.process?.getBuiltinModule?.("node:crypto");
|
|
129
|
+
if (fromProcess) return fromProcess;
|
|
130
|
+
if (typeof require === "function") {
|
|
131
|
+
return require("crypto");
|
|
132
|
+
}
|
|
133
|
+
throw new Error(`${purpose} needs node:crypto (Node.js 20.16+ for the ES module build).`);
|
|
134
|
+
}
|
|
135
|
+
function randomUuid() {
|
|
136
|
+
const webCrypto = globalThis.crypto;
|
|
137
|
+
return webCrypto?.randomUUID ? webCrypto.randomUUID() : loadNodeCrypto("Generating an Idempotency-Key").randomUUID();
|
|
138
|
+
}
|
|
139
|
+
|
|
74
140
|
// src/http.ts
|
|
75
141
|
var DEFAULT_BASE_URL = "https://gateway.flexops.io";
|
|
76
142
|
var DEFAULT_TIMEOUT = 3e4;
|
|
@@ -79,6 +145,9 @@ var DEFAULT_RETRY = {
|
|
|
79
145
|
baseDelay: 1e3,
|
|
80
146
|
retryableStatusCodes: [429, 500, 502, 503, 504]
|
|
81
147
|
};
|
|
148
|
+
var WRITE_METHODS = /* @__PURE__ */ new Set(["POST", "PUT", "PATCH"]);
|
|
149
|
+
var WRITE_RETRYABLE_STATUSES = /* @__PURE__ */ new Set([502, 503, 504]);
|
|
150
|
+
var IDEMPOTENCY_CONFLICT = "IDEMPOTENCY_CONFLICT";
|
|
82
151
|
var HttpClient = class {
|
|
83
152
|
baseUrl;
|
|
84
153
|
timeout;
|
|
@@ -99,6 +168,10 @@ var HttpClient = class {
|
|
|
99
168
|
setAccessToken(token) {
|
|
100
169
|
this.accessToken = token;
|
|
101
170
|
}
|
|
171
|
+
/** The JWT access token in use, if any. */
|
|
172
|
+
getAccessToken() {
|
|
173
|
+
return this.accessToken;
|
|
174
|
+
}
|
|
102
175
|
setApiKey(key) {
|
|
103
176
|
this.apiKey = key;
|
|
104
177
|
}
|
|
@@ -107,6 +180,10 @@ var HttpClient = class {
|
|
|
107
180
|
const headers = this.buildHeaders(options?.headers);
|
|
108
181
|
const body = options?.body ? JSON.stringify(options.body) : void 0;
|
|
109
182
|
const timeout = options?.timeout ?? this.timeout;
|
|
183
|
+
const verb = method.toUpperCase();
|
|
184
|
+
if (WRITE_METHODS.has(verb) && !Object.keys(headers).some((h) => h.toLowerCase() === "idempotency-key")) {
|
|
185
|
+
headers["Idempotency-Key"] = randomUuid();
|
|
186
|
+
}
|
|
110
187
|
let lastError;
|
|
111
188
|
for (let attempt = 0; attempt <= this.retry.maxRetries; attempt++) {
|
|
112
189
|
if (attempt > 0) {
|
|
@@ -115,65 +192,60 @@ var HttpClient = class {
|
|
|
115
192
|
}
|
|
116
193
|
const controller = new AbortController();
|
|
117
194
|
const timer = setTimeout(() => controller.abort(), timeout);
|
|
195
|
+
let response;
|
|
118
196
|
try {
|
|
119
|
-
|
|
197
|
+
response = await this.fetchFn(url, {
|
|
120
198
|
method,
|
|
121
199
|
headers,
|
|
122
200
|
body,
|
|
123
201
|
signal: controller.signal
|
|
124
202
|
});
|
|
125
|
-
clearTimeout(timer);
|
|
126
|
-
if (response.ok) {
|
|
127
|
-
const contentType = response.headers.get("content-type") ?? "";
|
|
128
|
-
if (contentType.includes("application/json")) {
|
|
129
|
-
return await response.json();
|
|
130
|
-
}
|
|
131
|
-
return response;
|
|
132
|
-
}
|
|
133
|
-
if (response.status === 429) {
|
|
134
|
-
const retryAfter = parseInt(response.headers.get("retry-after") ?? "0", 10);
|
|
135
|
-
lastError = new FlexOpsRateLimitError(
|
|
136
|
-
`Rate limited. Retry after ${retryAfter}s`,
|
|
137
|
-
retryAfter
|
|
138
|
-
);
|
|
139
|
-
if (this.retry.retryableStatusCodes.includes(429)) continue;
|
|
140
|
-
throw lastError;
|
|
141
|
-
}
|
|
142
|
-
if (response.status === 401) {
|
|
143
|
-
throw new FlexOpsAuthError("Authentication required. Check your access token or API key.");
|
|
144
|
-
}
|
|
145
|
-
if (response.status === 403) {
|
|
146
|
-
throw new FlexOpsError("Access denied. Check your plan tier and feature entitlements.", 403, "FORBIDDEN");
|
|
147
|
-
}
|
|
148
|
-
let errorBody = {};
|
|
149
|
-
try {
|
|
150
|
-
errorBody = await response.json();
|
|
151
|
-
} catch {
|
|
152
|
-
}
|
|
153
|
-
const error = new FlexOpsError(
|
|
154
|
-
errorBody.message ?? `HTTP ${response.status}: ${response.statusText}`,
|
|
155
|
-
response.status,
|
|
156
|
-
errorBody.code ?? errorBody.errorCode,
|
|
157
|
-
errorBody.errors
|
|
158
|
-
);
|
|
159
|
-
if (this.retry.retryableStatusCodes.includes(response.status)) {
|
|
160
|
-
lastError = error;
|
|
161
|
-
continue;
|
|
162
|
-
}
|
|
163
|
-
throw error;
|
|
164
203
|
} catch (err) {
|
|
204
|
+
lastError = err instanceof DOMException && err.name === "AbortError" ? new FlexOpsError(`Request timed out after ${timeout}ms`, 0, "TIMEOUT") : err instanceof Error ? err : new Error(String(err));
|
|
205
|
+
if (verb === "DELETE") throw lastError;
|
|
206
|
+
continue;
|
|
207
|
+
} finally {
|
|
165
208
|
clearTimeout(timer);
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
209
|
+
}
|
|
210
|
+
if (response.ok) {
|
|
211
|
+
if (response.status === 204 || response.headers.get("content-length") === "0") {
|
|
212
|
+
return void 0;
|
|
169
213
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
214
|
+
const contentType = response.headers.get("content-type") ?? "";
|
|
215
|
+
if (contentType.includes("application/json")) {
|
|
216
|
+
return await response.json();
|
|
173
217
|
}
|
|
174
|
-
|
|
175
|
-
|
|
218
|
+
return response;
|
|
219
|
+
}
|
|
220
|
+
if (response.status === 429) {
|
|
221
|
+
const retryAfter = parseInt(response.headers.get("retry-after") ?? "0", 10);
|
|
222
|
+
lastError = new FlexOpsRateLimitError(
|
|
223
|
+
`Rate limited. Retry after ${retryAfter}s`,
|
|
224
|
+
retryAfter
|
|
225
|
+
);
|
|
226
|
+
if (this.retry.retryableStatusCodes.includes(429)) continue;
|
|
227
|
+
throw lastError;
|
|
228
|
+
}
|
|
229
|
+
if (response.status === 401) {
|
|
230
|
+
throw new FlexOpsAuthError("Authentication required. Check your access token or API key.");
|
|
176
231
|
}
|
|
232
|
+
let errorBody = {};
|
|
233
|
+
try {
|
|
234
|
+
errorBody = await response.json();
|
|
235
|
+
} catch {
|
|
236
|
+
}
|
|
237
|
+
const code = errorBody.code ?? errorBody.errorCode;
|
|
238
|
+
const error = new FlexOpsError(
|
|
239
|
+
errorBody.message ?? `HTTP ${response.status}: ${response.statusText}`,
|
|
240
|
+
response.status,
|
|
241
|
+
code ?? (response.status === 403 ? "FORBIDDEN" : void 0),
|
|
242
|
+
errorBody.errors
|
|
243
|
+
);
|
|
244
|
+
if (this.isRetryable(verb, response.status, code)) {
|
|
245
|
+
lastError = error;
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
throw error;
|
|
177
249
|
}
|
|
178
250
|
throw lastError ?? new FlexOpsError("Request failed after retries", 0, "RETRY_EXHAUSTED");
|
|
179
251
|
}
|
|
@@ -217,6 +289,17 @@ var HttpClient = class {
|
|
|
217
289
|
}
|
|
218
290
|
return headers;
|
|
219
291
|
}
|
|
292
|
+
/**
|
|
293
|
+
* GETs retry on every configured status. A write retries only where the Gateway either did not
|
|
294
|
+
* run it or will replay it for the same Idempotency-Key: never after a 500, whose response the
|
|
295
|
+
* Gateway does not cache, so a retry would run the write again. A DELETE retries only on 429.
|
|
296
|
+
*/
|
|
297
|
+
isRetryable(verb, status, code) {
|
|
298
|
+
if (verb === "GET" || verb === "HEAD") return this.retry.retryableStatusCodes.includes(status);
|
|
299
|
+
if (verb === "DELETE") return false;
|
|
300
|
+
if (status === 409) return code === IDEMPOTENCY_CONFLICT;
|
|
301
|
+
return WRITE_RETRYABLE_STATUSES.has(status) && this.retry.retryableStatusCodes.includes(status);
|
|
302
|
+
}
|
|
220
303
|
calculateBackoff(attempt) {
|
|
221
304
|
const jitter = Math.random() * 0.3 + 0.85;
|
|
222
305
|
return Math.min(this.retry.baseDelay * Math.pow(2, attempt - 1) * jitter, 3e4);
|
|
@@ -231,30 +314,34 @@ var AuthResource = class {
|
|
|
231
314
|
constructor(http) {
|
|
232
315
|
this.http = http;
|
|
233
316
|
}
|
|
234
|
-
/**
|
|
317
|
+
/**
|
|
318
|
+
* Authenticate with email and password. On success the returned access token (`data.token`) is
|
|
319
|
+
* used for later requests. When `data.requiresTwoFactor` is true no token is issued yet.
|
|
320
|
+
*/
|
|
235
321
|
async login(request) {
|
|
236
322
|
const result = await this.http.post(
|
|
237
323
|
"/api/Account/login",
|
|
238
324
|
request
|
|
239
325
|
);
|
|
240
|
-
if (result.data?.
|
|
241
|
-
this.http.setAccessToken(result.data.
|
|
326
|
+
if (result.data?.token) {
|
|
327
|
+
this.http.setAccessToken(result.data.token);
|
|
242
328
|
}
|
|
243
329
|
return result;
|
|
244
330
|
}
|
|
245
|
-
/**
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
331
|
+
/**
|
|
332
|
+
* Exchange a refresh token for a new access token. The Gateway needs the expired access token
|
|
333
|
+
* too; it defaults to the one this client holds.
|
|
334
|
+
*/
|
|
335
|
+
async refreshToken(refreshToken, accessToken = this.http.getAccessToken()) {
|
|
336
|
+
if (!accessToken) {
|
|
337
|
+
throw new FlexOpsAuthError("refreshToken needs the expired access token; log in first or pass it.");
|
|
338
|
+
}
|
|
339
|
+
const response = await this.http.post(
|
|
253
340
|
"/api/Account/refresh-token",
|
|
254
|
-
{
|
|
341
|
+
{ token: accessToken, refreshToken }
|
|
255
342
|
);
|
|
256
|
-
if (response.data?.
|
|
257
|
-
this.http.setAccessToken(response.data.
|
|
343
|
+
if (response.data?.token) {
|
|
344
|
+
this.http.setAccessToken(response.data.token);
|
|
258
345
|
}
|
|
259
346
|
return response;
|
|
260
347
|
}
|
|
@@ -262,33 +349,6 @@ var AuthResource = class {
|
|
|
262
349
|
async logout() {
|
|
263
350
|
return this.http.post("/api/Account/logout");
|
|
264
351
|
}
|
|
265
|
-
/** Get the current user's profile. */
|
|
266
|
-
async getProfile() {
|
|
267
|
-
return this.http.get("/api/Account/profile");
|
|
268
|
-
}
|
|
269
|
-
/** Update the current user's profile. */
|
|
270
|
-
async updateProfile(data) {
|
|
271
|
-
return this.http.put("/api/Account/profile", data);
|
|
272
|
-
}
|
|
273
|
-
/** Change the current user's password. */
|
|
274
|
-
async changePassword(currentPassword, newPassword) {
|
|
275
|
-
return this.http.post("/api/Account/change-password", {
|
|
276
|
-
currentPassword,
|
|
277
|
-
newPassword
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
/** Request a password reset email. */
|
|
281
|
-
async forgotPassword(email) {
|
|
282
|
-
return this.http.post("/api/Account/forgot-password", { email });
|
|
283
|
-
}
|
|
284
|
-
/** Reset password using a reset token. */
|
|
285
|
-
async resetPassword(token, newPassword) {
|
|
286
|
-
return this.http.post("/api/Account/reset-password", { token, newPassword });
|
|
287
|
-
}
|
|
288
|
-
/** Verify email with the verification token. */
|
|
289
|
-
async verifyEmail(token) {
|
|
290
|
-
return this.http.post("/api/Account/verify-email", { token });
|
|
291
|
-
}
|
|
292
352
|
};
|
|
293
353
|
|
|
294
354
|
// src/resources/workspaces.ts
|
|
@@ -311,29 +371,21 @@ var WorkspacesResource = class {
|
|
|
311
371
|
const id = workspaceId ?? this.getWorkspaceId();
|
|
312
372
|
return this.http.get(`/api/workspaces/${id}`);
|
|
313
373
|
}
|
|
314
|
-
/**
|
|
315
|
-
async create(request) {
|
|
316
|
-
return this.http.post("/api/workspaces", request);
|
|
317
|
-
}
|
|
318
|
-
/** Update workspace settings. */
|
|
319
|
-
async update(data) {
|
|
320
|
-
return this.http.put(this.wsPath(), data);
|
|
321
|
-
}
|
|
322
|
-
/** List members of the current workspace. */
|
|
374
|
+
/** List the current workspace's members and pending invites. */
|
|
323
375
|
async listMembers() {
|
|
324
376
|
return this.http.get(this.wsPath("members"));
|
|
325
377
|
}
|
|
326
378
|
/** Invite a user to the workspace. */
|
|
327
|
-
async inviteMember(email, role =
|
|
379
|
+
async inviteMember(email, role = WorkspaceRole.Member) {
|
|
328
380
|
return this.http.post(this.wsPath("members/invite"), { email, role });
|
|
329
381
|
}
|
|
330
382
|
/** Remove a member from the workspace. */
|
|
331
383
|
async removeMember(userId) {
|
|
332
384
|
return this.http.delete(this.wsPath(`members/${userId}`));
|
|
333
385
|
}
|
|
334
|
-
/**
|
|
386
|
+
/** Change a member's role. */
|
|
335
387
|
async updateMemberRole(userId, role) {
|
|
336
|
-
return this.http.put(this.wsPath(`members/${userId}/role`), { role });
|
|
388
|
+
return this.http.put(this.wsPath(`members/${userId}/role`), { newRole: role });
|
|
337
389
|
}
|
|
338
390
|
};
|
|
339
391
|
|
|
@@ -353,15 +405,15 @@ var ShippingResource = class {
|
|
|
353
405
|
// -----------------------------------------------------------------------
|
|
354
406
|
/** Get shipping rates from all configured carriers. */
|
|
355
407
|
async getRates(request) {
|
|
356
|
-
return this.http.post("/api/shipping/rates", request);
|
|
408
|
+
return this.http.post("/api/shipping/rates", toRateWire(request));
|
|
357
409
|
}
|
|
358
410
|
/** Get the single cheapest rate across all carriers. */
|
|
359
411
|
async getCheapestRate(request) {
|
|
360
|
-
return this.http.post("/api/shipping/rates/cheapest", request);
|
|
412
|
+
return this.http.post("/api/shipping/rates/cheapest", toRateWire(request));
|
|
361
413
|
}
|
|
362
414
|
/** Get the single fastest rate across all carriers. */
|
|
363
415
|
async getFastestRate(request) {
|
|
364
|
-
return this.http.post("/api/shipping/rates/fastest", request);
|
|
416
|
+
return this.http.post("/api/shipping/rates/fastest", toRateWire(request));
|
|
365
417
|
}
|
|
366
418
|
// -----------------------------------------------------------------------
|
|
367
419
|
// Labels
|
|
@@ -372,7 +424,11 @@ var ShippingResource = class {
|
|
|
372
424
|
* server-side and postage is settled atomically. Returns the raw label (HTTP 201).
|
|
373
425
|
*/
|
|
374
426
|
async createLabel(request) {
|
|
375
|
-
const
|
|
427
|
+
const { body, idempotencyKey } = toLabelWire(request);
|
|
428
|
+
const result = await this.http.request("POST", "/api/shipping/labels", {
|
|
429
|
+
body,
|
|
430
|
+
...idempotencyKey ? { headers: { "Idempotency-Key": idempotencyKey } } : {}
|
|
431
|
+
});
|
|
376
432
|
if ("status" in result) throw new FlexOpsError("Approval required. Use prepareLabel, review its preview, then purchaseLabel.", 400, "ApprovalRequired");
|
|
377
433
|
return result;
|
|
378
434
|
}
|
|
@@ -422,7 +478,16 @@ var ShippingResource = class {
|
|
|
422
478
|
// -----------------------------------------------------------------------
|
|
423
479
|
/** Validate and correct a shipping address. */
|
|
424
480
|
async validateAddress(address) {
|
|
425
|
-
|
|
481
|
+
const a = toShippingAddress(address);
|
|
482
|
+
return this.http.post("/api/addresses/validate", {
|
|
483
|
+
name: a.name,
|
|
484
|
+
line1: a.addressLine1,
|
|
485
|
+
line2: a.addressLine2,
|
|
486
|
+
city: a.city,
|
|
487
|
+
state: a.stateProvince,
|
|
488
|
+
postalCode: a.postalCode,
|
|
489
|
+
country: a.countryCode ?? "US"
|
|
490
|
+
});
|
|
426
491
|
}
|
|
427
492
|
// -----------------------------------------------------------------------
|
|
428
493
|
// Batch Labels
|
|
@@ -466,6 +531,48 @@ var ShippingResource = class {
|
|
|
466
531
|
return this.http.get("/api/shipping/savings");
|
|
467
532
|
}
|
|
468
533
|
};
|
|
534
|
+
function unsupported(message) {
|
|
535
|
+
return new FlexOpsError(message, 400, "UnsupportedRequestShape");
|
|
536
|
+
}
|
|
537
|
+
function toShippingAddress(address) {
|
|
538
|
+
if (!("street1" in address)) return address;
|
|
539
|
+
return {
|
|
540
|
+
name: address.name,
|
|
541
|
+
company: address.company,
|
|
542
|
+
addressLine1: address.street1,
|
|
543
|
+
addressLine2: address.street2,
|
|
544
|
+
city: address.city,
|
|
545
|
+
stateProvince: address.state,
|
|
546
|
+
postalCode: address.zip,
|
|
547
|
+
countryCode: address.country,
|
|
548
|
+
phone: address.phone,
|
|
549
|
+
email: address.email
|
|
550
|
+
};
|
|
551
|
+
}
|
|
552
|
+
function toRateWire(request) {
|
|
553
|
+
if ("fromZip" in request)
|
|
554
|
+
throw unsupported("The Gateway needs full origin and destination addresses. Use origin, destination and package.");
|
|
555
|
+
return request;
|
|
556
|
+
}
|
|
557
|
+
function isLegacyLabelRequest(request) {
|
|
558
|
+
return "fromAddress" in request && !("origin" in request);
|
|
559
|
+
}
|
|
560
|
+
function toLabelWire(request) {
|
|
561
|
+
if (!isLegacyLabelRequest(request)) return { body: request };
|
|
562
|
+
if (request.returnLabel)
|
|
563
|
+
throw unsupported("createLabel cannot buy return labels. Use the returns API.");
|
|
564
|
+
const body = {
|
|
565
|
+
carrierCode: request.carrier,
|
|
566
|
+
serviceCode: request.service,
|
|
567
|
+
origin: toShippingAddress(request.fromAddress),
|
|
568
|
+
destination: toShippingAddress(request.toAddress),
|
|
569
|
+
package: { ...request.parcel },
|
|
570
|
+
labelFormat: request.labelFormat,
|
|
571
|
+
orderId: request.orderId,
|
|
572
|
+
hazmatClassification: request.hazmatClassification
|
|
573
|
+
};
|
|
574
|
+
return { body, idempotencyKey: request.idempotencyKey };
|
|
575
|
+
}
|
|
469
576
|
|
|
470
577
|
// src/resources/carriers.ts
|
|
471
578
|
var CarriersResource = class {
|
|
@@ -485,38 +592,94 @@ var CarriersResource = class {
|
|
|
485
592
|
cityStateLookup: (zipCode) => this.http.get(this.proxy("api/v3/AddressValidation/getUspsCityStateLookupByZipCode"), { zipCode }),
|
|
486
593
|
/** ZIP code lookup by address. */
|
|
487
594
|
zipCodeLookup: (params) => this.http.get(this.proxy("api/v3/AddressValidation/getUspsZipCodeLookupByAddress"), params),
|
|
488
|
-
/**
|
|
595
|
+
/**
|
|
596
|
+
* Search domestic shipping rates.
|
|
597
|
+
*
|
|
598
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
599
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
600
|
+
* cover this.
|
|
601
|
+
*/
|
|
489
602
|
getDomesticRates: (body) => this.http.post(this.proxy("api/v3/RateCalculator/postUspsSearchDomesticBaseRates"), body),
|
|
490
|
-
/**
|
|
603
|
+
/**
|
|
604
|
+
* Search domestic product eligibility.
|
|
605
|
+
*
|
|
606
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
607
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
608
|
+
* cover this.
|
|
609
|
+
*/
|
|
491
610
|
getDomesticProducts: (body) => this.http.post(this.proxy("api/v3/RateCalculator/postUspsSearchEligibleDomesticProducts"), body),
|
|
492
|
-
/**
|
|
611
|
+
/**
|
|
612
|
+
* Search domestic prices.
|
|
613
|
+
*
|
|
614
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
615
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
616
|
+
* cover this.
|
|
617
|
+
*/
|
|
493
618
|
getDomesticPrices: (body) => this.http.post(this.proxy("api/v3/RateCalculator/postUspsSearchEligibleDomesticPrices"), body),
|
|
494
|
-
/**
|
|
619
|
+
/**
|
|
620
|
+
* Search international rates.
|
|
621
|
+
*
|
|
622
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
623
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
624
|
+
* cover this.
|
|
625
|
+
*/
|
|
495
626
|
getInternationalRates: (body) => this.http.post(this.proxy("api/v3/RateCalculator/postUspsSearchInternationalBaseRates"), body),
|
|
496
|
-
/**
|
|
627
|
+
/**
|
|
628
|
+
* Search international prices.
|
|
629
|
+
*
|
|
630
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
631
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
632
|
+
* cover this.
|
|
633
|
+
*/
|
|
497
634
|
getInternationalPrices: (body) => this.http.post(this.proxy("api/v3/RateCalculator/postUspsSearchEligibleInternationalPrices"), body),
|
|
498
635
|
/** Generate a domestic shipping label. */
|
|
499
636
|
// Domestic USPS labels go through the reliable order-based Gateway path
|
|
500
637
|
// (POST /api/shipping/labels): pass a LabelRequest body with carrierCode:'USPS'
|
|
501
638
|
// and orderId set — server-side order validation + atomic postage settlement.
|
|
502
639
|
createDomesticLabel: (body) => new ShippingResource(this.http, () => void 0).createLabel(body),
|
|
503
|
-
/**
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
640
|
+
/**
|
|
641
|
+
* Cancel a domestic label.
|
|
642
|
+
*
|
|
643
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
644
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
645
|
+
* cover this.
|
|
646
|
+
*/
|
|
508
647
|
cancelDomesticLabel: () => this.http.delete(this.proxy("api/v3/Shipping/cancelUspsDomesticShipmentLabel")),
|
|
509
|
-
/**
|
|
648
|
+
/**
|
|
649
|
+
* Cancel an international label.
|
|
650
|
+
*
|
|
651
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
652
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
653
|
+
* cover this.
|
|
654
|
+
*/
|
|
510
655
|
cancelInternationalLabel: () => this.http.delete(this.proxy("api/v3/Shipping/cancelUspsInternationalShipmentLabel")),
|
|
511
656
|
/** Get tracking summary. */
|
|
512
657
|
trackSummary: (params) => this.http.get(this.proxy("api/v3/Tracking/getUspsTrackingSummaryInformation"), params),
|
|
513
658
|
/** Get detailed tracking info. */
|
|
514
659
|
trackDetail: (params) => this.http.get(this.proxy("api/v3/Tracking/getUspsTrackingDetailInformation"), params),
|
|
515
|
-
/**
|
|
660
|
+
/**
|
|
661
|
+
* Schedule a carrier pickup.
|
|
662
|
+
*
|
|
663
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
664
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
665
|
+
* cover this.
|
|
666
|
+
*/
|
|
516
667
|
createPickup: (body) => this.http.post(this.proxy("api/v3/CarrierPickup/postUspsCreateCarrierPickupSchedule"), body),
|
|
517
|
-
/**
|
|
668
|
+
/**
|
|
669
|
+
* Cancel a pickup.
|
|
670
|
+
*
|
|
671
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
672
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
673
|
+
* cover this.
|
|
674
|
+
*/
|
|
518
675
|
cancelPickup: () => this.http.delete(this.proxy("api/v3/CarrierPickup/cancelUspsCarrierPickupSchedule")),
|
|
519
|
-
/**
|
|
676
|
+
/**
|
|
677
|
+
* Create a scan form.
|
|
678
|
+
*
|
|
679
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
680
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
681
|
+
* cover this.
|
|
682
|
+
*/
|
|
520
683
|
createScanForm: (body) => this.http.post(this.proxy("api/v3/ScanForm/postUspsCreateScanFormLabelShipment"), body),
|
|
521
684
|
/** Get delivery standards estimates. */
|
|
522
685
|
deliveryStandards: (params) => this.http.get(this.proxy("api/v3/ServiceStandards/getUspsGetDeliveryStandardsEstimates"), params),
|
|
@@ -529,77 +692,245 @@ var CarriersResource = class {
|
|
|
529
692
|
// UPS (V2 endpoints)
|
|
530
693
|
// -----------------------------------------------------------------------
|
|
531
694
|
ups = {
|
|
532
|
-
/**
|
|
695
|
+
/**
|
|
696
|
+
* Verify an address via UPS.
|
|
697
|
+
*
|
|
698
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
699
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
700
|
+
* cover this.
|
|
701
|
+
*/
|
|
533
702
|
validateAddress: (body) => this.http.post(this.proxy("api/v2/ShippingLabel/postUpsVerifyAddress"), body),
|
|
534
|
-
/**
|
|
703
|
+
/**
|
|
704
|
+
* Get UPS rate quotes.
|
|
705
|
+
*
|
|
706
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
707
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
708
|
+
* cover this.
|
|
709
|
+
*/
|
|
535
710
|
getRates: (body) => this.http.post(this.proxy("api/v2/ShippingLabel/postUpsRateCheck"), body),
|
|
536
|
-
/** Generate a UPS shipping label. */
|
|
537
|
-
createLabel: (body) => this.http.post(this.proxy("api/v2/ShippingLabel/generateNewUpsShipLabel"), body),
|
|
538
711
|
/** Track a UPS shipment. */
|
|
539
712
|
track: (params) => this.http.get(this.proxy("api/v2/ShippingLabel/getSingleUpsTrackingDetail"), params),
|
|
540
|
-
/**
|
|
713
|
+
/**
|
|
714
|
+
* Create a UPS pickup.
|
|
715
|
+
*
|
|
716
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
717
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
718
|
+
* cover this.
|
|
719
|
+
*/
|
|
541
720
|
createPickup: (body) => this.http.post(this.proxy("api/v2/ShippingLabel/postUpsCreatePickup"), body),
|
|
542
|
-
/**
|
|
721
|
+
/**
|
|
722
|
+
* Cancel a UPS pickup.
|
|
723
|
+
*
|
|
724
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
725
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
726
|
+
* cover this.
|
|
727
|
+
*/
|
|
543
728
|
cancelPickup: () => this.http.delete(this.proxy("api/v2/ShippingLabel/deleteUpsPickup")),
|
|
544
|
-
/**
|
|
729
|
+
/**
|
|
730
|
+
* Get UPS transit times.
|
|
731
|
+
*
|
|
732
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
733
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
734
|
+
* cover this.
|
|
735
|
+
*/
|
|
545
736
|
getTransitTimes: (body) => this.http.post(this.proxy("api/v2/ShippingLabel/postUpsGetTransitTimes"), body),
|
|
546
|
-
/**
|
|
737
|
+
/**
|
|
738
|
+
* Get UPS landed cost quote (international).
|
|
739
|
+
*
|
|
740
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
741
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
742
|
+
* cover this.
|
|
743
|
+
*/
|
|
547
744
|
getLandedCost: (body) => this.http.post(this.proxy("api/v2/ShippingLabel/postUpsGetLandedCostQuote"), body),
|
|
548
|
-
/**
|
|
745
|
+
/**
|
|
746
|
+
* Search UPS locations.
|
|
747
|
+
*
|
|
748
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
749
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
750
|
+
* cover this.
|
|
751
|
+
*/
|
|
549
752
|
searchLocations: (body) => this.http.post(this.proxy("api/v2/ShippingLabel/postUpsSearchLocations"), body),
|
|
550
|
-
/**
|
|
753
|
+
/**
|
|
754
|
+
* Upload paperless trade document.
|
|
755
|
+
*
|
|
756
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
757
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
758
|
+
* cover this.
|
|
759
|
+
*/
|
|
551
760
|
uploadDocument: (body) => this.http.post(this.proxy("api/v2/ShippingLabel/postUpsUploadPaperlessDocument"), body),
|
|
552
|
-
/**
|
|
761
|
+
/**
|
|
762
|
+
* Create UPS freight shipment.
|
|
763
|
+
*
|
|
764
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
765
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
766
|
+
* cover this.
|
|
767
|
+
*/
|
|
553
768
|
createFreightShipment: (body) => this.http.post(this.proxy("api/v2/ShippingLabel/postUpsCreateFreightShipment"), body),
|
|
554
|
-
/**
|
|
769
|
+
/**
|
|
770
|
+
* Get UPS freight rate.
|
|
771
|
+
*
|
|
772
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
773
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
774
|
+
* cover this.
|
|
775
|
+
*/
|
|
555
776
|
getFreightRate: (body) => this.http.post(this.proxy("api/v2/ShippingLabel/postUpsGetFreightRate"), body)
|
|
556
777
|
};
|
|
557
778
|
// -----------------------------------------------------------------------
|
|
558
779
|
// FedEx (V3 endpoints)
|
|
559
780
|
// -----------------------------------------------------------------------
|
|
560
781
|
fedex = {
|
|
561
|
-
/**
|
|
782
|
+
/**
|
|
783
|
+
* Validate a domestic address via FedEx.
|
|
784
|
+
*
|
|
785
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
786
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
787
|
+
* cover this.
|
|
788
|
+
*/
|
|
562
789
|
validateAddress: (body) => this.http.post(this.proxy("api/v3/AddressValidation/postFedExValidateAndCorrectDomesticAddress"), body),
|
|
563
|
-
/**
|
|
790
|
+
/**
|
|
791
|
+
* Validate a postal code.
|
|
792
|
+
*
|
|
793
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
794
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
795
|
+
* cover this.
|
|
796
|
+
*/
|
|
564
797
|
validatePostalCode: (body) => this.http.post(this.proxy("api/v3/AddressValidation/postFedExValidatePostalCode"), body),
|
|
565
|
-
/**
|
|
798
|
+
/**
|
|
799
|
+
* Get FedEx rate and transit times.
|
|
800
|
+
*
|
|
801
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
802
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
803
|
+
* cover this.
|
|
804
|
+
*/
|
|
566
805
|
getRates: (body) => this.http.post(this.proxy("api/v3/RateCalculator/postRetrieveFedExRateAndTransitTimesAsync"), body),
|
|
567
|
-
/**
|
|
568
|
-
|
|
569
|
-
|
|
806
|
+
/**
|
|
807
|
+
* Cancel a FedEx shipment.
|
|
808
|
+
*
|
|
809
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
810
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
811
|
+
* cover this.
|
|
812
|
+
*/
|
|
570
813
|
cancelShipment: (body) => this.http.put(this.proxy("api/v3/Shipping/putFedExCancelShipment"), body),
|
|
571
|
-
/**
|
|
814
|
+
/**
|
|
815
|
+
* Validate a shipment (dry run).
|
|
816
|
+
*
|
|
817
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
818
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
819
|
+
* cover this.
|
|
820
|
+
*/
|
|
572
821
|
validateShipment: (body) => this.http.post(this.proxy("api/v3/Shipping/postFedExValidateShipment"), body),
|
|
573
|
-
/**
|
|
574
|
-
|
|
575
|
-
|
|
822
|
+
/**
|
|
823
|
+
* Track by tracking number.
|
|
824
|
+
*
|
|
825
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
826
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
827
|
+
* cover this.
|
|
828
|
+
*/
|
|
576
829
|
track: (body) => this.http.post(this.proxy("api/v3/Tracking/postFedExRetrieveTrackingInfoByTrackingNumber"), body),
|
|
577
|
-
/**
|
|
830
|
+
/**
|
|
831
|
+
* Track multi-piece shipment.
|
|
832
|
+
*
|
|
833
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
834
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
835
|
+
* cover this.
|
|
836
|
+
*/
|
|
578
837
|
trackMultiPiece: (body) => this.http.post(this.proxy("api/v3/Tracking/postFedExRetrieveTrackingInfoForMultiPieceShipment"), body),
|
|
579
|
-
/**
|
|
838
|
+
/**
|
|
839
|
+
* Register for tracking notifications.
|
|
840
|
+
*
|
|
841
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
842
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
843
|
+
* cover this.
|
|
844
|
+
*/
|
|
580
845
|
registerTrackingNotification: (body) => this.http.post(this.proxy("api/v3/Tracking/postFedExRegisterForTrackingNotification"), body),
|
|
581
|
-
/**
|
|
846
|
+
/**
|
|
847
|
+
* Create a carrier pickup.
|
|
848
|
+
*
|
|
849
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
850
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
851
|
+
* cover this.
|
|
852
|
+
*/
|
|
582
853
|
createPickup: (body) => this.http.post(this.proxy("api/v3/CarrierPickup/postFedExCreateCarrierPickupRequest"), body),
|
|
583
|
-
/**
|
|
854
|
+
/**
|
|
855
|
+
* Cancel a pickup.
|
|
856
|
+
*
|
|
857
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
858
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
859
|
+
* cover this.
|
|
860
|
+
*/
|
|
584
861
|
cancelPickup: (body) => this.http.put(this.proxy("api/v3/CarrierPickup/putFedExCancelCarrierPickupRequest"), body),
|
|
585
|
-
/**
|
|
862
|
+
/**
|
|
863
|
+
* Search valid locations.
|
|
864
|
+
*
|
|
865
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
866
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
867
|
+
* cover this.
|
|
868
|
+
*/
|
|
586
869
|
searchLocations: (body) => this.http.post(this.proxy("api/v3/LocationSearch/postFedExSearchValidLocations"), body),
|
|
587
|
-
/**
|
|
870
|
+
/**
|
|
871
|
+
* Get service standards and transit times.
|
|
872
|
+
*
|
|
873
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
874
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
875
|
+
* cover this.
|
|
876
|
+
*/
|
|
588
877
|
getServiceStandards: (body) => this.http.post(this.proxy("api/v3/ServiceStandards/postFedExRetrieveServicesAndTransitTimes"), body),
|
|
589
|
-
/**
|
|
878
|
+
/**
|
|
879
|
+
* Get freight rate quote.
|
|
880
|
+
*
|
|
881
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
882
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
883
|
+
* cover this.
|
|
884
|
+
*/
|
|
590
885
|
getFreightRate: (body) => this.http.post(this.proxy("api/v3/Freight/postFedExGetFreightRateQuote"), body),
|
|
591
|
-
/**
|
|
886
|
+
/**
|
|
887
|
+
* Create freight shipment.
|
|
888
|
+
*
|
|
889
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
890
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
891
|
+
* cover this.
|
|
892
|
+
*/
|
|
592
893
|
createFreightShipment: (body) => this.http.post(this.proxy("api/v3/Freight/postFedExCreateFreightShipment"), body),
|
|
593
|
-
/**
|
|
894
|
+
/**
|
|
895
|
+
* Ground close with documents.
|
|
896
|
+
*
|
|
897
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
898
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
899
|
+
* cover this.
|
|
900
|
+
*/
|
|
594
901
|
groundClose: (body) => this.http.post(this.proxy("api/v3/GroundClose/postFedExCloseWithDocuments"), body),
|
|
595
|
-
/**
|
|
902
|
+
/**
|
|
903
|
+
* Upload trade documents.
|
|
904
|
+
*
|
|
905
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
906
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
907
|
+
* cover this.
|
|
908
|
+
*/
|
|
596
909
|
uploadTradeDocuments: (body) => this.http.post(this.proxy("api/v3/Trade/postFedExUploadTradeDocuments"), body),
|
|
597
910
|
// --- Open Ship (multi-package) ---
|
|
598
|
-
/**
|
|
911
|
+
/**
|
|
912
|
+
* Create an open shipment.
|
|
913
|
+
*
|
|
914
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
915
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
916
|
+
* cover this.
|
|
917
|
+
*/
|
|
599
918
|
createOpenShipment: (body) => this.http.post(this.proxy("api/v3/OpenShip/postFedExCreateOpenShipment"), body),
|
|
600
|
-
/**
|
|
919
|
+
/**
|
|
920
|
+
* Add packages to an open shipment.
|
|
921
|
+
*
|
|
922
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
923
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
924
|
+
* cover this.
|
|
925
|
+
*/
|
|
601
926
|
addPackagesToOpenShipment: (body) => this.http.post(this.proxy("api/v3/OpenShip/postFedExAddPackagesToOpenShipment"), body),
|
|
602
|
-
/**
|
|
927
|
+
/**
|
|
928
|
+
* Confirm and finalize an open shipment.
|
|
929
|
+
*
|
|
930
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
931
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
932
|
+
* cover this.
|
|
933
|
+
*/
|
|
603
934
|
confirmOpenShipment: (body) => this.http.post(this.proxy("api/v3/OpenShip/postFedExConfirmOpenShipment"), body)
|
|
604
935
|
};
|
|
605
936
|
// -----------------------------------------------------------------------
|
|
@@ -610,27 +941,59 @@ var CarriersResource = class {
|
|
|
610
941
|
validateAddress: (params) => this.http.get(this.proxy("api/v2/ShippingLabel/getDhlValidateAddress"), params),
|
|
611
942
|
/** Get DHL shipping rates. */
|
|
612
943
|
getRates: (params) => this.http.get(this.proxy("api/v2/ShippingLabel/getDhlRates"), params),
|
|
613
|
-
/**
|
|
944
|
+
/**
|
|
945
|
+
* Get multi-piece rates.
|
|
946
|
+
*
|
|
947
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
948
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
949
|
+
* cover this.
|
|
950
|
+
*/
|
|
614
951
|
getMultiPieceRates: (body) => this.http.post(this.proxy("api/v2/ShippingLabel/postDhlMultiPieceRates"), body),
|
|
615
952
|
/** Get DHL products/services. */
|
|
616
953
|
getProducts: (params) => this.http.get(this.proxy("api/v2/ShippingLabel/getDhlProducts"), params),
|
|
617
|
-
/** Create a DHL shipment (label). */
|
|
618
|
-
createShipment: (body) => this.http.post(this.proxy("api/v2/ShippingLabel/postDhlCreateShipment"), body),
|
|
619
954
|
/** Track a DHL shipment. */
|
|
620
955
|
track: (params) => this.http.get(this.proxy("api/v2/ShippingLabel/getDhlTrackSingleShipment"), params),
|
|
621
956
|
/** Track multiple DHL shipments. */
|
|
622
957
|
trackMultiple: (params) => this.http.get(this.proxy("api/v2/ShippingLabel/getDhlTrackMultipleShipments"), params),
|
|
623
|
-
/**
|
|
958
|
+
/**
|
|
959
|
+
* Create a DHL pickup.
|
|
960
|
+
*
|
|
961
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
962
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
963
|
+
* cover this.
|
|
964
|
+
*/
|
|
624
965
|
createPickup: (body) => this.http.post(this.proxy("api/v2/ShippingLabel/postDhlCreatePickup"), body),
|
|
625
|
-
/**
|
|
626
|
-
|
|
627
|
-
|
|
966
|
+
/**
|
|
967
|
+
* Cancel a DHL pickup.
|
|
968
|
+
*
|
|
969
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
970
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
971
|
+
* cover this.
|
|
972
|
+
*/
|
|
628
973
|
cancelPickup: () => this.http.delete(this.proxy("api/v2/ShippingLabel/deleteDhlPickup")),
|
|
629
|
-
/**
|
|
974
|
+
/**
|
|
975
|
+
* Calculate landed cost (duties/taxes).
|
|
976
|
+
*
|
|
977
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
978
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
979
|
+
* cover this.
|
|
980
|
+
*/
|
|
630
981
|
calculateLandedCost: (body) => this.http.post(this.proxy("api/v2/ShippingLabel/postDhlCalculateLandedCost"), body),
|
|
631
|
-
/**
|
|
982
|
+
/**
|
|
983
|
+
* Screen a shipment for compliance.
|
|
984
|
+
*
|
|
985
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
986
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
987
|
+
* cover this.
|
|
988
|
+
*/
|
|
632
989
|
screenShipment: (body) => this.http.post(this.proxy("api/v2/ShippingLabel/postDhlScreenShipment"), body),
|
|
633
|
-
/**
|
|
990
|
+
/**
|
|
991
|
+
* Upload an invoice.
|
|
992
|
+
*
|
|
993
|
+
* @deprecated Legacy carrier proxy (sunset 2027-06-30). Needs a user token: API keys get 403
|
|
994
|
+
* `API_KEY_SCOPE_REQUIRED`. Use `client.shipping` / `client.pickups` / `client.scanForms` where they
|
|
995
|
+
* cover this.
|
|
996
|
+
*/
|
|
634
997
|
uploadInvoice: (body) => this.http.post(this.proxy("api/v2/ShippingLabel/postDhlUploadInvoice"), body),
|
|
635
998
|
/** Get electronic proof of delivery. */
|
|
636
999
|
getProofOfDelivery: (params) => this.http.get(this.proxy("api/v2/ShippingLabel/getDhlElectronicProofOfDelivery"), params),
|
|
@@ -656,17 +1019,21 @@ var WebhooksResource = class {
|
|
|
656
1019
|
async list() {
|
|
657
1020
|
return this.http.get(this.wsPath(""));
|
|
658
1021
|
}
|
|
659
|
-
/**
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
1022
|
+
/**
|
|
1023
|
+
* Create a webhook subscription. `events` is sent as the Gateway's comma-separated `eventTypes`;
|
|
1024
|
+
* omit it to receive every event. The result's `data.secret` is the signing secret, returned only here.
|
|
1025
|
+
* @throws FlexOpsError (`UnknownWebhookEvent`) when `events` is empty or names an event FlexOps does not send.
|
|
1026
|
+
*/
|
|
664
1027
|
async create(request) {
|
|
665
|
-
|
|
1028
|
+
const body = await this.http.post(this.wsPath(""), toWireRequest(request));
|
|
1029
|
+
return toEnvelope(body);
|
|
666
1030
|
}
|
|
667
|
-
/**
|
|
1031
|
+
/**
|
|
1032
|
+
* Update a webhook subscription. `events`, when given, replaces the subscribed events.
|
|
1033
|
+
* @throws FlexOpsError (`UnknownWebhookEvent`) when `events` is empty or names an event FlexOps does not send.
|
|
1034
|
+
*/
|
|
668
1035
|
async update(webhookId, data) {
|
|
669
|
-
return this.http.put(this.wsPath(webhookId), data);
|
|
1036
|
+
return this.http.put(this.wsPath(webhookId), toWireRequest(data));
|
|
670
1037
|
}
|
|
671
1038
|
/** Delete a webhook subscription. */
|
|
672
1039
|
async delete(webhookId) {
|
|
@@ -680,23 +1047,80 @@ var WebhooksResource = class {
|
|
|
680
1047
|
async listDeliveryLogs(webhookId) {
|
|
681
1048
|
return this.http.get(this.wsPath(`${webhookId}/deliveries`));
|
|
682
1049
|
}
|
|
1050
|
+
/** Send a test event to a webhook's endpoint. */
|
|
1051
|
+
async test(webhookId) {
|
|
1052
|
+
return this.http.post(this.wsPath(`${webhookId}/test`));
|
|
1053
|
+
}
|
|
683
1054
|
/**
|
|
684
|
-
* Verify
|
|
685
|
-
*
|
|
1055
|
+
* Verify that an incoming request is a genuine FlexOps webhook delivery.
|
|
1056
|
+
*
|
|
1057
|
+
* FlexOps signs `{X-FlexOps-Timestamp}.{raw body}` with HMAC-SHA256, keyed with the
|
|
1058
|
+
* subscription secret (the whole `whsec_...` string), and sends
|
|
1059
|
+
* `X-FlexOps-Signature: sha256=<lowercase hex>`.
|
|
1060
|
+
*
|
|
1061
|
+
* @param payload The raw request body exactly as received (string or bytes). Do not pass
|
|
1062
|
+
* re-serialized JSON: `JSON.stringify(req.body)` will not reproduce the signed bytes.
|
|
1063
|
+
* @param signature The `X-FlexOps-Signature` header. `sha256=<hex>` and bare `<hex>` are accepted.
|
|
1064
|
+
* @param secret The subscription signing secret.
|
|
1065
|
+
* @param timestamp The `X-FlexOps-Timestamp` header (Unix seconds).
|
|
1066
|
+
* @param options `toleranceSeconds` (default 300) bounds how far the timestamp may be from now
|
|
1067
|
+
* in either direction; `now` (Unix seconds) overrides the clock, for tests.
|
|
1068
|
+
* @returns `true` only when the signature matches and the timestamp is within tolerance.
|
|
1069
|
+
* @throws TypeError when `secret` is empty or `payload` is not a string or bytes.
|
|
686
1070
|
*/
|
|
687
|
-
static verifySignature(payload, signature, secret) {
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
const expected = crypto.createHmac("sha256", secret).update(payload, "utf-8").digest("hex");
|
|
691
|
-
return crypto.timingSafeEqual(
|
|
692
|
-
Buffer.from(signature, "hex"),
|
|
693
|
-
Buffer.from(expected, "hex")
|
|
694
|
-
);
|
|
695
|
-
} catch {
|
|
696
|
-
return false;
|
|
1071
|
+
static verifySignature(payload, signature, secret, timestamp, options = {}) {
|
|
1072
|
+
if (typeof secret !== "string" || secret.length === 0) {
|
|
1073
|
+
throw new TypeError("A webhook signing secret is required.");
|
|
697
1074
|
}
|
|
1075
|
+
if (typeof payload !== "string" && !(payload instanceof Uint8Array)) {
|
|
1076
|
+
throw new TypeError("payload must be the raw request body as a string or bytes.");
|
|
1077
|
+
}
|
|
1078
|
+
const toleranceSeconds = options.toleranceSeconds ?? DEFAULT_TOLERANCE_SECONDS;
|
|
1079
|
+
if (!Number.isFinite(toleranceSeconds) || toleranceSeconds < 0) {
|
|
1080
|
+
throw new TypeError("toleranceSeconds must be a non-negative number.");
|
|
1081
|
+
}
|
|
1082
|
+
if (typeof signature !== "string" || typeof timestamp !== "string") return false;
|
|
1083
|
+
const ts = timestamp.trim();
|
|
1084
|
+
if (!/^[0-9]+$/.test(ts)) return false;
|
|
1085
|
+
const now = options.now ?? Date.now() / 1e3;
|
|
1086
|
+
if (!(Math.abs(now - Number(ts)) <= toleranceSeconds)) return false;
|
|
1087
|
+
let hex = signature.trim();
|
|
1088
|
+
if (hex.slice(0, SIGNATURE_PREFIX.length).toLowerCase() === SIGNATURE_PREFIX) {
|
|
1089
|
+
hex = hex.slice(SIGNATURE_PREFIX.length);
|
|
1090
|
+
}
|
|
1091
|
+
hex = hex.toLowerCase();
|
|
1092
|
+
if (!/^[0-9a-f]{64}$/.test(hex)) return false;
|
|
1093
|
+
const crypto = loadNodeCrypto("Webhook signature verification");
|
|
1094
|
+
const expected = crypto.createHmac("sha256", secret).update(`${ts}.`, "utf8").update(payload).digest();
|
|
1095
|
+
return crypto.timingSafeEqual(Buffer.from(hex, "hex"), expected);
|
|
698
1096
|
}
|
|
699
1097
|
};
|
|
1098
|
+
var DEFAULT_TOLERANCE_SECONDS = 300;
|
|
1099
|
+
var SIGNATURE_PREFIX = "sha256=";
|
|
1100
|
+
var KNOWN_EVENTS = new Set(Object.values(WebhookEventType));
|
|
1101
|
+
function toWireRequest(request) {
|
|
1102
|
+
const { events, ...rest } = request;
|
|
1103
|
+
if (events === void 0) return rest;
|
|
1104
|
+
if (!Array.isArray(events) || events.length === 0) {
|
|
1105
|
+
throw new FlexOpsError("events must name at least one event; omit it to receive every event.", 400, "UnknownWebhookEvent");
|
|
1106
|
+
}
|
|
1107
|
+
const unknown = events.filter((name) => !KNOWN_EVENTS.has(name));
|
|
1108
|
+
if (unknown.length > 0) {
|
|
1109
|
+
throw new FlexOpsError(
|
|
1110
|
+
`Unknown webhook event: ${unknown.join(", ")}. FlexOps sends ${[...KNOWN_EVENTS].join(", ")}.`,
|
|
1111
|
+
400,
|
|
1112
|
+
"UnknownWebhookEvent"
|
|
1113
|
+
);
|
|
1114
|
+
}
|
|
1115
|
+
return { ...rest, eventTypes: [...new Set(events)].join(",") };
|
|
1116
|
+
}
|
|
1117
|
+
function toEnvelope(body) {
|
|
1118
|
+
if (isObject(body) && isObject(body.data)) return body;
|
|
1119
|
+
return { success: true, data: body };
|
|
1120
|
+
}
|
|
1121
|
+
function isObject(value) {
|
|
1122
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1123
|
+
}
|
|
700
1124
|
|
|
701
1125
|
// src/resources/wallet.ts
|
|
702
1126
|
var WalletResource = class {
|
|
@@ -704,29 +1128,11 @@ var WalletResource = class {
|
|
|
704
1128
|
this.http = http;
|
|
705
1129
|
this.getWorkspaceId = getWorkspaceId;
|
|
706
1130
|
}
|
|
707
|
-
|
|
1131
|
+
/** Get the configured workspace's wallet balance. */
|
|
1132
|
+
async getBalance() {
|
|
708
1133
|
const id = this.getWorkspaceId();
|
|
709
1134
|
if (!id) throw new Error("workspaceId is required.");
|
|
710
|
-
return
|
|
711
|
-
}
|
|
712
|
-
/** Get the current wallet balance. */
|
|
713
|
-
async getBalance() {
|
|
714
|
-
return this.http.get(this.wsPath("balance"));
|
|
715
|
-
}
|
|
716
|
-
/** Add funds to the wallet. */
|
|
717
|
-
async addFunds(amount) {
|
|
718
|
-
return this.http.post(this.wsPath("add-funds"), { amount });
|
|
719
|
-
}
|
|
720
|
-
/** List wallet transactions. */
|
|
721
|
-
async listTransactions(query) {
|
|
722
|
-
return this.http.get(
|
|
723
|
-
this.wsPath("transactions"),
|
|
724
|
-
query
|
|
725
|
-
);
|
|
726
|
-
}
|
|
727
|
-
/** Configure auto-reload settings. */
|
|
728
|
-
async configureAutoReload(config) {
|
|
729
|
-
return this.http.put(this.wsPath("auto-reload"), config);
|
|
1135
|
+
return this.http.request("GET", "/api/wallet/my-balance", { headers: { "X-Workspace-Id": id } });
|
|
730
1136
|
}
|
|
731
1137
|
};
|
|
732
1138
|
|
|
@@ -749,17 +1155,27 @@ var InsuranceResource = class {
|
|
|
749
1155
|
async getQuote(request) {
|
|
750
1156
|
return this.http.post(this.wsPath("quote"), request);
|
|
751
1157
|
}
|
|
752
|
-
/**
|
|
753
|
-
|
|
754
|
-
|
|
1158
|
+
/**
|
|
1159
|
+
* Purchase insurance for a shipment. The premium is charged to the workspace wallet. A shipment
|
|
1160
|
+
* that already has a policy in force is refused with 409 `ALREADY_EXISTS`.
|
|
1161
|
+
*
|
|
1162
|
+
* Pass an `idempotencyKey` you store with the purchase to make your own retry safe: after an error or
|
|
1163
|
+
* a timeout, retry with the same key and the Gateway returns the first result instead of buying again.
|
|
1164
|
+
* Without one, the SDK's own retries still share a key, but a new call gets a new key.
|
|
1165
|
+
*/
|
|
1166
|
+
async purchase(request, idempotencyKey) {
|
|
1167
|
+
return this.http.request("POST", this.wsPath("policies"), {
|
|
1168
|
+
body: request,
|
|
1169
|
+
headers: idempotencyKey ? { "Idempotency-Key": idempotencyKey } : void 0
|
|
1170
|
+
});
|
|
755
1171
|
}
|
|
756
|
-
/** Void an insurance policy. */
|
|
1172
|
+
/** Void (cancel) an insurance policy. */
|
|
757
1173
|
async void(policyId) {
|
|
758
1174
|
return this.http.delete(this.wsPath(`policies/${policyId}`));
|
|
759
1175
|
}
|
|
760
|
-
/** File
|
|
761
|
-
async fileClaim(
|
|
762
|
-
return this.http.post(this.wsPath(
|
|
1176
|
+
/** File a claim against a policy. */
|
|
1177
|
+
async fileClaim(claim) {
|
|
1178
|
+
return this.http.post(this.wsPath("claims"), claim);
|
|
763
1179
|
}
|
|
764
1180
|
};
|
|
765
1181
|
|
|
@@ -772,9 +1188,9 @@ var ReturnsResource = class {
|
|
|
772
1188
|
wsPath(suffix) {
|
|
773
1189
|
const id = this.getWorkspaceId();
|
|
774
1190
|
if (!id) throw new Error("workspaceId is required.");
|
|
775
|
-
return `/api/workspaces/${id}/returns
|
|
1191
|
+
return `/api/workspaces/${id}/returns${suffix ? `/${suffix}` : ""}`;
|
|
776
1192
|
}
|
|
777
|
-
/** List
|
|
1193
|
+
/** List return authorizations, optionally created between `startDate` and `endDate` (ISO 8601). */
|
|
778
1194
|
async list(query) {
|
|
779
1195
|
return this.http.get(
|
|
780
1196
|
this.wsPath(""),
|
|
@@ -785,62 +1201,24 @@ var ReturnsResource = class {
|
|
|
785
1201
|
async get(returnId) {
|
|
786
1202
|
return this.http.get(this.wsPath(returnId));
|
|
787
1203
|
}
|
|
788
|
-
/** Create a return authorization (RMA). */
|
|
789
|
-
async create(request) {
|
|
790
|
-
return this.http.post(this.wsPath(""), request);
|
|
791
|
-
}
|
|
792
|
-
/** Approve a return authorization. */
|
|
793
|
-
async approve(returnId) {
|
|
794
|
-
return this.http.post(this.wsPath(`${returnId}/approve`));
|
|
795
|
-
}
|
|
796
|
-
/** Reject a return authorization. */
|
|
797
|
-
async reject(returnId, reason) {
|
|
798
|
-
return this.http.post(this.wsPath(`${returnId}/reject`), { reason });
|
|
799
|
-
}
|
|
800
|
-
/** Cancel a return authorization. */
|
|
801
|
-
async cancel(returnId) {
|
|
802
|
-
return this.http.post(this.wsPath(`${returnId}/cancel`));
|
|
803
|
-
}
|
|
804
|
-
/** Generate a return label for an approved RMA. */
|
|
805
|
-
async generateLabel(returnId) {
|
|
806
|
-
return this.http.post(this.wsPath(`${returnId}/label`));
|
|
807
|
-
}
|
|
808
|
-
/** Mark items as received. */
|
|
809
|
-
async markReceived(returnId, items) {
|
|
810
|
-
return this.http.post(this.wsPath(`${returnId}/receive`), { items });
|
|
811
|
-
}
|
|
812
|
-
/** Process refund for a return. */
|
|
813
|
-
async processRefund(returnId) {
|
|
814
|
-
return this.http.post(this.wsPath(`${returnId}/refund`));
|
|
815
|
-
}
|
|
816
|
-
};
|
|
817
|
-
|
|
818
|
-
// src/resources/api-keys.ts
|
|
819
|
-
var ApiKeysResource = class {
|
|
820
|
-
constructor(http, getWorkspaceId) {
|
|
821
|
-
this.http = http;
|
|
822
|
-
this.getWorkspaceId = getWorkspaceId;
|
|
823
|
-
}
|
|
824
|
-
wsPath(suffix) {
|
|
825
|
-
const id = this.getWorkspaceId();
|
|
826
|
-
if (!id) throw new Error("workspaceId is required.");
|
|
827
|
-
return `/api/workspaces/${id}/api-keys${suffix ? `/${suffix}` : ""}`;
|
|
828
|
-
}
|
|
829
|
-
/** List all API keys for the workspace. */
|
|
830
|
-
async list() {
|
|
831
|
-
return this.http.get(this.wsPath(""));
|
|
832
|
-
}
|
|
833
|
-
/** Create a new API key. The full key is only returned once. */
|
|
1204
|
+
/** Create a return authorization (RMA) for an order. */
|
|
834
1205
|
async create(request) {
|
|
835
|
-
return this.http.post(this.wsPath(""), request);
|
|
1206
|
+
return this.http.post(this.wsPath("rma"), request);
|
|
836
1207
|
}
|
|
837
|
-
/**
|
|
838
|
-
|
|
839
|
-
|
|
1208
|
+
/**
|
|
1209
|
+
* Generate a return label for an approved RMA.
|
|
1210
|
+
*
|
|
1211
|
+
* The Gateway binds a required request body, so one is always sent (`{}` when `request` is
|
|
1212
|
+
* omitted). Pass `weightOz`, `lengthIn`, `widthIn` and `heightIn`: a workspace with no default
|
|
1213
|
+
* shipping preset has nothing else to take the package from and the call fails with a 400 that
|
|
1214
|
+
* names the missing fields.
|
|
1215
|
+
*/
|
|
1216
|
+
async generateLabel(rmaNumber, request = {}) {
|
|
1217
|
+
return this.http.post(this.wsPath(`${rmaNumber}/label`), request);
|
|
840
1218
|
}
|
|
841
|
-
/**
|
|
842
|
-
async
|
|
843
|
-
return this.http.post(this.wsPath(`${
|
|
1219
|
+
/** Record the inspected items of a returned package at a warehouse. */
|
|
1220
|
+
async markReceived(rmaId, request) {
|
|
1221
|
+
return this.http.post(this.wsPath(`${rmaId}/receive`), request);
|
|
844
1222
|
}
|
|
845
1223
|
};
|
|
846
1224
|
|
|
@@ -922,10 +1300,6 @@ var OrdersResource = class {
|
|
|
922
1300
|
path(endpoint) {
|
|
923
1301
|
return `/api/ApiProxy/api/v1/Order/${endpoint}`;
|
|
924
1302
|
}
|
|
925
|
-
/** Create a new order. */
|
|
926
|
-
async create(order) {
|
|
927
|
-
return this.http.post(this.path("postNewOrder"), order);
|
|
928
|
-
}
|
|
929
1303
|
/** Get new orders awaiting processing. */
|
|
930
1304
|
async getNewOrders(params) {
|
|
931
1305
|
return this.http.get(this.path("getNewOrderList"), params);
|
|
@@ -946,10 +1320,6 @@ var OrdersResource = class {
|
|
|
946
1320
|
async getStatus(orderNumber) {
|
|
947
1321
|
return this.http.get(this.path("getIndividualOrderStatusByOrderNumber"), { orderNumber });
|
|
948
1322
|
}
|
|
949
|
-
/** Cancel an order. */
|
|
950
|
-
async cancel(orderNumber) {
|
|
951
|
-
return this.http.post(this.path("cancelOrderByOrderNumber"), { orderNumber });
|
|
952
|
-
}
|
|
953
1323
|
/** Get all items for an order. */
|
|
954
1324
|
async getItems(orderNumber) {
|
|
955
1325
|
return this.http.get(this.path("getAllOrderItemsByOrderNumber"), { orderNumber });
|
|
@@ -977,10 +1347,6 @@ var InventoryResource = class {
|
|
|
977
1347
|
constructor(http) {
|
|
978
1348
|
this.http = http;
|
|
979
1349
|
}
|
|
980
|
-
/** Post a new ASN (Advance Shipment Notice) receipt. */
|
|
981
|
-
async postAsnReceipt(receipt) {
|
|
982
|
-
return this.http.post("/api/ApiProxy/api/v1/Inventory/postNewAsnReceipt", receipt);
|
|
983
|
-
}
|
|
984
1350
|
/** Get a warehouse inventory snapshot. */
|
|
985
1351
|
async getWarehouseSnapshot(params) {
|
|
986
1352
|
return this.http.get("/api/ApiProxy/api/v1/Inventory/getWarehouseInventorySnapshot", params);
|
|
@@ -993,10 +1359,6 @@ var InventoryResource = class {
|
|
|
993
1359
|
async getPartNumbers(params) {
|
|
994
1360
|
return this.http.get("/api/ApiProxy/api/v1/Inventory/getPartNumberList", params);
|
|
995
1361
|
}
|
|
996
|
-
/** Update customer inventory (V2). */
|
|
997
|
-
async updateInventory(data) {
|
|
998
|
-
return this.http.post("/api/ApiProxy/api/v2/Inventory/postCustomerInventoryUpdate", data);
|
|
999
|
-
}
|
|
1000
1362
|
};
|
|
1001
1363
|
|
|
1002
1364
|
// src/resources/pickups.ts
|
|
@@ -1016,11 +1378,11 @@ var PickupsResource = class {
|
|
|
1016
1378
|
}
|
|
1017
1379
|
/** List scheduled pickups. */
|
|
1018
1380
|
async list() {
|
|
1019
|
-
return this.http.get(this.wsPath(""));
|
|
1381
|
+
return this.http.get(this.wsPath("scheduled"));
|
|
1020
1382
|
}
|
|
1021
|
-
/** Get pickup details. */
|
|
1022
|
-
async get(pickupId) {
|
|
1023
|
-
return this.http.get(this.wsPath(pickupId));
|
|
1383
|
+
/** Get pickup details. The carrier defaults to `usps` on the Gateway. */
|
|
1384
|
+
async get(pickupId, carrierCode) {
|
|
1385
|
+
return this.http.get(this.wsPath(pickupId), { carrierCode });
|
|
1024
1386
|
}
|
|
1025
1387
|
/** Cancel a scheduled pickup. */
|
|
1026
1388
|
async cancel(pickupId) {
|
|
@@ -1076,7 +1438,7 @@ var RulesResource = class {
|
|
|
1076
1438
|
async create(rule) {
|
|
1077
1439
|
return this.http.post(this.wsPath(""), rule);
|
|
1078
1440
|
}
|
|
1079
|
-
/**
|
|
1441
|
+
/** Replace a shipping rule. */
|
|
1080
1442
|
async update(ruleId, rule) {
|
|
1081
1443
|
return this.http.put(this.wsPath(ruleId), rule);
|
|
1082
1444
|
}
|
|
@@ -1084,62 +1446,66 @@ var RulesResource = class {
|
|
|
1084
1446
|
async delete(ruleId) {
|
|
1085
1447
|
return this.http.delete(this.wsPath(ruleId));
|
|
1086
1448
|
}
|
|
1087
|
-
/** Reorder rules (
|
|
1449
|
+
/** Reorder rules: each listed rule gets its position in `ruleIds` as its priority (0 first). */
|
|
1088
1450
|
async reorder(ruleIds) {
|
|
1089
|
-
return this.http.
|
|
1451
|
+
return this.http.post(this.wsPath("reorder"), {
|
|
1452
|
+
rules: ruleIds.map((ruleId, priority) => ({ ruleId, priority }))
|
|
1453
|
+
});
|
|
1454
|
+
}
|
|
1455
|
+
/** Dry-run the workspace's rules against a sample shipment, without changing anything. */
|
|
1456
|
+
async test(request) {
|
|
1457
|
+
return this.http.post(this.wsPath("test"), { tags: [], ...request });
|
|
1090
1458
|
}
|
|
1091
1459
|
};
|
|
1092
1460
|
|
|
1093
|
-
// src/resources/offsets.ts
|
|
1094
|
-
var
|
|
1461
|
+
// src/resources/carbon-offsets.ts
|
|
1462
|
+
var CarbonOffsetsResource = class {
|
|
1095
1463
|
constructor(http, getWorkspaceId) {
|
|
1096
1464
|
this.http = http;
|
|
1097
1465
|
this.getWorkspaceId = getWorkspaceId;
|
|
1098
1466
|
}
|
|
1099
|
-
wsPath(suffix) {
|
|
1467
|
+
wsPath(suffix = "") {
|
|
1100
1468
|
const id = this.getWorkspaceId();
|
|
1101
1469
|
if (!id) throw new Error("workspaceId is required.");
|
|
1102
|
-
return `/api/workspaces/${id}
|
|
1470
|
+
return `/api/workspaces/${id}/carbon-offsets${suffix ? `/${suffix}` : ""}`;
|
|
1103
1471
|
}
|
|
1104
|
-
/**
|
|
1105
|
-
async
|
|
1106
|
-
return this.http.post(this.wsPath(
|
|
1472
|
+
/** Quote an offset for a shipment without buying it. */
|
|
1473
|
+
async quote(request) {
|
|
1474
|
+
return this.http.post(this.wsPath("quote"), request);
|
|
1107
1475
|
}
|
|
1108
|
-
/**
|
|
1109
|
-
|
|
1110
|
-
|
|
1476
|
+
/**
|
|
1477
|
+
* Buy an offset for a shipment. The cost is charged to the workspace wallet and refunded if the
|
|
1478
|
+
* offset provider fails.
|
|
1479
|
+
*
|
|
1480
|
+
* Pass an `idempotencyKey` you store with the purchase to make your own retry safe: after an error or
|
|
1481
|
+
* a timeout, retry with the same key and the Gateway returns the first result instead of buying again.
|
|
1482
|
+
* Without one, the SDK's own retries still share a key, but a new call gets a new key.
|
|
1483
|
+
*/
|
|
1484
|
+
async purchase(request, idempotencyKey) {
|
|
1485
|
+
return this.http.request("POST", this.wsPath("purchase"), {
|
|
1486
|
+
body: request,
|
|
1487
|
+
headers: idempotencyKey ? { "Idempotency-Key": idempotencyKey } : void 0
|
|
1488
|
+
});
|
|
1111
1489
|
}
|
|
1112
|
-
/**
|
|
1113
|
-
async
|
|
1114
|
-
return this.http.
|
|
1490
|
+
/** List the workspace's offsets, newest first. */
|
|
1491
|
+
async list(query) {
|
|
1492
|
+
return this.http.get(this.wsPath(), query);
|
|
1115
1493
|
}
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
var HsCodesResource = class {
|
|
1120
|
-
constructor(http, getWorkspaceId) {
|
|
1121
|
-
this.http = http;
|
|
1122
|
-
this.getWorkspaceId = getWorkspaceId;
|
|
1494
|
+
/** Get one offset. */
|
|
1495
|
+
async get(offsetId) {
|
|
1496
|
+
return this.http.get(this.wsPath(offsetId));
|
|
1123
1497
|
}
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
return `/api/workspaces/${id}/${suffix}`;
|
|
1498
|
+
/** Totals across the workspace's offsets. */
|
|
1499
|
+
async getSummary() {
|
|
1500
|
+
return this.http.get(this.wsPath("summary"));
|
|
1128
1501
|
}
|
|
1129
|
-
/**
|
|
1130
|
-
async
|
|
1131
|
-
return this.http.get(this.wsPath("
|
|
1132
|
-
query,
|
|
1133
|
-
...options
|
|
1134
|
-
});
|
|
1502
|
+
/** Get the automatic-offset setting. */
|
|
1503
|
+
async getSettings() {
|
|
1504
|
+
return this.http.get(this.wsPath("settings"));
|
|
1135
1505
|
}
|
|
1136
|
-
/**
|
|
1137
|
-
async
|
|
1138
|
-
return this.http.
|
|
1139
|
-
}
|
|
1140
|
-
/** Estimate the total landed cost (duty + tax + shipping) for a shipment. Requires Enterprise plan. */
|
|
1141
|
-
async estimateLandedCost(request) {
|
|
1142
|
-
return this.http.post(this.wsPath("shipping/landed-cost"), request);
|
|
1506
|
+
/** Turn automatic offsets on or off. */
|
|
1507
|
+
async updateSettings(settings) {
|
|
1508
|
+
return this.http.put(this.wsPath("settings"), settings);
|
|
1143
1509
|
}
|
|
1144
1510
|
};
|
|
1145
1511
|
|
|
@@ -1149,115 +1515,136 @@ var RecurringShipmentsResource = class {
|
|
|
1149
1515
|
this.http = http;
|
|
1150
1516
|
this.getWorkspaceId = getWorkspaceId;
|
|
1151
1517
|
}
|
|
1152
|
-
wsPath(suffix) {
|
|
1518
|
+
wsPath(suffix = "") {
|
|
1153
1519
|
const id = this.getWorkspaceId();
|
|
1154
1520
|
if (!id) throw new Error("workspaceId is required.");
|
|
1155
|
-
return `/api/workspaces/${id}/recurring-shipments
|
|
1521
|
+
return `/api/workspaces/${id}/recurring-shipments${suffix ? `/${suffix}` : ""}`;
|
|
1156
1522
|
}
|
|
1157
|
-
/** List
|
|
1158
|
-
async list(
|
|
1159
|
-
return this.http.get(
|
|
1160
|
-
this.wsPath(""),
|
|
1161
|
-
query
|
|
1162
|
-
);
|
|
1523
|
+
/** List the workspace's recurring shipments. */
|
|
1524
|
+
async list() {
|
|
1525
|
+
return this.http.get(this.wsPath());
|
|
1163
1526
|
}
|
|
1164
|
-
/** Get
|
|
1527
|
+
/** Get one recurring shipment. */
|
|
1165
1528
|
async get(id) {
|
|
1166
1529
|
return this.http.get(this.wsPath(id));
|
|
1167
1530
|
}
|
|
1168
|
-
/** Create a recurring shipment
|
|
1531
|
+
/** Create a recurring shipment. The first run is at `firstRunUtc`. */
|
|
1169
1532
|
async create(request) {
|
|
1170
|
-
return this.http.post(this.wsPath(
|
|
1533
|
+
return this.http.post(this.wsPath(), request);
|
|
1171
1534
|
}
|
|
1172
|
-
/**
|
|
1535
|
+
/** Change a recurring shipment. Fields left out stay as they are. */
|
|
1173
1536
|
async update(id, request) {
|
|
1174
1537
|
return this.http.put(this.wsPath(id), request);
|
|
1175
1538
|
}
|
|
1176
|
-
/** Delete a recurring shipment
|
|
1539
|
+
/** Delete a recurring shipment. */
|
|
1177
1540
|
async delete(id) {
|
|
1178
|
-
|
|
1541
|
+
await this.http.delete(this.wsPath(id));
|
|
1179
1542
|
}
|
|
1180
|
-
/**
|
|
1543
|
+
/** Stop scheduled runs until `resume` is called. */
|
|
1181
1544
|
async pause(id) {
|
|
1182
|
-
|
|
1545
|
+
await this.http.post(this.wsPath(`${id}/pause`));
|
|
1183
1546
|
}
|
|
1184
|
-
/**
|
|
1547
|
+
/** Restart scheduled runs. */
|
|
1185
1548
|
async resume(id) {
|
|
1186
|
-
|
|
1549
|
+
await this.http.post(this.wsPath(`${id}/resume`));
|
|
1187
1550
|
}
|
|
1188
|
-
/**
|
|
1189
|
-
|
|
1190
|
-
|
|
1551
|
+
/**
|
|
1552
|
+
* Run a recurring shipment now, which creates an order. Pass your own `idempotencyKey` to make a
|
|
1553
|
+
* retry from your side safe too; the SDK's own retries always reuse one key.
|
|
1554
|
+
*/
|
|
1555
|
+
async trigger(id, idempotencyKey) {
|
|
1556
|
+
await this.http.request("POST", this.wsPath(`${id}/trigger`), {
|
|
1557
|
+
headers: idempotencyKey ? { "Idempotency-Key": idempotencyKey } : void 0
|
|
1558
|
+
});
|
|
1191
1559
|
}
|
|
1192
1560
|
};
|
|
1193
1561
|
|
|
1194
|
-
// src/resources/
|
|
1195
|
-
var
|
|
1562
|
+
// src/resources/report-schedules.ts
|
|
1563
|
+
var ReportSchedulesResource = class {
|
|
1196
1564
|
constructor(http, getWorkspaceId) {
|
|
1197
1565
|
this.http = http;
|
|
1198
1566
|
this.getWorkspaceId = getWorkspaceId;
|
|
1199
1567
|
}
|
|
1200
|
-
wsPath(suffix) {
|
|
1568
|
+
wsPath(suffix = "") {
|
|
1201
1569
|
const id = this.getWorkspaceId();
|
|
1202
1570
|
if (!id) throw new Error("workspaceId is required.");
|
|
1203
|
-
return `/api/workspaces/${id}/
|
|
1571
|
+
return `/api/workspaces/${id}/report-schedules${suffix ? `/${suffix}` : ""}`;
|
|
1204
1572
|
}
|
|
1205
|
-
/** List
|
|
1573
|
+
/** List the workspace's report schedules. */
|
|
1206
1574
|
async list() {
|
|
1207
|
-
return this.http.get(this.wsPath(
|
|
1575
|
+
return this.http.get(this.wsPath());
|
|
1208
1576
|
}
|
|
1209
|
-
/** Get
|
|
1577
|
+
/** Get one report schedule. */
|
|
1210
1578
|
async get(id) {
|
|
1211
1579
|
return this.http.get(this.wsPath(id));
|
|
1212
1580
|
}
|
|
1213
|
-
/** Create
|
|
1581
|
+
/** Create a report schedule. */
|
|
1214
1582
|
async create(request) {
|
|
1215
|
-
return this.http.post(this.wsPath(
|
|
1583
|
+
return this.http.post(this.wsPath(), request);
|
|
1216
1584
|
}
|
|
1217
|
-
/**
|
|
1585
|
+
/** Change a report schedule. Fields left out stay as they are. */
|
|
1218
1586
|
async update(id, request) {
|
|
1219
1587
|
return this.http.put(this.wsPath(id), request);
|
|
1220
1588
|
}
|
|
1221
|
-
/** Delete
|
|
1589
|
+
/** Delete a report schedule. */
|
|
1222
1590
|
async delete(id) {
|
|
1223
|
-
|
|
1591
|
+
await this.http.delete(this.wsPath(id));
|
|
1224
1592
|
}
|
|
1225
|
-
/**
|
|
1226
|
-
async
|
|
1227
|
-
return this.http.post(this.wsPath(`${id}/
|
|
1593
|
+
/** Turn a schedule on or off (flips `isEnabled`). */
|
|
1594
|
+
async toggle(id) {
|
|
1595
|
+
return this.http.post(this.wsPath(`${id}/toggle`));
|
|
1228
1596
|
}
|
|
1229
1597
|
};
|
|
1230
1598
|
|
|
1231
|
-
// src/resources/
|
|
1232
|
-
var
|
|
1599
|
+
// src/resources/email-templates.ts
|
|
1600
|
+
var EmailTemplatesResource = class {
|
|
1233
1601
|
constructor(http, getWorkspaceId) {
|
|
1234
1602
|
this.http = http;
|
|
1235
1603
|
this.getWorkspaceId = getWorkspaceId;
|
|
1236
1604
|
}
|
|
1237
|
-
wsPath(suffix) {
|
|
1605
|
+
wsPath(suffix = "") {
|
|
1238
1606
|
const id = this.getWorkspaceId();
|
|
1239
1607
|
if (!id) throw new Error("workspaceId is required.");
|
|
1240
|
-
return `/api/workspaces/${id}/
|
|
1608
|
+
return `/api/workspaces/${id}/email-templates${suffix ? `/${suffix}` : ""}`;
|
|
1241
1609
|
}
|
|
1242
|
-
/** List
|
|
1610
|
+
/** List the workspace's templates. */
|
|
1243
1611
|
async list() {
|
|
1244
|
-
return this.http.get(this.wsPath(
|
|
1612
|
+
return this.http.get(this.wsPath());
|
|
1245
1613
|
}
|
|
1246
|
-
/** Get
|
|
1247
|
-
async get(
|
|
1248
|
-
return this.http.get(this.wsPath(
|
|
1614
|
+
/** Get one template. */
|
|
1615
|
+
async get(templateId) {
|
|
1616
|
+
return this.http.get(this.wsPath(templateId));
|
|
1249
1617
|
}
|
|
1250
|
-
/** Create
|
|
1251
|
-
async
|
|
1252
|
-
return this.http.
|
|
1618
|
+
/** Create or replace the template for `request.eventType`. */
|
|
1619
|
+
async upsert(request) {
|
|
1620
|
+
return this.http.put(this.wsPath(), request);
|
|
1253
1621
|
}
|
|
1254
|
-
/**
|
|
1255
|
-
async
|
|
1256
|
-
|
|
1622
|
+
/** Delete a template; that event then uses the FlexOps default email. */
|
|
1623
|
+
async delete(templateId) {
|
|
1624
|
+
await this.http.delete(this.wsPath(templateId));
|
|
1257
1625
|
}
|
|
1258
|
-
/**
|
|
1259
|
-
async
|
|
1260
|
-
return this.http.
|
|
1626
|
+
/** Render a subject and body with sample shipment data, without saving anything. */
|
|
1627
|
+
async preview(request) {
|
|
1628
|
+
return this.http.post(this.wsPath("preview"), request);
|
|
1629
|
+
}
|
|
1630
|
+
};
|
|
1631
|
+
|
|
1632
|
+
// src/resources/hs-codes.ts
|
|
1633
|
+
var HsCodesResource = class {
|
|
1634
|
+
constructor(http) {
|
|
1635
|
+
this.http = http;
|
|
1636
|
+
}
|
|
1637
|
+
/** Search for HS codes by product description. Requires Enterprise plan. */
|
|
1638
|
+
async search(query, options) {
|
|
1639
|
+
return this.http.get("/api/shipping/hs-codes/search", { query, ...options });
|
|
1640
|
+
}
|
|
1641
|
+
/** Look up a specific HS code by its tariff number. Requires Enterprise plan. */
|
|
1642
|
+
async lookup(code) {
|
|
1643
|
+
return this.http.get(`/api/shipping/hs-codes/${encodeURIComponent(code)}`);
|
|
1644
|
+
}
|
|
1645
|
+
/** Estimate the total landed cost (duty + tax + shipping) for a shipment. Requires Enterprise plan. */
|
|
1646
|
+
async estimateLandedCost(request) {
|
|
1647
|
+
return this.http.post("/api/shipping/landed-cost", request);
|
|
1261
1648
|
}
|
|
1262
1649
|
};
|
|
1263
1650
|
|
|
@@ -1274,18 +1661,17 @@ var FlexOps = class {
|
|
|
1274
1661
|
wallet;
|
|
1275
1662
|
insurance;
|
|
1276
1663
|
returns;
|
|
1277
|
-
apiKeys;
|
|
1278
1664
|
analytics;
|
|
1279
1665
|
orders;
|
|
1280
1666
|
inventory;
|
|
1281
1667
|
pickups;
|
|
1282
1668
|
scanForms;
|
|
1283
1669
|
rules;
|
|
1284
|
-
|
|
1285
|
-
hsCodes;
|
|
1670
|
+
carbonOffsets;
|
|
1286
1671
|
recurringShipments;
|
|
1672
|
+
reportSchedules;
|
|
1287
1673
|
emailTemplates;
|
|
1288
|
-
|
|
1674
|
+
hsCodes;
|
|
1289
1675
|
constructor(config = {}) {
|
|
1290
1676
|
this.http = new HttpClient(config);
|
|
1291
1677
|
this._workspaceId = config.workspaceId;
|
|
@@ -1298,18 +1684,17 @@ var FlexOps = class {
|
|
|
1298
1684
|
this.wallet = new WalletResource(this.http, getWsId);
|
|
1299
1685
|
this.insurance = new InsuranceResource(this.http, getWsId);
|
|
1300
1686
|
this.returns = new ReturnsResource(this.http, getWsId);
|
|
1301
|
-
this.apiKeys = new ApiKeysResource(this.http, getWsId);
|
|
1302
1687
|
this.analytics = new AnalyticsResource(this.http);
|
|
1303
1688
|
this.orders = new OrdersResource(this.http);
|
|
1304
1689
|
this.inventory = new InventoryResource(this.http);
|
|
1305
1690
|
this.pickups = new PickupsResource(this.http, getWsId);
|
|
1306
1691
|
this.scanForms = new ScanFormsResource(this.http, getWsId);
|
|
1307
1692
|
this.rules = new RulesResource(this.http, getWsId);
|
|
1308
|
-
this.
|
|
1309
|
-
this.hsCodes = new HsCodesResource(this.http, getWsId);
|
|
1693
|
+
this.carbonOffsets = new CarbonOffsetsResource(this.http, getWsId);
|
|
1310
1694
|
this.recurringShipments = new RecurringShipmentsResource(this.http, getWsId);
|
|
1695
|
+
this.reportSchedules = new ReportSchedulesResource(this.http, getWsId);
|
|
1311
1696
|
this.emailTemplates = new EmailTemplatesResource(this.http, getWsId);
|
|
1312
|
-
this.
|
|
1697
|
+
this.hsCodes = new HsCodesResource(this.http);
|
|
1313
1698
|
}
|
|
1314
1699
|
/** Get or set the active workspace ID. */
|
|
1315
1700
|
get workspaceId() {
|
|
@@ -1330,27 +1715,33 @@ var FlexOps = class {
|
|
|
1330
1715
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1331
1716
|
0 && (module.exports = {
|
|
1332
1717
|
AnalyticsResource,
|
|
1333
|
-
ApiKeysResource,
|
|
1334
1718
|
AuthResource,
|
|
1719
|
+
CarbonOffsetsResource,
|
|
1335
1720
|
CarriersResource,
|
|
1336
1721
|
EmailTemplatesResource,
|
|
1337
1722
|
FlexOps,
|
|
1338
1723
|
FlexOpsAuthError,
|
|
1339
1724
|
FlexOpsError,
|
|
1340
1725
|
FlexOpsRateLimitError,
|
|
1726
|
+
HazmatClassification,
|
|
1341
1727
|
HsCodesResource,
|
|
1342
1728
|
InsuranceResource,
|
|
1343
1729
|
InventoryResource,
|
|
1344
|
-
OffsetResource,
|
|
1345
1730
|
OrdersResource,
|
|
1346
1731
|
PickupsResource,
|
|
1732
|
+
RecurrenceInterval,
|
|
1347
1733
|
RecurringShipmentsResource,
|
|
1348
|
-
|
|
1734
|
+
ReportFormat,
|
|
1735
|
+
ReportFrequency,
|
|
1736
|
+
ReportSchedulesResource,
|
|
1349
1737
|
ReturnsResource,
|
|
1350
1738
|
RulesResource,
|
|
1351
1739
|
ScanFormsResource,
|
|
1352
1740
|
ShippingResource,
|
|
1741
|
+
TrackingEmailEvent,
|
|
1353
1742
|
WalletResource,
|
|
1743
|
+
WebhookEventType,
|
|
1354
1744
|
WebhooksResource,
|
|
1745
|
+
WorkspaceRole,
|
|
1355
1746
|
WorkspacesResource
|
|
1356
1747
|
});
|