@lonca/trendyol 0.7.0 → 0.8.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/dist/index.cjs +70 -94
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -37
- package/dist/index.d.ts +14 -37
- package/dist/index.js +70 -94
- 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,7 +390,7 @@ 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 : [];
|
|
@@ -446,19 +435,20 @@ function normalizeRow(row) {
|
|
|
446
435
|
return out;
|
|
447
436
|
}
|
|
448
437
|
var FinanceResource = class {
|
|
449
|
-
constructor(transport,
|
|
438
|
+
constructor(transport, limiter) {
|
|
450
439
|
this.transport = transport;
|
|
451
|
-
this.sellerId = sellerId;
|
|
452
440
|
this.limiter = limiter ?? new core.TokenBucketRateLimiter({ capacity: 100, intervalMs: 6e4 });
|
|
453
441
|
}
|
|
454
442
|
transport;
|
|
455
|
-
sellerId;
|
|
456
443
|
limiter;
|
|
457
444
|
async getSettlements(params = {}) {
|
|
458
|
-
return this.queryPage(`/integration/sellers/${this.sellerId}/settlements`, params);
|
|
445
|
+
return this.queryPage(`/integration/sellers/${this.transport.sellerId}/settlements`, params);
|
|
459
446
|
}
|
|
460
447
|
async getOtherFinancials(params = {}) {
|
|
461
|
-
return this.queryPage(
|
|
448
|
+
return this.queryPage(
|
|
449
|
+
`/integration/sellers/${this.transport.sellerId}/otherfinancials`,
|
|
450
|
+
params
|
|
451
|
+
);
|
|
462
452
|
}
|
|
463
453
|
async queryPage(path, params) {
|
|
464
454
|
const size = Math.min(params.limit ?? 50, 200);
|
|
@@ -484,12 +474,10 @@ var FinanceResource = class {
|
|
|
484
474
|
};
|
|
485
475
|
var MAX_ITEMS_PER_REQUEST = 1e3;
|
|
486
476
|
var InventoryResource = class {
|
|
487
|
-
constructor(transport
|
|
477
|
+
constructor(transport) {
|
|
488
478
|
this.transport = transport;
|
|
489
|
-
this.sellerId = sellerId;
|
|
490
479
|
}
|
|
491
480
|
transport;
|
|
492
|
-
sellerId;
|
|
493
481
|
/**
|
|
494
482
|
* Update price and/or stock for one or more SKUs (by barcode).
|
|
495
483
|
*
|
|
@@ -515,20 +503,18 @@ var InventoryResource = class {
|
|
|
515
503
|
}
|
|
516
504
|
const data = await this.transport.request({
|
|
517
505
|
method: "POST",
|
|
518
|
-
path: `/integration/inventory/sellers/${this.sellerId}/products/price-and-inventory`,
|
|
506
|
+
path: `/integration/inventory/sellers/${this.transport.sellerId}/products/price-and-inventory`,
|
|
519
507
|
body: { items }
|
|
520
508
|
});
|
|
521
509
|
return { batchRequestId: data.batchRequestId ?? "" };
|
|
522
510
|
}
|
|
523
511
|
};
|
|
524
512
|
var InvoicesResource = class {
|
|
525
|
-
constructor(transport,
|
|
513
|
+
constructor(transport, limiter) {
|
|
526
514
|
this.transport = transport;
|
|
527
|
-
this.sellerId = sellerId;
|
|
528
515
|
this.limiter = limiter ?? new core.TokenBucketRateLimiter({ capacity: 500, intervalMs: 6e4 });
|
|
529
516
|
}
|
|
530
517
|
transport;
|
|
531
|
-
sellerId;
|
|
532
518
|
limiter;
|
|
533
519
|
/**
|
|
534
520
|
* Upload an invoice file for a shipment package. **Multipart**: the
|
|
@@ -554,7 +540,7 @@ var InvoicesResource = class {
|
|
|
554
540
|
}
|
|
555
541
|
return this.transport.request({
|
|
556
542
|
method: "POST",
|
|
557
|
-
path: `/integration/sellers/${this.sellerId}/seller-invoice-file`,
|
|
543
|
+
path: `/integration/sellers/${this.transport.sellerId}/seller-invoice-file`,
|
|
558
544
|
body: form,
|
|
559
545
|
rateLimiter: this.limiter
|
|
560
546
|
});
|
|
@@ -566,7 +552,7 @@ var InvoicesResource = class {
|
|
|
566
552
|
}
|
|
567
553
|
return this.transport.request({
|
|
568
554
|
method: "POST",
|
|
569
|
-
path: `/integration/sellers/${this.sellerId}/seller-invoice-links`,
|
|
555
|
+
path: `/integration/sellers/${this.transport.sellerId}/seller-invoice-links`,
|
|
570
556
|
body: input,
|
|
571
557
|
rateLimiter: this.limiter
|
|
572
558
|
});
|
|
@@ -575,20 +561,18 @@ var InvoicesResource = class {
|
|
|
575
561
|
async deleteLink(input) {
|
|
576
562
|
return this.transport.request({
|
|
577
563
|
method: "POST",
|
|
578
|
-
path: `/integration/sellers/${this.sellerId}/seller-invoice-links/delete`,
|
|
564
|
+
path: `/integration/sellers/${this.transport.sellerId}/seller-invoice-links/delete`,
|
|
579
565
|
body: input,
|
|
580
566
|
rateLimiter: this.limiter
|
|
581
567
|
});
|
|
582
568
|
}
|
|
583
569
|
};
|
|
584
570
|
var LabelsResource = class {
|
|
585
|
-
constructor(transport,
|
|
571
|
+
constructor(transport, limiter) {
|
|
586
572
|
this.transport = transport;
|
|
587
|
-
this.sellerId = sellerId;
|
|
588
573
|
this.limiter = limiter ?? new core.TokenBucketRateLimiter({ capacity: 100, intervalMs: 6e4 });
|
|
589
574
|
}
|
|
590
575
|
transport;
|
|
591
|
-
sellerId;
|
|
592
576
|
limiter;
|
|
593
577
|
/**
|
|
594
578
|
* Request a common ZPL label for a cargo tracking number. After this
|
|
@@ -603,7 +587,7 @@ var LabelsResource = class {
|
|
|
603
587
|
}
|
|
604
588
|
return this.transport.request({
|
|
605
589
|
method: "POST",
|
|
606
|
-
path: `/integration/sellers/${this.sellerId}/common-label/${encodeURIComponent(String(cargoTrackingNumber))}`,
|
|
590
|
+
path: `/integration/sellers/${this.transport.sellerId}/common-label/${encodeURIComponent(String(cargoTrackingNumber))}`,
|
|
607
591
|
body: input,
|
|
608
592
|
rateLimiter: this.limiter
|
|
609
593
|
});
|
|
@@ -619,7 +603,7 @@ var LabelsResource = class {
|
|
|
619
603
|
async getCommon(cargoTrackingNumber) {
|
|
620
604
|
const raw = await this.transport.request({
|
|
621
605
|
method: "GET",
|
|
622
|
-
path: `/integration/sellers/${this.sellerId}/common-label/${encodeURIComponent(String(cargoTrackingNumber))}`,
|
|
606
|
+
path: `/integration/sellers/${this.transport.sellerId}/common-label/${encodeURIComponent(String(cargoTrackingNumber))}`,
|
|
623
607
|
rateLimiter: this.limiter
|
|
624
608
|
});
|
|
625
609
|
const labels = (raw?.data ?? []).map((row) => ({
|
|
@@ -882,13 +866,11 @@ function normalizePackage(node) {
|
|
|
882
866
|
return out;
|
|
883
867
|
}
|
|
884
868
|
var OrdersResource = class {
|
|
885
|
-
constructor(transport,
|
|
869
|
+
constructor(transport, limiter) {
|
|
886
870
|
this.transport = transport;
|
|
887
|
-
this.sellerId = sellerId;
|
|
888
871
|
this.limiter = limiter ?? new core.TokenBucketRateLimiter({ capacity: 1e3, intervalMs: 6e4 });
|
|
889
872
|
}
|
|
890
873
|
transport;
|
|
891
|
-
sellerId;
|
|
892
874
|
limiter;
|
|
893
875
|
/**
|
|
894
876
|
* List shipment packages for the seller.
|
|
@@ -911,7 +893,7 @@ var OrdersResource = class {
|
|
|
911
893
|
if (params.endDate) query.endDate = params.endDate.getTime();
|
|
912
894
|
const data = await this.transport.request({
|
|
913
895
|
method: "GET",
|
|
914
|
-
path: `/integration/order/sellers/${this.sellerId}/orders`,
|
|
896
|
+
path: `/integration/order/sellers/${this.transport.sellerId}/orders`,
|
|
915
897
|
query,
|
|
916
898
|
rateLimiter: this.limiter
|
|
917
899
|
});
|
|
@@ -1120,7 +1102,7 @@ var OrdersResource = class {
|
|
|
1120
1102
|
async manualDeliverByTrackingNumber(cargoTrackingNumber) {
|
|
1121
1103
|
await this.transport.request({
|
|
1122
1104
|
method: "PUT",
|
|
1123
|
-
path: `/integration/order/sellers/${this.sellerId}/shipment-packages/manual-invoice-delivery-by-tracking-number/${encodeURIComponent(String(cargoTrackingNumber))}`,
|
|
1105
|
+
path: `/integration/order/sellers/${this.transport.sellerId}/shipment-packages/manual-invoice-delivery-by-tracking-number/${encodeURIComponent(String(cargoTrackingNumber))}`,
|
|
1124
1106
|
rateLimiter: this.limiter
|
|
1125
1107
|
});
|
|
1126
1108
|
}
|
|
@@ -1208,7 +1190,7 @@ var OrdersResource = class {
|
|
|
1208
1190
|
}
|
|
1209
1191
|
const data = await this.transport.request({
|
|
1210
1192
|
method: "GET",
|
|
1211
|
-
path: `/integration/order/sellers/${this.sellerId}/orders/stream`,
|
|
1193
|
+
path: `/integration/order/sellers/${this.transport.sellerId}/orders/stream`,
|
|
1212
1194
|
query,
|
|
1213
1195
|
rateLimiter: this.limiter
|
|
1214
1196
|
});
|
|
@@ -1234,7 +1216,7 @@ var OrdersResource = class {
|
|
|
1234
1216
|
const page = params.cursor ? Number.parseInt(params.cursor, 10) : 0;
|
|
1235
1217
|
const data = await this.transport.request({
|
|
1236
1218
|
method: "GET",
|
|
1237
|
-
path: `/integration/finance/che/sellers/${this.sellerId}/cargo-invoice/${encodeURIComponent(invoiceSerialNumber)}/items`,
|
|
1219
|
+
path: `/integration/finance/che/sellers/${this.transport.sellerId}/cargo-invoice/${encodeURIComponent(invoiceSerialNumber)}/items`,
|
|
1238
1220
|
query: { page, size },
|
|
1239
1221
|
rateLimiter: this.limiter
|
|
1240
1222
|
});
|
|
@@ -1280,7 +1262,7 @@ var OrdersResource = class {
|
|
|
1280
1262
|
async manualReturnByTrackingNumber(cargoTrackingNumber) {
|
|
1281
1263
|
await this.transport.request({
|
|
1282
1264
|
method: "PUT",
|
|
1283
|
-
path: `/integration/order/sellers/${this.sellerId}/shipment-packages/manual-return-by-tracking-number/${encodeURIComponent(String(cargoTrackingNumber))}`,
|
|
1265
|
+
path: `/integration/order/sellers/${this.transport.sellerId}/shipment-packages/manual-return-by-tracking-number/${encodeURIComponent(String(cargoTrackingNumber))}`,
|
|
1284
1266
|
rateLimiter: this.limiter
|
|
1285
1267
|
});
|
|
1286
1268
|
}
|
|
@@ -1312,7 +1294,7 @@ var OrdersResource = class {
|
|
|
1312
1294
|
if (params.endDate) query.endDate = params.endDate.getTime();
|
|
1313
1295
|
const res = await this.transport.request({
|
|
1314
1296
|
method: "GET",
|
|
1315
|
-
path: `/integration/tex/compensation/sellers/${this.sellerId}/tickets`,
|
|
1297
|
+
path: `/integration/tex/compensation/sellers/${this.transport.sellerId}/tickets`,
|
|
1316
1298
|
query,
|
|
1317
1299
|
rateLimiter: this.limiter
|
|
1318
1300
|
});
|
|
@@ -1352,7 +1334,7 @@ var OrdersResource = class {
|
|
|
1352
1334
|
return result;
|
|
1353
1335
|
}
|
|
1354
1336
|
packagePath(packageId) {
|
|
1355
|
-
return `/integration/order/sellers/${this.sellerId}/shipment-packages/${encodeURIComponent(String(packageId))}`;
|
|
1337
|
+
return `/integration/order/sellers/${this.transport.sellerId}/shipment-packages/${encodeURIComponent(String(packageId))}`;
|
|
1356
1338
|
}
|
|
1357
1339
|
};
|
|
1358
1340
|
var DEFAULT_PAGE_SIZE3 = 50;
|
|
@@ -1528,9 +1510,8 @@ function normalizeBatchResult(data) {
|
|
|
1528
1510
|
var MAX_WRITE_ITEMS = 1e3;
|
|
1529
1511
|
var DELETE_RATE_PER_MIN = 100;
|
|
1530
1512
|
var ProductsResource = class {
|
|
1531
|
-
constructor(transport,
|
|
1513
|
+
constructor(transport, options = {}) {
|
|
1532
1514
|
this.transport = transport;
|
|
1533
|
-
this.sellerId = sellerId;
|
|
1534
1515
|
this.filterLimiter = options.filterLimiter ?? new core.TokenBucketRateLimiter({ capacity: 2e3, intervalMs: 6e4 });
|
|
1535
1516
|
this.batchLimiter = options.batchLimiter ?? new core.TokenBucketRateLimiter({ capacity: 1e3, intervalMs: 6e4 });
|
|
1536
1517
|
this.buyboxLimiter = options.buyboxLimiter ?? new core.TokenBucketRateLimiter({ capacity: 1e3, intervalMs: 6e4 });
|
|
@@ -1538,7 +1519,6 @@ var ProductsResource = class {
|
|
|
1538
1519
|
this.deleteLimiter = options.deleteLimiter ?? new core.TokenBucketRateLimiter({ capacity: DELETE_RATE_PER_MIN, intervalMs: 6e4 });
|
|
1539
1520
|
}
|
|
1540
1521
|
transport;
|
|
1541
|
-
sellerId;
|
|
1542
1522
|
filterLimiter;
|
|
1543
1523
|
batchLimiter;
|
|
1544
1524
|
buyboxLimiter;
|
|
@@ -1565,7 +1545,7 @@ var ProductsResource = class {
|
|
|
1565
1545
|
}
|
|
1566
1546
|
const data = await this.transport.request({
|
|
1567
1547
|
method: "POST",
|
|
1568
|
-
path: `/integration/product/sellers/${this.sellerId}${endpoint}`,
|
|
1548
|
+
path: `/integration/product/sellers/${this.transport.sellerId}${endpoint}`,
|
|
1569
1549
|
body: { items },
|
|
1570
1550
|
rateLimiter: this.writeLimiter
|
|
1571
1551
|
});
|
|
@@ -1603,7 +1583,7 @@ var ProductsResource = class {
|
|
|
1603
1583
|
if (params.endDate) query.endDate = params.endDate.getTime();
|
|
1604
1584
|
const data = await this.transport.request({
|
|
1605
1585
|
method: "GET",
|
|
1606
|
-
path: `/integration/product/sellers/${this.sellerId}/products/approved`,
|
|
1586
|
+
path: `/integration/product/sellers/${this.transport.sellerId}/products/approved`,
|
|
1607
1587
|
query,
|
|
1608
1588
|
rateLimiter: this.filterLimiter
|
|
1609
1589
|
});
|
|
@@ -1627,7 +1607,7 @@ var ProductsResource = class {
|
|
|
1627
1607
|
const id = encodeURIComponent(batchRequestId);
|
|
1628
1608
|
const data = await this.transport.request({
|
|
1629
1609
|
method: "GET",
|
|
1630
|
-
path: `/integration/product/sellers/${this.sellerId}/products/batch-requests/${id}`,
|
|
1610
|
+
path: `/integration/product/sellers/${this.transport.sellerId}/products/batch-requests/${id}`,
|
|
1631
1611
|
rateLimiter: this.batchLimiter
|
|
1632
1612
|
});
|
|
1633
1613
|
return normalizeBatchResult(data);
|
|
@@ -1668,7 +1648,7 @@ var ProductsResource = class {
|
|
|
1668
1648
|
if (params.supplierId !== void 0) query.supplierId = params.supplierId;
|
|
1669
1649
|
const data = await this.transport.request({
|
|
1670
1650
|
method: "GET",
|
|
1671
|
-
path: `/integration/product/sellers/${this.sellerId}/products/unapproved`,
|
|
1651
|
+
path: `/integration/product/sellers/${this.transport.sellerId}/products/unapproved`,
|
|
1672
1652
|
query,
|
|
1673
1653
|
rateLimiter: this.filterLimiter
|
|
1674
1654
|
});
|
|
@@ -1692,7 +1672,7 @@ var ProductsResource = class {
|
|
|
1692
1672
|
const code = encodeURIComponent(barcode);
|
|
1693
1673
|
const data = await this.transport.request({
|
|
1694
1674
|
method: "GET",
|
|
1695
|
-
path: `/integration/product/sellers/${this.sellerId}/product/${code}`,
|
|
1675
|
+
path: `/integration/product/sellers/${this.transport.sellerId}/product/${code}`,
|
|
1696
1676
|
rateLimiter: this.filterLimiter
|
|
1697
1677
|
});
|
|
1698
1678
|
return normalizeProductBase(data);
|
|
@@ -1720,7 +1700,7 @@ var ProductsResource = class {
|
|
|
1720
1700
|
}
|
|
1721
1701
|
const data = await this.transport.request({
|
|
1722
1702
|
method: "POST",
|
|
1723
|
-
path: `/integration/product/sellers/${this.sellerId}/products/buybox-information`,
|
|
1703
|
+
path: `/integration/product/sellers/${this.transport.sellerId}/products/buybox-information`,
|
|
1724
1704
|
body: { barcodes },
|
|
1725
1705
|
rateLimiter: this.buyboxLimiter
|
|
1726
1706
|
});
|
|
@@ -1805,7 +1785,7 @@ var ProductsResource = class {
|
|
|
1805
1785
|
this.validateBarcodes(barcodes, "delete");
|
|
1806
1786
|
const data = await this.transport.request({
|
|
1807
1787
|
method: "DELETE",
|
|
1808
|
-
path: `/integration/product/sellers/${this.sellerId}/products`,
|
|
1788
|
+
path: `/integration/product/sellers/${this.transport.sellerId}/products`,
|
|
1809
1789
|
body: { items: barcodes.map((barcode) => ({ barcode })) },
|
|
1810
1790
|
rateLimiter: this.deleteLimiter
|
|
1811
1791
|
});
|
|
@@ -1836,7 +1816,7 @@ var ProductsResource = class {
|
|
|
1836
1816
|
this.validateBarcodes(barcodes, methodLabel);
|
|
1837
1817
|
const data = await this.transport.request({
|
|
1838
1818
|
method: "PUT",
|
|
1839
|
-
path: `/integration/product/sellers/${this.sellerId}/products/archive-state`,
|
|
1819
|
+
path: `/integration/product/sellers/${this.transport.sellerId}/products/archive-state`,
|
|
1840
1820
|
body: { items: barcodes.map((barcode) => ({ barcode, archived })) },
|
|
1841
1821
|
rateLimiter: this.writeLimiter
|
|
1842
1822
|
});
|
|
@@ -1855,7 +1835,7 @@ var ProductsResource = class {
|
|
|
1855
1835
|
this.validateBarcodes(barcodes, "unlock");
|
|
1856
1836
|
const data = await this.transport.request({
|
|
1857
1837
|
method: "PUT",
|
|
1858
|
-
path: `/integration/product/sellers/${this.sellerId}/products/unlock`,
|
|
1838
|
+
path: `/integration/product/sellers/${this.transport.sellerId}/products/unlock`,
|
|
1859
1839
|
body: { items: barcodes.map((barcode) => ({ barcode })) },
|
|
1860
1840
|
rateLimiter: this.writeLimiter
|
|
1861
1841
|
});
|
|
@@ -1908,19 +1888,17 @@ function normalizeQuestion(node) {
|
|
|
1908
1888
|
return out;
|
|
1909
1889
|
}
|
|
1910
1890
|
var QuestionsResource = class {
|
|
1911
|
-
constructor(transport,
|
|
1891
|
+
constructor(transport, limiter) {
|
|
1912
1892
|
this.transport = transport;
|
|
1913
|
-
this.sellerId = sellerId;
|
|
1914
1893
|
this.limiter = limiter ?? new core.TokenBucketRateLimiter({ capacity: 500, intervalMs: 6e4 });
|
|
1915
1894
|
}
|
|
1916
1895
|
transport;
|
|
1917
|
-
sellerId;
|
|
1918
1896
|
limiter;
|
|
1919
1897
|
/** Fetch a single question by its numeric ID. */
|
|
1920
1898
|
async get(questionId) {
|
|
1921
1899
|
const data = await this.transport.request({
|
|
1922
1900
|
method: "GET",
|
|
1923
|
-
path: `/integration/qna/sellers/${this.sellerId}/questions/${encodeURIComponent(String(questionId))}`,
|
|
1901
|
+
path: `/integration/qna/sellers/${this.transport.sellerId}/questions/${encodeURIComponent(String(questionId))}`,
|
|
1924
1902
|
rateLimiter: this.limiter
|
|
1925
1903
|
});
|
|
1926
1904
|
return normalizeQuestion(data);
|
|
@@ -1939,7 +1917,7 @@ var QuestionsResource = class {
|
|
|
1939
1917
|
if (params.status) query.status = params.status;
|
|
1940
1918
|
const data = await this.transport.request({
|
|
1941
1919
|
method: "GET",
|
|
1942
|
-
path: `/integration/qna/sellers/${this.sellerId}/questions/filter`,
|
|
1920
|
+
path: `/integration/qna/sellers/${this.transport.sellerId}/questions/filter`,
|
|
1943
1921
|
query,
|
|
1944
1922
|
rateLimiter: this.limiter
|
|
1945
1923
|
});
|
|
@@ -1970,7 +1948,7 @@ var QuestionsResource = class {
|
|
|
1970
1948
|
}
|
|
1971
1949
|
return this.transport.request({
|
|
1972
1950
|
method: "POST",
|
|
1973
|
-
path: `/integration/qna/sellers/${this.sellerId}/questions/${encodeURIComponent(String(questionId))}/answers`,
|
|
1951
|
+
path: `/integration/qna/sellers/${this.transport.sellerId}/questions/${encodeURIComponent(String(questionId))}/answers`,
|
|
1974
1952
|
body: { text },
|
|
1975
1953
|
rateLimiter: this.limiter
|
|
1976
1954
|
});
|
|
@@ -2010,9 +1988,8 @@ function normalizeAddress2(node) {
|
|
|
2010
1988
|
}
|
|
2011
1989
|
var DEFAULT_CACHE_TTL_MS = 60 * 60 * 1e3;
|
|
2012
1990
|
var SuppliersResource = class {
|
|
2013
|
-
constructor(transport,
|
|
1991
|
+
constructor(transport, options = {}) {
|
|
2014
1992
|
this.transport = transport;
|
|
2015
|
-
this.sellerId = sellerId;
|
|
2016
1993
|
this.cacheTtlMs = options.cacheTtlMs ?? DEFAULT_CACHE_TTL_MS;
|
|
2017
1994
|
this.limiter = new core.TokenBucketRateLimiter({
|
|
2018
1995
|
capacity: 1,
|
|
@@ -2020,7 +1997,6 @@ var SuppliersResource = class {
|
|
|
2020
1997
|
});
|
|
2021
1998
|
}
|
|
2022
1999
|
transport;
|
|
2023
|
-
sellerId;
|
|
2024
2000
|
cache = null;
|
|
2025
2001
|
cacheTtlMs;
|
|
2026
2002
|
limiter;
|
|
@@ -2048,7 +2024,7 @@ var SuppliersResource = class {
|
|
|
2048
2024
|
async fetchFresh() {
|
|
2049
2025
|
const data = await this.transport.request({
|
|
2050
2026
|
method: "GET",
|
|
2051
|
-
path: `/integration/sellers/${this.sellerId}/addresses`,
|
|
2027
|
+
path: `/integration/sellers/${this.transport.sellerId}/addresses`,
|
|
2052
2028
|
rateLimiter: this.limiter
|
|
2053
2029
|
});
|
|
2054
2030
|
const items = data.supplierAddresses.map(normalizeAddress2);
|
|
@@ -2057,13 +2033,11 @@ var SuppliersResource = class {
|
|
|
2057
2033
|
}
|
|
2058
2034
|
};
|
|
2059
2035
|
var TestOrdersResource = class {
|
|
2060
|
-
constructor(transport,
|
|
2036
|
+
constructor(transport, limiter) {
|
|
2061
2037
|
this.transport = transport;
|
|
2062
|
-
this.sellerId = sellerId;
|
|
2063
2038
|
this.limiter = limiter ?? new core.TokenBucketRateLimiter({ capacity: 60, intervalMs: 6e4 });
|
|
2064
2039
|
}
|
|
2065
2040
|
transport;
|
|
2066
|
-
sellerId;
|
|
2067
2041
|
limiter;
|
|
2068
2042
|
/**
|
|
2069
2043
|
* Create a test order with the given customer / addresses / lines. The
|
|
@@ -2089,7 +2063,7 @@ var TestOrdersResource = class {
|
|
|
2089
2063
|
async updateStatus(packageId, status) {
|
|
2090
2064
|
return this.transport.request({
|
|
2091
2065
|
method: "PUT",
|
|
2092
|
-
path: `/integration/test/order/sellers/${this.sellerId}/shipment-packages/${encodeURIComponent(String(packageId))}/status`,
|
|
2066
|
+
path: `/integration/test/order/sellers/${this.transport.sellerId}/shipment-packages/${encodeURIComponent(String(packageId))}/status`,
|
|
2093
2067
|
body: { status },
|
|
2094
2068
|
rateLimiter: this.limiter
|
|
2095
2069
|
});
|
|
@@ -2098,7 +2072,7 @@ var TestOrdersResource = class {
|
|
|
2098
2072
|
async setClaimsWaitingInAction() {
|
|
2099
2073
|
return this.transport.request({
|
|
2100
2074
|
method: "PUT",
|
|
2101
|
-
path: `/integration/test/order/sellers/${this.sellerId}/claims/waiting-in-action`,
|
|
2075
|
+
path: `/integration/test/order/sellers/${this.transport.sellerId}/claims/waiting-in-action`,
|
|
2102
2076
|
rateLimiter: this.limiter
|
|
2103
2077
|
});
|
|
2104
2078
|
}
|
|
@@ -2119,13 +2093,11 @@ function normalizeWebhook(node) {
|
|
|
2119
2093
|
return out;
|
|
2120
2094
|
}
|
|
2121
2095
|
var WebhooksResource = class {
|
|
2122
|
-
constructor(transport,
|
|
2096
|
+
constructor(transport, limiter) {
|
|
2123
2097
|
this.transport = transport;
|
|
2124
|
-
this.sellerId = sellerId;
|
|
2125
2098
|
this.limiter = limiter ?? new core.TokenBucketRateLimiter({ capacity: 50, intervalMs: 6e4 });
|
|
2126
2099
|
}
|
|
2127
2100
|
transport;
|
|
2128
|
-
sellerId;
|
|
2129
2101
|
limiter;
|
|
2130
2102
|
/**
|
|
2131
2103
|
* Create a new webhook subscription. Trendyol caps subscriptions at 15
|
|
@@ -2138,7 +2110,7 @@ var WebhooksResource = class {
|
|
|
2138
2110
|
this.validateInput(input, "create");
|
|
2139
2111
|
return this.transport.request({
|
|
2140
2112
|
method: "POST",
|
|
2141
|
-
path: `/integration/sellers/${this.sellerId}/webhooks`,
|
|
2113
|
+
path: `/integration/sellers/${this.transport.sellerId}/webhooks`,
|
|
2142
2114
|
body: input,
|
|
2143
2115
|
rateLimiter: this.limiter
|
|
2144
2116
|
});
|
|
@@ -2147,7 +2119,7 @@ var WebhooksResource = class {
|
|
|
2147
2119
|
async list() {
|
|
2148
2120
|
const data = await this.transport.request({
|
|
2149
2121
|
method: "GET",
|
|
2150
|
-
path: `/integration/sellers/${this.sellerId}/webhooks`,
|
|
2122
|
+
path: `/integration/sellers/${this.transport.sellerId}/webhooks`,
|
|
2151
2123
|
rateLimiter: this.limiter
|
|
2152
2124
|
});
|
|
2153
2125
|
const rows = Array.isArray(data) ? data : Array.isArray(data?.webhooks) ? data.webhooks : Array.isArray(data?.content) ? data.content : [];
|
|
@@ -2217,7 +2189,7 @@ var WebhooksResource = class {
|
|
|
2217
2189
|
if (input.subscribedStatuses && input.subscribedStatuses.length === 0) ;
|
|
2218
2190
|
}
|
|
2219
2191
|
webhookPath(webhookId) {
|
|
2220
|
-
return `/integration/sellers/${this.sellerId}/webhooks/${encodeURIComponent(String(webhookId))}`;
|
|
2192
|
+
return `/integration/sellers/${this.transport.sellerId}/webhooks/${encodeURIComponent(String(webhookId))}`;
|
|
2221
2193
|
}
|
|
2222
2194
|
};
|
|
2223
2195
|
|
|
@@ -2299,6 +2271,10 @@ var TrendyolTransport = class {
|
|
|
2299
2271
|
logger;
|
|
2300
2272
|
timeoutMs;
|
|
2301
2273
|
fetchImpl;
|
|
2274
|
+
/** Seller ID this transport is configured with. Resources read it for path-building. */
|
|
2275
|
+
get sellerId() {
|
|
2276
|
+
return this.config.sellerId;
|
|
2277
|
+
}
|
|
2302
2278
|
async request(opts) {
|
|
2303
2279
|
return core.retry(
|
|
2304
2280
|
async (attempt) => {
|
|
@@ -2427,18 +2403,18 @@ function createTrendyolClient(opts) {
|
|
|
2427
2403
|
});
|
|
2428
2404
|
return {
|
|
2429
2405
|
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
|
|
2406
|
+
categories: new CategoriesResource(transport),
|
|
2407
|
+
suppliers: new SuppliersResource(transport),
|
|
2408
|
+
products: new ProductsResource(transport),
|
|
2409
|
+
inventory: new InventoryResource(transport),
|
|
2410
|
+
orders: new OrdersResource(transport),
|
|
2411
|
+
claims: new ClaimsResource(transport),
|
|
2412
|
+
webhooks: new WebhooksResource(transport),
|
|
2413
|
+
questions: new QuestionsResource(transport),
|
|
2414
|
+
invoices: new InvoicesResource(transport),
|
|
2415
|
+
finance: new FinanceResource(transport),
|
|
2416
|
+
labels: new LabelsResource(transport),
|
|
2417
|
+
testOrders: new TestOrdersResource(transport),
|
|
2442
2418
|
locations: new LocationsResource(transport)
|
|
2443
2419
|
};
|
|
2444
2420
|
}
|