@lonca/trendyol 0.6.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/README.md +268 -46
- package/dist/index.cjs +73 -98
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -41
- package/dist/index.d.ts +19 -41
- package/dist/index.js +73 -98
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -89,13 +89,11 @@ function normalizeAttribute(node) {
|
|
|
89
89
|
var MAX_ATTR_VALUES_PAGE_SIZE = 1e3;
|
|
90
90
|
var DEFAULT_ATTR_VALUES_PAGE_SIZE = 100;
|
|
91
91
|
var CategoriesResource = class {
|
|
92
|
-
constructor(transport, limiter
|
|
92
|
+
constructor(transport, limiter) {
|
|
93
93
|
this.transport = transport;
|
|
94
|
-
this.sellerId = sellerId;
|
|
95
94
|
this.limiter = limiter ?? new TokenBucketRateLimiter({ capacity: 50, intervalMs: 6e4 });
|
|
96
95
|
}
|
|
97
96
|
transport;
|
|
98
|
-
sellerId;
|
|
99
97
|
limiter;
|
|
100
98
|
/**
|
|
101
99
|
* Fetch the full Trendyol category tree.
|
|
@@ -191,21 +189,14 @@ var CategoriesResource = class {
|
|
|
191
189
|
*
|
|
192
190
|
* @param barcodes 1–N barcodes to look up.
|
|
193
191
|
* @throws {ValidationError} when `barcodes` is empty.
|
|
194
|
-
* @throws Error when the client was created without a `sellerId` and this
|
|
195
|
-
* method is called directly (use `createTrendyolClient` to wire it).
|
|
196
192
|
*/
|
|
197
193
|
async getByBarcodes(barcodes) {
|
|
198
194
|
if (!Array.isArray(barcodes) || barcodes.length === 0) {
|
|
199
195
|
throw new ValidationError({ message: "getByBarcodes: barcodes must not be empty" });
|
|
200
196
|
}
|
|
201
|
-
if (this.sellerId === void 0) {
|
|
202
|
-
throw new Error(
|
|
203
|
-
"CategoriesResource.getByBarcodes requires a sellerId; instantiate via createTrendyolClient"
|
|
204
|
-
);
|
|
205
|
-
}
|
|
206
197
|
const data = await this.transport.request({
|
|
207
198
|
method: "POST",
|
|
208
|
-
path: `/integration/ecgw/v1/${this.sellerId}/lookup/product-categories/by-barcodes`,
|
|
199
|
+
path: `/integration/ecgw/v1/${this.transport.sellerId}/lookup/product-categories/by-barcodes`,
|
|
209
200
|
body: { barcodes },
|
|
210
201
|
rateLimiter: this.limiter
|
|
211
202
|
});
|
|
@@ -253,13 +244,11 @@ function normalizeClaim(node) {
|
|
|
253
244
|
return out;
|
|
254
245
|
}
|
|
255
246
|
var ClaimsResource = class {
|
|
256
|
-
constructor(transport,
|
|
247
|
+
constructor(transport, limiter) {
|
|
257
248
|
this.transport = transport;
|
|
258
|
-
this.sellerId = sellerId;
|
|
259
249
|
this.limiter = limiter ?? new TokenBucketRateLimiter({ capacity: 1e3, intervalMs: 6e4 });
|
|
260
250
|
}
|
|
261
251
|
transport;
|
|
262
|
-
sellerId;
|
|
263
252
|
limiter;
|
|
264
253
|
/**
|
|
265
254
|
* Create a return claim against an order. Use this to file a return on
|
|
@@ -277,7 +266,7 @@ var ClaimsResource = class {
|
|
|
277
266
|
}
|
|
278
267
|
return this.transport.request({
|
|
279
268
|
method: "POST",
|
|
280
|
-
path: `/integration/order/sellers/${this.sellerId}/claims/create`,
|
|
269
|
+
path: `/integration/order/sellers/${this.transport.sellerId}/claims/create`,
|
|
281
270
|
body: input,
|
|
282
271
|
rateLimiter: this.limiter
|
|
283
272
|
});
|
|
@@ -315,7 +304,7 @@ var ClaimsResource = class {
|
|
|
315
304
|
}
|
|
316
305
|
return this.transport.request({
|
|
317
306
|
method: "POST",
|
|
318
|
-
path: `/integration/order/sellers/${this.sellerId}/claims/${encodeURIComponent(claimId)}/issue`,
|
|
307
|
+
path: `/integration/order/sellers/${this.transport.sellerId}/claims/${encodeURIComponent(claimId)}/issue`,
|
|
319
308
|
body: form,
|
|
320
309
|
rateLimiter: this.limiter
|
|
321
310
|
});
|
|
@@ -334,7 +323,7 @@ var ClaimsResource = class {
|
|
|
334
323
|
}
|
|
335
324
|
return this.transport.request({
|
|
336
325
|
method: "PUT",
|
|
337
|
-
path: `/integration/order/sellers/${this.sellerId}/claims/${encodeURIComponent(claimId)}/items/approve`,
|
|
326
|
+
path: `/integration/order/sellers/${this.transport.sellerId}/claims/${encodeURIComponent(claimId)}/items/approve`,
|
|
338
327
|
body: input,
|
|
339
328
|
rateLimiter: this.limiter
|
|
340
329
|
});
|
|
@@ -361,7 +350,7 @@ var ClaimsResource = class {
|
|
|
361
350
|
if (params.claimItemStatus) query.claimItemStatus = params.claimItemStatus;
|
|
362
351
|
const data = await this.transport.request({
|
|
363
352
|
method: "GET",
|
|
364
|
-
path: `/integration/order/sellers/${this.sellerId}/claims`,
|
|
353
|
+
path: `/integration/order/sellers/${this.transport.sellerId}/claims`,
|
|
365
354
|
query,
|
|
366
355
|
rateLimiter: this.limiter
|
|
367
356
|
});
|
|
@@ -399,7 +388,7 @@ var ClaimsResource = class {
|
|
|
399
388
|
async getItemAudits(claimItemId) {
|
|
400
389
|
const data = await this.transport.request({
|
|
401
390
|
method: "GET",
|
|
402
|
-
path: `/integration/order/sellers/${this.sellerId}/claims/items/${encodeURIComponent(claimItemId)}/audit`,
|
|
391
|
+
path: `/integration/order/sellers/${this.transport.sellerId}/claims/items/${encodeURIComponent(claimItemId)}/audit`,
|
|
403
392
|
rateLimiter: this.limiter
|
|
404
393
|
});
|
|
405
394
|
const rows = Array.isArray(data) ? data : Array.isArray(data?.content) ? data.content : [];
|
|
@@ -444,19 +433,20 @@ function normalizeRow(row) {
|
|
|
444
433
|
return out;
|
|
445
434
|
}
|
|
446
435
|
var FinanceResource = class {
|
|
447
|
-
constructor(transport,
|
|
436
|
+
constructor(transport, limiter) {
|
|
448
437
|
this.transport = transport;
|
|
449
|
-
this.sellerId = sellerId;
|
|
450
438
|
this.limiter = limiter ?? new TokenBucketRateLimiter({ capacity: 100, intervalMs: 6e4 });
|
|
451
439
|
}
|
|
452
440
|
transport;
|
|
453
|
-
sellerId;
|
|
454
441
|
limiter;
|
|
455
442
|
async getSettlements(params = {}) {
|
|
456
|
-
return this.queryPage(`/integration/sellers/${this.sellerId}/settlements`, params);
|
|
443
|
+
return this.queryPage(`/integration/sellers/${this.transport.sellerId}/settlements`, params);
|
|
457
444
|
}
|
|
458
445
|
async getOtherFinancials(params = {}) {
|
|
459
|
-
return this.queryPage(
|
|
446
|
+
return this.queryPage(
|
|
447
|
+
`/integration/sellers/${this.transport.sellerId}/otherfinancials`,
|
|
448
|
+
params
|
|
449
|
+
);
|
|
460
450
|
}
|
|
461
451
|
async queryPage(path, params) {
|
|
462
452
|
const size = Math.min(params.limit ?? 50, 200);
|
|
@@ -482,12 +472,10 @@ var FinanceResource = class {
|
|
|
482
472
|
};
|
|
483
473
|
var MAX_ITEMS_PER_REQUEST = 1e3;
|
|
484
474
|
var InventoryResource = class {
|
|
485
|
-
constructor(transport
|
|
475
|
+
constructor(transport) {
|
|
486
476
|
this.transport = transport;
|
|
487
|
-
this.sellerId = sellerId;
|
|
488
477
|
}
|
|
489
478
|
transport;
|
|
490
|
-
sellerId;
|
|
491
479
|
/**
|
|
492
480
|
* Update price and/or stock for one or more SKUs (by barcode).
|
|
493
481
|
*
|
|
@@ -513,20 +501,18 @@ var InventoryResource = class {
|
|
|
513
501
|
}
|
|
514
502
|
const data = await this.transport.request({
|
|
515
503
|
method: "POST",
|
|
516
|
-
path: `/integration/inventory/sellers/${this.sellerId}/products/price-and-inventory`,
|
|
504
|
+
path: `/integration/inventory/sellers/${this.transport.sellerId}/products/price-and-inventory`,
|
|
517
505
|
body: { items }
|
|
518
506
|
});
|
|
519
507
|
return { batchRequestId: data.batchRequestId ?? "" };
|
|
520
508
|
}
|
|
521
509
|
};
|
|
522
510
|
var InvoicesResource = class {
|
|
523
|
-
constructor(transport,
|
|
511
|
+
constructor(transport, limiter) {
|
|
524
512
|
this.transport = transport;
|
|
525
|
-
this.sellerId = sellerId;
|
|
526
513
|
this.limiter = limiter ?? new TokenBucketRateLimiter({ capacity: 500, intervalMs: 6e4 });
|
|
527
514
|
}
|
|
528
515
|
transport;
|
|
529
|
-
sellerId;
|
|
530
516
|
limiter;
|
|
531
517
|
/**
|
|
532
518
|
* Upload an invoice file for a shipment package. **Multipart**: the
|
|
@@ -552,7 +538,7 @@ var InvoicesResource = class {
|
|
|
552
538
|
}
|
|
553
539
|
return this.transport.request({
|
|
554
540
|
method: "POST",
|
|
555
|
-
path: `/integration/sellers/${this.sellerId}/seller-invoice-file`,
|
|
541
|
+
path: `/integration/sellers/${this.transport.sellerId}/seller-invoice-file`,
|
|
556
542
|
body: form,
|
|
557
543
|
rateLimiter: this.limiter
|
|
558
544
|
});
|
|
@@ -564,7 +550,7 @@ var InvoicesResource = class {
|
|
|
564
550
|
}
|
|
565
551
|
return this.transport.request({
|
|
566
552
|
method: "POST",
|
|
567
|
-
path: `/integration/sellers/${this.sellerId}/seller-invoice-links`,
|
|
553
|
+
path: `/integration/sellers/${this.transport.sellerId}/seller-invoice-links`,
|
|
568
554
|
body: input,
|
|
569
555
|
rateLimiter: this.limiter
|
|
570
556
|
});
|
|
@@ -573,20 +559,18 @@ var InvoicesResource = class {
|
|
|
573
559
|
async deleteLink(input) {
|
|
574
560
|
return this.transport.request({
|
|
575
561
|
method: "POST",
|
|
576
|
-
path: `/integration/sellers/${this.sellerId}/seller-invoice-links/delete`,
|
|
562
|
+
path: `/integration/sellers/${this.transport.sellerId}/seller-invoice-links/delete`,
|
|
577
563
|
body: input,
|
|
578
564
|
rateLimiter: this.limiter
|
|
579
565
|
});
|
|
580
566
|
}
|
|
581
567
|
};
|
|
582
568
|
var LabelsResource = class {
|
|
583
|
-
constructor(transport,
|
|
569
|
+
constructor(transport, limiter) {
|
|
584
570
|
this.transport = transport;
|
|
585
|
-
this.sellerId = sellerId;
|
|
586
571
|
this.limiter = limiter ?? new TokenBucketRateLimiter({ capacity: 100, intervalMs: 6e4 });
|
|
587
572
|
}
|
|
588
573
|
transport;
|
|
589
|
-
sellerId;
|
|
590
574
|
limiter;
|
|
591
575
|
/**
|
|
592
576
|
* Request a common ZPL label for a cargo tracking number. After this
|
|
@@ -601,7 +585,7 @@ var LabelsResource = class {
|
|
|
601
585
|
}
|
|
602
586
|
return this.transport.request({
|
|
603
587
|
method: "POST",
|
|
604
|
-
path: `/integration/sellers/${this.sellerId}/common-label/${encodeURIComponent(String(cargoTrackingNumber))}`,
|
|
588
|
+
path: `/integration/sellers/${this.transport.sellerId}/common-label/${encodeURIComponent(String(cargoTrackingNumber))}`,
|
|
605
589
|
body: input,
|
|
606
590
|
rateLimiter: this.limiter
|
|
607
591
|
});
|
|
@@ -617,7 +601,7 @@ var LabelsResource = class {
|
|
|
617
601
|
async getCommon(cargoTrackingNumber) {
|
|
618
602
|
const raw = await this.transport.request({
|
|
619
603
|
method: "GET",
|
|
620
|
-
path: `/integration/sellers/${this.sellerId}/common-label/${encodeURIComponent(String(cargoTrackingNumber))}`,
|
|
604
|
+
path: `/integration/sellers/${this.transport.sellerId}/common-label/${encodeURIComponent(String(cargoTrackingNumber))}`,
|
|
621
605
|
rateLimiter: this.limiter
|
|
622
606
|
});
|
|
623
607
|
const labels = (raw?.data ?? []).map((row) => ({
|
|
@@ -880,13 +864,11 @@ function normalizePackage(node) {
|
|
|
880
864
|
return out;
|
|
881
865
|
}
|
|
882
866
|
var OrdersResource = class {
|
|
883
|
-
constructor(transport,
|
|
867
|
+
constructor(transport, limiter) {
|
|
884
868
|
this.transport = transport;
|
|
885
|
-
this.sellerId = sellerId;
|
|
886
869
|
this.limiter = limiter ?? new TokenBucketRateLimiter({ capacity: 1e3, intervalMs: 6e4 });
|
|
887
870
|
}
|
|
888
871
|
transport;
|
|
889
|
-
sellerId;
|
|
890
872
|
limiter;
|
|
891
873
|
/**
|
|
892
874
|
* List shipment packages for the seller.
|
|
@@ -909,7 +891,7 @@ var OrdersResource = class {
|
|
|
909
891
|
if (params.endDate) query.endDate = params.endDate.getTime();
|
|
910
892
|
const data = await this.transport.request({
|
|
911
893
|
method: "GET",
|
|
912
|
-
path: `/integration/order/sellers/${this.sellerId}/orders`,
|
|
894
|
+
path: `/integration/order/sellers/${this.transport.sellerId}/orders`,
|
|
913
895
|
query,
|
|
914
896
|
rateLimiter: this.limiter
|
|
915
897
|
});
|
|
@@ -1118,7 +1100,7 @@ var OrdersResource = class {
|
|
|
1118
1100
|
async manualDeliverByTrackingNumber(cargoTrackingNumber) {
|
|
1119
1101
|
await this.transport.request({
|
|
1120
1102
|
method: "PUT",
|
|
1121
|
-
path: `/integration/order/sellers/${this.sellerId}/shipment-packages/manual-invoice-delivery-by-tracking-number/${encodeURIComponent(String(cargoTrackingNumber))}`,
|
|
1103
|
+
path: `/integration/order/sellers/${this.transport.sellerId}/shipment-packages/manual-invoice-delivery-by-tracking-number/${encodeURIComponent(String(cargoTrackingNumber))}`,
|
|
1122
1104
|
rateLimiter: this.limiter
|
|
1123
1105
|
});
|
|
1124
1106
|
}
|
|
@@ -1206,7 +1188,7 @@ var OrdersResource = class {
|
|
|
1206
1188
|
}
|
|
1207
1189
|
const data = await this.transport.request({
|
|
1208
1190
|
method: "GET",
|
|
1209
|
-
path: `/integration/order/sellers/${this.sellerId}/orders/stream`,
|
|
1191
|
+
path: `/integration/order/sellers/${this.transport.sellerId}/orders/stream`,
|
|
1210
1192
|
query,
|
|
1211
1193
|
rateLimiter: this.limiter
|
|
1212
1194
|
});
|
|
@@ -1232,7 +1214,7 @@ var OrdersResource = class {
|
|
|
1232
1214
|
const page = params.cursor ? Number.parseInt(params.cursor, 10) : 0;
|
|
1233
1215
|
const data = await this.transport.request({
|
|
1234
1216
|
method: "GET",
|
|
1235
|
-
path: `/integration/finance/che/sellers/${this.sellerId}/cargo-invoice/${encodeURIComponent(invoiceSerialNumber)}/items`,
|
|
1217
|
+
path: `/integration/finance/che/sellers/${this.transport.sellerId}/cargo-invoice/${encodeURIComponent(invoiceSerialNumber)}/items`,
|
|
1236
1218
|
query: { page, size },
|
|
1237
1219
|
rateLimiter: this.limiter
|
|
1238
1220
|
});
|
|
@@ -1278,7 +1260,7 @@ var OrdersResource = class {
|
|
|
1278
1260
|
async manualReturnByTrackingNumber(cargoTrackingNumber) {
|
|
1279
1261
|
await this.transport.request({
|
|
1280
1262
|
method: "PUT",
|
|
1281
|
-
path: `/integration/order/sellers/${this.sellerId}/shipment-packages/manual-return-by-tracking-number/${encodeURIComponent(String(cargoTrackingNumber))}`,
|
|
1263
|
+
path: `/integration/order/sellers/${this.transport.sellerId}/shipment-packages/manual-return-by-tracking-number/${encodeURIComponent(String(cargoTrackingNumber))}`,
|
|
1282
1264
|
rateLimiter: this.limiter
|
|
1283
1265
|
});
|
|
1284
1266
|
}
|
|
@@ -1310,7 +1292,7 @@ var OrdersResource = class {
|
|
|
1310
1292
|
if (params.endDate) query.endDate = params.endDate.getTime();
|
|
1311
1293
|
const res = await this.transport.request({
|
|
1312
1294
|
method: "GET",
|
|
1313
|
-
path: `/integration/tex/compensation/sellers/${this.sellerId}/tickets`,
|
|
1295
|
+
path: `/integration/tex/compensation/sellers/${this.transport.sellerId}/tickets`,
|
|
1314
1296
|
query,
|
|
1315
1297
|
rateLimiter: this.limiter
|
|
1316
1298
|
});
|
|
@@ -1350,7 +1332,7 @@ var OrdersResource = class {
|
|
|
1350
1332
|
return result;
|
|
1351
1333
|
}
|
|
1352
1334
|
packagePath(packageId) {
|
|
1353
|
-
return `/integration/order/sellers/${this.sellerId}/shipment-packages/${encodeURIComponent(String(packageId))}`;
|
|
1335
|
+
return `/integration/order/sellers/${this.transport.sellerId}/shipment-packages/${encodeURIComponent(String(packageId))}`;
|
|
1354
1336
|
}
|
|
1355
1337
|
};
|
|
1356
1338
|
var DEFAULT_PAGE_SIZE3 = 50;
|
|
@@ -1526,9 +1508,8 @@ function normalizeBatchResult(data) {
|
|
|
1526
1508
|
var MAX_WRITE_ITEMS = 1e3;
|
|
1527
1509
|
var DELETE_RATE_PER_MIN = 100;
|
|
1528
1510
|
var ProductsResource = class {
|
|
1529
|
-
constructor(transport,
|
|
1511
|
+
constructor(transport, options = {}) {
|
|
1530
1512
|
this.transport = transport;
|
|
1531
|
-
this.sellerId = sellerId;
|
|
1532
1513
|
this.filterLimiter = options.filterLimiter ?? new TokenBucketRateLimiter({ capacity: 2e3, intervalMs: 6e4 });
|
|
1533
1514
|
this.batchLimiter = options.batchLimiter ?? new TokenBucketRateLimiter({ capacity: 1e3, intervalMs: 6e4 });
|
|
1534
1515
|
this.buyboxLimiter = options.buyboxLimiter ?? new TokenBucketRateLimiter({ capacity: 1e3, intervalMs: 6e4 });
|
|
@@ -1536,7 +1517,6 @@ var ProductsResource = class {
|
|
|
1536
1517
|
this.deleteLimiter = options.deleteLimiter ?? new TokenBucketRateLimiter({ capacity: DELETE_RATE_PER_MIN, intervalMs: 6e4 });
|
|
1537
1518
|
}
|
|
1538
1519
|
transport;
|
|
1539
|
-
sellerId;
|
|
1540
1520
|
filterLimiter;
|
|
1541
1521
|
batchLimiter;
|
|
1542
1522
|
buyboxLimiter;
|
|
@@ -1563,7 +1543,7 @@ var ProductsResource = class {
|
|
|
1563
1543
|
}
|
|
1564
1544
|
const data = await this.transport.request({
|
|
1565
1545
|
method: "POST",
|
|
1566
|
-
path: `/integration/product/sellers/${this.sellerId}${endpoint}`,
|
|
1546
|
+
path: `/integration/product/sellers/${this.transport.sellerId}${endpoint}`,
|
|
1567
1547
|
body: { items },
|
|
1568
1548
|
rateLimiter: this.writeLimiter
|
|
1569
1549
|
});
|
|
@@ -1601,7 +1581,7 @@ var ProductsResource = class {
|
|
|
1601
1581
|
if (params.endDate) query.endDate = params.endDate.getTime();
|
|
1602
1582
|
const data = await this.transport.request({
|
|
1603
1583
|
method: "GET",
|
|
1604
|
-
path: `/integration/product/sellers/${this.sellerId}/products/approved`,
|
|
1584
|
+
path: `/integration/product/sellers/${this.transport.sellerId}/products/approved`,
|
|
1605
1585
|
query,
|
|
1606
1586
|
rateLimiter: this.filterLimiter
|
|
1607
1587
|
});
|
|
@@ -1625,7 +1605,7 @@ var ProductsResource = class {
|
|
|
1625
1605
|
const id = encodeURIComponent(batchRequestId);
|
|
1626
1606
|
const data = await this.transport.request({
|
|
1627
1607
|
method: "GET",
|
|
1628
|
-
path: `/integration/product/sellers/${this.sellerId}/products/batch-requests/${id}`,
|
|
1608
|
+
path: `/integration/product/sellers/${this.transport.sellerId}/products/batch-requests/${id}`,
|
|
1629
1609
|
rateLimiter: this.batchLimiter
|
|
1630
1610
|
});
|
|
1631
1611
|
return normalizeBatchResult(data);
|
|
@@ -1666,7 +1646,7 @@ var ProductsResource = class {
|
|
|
1666
1646
|
if (params.supplierId !== void 0) query.supplierId = params.supplierId;
|
|
1667
1647
|
const data = await this.transport.request({
|
|
1668
1648
|
method: "GET",
|
|
1669
|
-
path: `/integration/product/sellers/${this.sellerId}/products/unapproved`,
|
|
1649
|
+
path: `/integration/product/sellers/${this.transport.sellerId}/products/unapproved`,
|
|
1670
1650
|
query,
|
|
1671
1651
|
rateLimiter: this.filterLimiter
|
|
1672
1652
|
});
|
|
@@ -1690,7 +1670,7 @@ var ProductsResource = class {
|
|
|
1690
1670
|
const code = encodeURIComponent(barcode);
|
|
1691
1671
|
const data = await this.transport.request({
|
|
1692
1672
|
method: "GET",
|
|
1693
|
-
path: `/integration/product/sellers/${this.sellerId}/product/${code}`,
|
|
1673
|
+
path: `/integration/product/sellers/${this.transport.sellerId}/product/${code}`,
|
|
1694
1674
|
rateLimiter: this.filterLimiter
|
|
1695
1675
|
});
|
|
1696
1676
|
return normalizeProductBase(data);
|
|
@@ -1718,7 +1698,7 @@ var ProductsResource = class {
|
|
|
1718
1698
|
}
|
|
1719
1699
|
const data = await this.transport.request({
|
|
1720
1700
|
method: "POST",
|
|
1721
|
-
path: `/integration/product/sellers/${this.sellerId}/products/buybox-information`,
|
|
1701
|
+
path: `/integration/product/sellers/${this.transport.sellerId}/products/buybox-information`,
|
|
1722
1702
|
body: { barcodes },
|
|
1723
1703
|
rateLimiter: this.buyboxLimiter
|
|
1724
1704
|
});
|
|
@@ -1803,7 +1783,7 @@ var ProductsResource = class {
|
|
|
1803
1783
|
this.validateBarcodes(barcodes, "delete");
|
|
1804
1784
|
const data = await this.transport.request({
|
|
1805
1785
|
method: "DELETE",
|
|
1806
|
-
path: `/integration/product/sellers/${this.sellerId}/products`,
|
|
1786
|
+
path: `/integration/product/sellers/${this.transport.sellerId}/products`,
|
|
1807
1787
|
body: { items: barcodes.map((barcode) => ({ barcode })) },
|
|
1808
1788
|
rateLimiter: this.deleteLimiter
|
|
1809
1789
|
});
|
|
@@ -1834,7 +1814,7 @@ var ProductsResource = class {
|
|
|
1834
1814
|
this.validateBarcodes(barcodes, methodLabel);
|
|
1835
1815
|
const data = await this.transport.request({
|
|
1836
1816
|
method: "PUT",
|
|
1837
|
-
path: `/integration/product/sellers/${this.sellerId}/products/archive-state`,
|
|
1817
|
+
path: `/integration/product/sellers/${this.transport.sellerId}/products/archive-state`,
|
|
1838
1818
|
body: { items: barcodes.map((barcode) => ({ barcode, archived })) },
|
|
1839
1819
|
rateLimiter: this.writeLimiter
|
|
1840
1820
|
});
|
|
@@ -1853,7 +1833,7 @@ var ProductsResource = class {
|
|
|
1853
1833
|
this.validateBarcodes(barcodes, "unlock");
|
|
1854
1834
|
const data = await this.transport.request({
|
|
1855
1835
|
method: "PUT",
|
|
1856
|
-
path: `/integration/product/sellers/${this.sellerId}/products/unlock`,
|
|
1836
|
+
path: `/integration/product/sellers/${this.transport.sellerId}/products/unlock`,
|
|
1857
1837
|
body: { items: barcodes.map((barcode) => ({ barcode })) },
|
|
1858
1838
|
rateLimiter: this.writeLimiter
|
|
1859
1839
|
});
|
|
@@ -1906,19 +1886,17 @@ function normalizeQuestion(node) {
|
|
|
1906
1886
|
return out;
|
|
1907
1887
|
}
|
|
1908
1888
|
var QuestionsResource = class {
|
|
1909
|
-
constructor(transport,
|
|
1889
|
+
constructor(transport, limiter) {
|
|
1910
1890
|
this.transport = transport;
|
|
1911
|
-
this.sellerId = sellerId;
|
|
1912
1891
|
this.limiter = limiter ?? new TokenBucketRateLimiter({ capacity: 500, intervalMs: 6e4 });
|
|
1913
1892
|
}
|
|
1914
1893
|
transport;
|
|
1915
|
-
sellerId;
|
|
1916
1894
|
limiter;
|
|
1917
1895
|
/** Fetch a single question by its numeric ID. */
|
|
1918
1896
|
async get(questionId) {
|
|
1919
1897
|
const data = await this.transport.request({
|
|
1920
1898
|
method: "GET",
|
|
1921
|
-
path: `/integration/qna/sellers/${this.sellerId}/questions/${encodeURIComponent(String(questionId))}`,
|
|
1899
|
+
path: `/integration/qna/sellers/${this.transport.sellerId}/questions/${encodeURIComponent(String(questionId))}`,
|
|
1922
1900
|
rateLimiter: this.limiter
|
|
1923
1901
|
});
|
|
1924
1902
|
return normalizeQuestion(data);
|
|
@@ -1937,7 +1915,7 @@ var QuestionsResource = class {
|
|
|
1937
1915
|
if (params.status) query.status = params.status;
|
|
1938
1916
|
const data = await this.transport.request({
|
|
1939
1917
|
method: "GET",
|
|
1940
|
-
path: `/integration/qna/sellers/${this.sellerId}/questions/filter`,
|
|
1918
|
+
path: `/integration/qna/sellers/${this.transport.sellerId}/questions/filter`,
|
|
1941
1919
|
query,
|
|
1942
1920
|
rateLimiter: this.limiter
|
|
1943
1921
|
});
|
|
@@ -1968,7 +1946,7 @@ var QuestionsResource = class {
|
|
|
1968
1946
|
}
|
|
1969
1947
|
return this.transport.request({
|
|
1970
1948
|
method: "POST",
|
|
1971
|
-
path: `/integration/qna/sellers/${this.sellerId}/questions/${encodeURIComponent(String(questionId))}/answers`,
|
|
1949
|
+
path: `/integration/qna/sellers/${this.transport.sellerId}/questions/${encodeURIComponent(String(questionId))}/answers`,
|
|
1972
1950
|
body: { text },
|
|
1973
1951
|
rateLimiter: this.limiter
|
|
1974
1952
|
});
|
|
@@ -2008,9 +1986,8 @@ function normalizeAddress2(node) {
|
|
|
2008
1986
|
}
|
|
2009
1987
|
var DEFAULT_CACHE_TTL_MS = 60 * 60 * 1e3;
|
|
2010
1988
|
var SuppliersResource = class {
|
|
2011
|
-
constructor(transport,
|
|
1989
|
+
constructor(transport, options = {}) {
|
|
2012
1990
|
this.transport = transport;
|
|
2013
|
-
this.sellerId = sellerId;
|
|
2014
1991
|
this.cacheTtlMs = options.cacheTtlMs ?? DEFAULT_CACHE_TTL_MS;
|
|
2015
1992
|
this.limiter = new TokenBucketRateLimiter({
|
|
2016
1993
|
capacity: 1,
|
|
@@ -2018,7 +1995,6 @@ var SuppliersResource = class {
|
|
|
2018
1995
|
});
|
|
2019
1996
|
}
|
|
2020
1997
|
transport;
|
|
2021
|
-
sellerId;
|
|
2022
1998
|
cache = null;
|
|
2023
1999
|
cacheTtlMs;
|
|
2024
2000
|
limiter;
|
|
@@ -2046,7 +2022,7 @@ var SuppliersResource = class {
|
|
|
2046
2022
|
async fetchFresh() {
|
|
2047
2023
|
const data = await this.transport.request({
|
|
2048
2024
|
method: "GET",
|
|
2049
|
-
path: `/integration/sellers/${this.sellerId}/addresses`,
|
|
2025
|
+
path: `/integration/sellers/${this.transport.sellerId}/addresses`,
|
|
2050
2026
|
rateLimiter: this.limiter
|
|
2051
2027
|
});
|
|
2052
2028
|
const items = data.supplierAddresses.map(normalizeAddress2);
|
|
@@ -2055,13 +2031,11 @@ var SuppliersResource = class {
|
|
|
2055
2031
|
}
|
|
2056
2032
|
};
|
|
2057
2033
|
var TestOrdersResource = class {
|
|
2058
|
-
constructor(transport,
|
|
2034
|
+
constructor(transport, limiter) {
|
|
2059
2035
|
this.transport = transport;
|
|
2060
|
-
this.sellerId = sellerId;
|
|
2061
2036
|
this.limiter = limiter ?? new TokenBucketRateLimiter({ capacity: 60, intervalMs: 6e4 });
|
|
2062
2037
|
}
|
|
2063
2038
|
transport;
|
|
2064
|
-
sellerId;
|
|
2065
2039
|
limiter;
|
|
2066
2040
|
/**
|
|
2067
2041
|
* Create a test order with the given customer / addresses / lines. The
|
|
@@ -2087,7 +2061,7 @@ var TestOrdersResource = class {
|
|
|
2087
2061
|
async updateStatus(packageId, status) {
|
|
2088
2062
|
return this.transport.request({
|
|
2089
2063
|
method: "PUT",
|
|
2090
|
-
path: `/integration/test/order/sellers/${this.sellerId}/shipment-packages/${encodeURIComponent(String(packageId))}/status`,
|
|
2064
|
+
path: `/integration/test/order/sellers/${this.transport.sellerId}/shipment-packages/${encodeURIComponent(String(packageId))}/status`,
|
|
2091
2065
|
body: { status },
|
|
2092
2066
|
rateLimiter: this.limiter
|
|
2093
2067
|
});
|
|
@@ -2096,7 +2070,7 @@ var TestOrdersResource = class {
|
|
|
2096
2070
|
async setClaimsWaitingInAction() {
|
|
2097
2071
|
return this.transport.request({
|
|
2098
2072
|
method: "PUT",
|
|
2099
|
-
path: `/integration/test/order/sellers/${this.sellerId}/claims/waiting-in-action`,
|
|
2073
|
+
path: `/integration/test/order/sellers/${this.transport.sellerId}/claims/waiting-in-action`,
|
|
2100
2074
|
rateLimiter: this.limiter
|
|
2101
2075
|
});
|
|
2102
2076
|
}
|
|
@@ -2117,13 +2091,11 @@ function normalizeWebhook(node) {
|
|
|
2117
2091
|
return out;
|
|
2118
2092
|
}
|
|
2119
2093
|
var WebhooksResource = class {
|
|
2120
|
-
constructor(transport,
|
|
2094
|
+
constructor(transport, limiter) {
|
|
2121
2095
|
this.transport = transport;
|
|
2122
|
-
this.sellerId = sellerId;
|
|
2123
2096
|
this.limiter = limiter ?? new TokenBucketRateLimiter({ capacity: 50, intervalMs: 6e4 });
|
|
2124
2097
|
}
|
|
2125
2098
|
transport;
|
|
2126
|
-
sellerId;
|
|
2127
2099
|
limiter;
|
|
2128
2100
|
/**
|
|
2129
2101
|
* Create a new webhook subscription. Trendyol caps subscriptions at 15
|
|
@@ -2136,7 +2108,7 @@ var WebhooksResource = class {
|
|
|
2136
2108
|
this.validateInput(input, "create");
|
|
2137
2109
|
return this.transport.request({
|
|
2138
2110
|
method: "POST",
|
|
2139
|
-
path: `/integration/sellers/${this.sellerId}/webhooks`,
|
|
2111
|
+
path: `/integration/sellers/${this.transport.sellerId}/webhooks`,
|
|
2140
2112
|
body: input,
|
|
2141
2113
|
rateLimiter: this.limiter
|
|
2142
2114
|
});
|
|
@@ -2145,7 +2117,7 @@ var WebhooksResource = class {
|
|
|
2145
2117
|
async list() {
|
|
2146
2118
|
const data = await this.transport.request({
|
|
2147
2119
|
method: "GET",
|
|
2148
|
-
path: `/integration/sellers/${this.sellerId}/webhooks`,
|
|
2120
|
+
path: `/integration/sellers/${this.transport.sellerId}/webhooks`,
|
|
2149
2121
|
rateLimiter: this.limiter
|
|
2150
2122
|
});
|
|
2151
2123
|
const rows = Array.isArray(data) ? data : Array.isArray(data?.webhooks) ? data.webhooks : Array.isArray(data?.content) ? data.content : [];
|
|
@@ -2215,7 +2187,7 @@ var WebhooksResource = class {
|
|
|
2215
2187
|
if (input.subscribedStatuses && input.subscribedStatuses.length === 0) ;
|
|
2216
2188
|
}
|
|
2217
2189
|
webhookPath(webhookId) {
|
|
2218
|
-
return `/integration/sellers/${this.sellerId}/webhooks/${encodeURIComponent(String(webhookId))}`;
|
|
2190
|
+
return `/integration/sellers/${this.transport.sellerId}/webhooks/${encodeURIComponent(String(webhookId))}`;
|
|
2219
2191
|
}
|
|
2220
2192
|
};
|
|
2221
2193
|
|
|
@@ -2224,7 +2196,7 @@ function buildAuthHeader(apiKey, apiSecret) {
|
|
|
2224
2196
|
const token = Buffer.from(`${apiKey}:${apiSecret}`, "utf8").toString("base64");
|
|
2225
2197
|
return `Basic ${token}`;
|
|
2226
2198
|
}
|
|
2227
|
-
function buildUserAgent(sellerId, integratorName
|
|
2199
|
+
function buildUserAgent(sellerId, integratorName) {
|
|
2228
2200
|
return `${sellerId} - ${integratorName}`;
|
|
2229
2201
|
}
|
|
2230
2202
|
function mapHttpError(status, body, retryAfterMs) {
|
|
@@ -2297,6 +2269,10 @@ var TrendyolTransport = class {
|
|
|
2297
2269
|
logger;
|
|
2298
2270
|
timeoutMs;
|
|
2299
2271
|
fetchImpl;
|
|
2272
|
+
/** Seller ID this transport is configured with. Resources read it for path-building. */
|
|
2273
|
+
get sellerId() {
|
|
2274
|
+
return this.config.sellerId;
|
|
2275
|
+
}
|
|
2300
2276
|
async request(opts) {
|
|
2301
2277
|
return retry(
|
|
2302
2278
|
async (attempt) => {
|
|
@@ -2385,13 +2361,12 @@ var TrendyolTransport = class {
|
|
|
2385
2361
|
return url.toString();
|
|
2386
2362
|
}
|
|
2387
2363
|
buildHeaders(correlationId) {
|
|
2388
|
-
const integratorName = this.config.integratorName ?? "SelfIntegration";
|
|
2389
2364
|
return {
|
|
2390
2365
|
Authorization: buildAuthHeader(this.config.apiKey, this.config.apiSecret),
|
|
2391
2366
|
"x-clientip": this.config.clientIp ?? "127.0.0.1",
|
|
2392
2367
|
"x-correlationid": correlationId,
|
|
2393
|
-
"x-agentname": integratorName,
|
|
2394
|
-
"User-Agent": buildUserAgent(this.config.sellerId, integratorName),
|
|
2368
|
+
"x-agentname": this.config.integratorName,
|
|
2369
|
+
"User-Agent": buildUserAgent(this.config.sellerId, this.config.integratorName),
|
|
2395
2370
|
"Content-Type": "application/json",
|
|
2396
2371
|
Accept: "application/json"
|
|
2397
2372
|
};
|
|
@@ -2426,18 +2401,18 @@ function createTrendyolClient(opts) {
|
|
|
2426
2401
|
});
|
|
2427
2402
|
return {
|
|
2428
2403
|
brands: new BrandsResource(transport),
|
|
2429
|
-
categories: new CategoriesResource(transport
|
|
2430
|
-
suppliers: new SuppliersResource(transport
|
|
2431
|
-
products: new ProductsResource(transport
|
|
2432
|
-
inventory: new InventoryResource(transport
|
|
2433
|
-
orders: new OrdersResource(transport
|
|
2434
|
-
claims: new ClaimsResource(transport
|
|
2435
|
-
webhooks: new WebhooksResource(transport
|
|
2436
|
-
questions: new QuestionsResource(transport
|
|
2437
|
-
invoices: new InvoicesResource(transport
|
|
2438
|
-
finance: new FinanceResource(transport
|
|
2439
|
-
labels: new LabelsResource(transport
|
|
2440
|
-
testOrders: new TestOrdersResource(transport
|
|
2404
|
+
categories: new CategoriesResource(transport),
|
|
2405
|
+
suppliers: new SuppliersResource(transport),
|
|
2406
|
+
products: new ProductsResource(transport),
|
|
2407
|
+
inventory: new InventoryResource(transport),
|
|
2408
|
+
orders: new OrdersResource(transport),
|
|
2409
|
+
claims: new ClaimsResource(transport),
|
|
2410
|
+
webhooks: new WebhooksResource(transport),
|
|
2411
|
+
questions: new QuestionsResource(transport),
|
|
2412
|
+
invoices: new InvoicesResource(transport),
|
|
2413
|
+
finance: new FinanceResource(transport),
|
|
2414
|
+
labels: new LabelsResource(transport),
|
|
2415
|
+
testOrders: new TestOrdersResource(transport),
|
|
2441
2416
|
locations: new LocationsResource(transport)
|
|
2442
2417
|
};
|
|
2443
2418
|
}
|