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