@lonca/trendyol 0.7.0 → 0.9.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 +28 -26
- package/dist/index.cjs +394 -99
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +285 -39
- package/dist/index.d.ts +285 -39
- package/dist/index.js +393 -100
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -91,13 +91,11 @@ function normalizeAttribute(node) {
|
|
|
91
91
|
var MAX_ATTR_VALUES_PAGE_SIZE = 1e3;
|
|
92
92
|
var DEFAULT_ATTR_VALUES_PAGE_SIZE = 100;
|
|
93
93
|
var CategoriesResource = class {
|
|
94
|
-
constructor(transport, limiter
|
|
94
|
+
constructor(transport, limiter) {
|
|
95
95
|
this.transport = transport;
|
|
96
|
-
this.sellerId = sellerId;
|
|
97
96
|
this.limiter = limiter ?? new core.TokenBucketRateLimiter({ capacity: 50, intervalMs: 6e4 });
|
|
98
97
|
}
|
|
99
98
|
transport;
|
|
100
|
-
sellerId;
|
|
101
99
|
limiter;
|
|
102
100
|
/**
|
|
103
101
|
* Fetch the full Trendyol category tree.
|
|
@@ -193,21 +191,14 @@ var CategoriesResource = class {
|
|
|
193
191
|
*
|
|
194
192
|
* @param barcodes 1–N barcodes to look up.
|
|
195
193
|
* @throws {ValidationError} when `barcodes` is empty.
|
|
196
|
-
* @throws Error when the client was created without a `sellerId` and this
|
|
197
|
-
* method is called directly (use `createTrendyolClient` to wire it).
|
|
198
194
|
*/
|
|
199
195
|
async getByBarcodes(barcodes) {
|
|
200
196
|
if (!Array.isArray(barcodes) || barcodes.length === 0) {
|
|
201
197
|
throw new core.ValidationError({ message: "getByBarcodes: barcodes must not be empty" });
|
|
202
198
|
}
|
|
203
|
-
if (this.sellerId === void 0) {
|
|
204
|
-
throw new Error(
|
|
205
|
-
"CategoriesResource.getByBarcodes requires a sellerId; instantiate via createTrendyolClient"
|
|
206
|
-
);
|
|
207
|
-
}
|
|
208
199
|
const data = await this.transport.request({
|
|
209
200
|
method: "POST",
|
|
210
|
-
path: `/integration/ecgw/v1/${this.sellerId}/lookup/product-categories/by-barcodes`,
|
|
201
|
+
path: `/integration/ecgw/v1/${this.transport.sellerId}/lookup/product-categories/by-barcodes`,
|
|
211
202
|
body: { barcodes },
|
|
212
203
|
rateLimiter: this.limiter
|
|
213
204
|
});
|
|
@@ -255,13 +246,11 @@ function normalizeClaim(node) {
|
|
|
255
246
|
return out;
|
|
256
247
|
}
|
|
257
248
|
var ClaimsResource = class {
|
|
258
|
-
constructor(transport,
|
|
249
|
+
constructor(transport, limiter) {
|
|
259
250
|
this.transport = transport;
|
|
260
|
-
this.sellerId = sellerId;
|
|
261
251
|
this.limiter = limiter ?? new core.TokenBucketRateLimiter({ capacity: 1e3, intervalMs: 6e4 });
|
|
262
252
|
}
|
|
263
253
|
transport;
|
|
264
|
-
sellerId;
|
|
265
254
|
limiter;
|
|
266
255
|
/**
|
|
267
256
|
* Create a return claim against an order. Use this to file a return on
|
|
@@ -279,7 +268,7 @@ var ClaimsResource = class {
|
|
|
279
268
|
}
|
|
280
269
|
return this.transport.request({
|
|
281
270
|
method: "POST",
|
|
282
|
-
path: `/integration/order/sellers/${this.sellerId}/claims/create`,
|
|
271
|
+
path: `/integration/order/sellers/${this.transport.sellerId}/claims/create`,
|
|
283
272
|
body: input,
|
|
284
273
|
rateLimiter: this.limiter
|
|
285
274
|
});
|
|
@@ -317,7 +306,7 @@ var ClaimsResource = class {
|
|
|
317
306
|
}
|
|
318
307
|
return this.transport.request({
|
|
319
308
|
method: "POST",
|
|
320
|
-
path: `/integration/order/sellers/${this.sellerId}/claims/${encodeURIComponent(claimId)}/issue`,
|
|
309
|
+
path: `/integration/order/sellers/${this.transport.sellerId}/claims/${encodeURIComponent(claimId)}/issue`,
|
|
321
310
|
body: form,
|
|
322
311
|
rateLimiter: this.limiter
|
|
323
312
|
});
|
|
@@ -336,7 +325,7 @@ var ClaimsResource = class {
|
|
|
336
325
|
}
|
|
337
326
|
return this.transport.request({
|
|
338
327
|
method: "PUT",
|
|
339
|
-
path: `/integration/order/sellers/${this.sellerId}/claims/${encodeURIComponent(claimId)}/items/approve`,
|
|
328
|
+
path: `/integration/order/sellers/${this.transport.sellerId}/claims/${encodeURIComponent(claimId)}/items/approve`,
|
|
340
329
|
body: input,
|
|
341
330
|
rateLimiter: this.limiter
|
|
342
331
|
});
|
|
@@ -363,7 +352,7 @@ var ClaimsResource = class {
|
|
|
363
352
|
if (params.claimItemStatus) query.claimItemStatus = params.claimItemStatus;
|
|
364
353
|
const data = await this.transport.request({
|
|
365
354
|
method: "GET",
|
|
366
|
-
path: `/integration/order/sellers/${this.sellerId}/claims`,
|
|
355
|
+
path: `/integration/order/sellers/${this.transport.sellerId}/claims`,
|
|
367
356
|
query,
|
|
368
357
|
rateLimiter: this.limiter
|
|
369
358
|
});
|
|
@@ -401,13 +390,276 @@ var ClaimsResource = class {
|
|
|
401
390
|
async getItemAudits(claimItemId) {
|
|
402
391
|
const data = await this.transport.request({
|
|
403
392
|
method: "GET",
|
|
404
|
-
path: `/integration/order/sellers/${this.sellerId}/claims/items/${encodeURIComponent(claimItemId)}/audit`,
|
|
393
|
+
path: `/integration/order/sellers/${this.transport.sellerId}/claims/items/${encodeURIComponent(claimItemId)}/audit`,
|
|
405
394
|
rateLimiter: this.limiter
|
|
406
395
|
});
|
|
407
396
|
const rows = Array.isArray(data) ? data : Array.isArray(data?.content) ? data.content : [];
|
|
408
397
|
return rows.map((row) => ({ raw: row }));
|
|
409
398
|
}
|
|
410
399
|
};
|
|
400
|
+
var MAX_BATCH_ITEMS = 5e3;
|
|
401
|
+
var ExportCenterResource = class {
|
|
402
|
+
constructor(transport, limiter) {
|
|
403
|
+
this.transport = transport;
|
|
404
|
+
this.limiter = limiter ?? new core.TokenBucketRateLimiter({ capacity: 1e3, intervalMs: 6e4 });
|
|
405
|
+
}
|
|
406
|
+
transport;
|
|
407
|
+
limiter;
|
|
408
|
+
// ─── Products ────────────────────────────────────────────────────────────
|
|
409
|
+
/**
|
|
410
|
+
* List Export Center-approved products. Uses Trendyol's `pageKey`
|
|
411
|
+
* pagination — the first call leaves `pageKey` empty; subsequent
|
|
412
|
+
* calls pass the `x-paging-key` value from the previous response.
|
|
413
|
+
*/
|
|
414
|
+
async listProducts(params = {}) {
|
|
415
|
+
const query = {};
|
|
416
|
+
if (params.barcodes && params.barcodes.length > 0) query.barcodes = params.barcodes.join(",");
|
|
417
|
+
if (params.pageKey) query.pageKey = params.pageKey;
|
|
418
|
+
if (params.size !== void 0) query.size = params.size;
|
|
419
|
+
const data = await this.transport.request({
|
|
420
|
+
method: "GET",
|
|
421
|
+
path: `/integration/ecgw/v2/${this.transport.sellerId}/products`,
|
|
422
|
+
query: Object.keys(query).length ? query : void 0,
|
|
423
|
+
rateLimiter: this.limiter
|
|
424
|
+
});
|
|
425
|
+
const rows = pickArray(data);
|
|
426
|
+
return rows.map((r) => ({ raw: r ?? {} }));
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Create Export Center products. Maximum 5000 per call. Returns a
|
|
430
|
+
* `batchId` you can poll via `getBatchStatus(batchId)`.
|
|
431
|
+
*
|
|
432
|
+
* @throws {ValidationError} when `products` is empty / oversized.
|
|
433
|
+
*/
|
|
434
|
+
async createProducts(products) {
|
|
435
|
+
this.assertBatch(products, "createProducts");
|
|
436
|
+
const data = await this.transport.request({
|
|
437
|
+
method: "POST",
|
|
438
|
+
path: `/integration/ecgw/v2/${this.transport.sellerId}/products`,
|
|
439
|
+
body: { products },
|
|
440
|
+
rateLimiter: this.limiter
|
|
441
|
+
});
|
|
442
|
+
return normalizeBatchResponse(data);
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Update Export Center prices. **Trendyol allows one price update per
|
|
446
|
+
* barcode per day.** Returns a `batchId`.
|
|
447
|
+
*
|
|
448
|
+
* @throws {ValidationError} when `priceInfos` is empty / oversized.
|
|
449
|
+
*/
|
|
450
|
+
async updatePrices(priceInfos) {
|
|
451
|
+
this.assertBatch(priceInfos, "updatePrices");
|
|
452
|
+
const data = await this.transport.request({
|
|
453
|
+
method: "POST",
|
|
454
|
+
path: `/integration/ecgw/v1/${this.transport.sellerId}/prices`,
|
|
455
|
+
body: { priceInfos },
|
|
456
|
+
rateLimiter: this.limiter
|
|
457
|
+
});
|
|
458
|
+
return normalizeBatchResponse(data);
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Update Export Center stocks. Returns a `batchId`. Sellers using
|
|
462
|
+
* Trendyol's shared inventory cannot use this endpoint (per portal docs).
|
|
463
|
+
*
|
|
464
|
+
* @throws {ValidationError} when `items` is empty / oversized.
|
|
465
|
+
*/
|
|
466
|
+
async updateStocks(items) {
|
|
467
|
+
this.assertBatch(items, "updateStocks");
|
|
468
|
+
const data = await this.transport.request({
|
|
469
|
+
method: "POST",
|
|
470
|
+
path: `/integration/ecgw/v1/${this.transport.sellerId}/stocks`,
|
|
471
|
+
body: { items },
|
|
472
|
+
rateLimiter: this.limiter
|
|
473
|
+
});
|
|
474
|
+
return normalizeBatchResponse(data);
|
|
475
|
+
}
|
|
476
|
+
// ─── Batch status ────────────────────────────────────────────────────────
|
|
477
|
+
/**
|
|
478
|
+
* Look up the status of a previously-submitted batch. Trendyol retains
|
|
479
|
+
* batch records for **24 hours** only — older `batchId`s return `404`.
|
|
480
|
+
*/
|
|
481
|
+
async getBatchStatus(batchId) {
|
|
482
|
+
if (!batchId) {
|
|
483
|
+
throw new core.ValidationError({ message: "exportCenter.getBatchStatus: batchId is required" });
|
|
484
|
+
}
|
|
485
|
+
const data = await this.transport.request({
|
|
486
|
+
method: "GET",
|
|
487
|
+
path: `/integration/ecgw/v1/${this.transport.sellerId}/check-status`,
|
|
488
|
+
query: { batchId },
|
|
489
|
+
rateLimiter: this.limiter
|
|
490
|
+
});
|
|
491
|
+
return normalizeBatchStatus(data);
|
|
492
|
+
}
|
|
493
|
+
// ─── Packages ────────────────────────────────────────────────────────────
|
|
494
|
+
/** List daily Export Center packages (V2 — query-based filters). */
|
|
495
|
+
async listPackagesV2(params = {}) {
|
|
496
|
+
const data = await this.transport.request({
|
|
497
|
+
method: "GET",
|
|
498
|
+
path: `/integration/ecgw/v2/${this.transport.sellerId}/packages`,
|
|
499
|
+
query: {
|
|
500
|
+
trackingNumber: params.trackingNumber,
|
|
501
|
+
status: params.status,
|
|
502
|
+
creationStartDate: params.creationStartDate,
|
|
503
|
+
creationEndDate: params.creationEndDate,
|
|
504
|
+
size: params.size,
|
|
505
|
+
boutiqueId: params.boutiqueId
|
|
506
|
+
},
|
|
507
|
+
rateLimiter: this.limiter
|
|
508
|
+
});
|
|
509
|
+
return pickArray(data).map(normalizePackage);
|
|
510
|
+
}
|
|
511
|
+
/** List Export Center packages (V3 — consolidated, page-based). */
|
|
512
|
+
async listPackagesV3(params = {}) {
|
|
513
|
+
const data = await this.transport.request({
|
|
514
|
+
method: "GET",
|
|
515
|
+
path: `/integration/ecgw/v3/${this.transport.sellerId}/packages`,
|
|
516
|
+
query: {
|
|
517
|
+
status: params.status,
|
|
518
|
+
page: params.offset !== void 0 ? params.offset : void 0,
|
|
519
|
+
size: params.limit,
|
|
520
|
+
creationStartDate: params.creationStartDate,
|
|
521
|
+
creationEndDate: params.creationEndDate
|
|
522
|
+
},
|
|
523
|
+
rateLimiter: this.limiter
|
|
524
|
+
});
|
|
525
|
+
return pickArray(data).map(normalizePackage);
|
|
526
|
+
}
|
|
527
|
+
/** Get the line items inside an Export Center package. */
|
|
528
|
+
async getPackageItems(params) {
|
|
529
|
+
if (!params || !params.packageId) {
|
|
530
|
+
throw new core.ValidationError({
|
|
531
|
+
message: "exportCenter.getPackageItems: packageId is required"
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
const data = await this.transport.request({
|
|
535
|
+
method: "GET",
|
|
536
|
+
path: `/integration/ecgw/v2/${this.transport.sellerId}/packages/items`,
|
|
537
|
+
query: {
|
|
538
|
+
packageId: params.packageId,
|
|
539
|
+
status: params.status,
|
|
540
|
+
page: params.offset,
|
|
541
|
+
size: params.limit
|
|
542
|
+
},
|
|
543
|
+
rateLimiter: this.limiter
|
|
544
|
+
});
|
|
545
|
+
return pickArray(data).map((r) => ({ raw: r ?? {} }));
|
|
546
|
+
}
|
|
547
|
+
// ─── Lookup ──────────────────────────────────────────────────────────────
|
|
548
|
+
/** Get the required attributes for an Export Center category. */
|
|
549
|
+
async getCategoryAttributes(categoryId) {
|
|
550
|
+
if (categoryId === void 0 || categoryId === null || categoryId === "") {
|
|
551
|
+
throw new core.ValidationError({
|
|
552
|
+
message: "exportCenter.getCategoryAttributes: categoryId is required"
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
const data = await this.transport.request({
|
|
556
|
+
method: "GET",
|
|
557
|
+
path: `/integration/ecgw/v1/${this.transport.sellerId}/lookup/product-categories/${encodeURIComponent(String(categoryId))}/attributes`,
|
|
558
|
+
rateLimiter: this.limiter
|
|
559
|
+
});
|
|
560
|
+
return pickArray(data).map((r) => {
|
|
561
|
+
const row = r ?? {};
|
|
562
|
+
const out = { raw: row };
|
|
563
|
+
if (typeof row.attributeId === "number" || typeof row.attributeId === "string") {
|
|
564
|
+
out.attributeId = row.attributeId;
|
|
565
|
+
}
|
|
566
|
+
if (typeof row.attributeName === "string") out.attributeName = row.attributeName;
|
|
567
|
+
if (typeof row.required === "boolean") out.required = row.required;
|
|
568
|
+
if (Array.isArray(row.values)) out.values = row.values;
|
|
569
|
+
return out;
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
/** Get the care-instruction lookup values used by `createProducts`. */
|
|
573
|
+
async getCareInstructions() {
|
|
574
|
+
const data = await this.transport.request({
|
|
575
|
+
method: "GET",
|
|
576
|
+
path: `/integration/ecgw/v1/${this.transport.sellerId}/lookup/care-instructions`,
|
|
577
|
+
rateLimiter: this.limiter
|
|
578
|
+
});
|
|
579
|
+
return pickArray(data).map(normalizeNamedRef);
|
|
580
|
+
}
|
|
581
|
+
/** Get the material-composition lookup values used by `createProducts`. */
|
|
582
|
+
async getCompositions() {
|
|
583
|
+
const data = await this.transport.request({
|
|
584
|
+
method: "GET",
|
|
585
|
+
path: `/integration/ecgw/v1/${this.transport.sellerId}/lookup/compositions`,
|
|
586
|
+
rateLimiter: this.limiter
|
|
587
|
+
});
|
|
588
|
+
return pickArray(data).map(normalizeNamedRef);
|
|
589
|
+
}
|
|
590
|
+
/** Get the country-of-origin lookup values used by `createProducts`. */
|
|
591
|
+
async getOrigins() {
|
|
592
|
+
const data = await this.transport.request({
|
|
593
|
+
method: "GET",
|
|
594
|
+
path: `/integration/ecgw/v1/${this.transport.sellerId}/lookup/origins`,
|
|
595
|
+
rateLimiter: this.limiter
|
|
596
|
+
});
|
|
597
|
+
return pickArray(data).map((r) => {
|
|
598
|
+
const row = r ?? {};
|
|
599
|
+
const out = { raw: row };
|
|
600
|
+
if (typeof row.id === "number" || typeof row.id === "string") out.id = row.id;
|
|
601
|
+
if (typeof row.name === "string") out.name = row.name;
|
|
602
|
+
if (typeof row.countryCode === "string") out.countryCode = row.countryCode;
|
|
603
|
+
return out;
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
// ─── Helpers ─────────────────────────────────────────────────────────────
|
|
607
|
+
assertBatch(items, methodLabel) {
|
|
608
|
+
if (!Array.isArray(items) || items.length === 0) {
|
|
609
|
+
throw new core.ValidationError({
|
|
610
|
+
message: `exportCenter.${methodLabel}: items must not be empty`
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
if (items.length > MAX_BATCH_ITEMS) {
|
|
614
|
+
throw new core.ValidationError({
|
|
615
|
+
message: `exportCenter.${methodLabel}: max ${MAX_BATCH_ITEMS} items per call (got ${items.length})`
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
};
|
|
620
|
+
function pickArray(data) {
|
|
621
|
+
if (Array.isArray(data)) return data;
|
|
622
|
+
if (data && typeof data === "object") {
|
|
623
|
+
const obj = data;
|
|
624
|
+
if (Array.isArray(obj.content)) return obj.content;
|
|
625
|
+
if (Array.isArray(obj.items)) return obj.items;
|
|
626
|
+
if (Array.isArray(obj.data)) return obj.data;
|
|
627
|
+
if (Array.isArray(obj.products)) return obj.products;
|
|
628
|
+
if (Array.isArray(obj.packages)) return obj.packages;
|
|
629
|
+
}
|
|
630
|
+
return [];
|
|
631
|
+
}
|
|
632
|
+
function normalizeBatchResponse(data) {
|
|
633
|
+
const obj = data && typeof data === "object" ? data : {};
|
|
634
|
+
return {
|
|
635
|
+
batchId: String(obj.batchId ?? obj.batchRequestId ?? obj.id ?? ""),
|
|
636
|
+
raw: obj
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
function normalizeBatchStatus(data) {
|
|
640
|
+
const obj = data && typeof data === "object" ? data : {};
|
|
641
|
+
const out = { raw: obj };
|
|
642
|
+
if (typeof obj.batchId === "string") out.batchId = obj.batchId;
|
|
643
|
+
if (typeof obj.status === "string") out.status = obj.status;
|
|
644
|
+
if (typeof obj.itemCount === "number") out.itemCount = obj.itemCount;
|
|
645
|
+
if (typeof obj.failedItemCount === "number") out.failedItemCount = obj.failedItemCount;
|
|
646
|
+
if (Array.isArray(obj.items)) out.items = obj.items;
|
|
647
|
+
return out;
|
|
648
|
+
}
|
|
649
|
+
function normalizePackage(row) {
|
|
650
|
+
const r = row ?? {};
|
|
651
|
+
const out = { raw: r };
|
|
652
|
+
if (typeof r.packageNumber === "string") out.packageNumber = r.packageNumber;
|
|
653
|
+
if (typeof r.status === "string") out.status = r.status;
|
|
654
|
+
return out;
|
|
655
|
+
}
|
|
656
|
+
function normalizeNamedRef(row) {
|
|
657
|
+
const r = row ?? {};
|
|
658
|
+
const out = { raw: r };
|
|
659
|
+
if (typeof r.id === "number" || typeof r.id === "string") out.id = r.id;
|
|
660
|
+
if (typeof r.name === "string") out.name = r.name;
|
|
661
|
+
return out;
|
|
662
|
+
}
|
|
411
663
|
function toIso2(epochMs) {
|
|
412
664
|
if (typeof epochMs !== "number" || !Number.isFinite(epochMs) || epochMs === 0) {
|
|
413
665
|
return void 0;
|
|
@@ -446,19 +698,23 @@ function normalizeRow(row) {
|
|
|
446
698
|
return out;
|
|
447
699
|
}
|
|
448
700
|
var FinanceResource = class {
|
|
449
|
-
constructor(transport,
|
|
701
|
+
constructor(transport, limiter) {
|
|
450
702
|
this.transport = transport;
|
|
451
|
-
this.sellerId = sellerId;
|
|
452
703
|
this.limiter = limiter ?? new core.TokenBucketRateLimiter({ capacity: 100, intervalMs: 6e4 });
|
|
453
704
|
}
|
|
454
705
|
transport;
|
|
455
|
-
sellerId;
|
|
456
706
|
limiter;
|
|
457
707
|
async getSettlements(params = {}) {
|
|
458
|
-
return this.queryPage(
|
|
708
|
+
return this.queryPage(
|
|
709
|
+
`/integration/finance/che/sellers/${this.transport.sellerId}/settlements`,
|
|
710
|
+
params
|
|
711
|
+
);
|
|
459
712
|
}
|
|
460
713
|
async getOtherFinancials(params = {}) {
|
|
461
|
-
return this.queryPage(
|
|
714
|
+
return this.queryPage(
|
|
715
|
+
`/integration/finance/che/sellers/${this.transport.sellerId}/otherfinancials`,
|
|
716
|
+
params
|
|
717
|
+
);
|
|
462
718
|
}
|
|
463
719
|
async queryPage(path, params) {
|
|
464
720
|
const size = Math.min(params.limit ?? 50, 200);
|
|
@@ -484,12 +740,10 @@ var FinanceResource = class {
|
|
|
484
740
|
};
|
|
485
741
|
var MAX_ITEMS_PER_REQUEST = 1e3;
|
|
486
742
|
var InventoryResource = class {
|
|
487
|
-
constructor(transport
|
|
743
|
+
constructor(transport) {
|
|
488
744
|
this.transport = transport;
|
|
489
|
-
this.sellerId = sellerId;
|
|
490
745
|
}
|
|
491
746
|
transport;
|
|
492
|
-
sellerId;
|
|
493
747
|
/**
|
|
494
748
|
* Update price and/or stock for one or more SKUs (by barcode).
|
|
495
749
|
*
|
|
@@ -515,20 +769,18 @@ var InventoryResource = class {
|
|
|
515
769
|
}
|
|
516
770
|
const data = await this.transport.request({
|
|
517
771
|
method: "POST",
|
|
518
|
-
path: `/integration/inventory/sellers/${this.sellerId}/products/price-and-inventory`,
|
|
772
|
+
path: `/integration/inventory/sellers/${this.transport.sellerId}/products/price-and-inventory`,
|
|
519
773
|
body: { items }
|
|
520
774
|
});
|
|
521
775
|
return { batchRequestId: data.batchRequestId ?? "" };
|
|
522
776
|
}
|
|
523
777
|
};
|
|
524
778
|
var InvoicesResource = class {
|
|
525
|
-
constructor(transport,
|
|
779
|
+
constructor(transport, limiter) {
|
|
526
780
|
this.transport = transport;
|
|
527
|
-
this.sellerId = sellerId;
|
|
528
781
|
this.limiter = limiter ?? new core.TokenBucketRateLimiter({ capacity: 500, intervalMs: 6e4 });
|
|
529
782
|
}
|
|
530
783
|
transport;
|
|
531
|
-
sellerId;
|
|
532
784
|
limiter;
|
|
533
785
|
/**
|
|
534
786
|
* Upload an invoice file for a shipment package. **Multipart**: the
|
|
@@ -554,7 +806,7 @@ var InvoicesResource = class {
|
|
|
554
806
|
}
|
|
555
807
|
return this.transport.request({
|
|
556
808
|
method: "POST",
|
|
557
|
-
path: `/integration/sellers/${this.sellerId}/seller-invoice-file`,
|
|
809
|
+
path: `/integration/sellers/${this.transport.sellerId}/seller-invoice-file`,
|
|
558
810
|
body: form,
|
|
559
811
|
rateLimiter: this.limiter
|
|
560
812
|
});
|
|
@@ -566,7 +818,7 @@ var InvoicesResource = class {
|
|
|
566
818
|
}
|
|
567
819
|
return this.transport.request({
|
|
568
820
|
method: "POST",
|
|
569
|
-
path: `/integration/sellers/${this.sellerId}/seller-invoice-links`,
|
|
821
|
+
path: `/integration/sellers/${this.transport.sellerId}/seller-invoice-links`,
|
|
570
822
|
body: input,
|
|
571
823
|
rateLimiter: this.limiter
|
|
572
824
|
});
|
|
@@ -575,20 +827,18 @@ var InvoicesResource = class {
|
|
|
575
827
|
async deleteLink(input) {
|
|
576
828
|
return this.transport.request({
|
|
577
829
|
method: "POST",
|
|
578
|
-
path: `/integration/sellers/${this.sellerId}/seller-invoice-links/delete`,
|
|
830
|
+
path: `/integration/sellers/${this.transport.sellerId}/seller-invoice-links/delete`,
|
|
579
831
|
body: input,
|
|
580
832
|
rateLimiter: this.limiter
|
|
581
833
|
});
|
|
582
834
|
}
|
|
583
835
|
};
|
|
584
836
|
var LabelsResource = class {
|
|
585
|
-
constructor(transport,
|
|
837
|
+
constructor(transport, limiter) {
|
|
586
838
|
this.transport = transport;
|
|
587
|
-
this.sellerId = sellerId;
|
|
588
839
|
this.limiter = limiter ?? new core.TokenBucketRateLimiter({ capacity: 100, intervalMs: 6e4 });
|
|
589
840
|
}
|
|
590
841
|
transport;
|
|
591
|
-
sellerId;
|
|
592
842
|
limiter;
|
|
593
843
|
/**
|
|
594
844
|
* Request a common ZPL label for a cargo tracking number. After this
|
|
@@ -603,7 +853,7 @@ var LabelsResource = class {
|
|
|
603
853
|
}
|
|
604
854
|
return this.transport.request({
|
|
605
855
|
method: "POST",
|
|
606
|
-
path: `/integration/sellers/${this.sellerId}/common-label/${encodeURIComponent(String(cargoTrackingNumber))}`,
|
|
856
|
+
path: `/integration/sellers/${this.transport.sellerId}/common-label/${encodeURIComponent(String(cargoTrackingNumber))}`,
|
|
607
857
|
body: input,
|
|
608
858
|
rateLimiter: this.limiter
|
|
609
859
|
});
|
|
@@ -619,7 +869,7 @@ var LabelsResource = class {
|
|
|
619
869
|
async getCommon(cargoTrackingNumber) {
|
|
620
870
|
const raw = await this.transport.request({
|
|
621
871
|
method: "GET",
|
|
622
|
-
path: `/integration/sellers/${this.sellerId}/common-label/${encodeURIComponent(String(cargoTrackingNumber))}`,
|
|
872
|
+
path: `/integration/sellers/${this.transport.sellerId}/common-label/${encodeURIComponent(String(cargoTrackingNumber))}`,
|
|
623
873
|
rateLimiter: this.limiter
|
|
624
874
|
});
|
|
625
875
|
const labels = (raw?.data ?? []).map((row) => ({
|
|
@@ -810,9 +1060,9 @@ function normalizeCustomer(node) {
|
|
|
810
1060
|
return out;
|
|
811
1061
|
}
|
|
812
1062
|
function normalizeShipmentPackage(rawNode) {
|
|
813
|
-
return
|
|
1063
|
+
return normalizePackage2(rawNode ?? {});
|
|
814
1064
|
}
|
|
815
|
-
function
|
|
1065
|
+
function normalizePackage2(node) {
|
|
816
1066
|
const pkgId = node.shipmentPackageId ?? node.id;
|
|
817
1067
|
const out = {
|
|
818
1068
|
id: pkgId !== void 0 ? String(pkgId) : "",
|
|
@@ -882,13 +1132,11 @@ function normalizePackage(node) {
|
|
|
882
1132
|
return out;
|
|
883
1133
|
}
|
|
884
1134
|
var OrdersResource = class {
|
|
885
|
-
constructor(transport,
|
|
1135
|
+
constructor(transport, limiter) {
|
|
886
1136
|
this.transport = transport;
|
|
887
|
-
this.sellerId = sellerId;
|
|
888
1137
|
this.limiter = limiter ?? new core.TokenBucketRateLimiter({ capacity: 1e3, intervalMs: 6e4 });
|
|
889
1138
|
}
|
|
890
1139
|
transport;
|
|
891
|
-
sellerId;
|
|
892
1140
|
limiter;
|
|
893
1141
|
/**
|
|
894
1142
|
* List shipment packages for the seller.
|
|
@@ -911,11 +1159,11 @@ var OrdersResource = class {
|
|
|
911
1159
|
if (params.endDate) query.endDate = params.endDate.getTime();
|
|
912
1160
|
const data = await this.transport.request({
|
|
913
1161
|
method: "GET",
|
|
914
|
-
path: `/integration/order/sellers/${this.sellerId}/orders`,
|
|
1162
|
+
path: `/integration/order/sellers/${this.transport.sellerId}/orders`,
|
|
915
1163
|
query,
|
|
916
1164
|
rateLimiter: this.limiter
|
|
917
1165
|
});
|
|
918
|
-
const items = (data.content ?? []).map(
|
|
1166
|
+
const items = (data.content ?? []).map(normalizePackage2);
|
|
919
1167
|
const totalPages = typeof data.totalPages === "number" ? data.totalPages : 0;
|
|
920
1168
|
const result = { items };
|
|
921
1169
|
if (page + 1 < totalPages) {
|
|
@@ -1120,7 +1368,7 @@ var OrdersResource = class {
|
|
|
1120
1368
|
async manualDeliverByTrackingNumber(cargoTrackingNumber) {
|
|
1121
1369
|
await this.transport.request({
|
|
1122
1370
|
method: "PUT",
|
|
1123
|
-
path: `/integration/order/sellers/${this.sellerId}/shipment-packages/manual-invoice-delivery-by-tracking-number/${encodeURIComponent(String(cargoTrackingNumber))}`,
|
|
1371
|
+
path: `/integration/order/sellers/${this.transport.sellerId}/shipment-packages/manual-invoice-delivery-by-tracking-number/${encodeURIComponent(String(cargoTrackingNumber))}`,
|
|
1124
1372
|
rateLimiter: this.limiter
|
|
1125
1373
|
});
|
|
1126
1374
|
}
|
|
@@ -1208,11 +1456,11 @@ var OrdersResource = class {
|
|
|
1208
1456
|
}
|
|
1209
1457
|
const data = await this.transport.request({
|
|
1210
1458
|
method: "GET",
|
|
1211
|
-
path: `/integration/order/sellers/${this.sellerId}/orders/stream`,
|
|
1459
|
+
path: `/integration/order/sellers/${this.transport.sellerId}/orders/stream`,
|
|
1212
1460
|
query,
|
|
1213
1461
|
rateLimiter: this.limiter
|
|
1214
1462
|
});
|
|
1215
|
-
const items = (data.content ?? []).map(
|
|
1463
|
+
const items = (data.content ?? []).map(normalizePackage2);
|
|
1216
1464
|
const result = { items };
|
|
1217
1465
|
if (data.hasMore && data.nextCursor) {
|
|
1218
1466
|
result.nextCursor = data.nextCursor;
|
|
@@ -1234,7 +1482,7 @@ var OrdersResource = class {
|
|
|
1234
1482
|
const page = params.cursor ? Number.parseInt(params.cursor, 10) : 0;
|
|
1235
1483
|
const data = await this.transport.request({
|
|
1236
1484
|
method: "GET",
|
|
1237
|
-
path: `/integration/finance/che/sellers/${this.sellerId}/cargo-invoice/${encodeURIComponent(invoiceSerialNumber)}/items`,
|
|
1485
|
+
path: `/integration/finance/che/sellers/${this.transport.sellerId}/cargo-invoice/${encodeURIComponent(invoiceSerialNumber)}/items`,
|
|
1238
1486
|
query: { page, size },
|
|
1239
1487
|
rateLimiter: this.limiter
|
|
1240
1488
|
});
|
|
@@ -1280,7 +1528,7 @@ var OrdersResource = class {
|
|
|
1280
1528
|
async manualReturnByTrackingNumber(cargoTrackingNumber) {
|
|
1281
1529
|
await this.transport.request({
|
|
1282
1530
|
method: "PUT",
|
|
1283
|
-
path: `/integration/order/sellers/${this.sellerId}/shipment-packages/manual-return-by-tracking-number/${encodeURIComponent(String(cargoTrackingNumber))}`,
|
|
1531
|
+
path: `/integration/order/sellers/${this.transport.sellerId}/shipment-packages/manual-return-by-tracking-number/${encodeURIComponent(String(cargoTrackingNumber))}`,
|
|
1284
1532
|
rateLimiter: this.limiter
|
|
1285
1533
|
});
|
|
1286
1534
|
}
|
|
@@ -1312,7 +1560,7 @@ var OrdersResource = class {
|
|
|
1312
1560
|
if (params.endDate) query.endDate = params.endDate.getTime();
|
|
1313
1561
|
const res = await this.transport.request({
|
|
1314
1562
|
method: "GET",
|
|
1315
|
-
path: `/integration/tex/compensation/sellers/${this.sellerId}/tickets`,
|
|
1563
|
+
path: `/integration/tex/compensation/sellers/${this.transport.sellerId}/tickets`,
|
|
1316
1564
|
query,
|
|
1317
1565
|
rateLimiter: this.limiter
|
|
1318
1566
|
});
|
|
@@ -1352,7 +1600,7 @@ var OrdersResource = class {
|
|
|
1352
1600
|
return result;
|
|
1353
1601
|
}
|
|
1354
1602
|
packagePath(packageId) {
|
|
1355
|
-
return `/integration/order/sellers/${this.sellerId}/shipment-packages/${encodeURIComponent(String(packageId))}`;
|
|
1603
|
+
return `/integration/order/sellers/${this.transport.sellerId}/shipment-packages/${encodeURIComponent(String(packageId))}`;
|
|
1356
1604
|
}
|
|
1357
1605
|
};
|
|
1358
1606
|
var DEFAULT_PAGE_SIZE3 = 50;
|
|
@@ -1528,9 +1776,8 @@ function normalizeBatchResult(data) {
|
|
|
1528
1776
|
var MAX_WRITE_ITEMS = 1e3;
|
|
1529
1777
|
var DELETE_RATE_PER_MIN = 100;
|
|
1530
1778
|
var ProductsResource = class {
|
|
1531
|
-
constructor(transport,
|
|
1779
|
+
constructor(transport, options = {}) {
|
|
1532
1780
|
this.transport = transport;
|
|
1533
|
-
this.sellerId = sellerId;
|
|
1534
1781
|
this.filterLimiter = options.filterLimiter ?? new core.TokenBucketRateLimiter({ capacity: 2e3, intervalMs: 6e4 });
|
|
1535
1782
|
this.batchLimiter = options.batchLimiter ?? new core.TokenBucketRateLimiter({ capacity: 1e3, intervalMs: 6e4 });
|
|
1536
1783
|
this.buyboxLimiter = options.buyboxLimiter ?? new core.TokenBucketRateLimiter({ capacity: 1e3, intervalMs: 6e4 });
|
|
@@ -1538,7 +1785,6 @@ var ProductsResource = class {
|
|
|
1538
1785
|
this.deleteLimiter = options.deleteLimiter ?? new core.TokenBucketRateLimiter({ capacity: DELETE_RATE_PER_MIN, intervalMs: 6e4 });
|
|
1539
1786
|
}
|
|
1540
1787
|
transport;
|
|
1541
|
-
sellerId;
|
|
1542
1788
|
filterLimiter;
|
|
1543
1789
|
batchLimiter;
|
|
1544
1790
|
buyboxLimiter;
|
|
@@ -1565,7 +1811,7 @@ var ProductsResource = class {
|
|
|
1565
1811
|
}
|
|
1566
1812
|
const data = await this.transport.request({
|
|
1567
1813
|
method: "POST",
|
|
1568
|
-
path: `/integration/product/sellers/${this.sellerId}${endpoint}`,
|
|
1814
|
+
path: `/integration/product/sellers/${this.transport.sellerId}${endpoint}`,
|
|
1569
1815
|
body: { items },
|
|
1570
1816
|
rateLimiter: this.writeLimiter
|
|
1571
1817
|
});
|
|
@@ -1603,7 +1849,7 @@ var ProductsResource = class {
|
|
|
1603
1849
|
if (params.endDate) query.endDate = params.endDate.getTime();
|
|
1604
1850
|
const data = await this.transport.request({
|
|
1605
1851
|
method: "GET",
|
|
1606
|
-
path: `/integration/product/sellers/${this.sellerId}/products/approved`,
|
|
1852
|
+
path: `/integration/product/sellers/${this.transport.sellerId}/products/approved`,
|
|
1607
1853
|
query,
|
|
1608
1854
|
rateLimiter: this.filterLimiter
|
|
1609
1855
|
});
|
|
@@ -1627,7 +1873,7 @@ var ProductsResource = class {
|
|
|
1627
1873
|
const id = encodeURIComponent(batchRequestId);
|
|
1628
1874
|
const data = await this.transport.request({
|
|
1629
1875
|
method: "GET",
|
|
1630
|
-
path: `/integration/product/sellers/${this.sellerId}/products/batch-requests/${id}`,
|
|
1876
|
+
path: `/integration/product/sellers/${this.transport.sellerId}/products/batch-requests/${id}`,
|
|
1631
1877
|
rateLimiter: this.batchLimiter
|
|
1632
1878
|
});
|
|
1633
1879
|
return normalizeBatchResult(data);
|
|
@@ -1668,7 +1914,7 @@ var ProductsResource = class {
|
|
|
1668
1914
|
if (params.supplierId !== void 0) query.supplierId = params.supplierId;
|
|
1669
1915
|
const data = await this.transport.request({
|
|
1670
1916
|
method: "GET",
|
|
1671
|
-
path: `/integration/product/sellers/${this.sellerId}/products/unapproved`,
|
|
1917
|
+
path: `/integration/product/sellers/${this.transport.sellerId}/products/unapproved`,
|
|
1672
1918
|
query,
|
|
1673
1919
|
rateLimiter: this.filterLimiter
|
|
1674
1920
|
});
|
|
@@ -1692,7 +1938,7 @@ var ProductsResource = class {
|
|
|
1692
1938
|
const code = encodeURIComponent(barcode);
|
|
1693
1939
|
const data = await this.transport.request({
|
|
1694
1940
|
method: "GET",
|
|
1695
|
-
path: `/integration/product/sellers/${this.sellerId}/product/${code}`,
|
|
1941
|
+
path: `/integration/product/sellers/${this.transport.sellerId}/product/${code}`,
|
|
1696
1942
|
rateLimiter: this.filterLimiter
|
|
1697
1943
|
});
|
|
1698
1944
|
return normalizeProductBase(data);
|
|
@@ -1720,7 +1966,7 @@ var ProductsResource = class {
|
|
|
1720
1966
|
}
|
|
1721
1967
|
const data = await this.transport.request({
|
|
1722
1968
|
method: "POST",
|
|
1723
|
-
path: `/integration/product/sellers/${this.sellerId}/products/buybox-information`,
|
|
1969
|
+
path: `/integration/product/sellers/${this.transport.sellerId}/products/buybox-information`,
|
|
1724
1970
|
body: { barcodes },
|
|
1725
1971
|
rateLimiter: this.buyboxLimiter
|
|
1726
1972
|
});
|
|
@@ -1805,7 +2051,7 @@ var ProductsResource = class {
|
|
|
1805
2051
|
this.validateBarcodes(barcodes, "delete");
|
|
1806
2052
|
const data = await this.transport.request({
|
|
1807
2053
|
method: "DELETE",
|
|
1808
|
-
path: `/integration/product/sellers/${this.sellerId}/products`,
|
|
2054
|
+
path: `/integration/product/sellers/${this.transport.sellerId}/products`,
|
|
1809
2055
|
body: { items: barcodes.map((barcode) => ({ barcode })) },
|
|
1810
2056
|
rateLimiter: this.deleteLimiter
|
|
1811
2057
|
});
|
|
@@ -1836,7 +2082,7 @@ var ProductsResource = class {
|
|
|
1836
2082
|
this.validateBarcodes(barcodes, methodLabel);
|
|
1837
2083
|
const data = await this.transport.request({
|
|
1838
2084
|
method: "PUT",
|
|
1839
|
-
path: `/integration/product/sellers/${this.sellerId}/products/archive-state`,
|
|
2085
|
+
path: `/integration/product/sellers/${this.transport.sellerId}/products/archive-state`,
|
|
1840
2086
|
body: { items: barcodes.map((barcode) => ({ barcode, archived })) },
|
|
1841
2087
|
rateLimiter: this.writeLimiter
|
|
1842
2088
|
});
|
|
@@ -1855,7 +2101,7 @@ var ProductsResource = class {
|
|
|
1855
2101
|
this.validateBarcodes(barcodes, "unlock");
|
|
1856
2102
|
const data = await this.transport.request({
|
|
1857
2103
|
method: "PUT",
|
|
1858
|
-
path: `/integration/product/sellers/${this.sellerId}/products/unlock`,
|
|
2104
|
+
path: `/integration/product/sellers/${this.transport.sellerId}/products/unlock`,
|
|
1859
2105
|
body: { items: barcodes.map((barcode) => ({ barcode })) },
|
|
1860
2106
|
rateLimiter: this.writeLimiter
|
|
1861
2107
|
});
|
|
@@ -1908,19 +2154,17 @@ function normalizeQuestion(node) {
|
|
|
1908
2154
|
return out;
|
|
1909
2155
|
}
|
|
1910
2156
|
var QuestionsResource = class {
|
|
1911
|
-
constructor(transport,
|
|
2157
|
+
constructor(transport, limiter) {
|
|
1912
2158
|
this.transport = transport;
|
|
1913
|
-
this.sellerId = sellerId;
|
|
1914
2159
|
this.limiter = limiter ?? new core.TokenBucketRateLimiter({ capacity: 500, intervalMs: 6e4 });
|
|
1915
2160
|
}
|
|
1916
2161
|
transport;
|
|
1917
|
-
sellerId;
|
|
1918
2162
|
limiter;
|
|
1919
2163
|
/** Fetch a single question by its numeric ID. */
|
|
1920
2164
|
async get(questionId) {
|
|
1921
2165
|
const data = await this.transport.request({
|
|
1922
2166
|
method: "GET",
|
|
1923
|
-
path: `/integration/qna/sellers/${this.sellerId}/questions/${encodeURIComponent(String(questionId))}`,
|
|
2167
|
+
path: `/integration/qna/sellers/${this.transport.sellerId}/questions/${encodeURIComponent(String(questionId))}`,
|
|
1924
2168
|
rateLimiter: this.limiter
|
|
1925
2169
|
});
|
|
1926
2170
|
return normalizeQuestion(data);
|
|
@@ -1939,7 +2183,7 @@ var QuestionsResource = class {
|
|
|
1939
2183
|
if (params.status) query.status = params.status;
|
|
1940
2184
|
const data = await this.transport.request({
|
|
1941
2185
|
method: "GET",
|
|
1942
|
-
path: `/integration/qna/sellers/${this.sellerId}/questions/filter`,
|
|
2186
|
+
path: `/integration/qna/sellers/${this.transport.sellerId}/questions/filter`,
|
|
1943
2187
|
query,
|
|
1944
2188
|
rateLimiter: this.limiter
|
|
1945
2189
|
});
|
|
@@ -1970,7 +2214,7 @@ var QuestionsResource = class {
|
|
|
1970
2214
|
}
|
|
1971
2215
|
return this.transport.request({
|
|
1972
2216
|
method: "POST",
|
|
1973
|
-
path: `/integration/qna/sellers/${this.sellerId}/questions/${encodeURIComponent(String(questionId))}/answers`,
|
|
2217
|
+
path: `/integration/qna/sellers/${this.transport.sellerId}/questions/${encodeURIComponent(String(questionId))}/answers`,
|
|
1974
2218
|
body: { text },
|
|
1975
2219
|
rateLimiter: this.limiter
|
|
1976
2220
|
});
|
|
@@ -2010,9 +2254,8 @@ function normalizeAddress2(node) {
|
|
|
2010
2254
|
}
|
|
2011
2255
|
var DEFAULT_CACHE_TTL_MS = 60 * 60 * 1e3;
|
|
2012
2256
|
var SuppliersResource = class {
|
|
2013
|
-
constructor(transport,
|
|
2257
|
+
constructor(transport, options = {}) {
|
|
2014
2258
|
this.transport = transport;
|
|
2015
|
-
this.sellerId = sellerId;
|
|
2016
2259
|
this.cacheTtlMs = options.cacheTtlMs ?? DEFAULT_CACHE_TTL_MS;
|
|
2017
2260
|
this.limiter = new core.TokenBucketRateLimiter({
|
|
2018
2261
|
capacity: 1,
|
|
@@ -2020,7 +2263,6 @@ var SuppliersResource = class {
|
|
|
2020
2263
|
});
|
|
2021
2264
|
}
|
|
2022
2265
|
transport;
|
|
2023
|
-
sellerId;
|
|
2024
2266
|
cache = null;
|
|
2025
2267
|
cacheTtlMs;
|
|
2026
2268
|
limiter;
|
|
@@ -2048,7 +2290,7 @@ var SuppliersResource = class {
|
|
|
2048
2290
|
async fetchFresh() {
|
|
2049
2291
|
const data = await this.transport.request({
|
|
2050
2292
|
method: "GET",
|
|
2051
|
-
path: `/integration/sellers/${this.sellerId}/addresses`,
|
|
2293
|
+
path: `/integration/sellers/${this.transport.sellerId}/addresses`,
|
|
2052
2294
|
rateLimiter: this.limiter
|
|
2053
2295
|
});
|
|
2054
2296
|
const items = data.supplierAddresses.map(normalizeAddress2);
|
|
@@ -2057,13 +2299,11 @@ var SuppliersResource = class {
|
|
|
2057
2299
|
}
|
|
2058
2300
|
};
|
|
2059
2301
|
var TestOrdersResource = class {
|
|
2060
|
-
constructor(transport,
|
|
2302
|
+
constructor(transport, limiter) {
|
|
2061
2303
|
this.transport = transport;
|
|
2062
|
-
this.sellerId = sellerId;
|
|
2063
2304
|
this.limiter = limiter ?? new core.TokenBucketRateLimiter({ capacity: 60, intervalMs: 6e4 });
|
|
2064
2305
|
}
|
|
2065
2306
|
transport;
|
|
2066
|
-
sellerId;
|
|
2067
2307
|
limiter;
|
|
2068
2308
|
/**
|
|
2069
2309
|
* Create a test order with the given customer / addresses / lines. The
|
|
@@ -2089,7 +2329,7 @@ var TestOrdersResource = class {
|
|
|
2089
2329
|
async updateStatus(packageId, status) {
|
|
2090
2330
|
return this.transport.request({
|
|
2091
2331
|
method: "PUT",
|
|
2092
|
-
path: `/integration/test/order/sellers/${this.sellerId}/shipment-packages/${encodeURIComponent(String(packageId))}/status`,
|
|
2332
|
+
path: `/integration/test/order/sellers/${this.transport.sellerId}/shipment-packages/${encodeURIComponent(String(packageId))}/status`,
|
|
2093
2333
|
body: { status },
|
|
2094
2334
|
rateLimiter: this.limiter
|
|
2095
2335
|
});
|
|
@@ -2098,11 +2338,60 @@ var TestOrdersResource = class {
|
|
|
2098
2338
|
async setClaimsWaitingInAction() {
|
|
2099
2339
|
return this.transport.request({
|
|
2100
2340
|
method: "PUT",
|
|
2101
|
-
path: `/integration/test/order/sellers/${this.sellerId}/claims/waiting-in-action`,
|
|
2341
|
+
path: `/integration/test/order/sellers/${this.transport.sellerId}/claims/waiting-in-action`,
|
|
2102
2342
|
rateLimiter: this.limiter
|
|
2103
2343
|
});
|
|
2104
2344
|
}
|
|
2105
2345
|
};
|
|
2346
|
+
var VideosResource = class {
|
|
2347
|
+
constructor(transport, options = {}) {
|
|
2348
|
+
this.transport = transport;
|
|
2349
|
+
this.createLimiter = options.createLimiter ?? new core.TokenBucketRateLimiter({ capacity: 200, intervalMs: 6e4 });
|
|
2350
|
+
this.listLimiter = options.listLimiter ?? new core.TokenBucketRateLimiter({ capacity: 1e3, intervalMs: 6e4 });
|
|
2351
|
+
}
|
|
2352
|
+
transport;
|
|
2353
|
+
createLimiter;
|
|
2354
|
+
listLimiter;
|
|
2355
|
+
/**
|
|
2356
|
+
* Queue a video for upload. Trendyol downloads from the URL in the
|
|
2357
|
+
* body asynchronously; poll `list()` (filtered by id) for status.
|
|
2358
|
+
*
|
|
2359
|
+
* @throws {ValidationError} when `input` is empty / not an object.
|
|
2360
|
+
*/
|
|
2361
|
+
async create(input) {
|
|
2362
|
+
if (!input || typeof input !== "object") {
|
|
2363
|
+
throw new core.ValidationError({ message: "videos.create: input is required" });
|
|
2364
|
+
}
|
|
2365
|
+
return this.transport.request({
|
|
2366
|
+
method: "POST",
|
|
2367
|
+
path: `/integration/video/sellers/${this.transport.sellerId}/videos`,
|
|
2368
|
+
body: input,
|
|
2369
|
+
rateLimiter: this.createLimiter
|
|
2370
|
+
});
|
|
2371
|
+
}
|
|
2372
|
+
/** List the seller's integration videos (optionally filtered by id / status). */
|
|
2373
|
+
async list(params = {}) {
|
|
2374
|
+
const data = await this.transport.request({
|
|
2375
|
+
method: "GET",
|
|
2376
|
+
path: `/integration/video/sellers/${this.transport.sellerId}/videos`,
|
|
2377
|
+
query: {
|
|
2378
|
+
id: params.id,
|
|
2379
|
+
sellerIntegrationStatus: params.sellerIntegrationStatus,
|
|
2380
|
+
page: params.offset,
|
|
2381
|
+
size: params.limit
|
|
2382
|
+
},
|
|
2383
|
+
rateLimiter: this.listLimiter
|
|
2384
|
+
});
|
|
2385
|
+
const rows = Array.isArray(data) ? data : Array.isArray(data?.content) ? data.content : Array.isArray(data?.items) ? data.items : [];
|
|
2386
|
+
return rows.map((r) => {
|
|
2387
|
+
const row = r ?? {};
|
|
2388
|
+
const out = { raw: row };
|
|
2389
|
+
if (typeof row.id === "string") out.id = row.id;
|
|
2390
|
+
if (typeof row.status === "string") out.status = row.status;
|
|
2391
|
+
return out;
|
|
2392
|
+
});
|
|
2393
|
+
}
|
|
2394
|
+
};
|
|
2106
2395
|
function normalizeWebhook(node) {
|
|
2107
2396
|
const out = {
|
|
2108
2397
|
id: node.id !== void 0 ? String(node.id) : "",
|
|
@@ -2119,13 +2408,11 @@ function normalizeWebhook(node) {
|
|
|
2119
2408
|
return out;
|
|
2120
2409
|
}
|
|
2121
2410
|
var WebhooksResource = class {
|
|
2122
|
-
constructor(transport,
|
|
2411
|
+
constructor(transport, limiter) {
|
|
2123
2412
|
this.transport = transport;
|
|
2124
|
-
this.sellerId = sellerId;
|
|
2125
2413
|
this.limiter = limiter ?? new core.TokenBucketRateLimiter({ capacity: 50, intervalMs: 6e4 });
|
|
2126
2414
|
}
|
|
2127
2415
|
transport;
|
|
2128
|
-
sellerId;
|
|
2129
2416
|
limiter;
|
|
2130
2417
|
/**
|
|
2131
2418
|
* Create a new webhook subscription. Trendyol caps subscriptions at 15
|
|
@@ -2138,7 +2425,7 @@ var WebhooksResource = class {
|
|
|
2138
2425
|
this.validateInput(input, "create");
|
|
2139
2426
|
return this.transport.request({
|
|
2140
2427
|
method: "POST",
|
|
2141
|
-
path: `/integration/sellers/${this.sellerId}/webhooks`,
|
|
2428
|
+
path: `/integration/sellers/${this.transport.sellerId}/webhooks`,
|
|
2142
2429
|
body: input,
|
|
2143
2430
|
rateLimiter: this.limiter
|
|
2144
2431
|
});
|
|
@@ -2147,7 +2434,7 @@ var WebhooksResource = class {
|
|
|
2147
2434
|
async list() {
|
|
2148
2435
|
const data = await this.transport.request({
|
|
2149
2436
|
method: "GET",
|
|
2150
|
-
path: `/integration/sellers/${this.sellerId}/webhooks`,
|
|
2437
|
+
path: `/integration/sellers/${this.transport.sellerId}/webhooks`,
|
|
2151
2438
|
rateLimiter: this.limiter
|
|
2152
2439
|
});
|
|
2153
2440
|
const rows = Array.isArray(data) ? data : Array.isArray(data?.webhooks) ? data.webhooks : Array.isArray(data?.content) ? data.content : [];
|
|
@@ -2217,7 +2504,7 @@ var WebhooksResource = class {
|
|
|
2217
2504
|
if (input.subscribedStatuses && input.subscribedStatuses.length === 0) ;
|
|
2218
2505
|
}
|
|
2219
2506
|
webhookPath(webhookId) {
|
|
2220
|
-
return `/integration/sellers/${this.sellerId}/webhooks/${encodeURIComponent(String(webhookId))}`;
|
|
2507
|
+
return `/integration/sellers/${this.transport.sellerId}/webhooks/${encodeURIComponent(String(webhookId))}`;
|
|
2221
2508
|
}
|
|
2222
2509
|
};
|
|
2223
2510
|
|
|
@@ -2299,6 +2586,10 @@ var TrendyolTransport = class {
|
|
|
2299
2586
|
logger;
|
|
2300
2587
|
timeoutMs;
|
|
2301
2588
|
fetchImpl;
|
|
2589
|
+
/** Seller ID this transport is configured with. Resources read it for path-building. */
|
|
2590
|
+
get sellerId() {
|
|
2591
|
+
return this.config.sellerId;
|
|
2592
|
+
}
|
|
2302
2593
|
async request(opts) {
|
|
2303
2594
|
return core.retry(
|
|
2304
2595
|
async (attempt) => {
|
|
@@ -2427,19 +2718,21 @@ function createTrendyolClient(opts) {
|
|
|
2427
2718
|
});
|
|
2428
2719
|
return {
|
|
2429
2720
|
brands: new BrandsResource(transport),
|
|
2430
|
-
categories: new CategoriesResource(transport
|
|
2431
|
-
suppliers: new SuppliersResource(transport
|
|
2432
|
-
products: new ProductsResource(transport
|
|
2433
|
-
inventory: new InventoryResource(transport
|
|
2434
|
-
orders: new OrdersResource(transport
|
|
2435
|
-
claims: new ClaimsResource(transport
|
|
2436
|
-
webhooks: new WebhooksResource(transport
|
|
2437
|
-
questions: new QuestionsResource(transport
|
|
2438
|
-
invoices: new InvoicesResource(transport
|
|
2439
|
-
finance: new FinanceResource(transport
|
|
2440
|
-
labels: new LabelsResource(transport
|
|
2441
|
-
testOrders: new TestOrdersResource(transport
|
|
2442
|
-
locations: new LocationsResource(transport)
|
|
2721
|
+
categories: new CategoriesResource(transport),
|
|
2722
|
+
suppliers: new SuppliersResource(transport),
|
|
2723
|
+
products: new ProductsResource(transport),
|
|
2724
|
+
inventory: new InventoryResource(transport),
|
|
2725
|
+
orders: new OrdersResource(transport),
|
|
2726
|
+
claims: new ClaimsResource(transport),
|
|
2727
|
+
webhooks: new WebhooksResource(transport),
|
|
2728
|
+
questions: new QuestionsResource(transport),
|
|
2729
|
+
invoices: new InvoicesResource(transport),
|
|
2730
|
+
finance: new FinanceResource(transport),
|
|
2731
|
+
labels: new LabelsResource(transport),
|
|
2732
|
+
testOrders: new TestOrdersResource(transport),
|
|
2733
|
+
locations: new LocationsResource(transport),
|
|
2734
|
+
exportCenter: new ExportCenterResource(transport),
|
|
2735
|
+
videos: new VideosResource(transport)
|
|
2443
2736
|
};
|
|
2444
2737
|
}
|
|
2445
2738
|
function parseWebhookEvent(rawBody) {
|
|
@@ -2480,6 +2773,7 @@ function parseWebhookEvent(rawBody) {
|
|
|
2480
2773
|
exports.BrandsResource = BrandsResource;
|
|
2481
2774
|
exports.CategoriesResource = CategoriesResource;
|
|
2482
2775
|
exports.ClaimsResource = ClaimsResource;
|
|
2776
|
+
exports.ExportCenterResource = ExportCenterResource;
|
|
2483
2777
|
exports.FinanceResource = FinanceResource;
|
|
2484
2778
|
exports.InventoryResource = InventoryResource;
|
|
2485
2779
|
exports.InvoicesResource = InvoicesResource;
|
|
@@ -2490,6 +2784,7 @@ exports.ProductsResource = ProductsResource;
|
|
|
2490
2784
|
exports.QuestionsResource = QuestionsResource;
|
|
2491
2785
|
exports.SuppliersResource = SuppliersResource;
|
|
2492
2786
|
exports.TestOrdersResource = TestOrdersResource;
|
|
2787
|
+
exports.VideosResource = VideosResource;
|
|
2493
2788
|
exports.WebhooksResource = WebhooksResource;
|
|
2494
2789
|
exports.createTrendyolClient = createTrendyolClient;
|
|
2495
2790
|
exports.normalizeShipmentPackage = normalizeShipmentPackage;
|