@lonca/trendyol 0.8.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 +326 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +271 -2
- package/dist/index.d.ts +271 -2
- package/dist/index.js +325 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,32 +10,34 @@ Type-safe TypeScript SDK for the [Trendyol Marketplace API](https://developers.t
|
|
|
10
10
|
|
|
11
11
|
Each entry is a method on the client. Endpoints marked `★` are discovery-first wire-verified against live Trendyol STAGE — the SDK normalizes any spec/wire mismatch.
|
|
12
12
|
|
|
13
|
-
| Resource | Methods
|
|
14
|
-
| ---------------- |
|
|
15
|
-
| `brands` | `list()`, `search(name)` ★
|
|
16
|
-
| `categories` | `list()`, `getAttributes(id)`, `getAttributeValues(catId, attrId)` ★, `getByBarcodes(barcodes)` (AutoFT)
|
|
17
|
-
| `suppliers` | `getAddresses({forceRefresh?})` (1-hour cache; rate-limited 1 req/hour on Trendyol)
|
|
18
|
-
| `products` read | `list({...})` ★, `listUnapproved({...})` ★, `getBase(barcode)` ★, `getBuyboxInfo(barcodes)` ★, `getBatchStatus(id)` ★
|
|
19
|
-
| `products` write | `create(items)`, `updateContent(items)`, `updateVariants(items)`, `updateUnapproved(items)` ★, `updateDeliveryInfo(items)`
|
|
20
|
-
| `products` life | `delete(barcodes)`, `archive(barcodes)`, `unarchive(barcodes)`, `unlock(barcodes)`
|
|
21
|
-
| `inventory` | `update(items)` ★ (stock + price, async batch)
|
|
22
|
-
| `orders` read | `list({...})` ★, `listStream({...})` ★ (opaque cursor for >10K), `getCargoInvoiceItems(serial, {...})`
|
|
23
|
-
| `orders` write | `updatePackageStatus(id, {...})`, `cancelPackageItem(id, {...})`, `extendDeliveryDate(id, 1\|2\|3)`, `processAlternativeDelivery(id, {...})`
|
|
24
|
-
| `orders` split | `splitPackage`, `splitPackageByQuantity`, `multiSplitPackage`, `splitMultiPackagesByQuantity` (4 variants)
|
|
25
|
-
| `orders` cargo | `changeCargoProvider(id, code)`, `manualDeliverByPackageId(id)`, `manualDeliverByTrackingNumber(trk)`, `markDeliveredByService(id)`
|
|
26
|
-
| `orders` ops | `updateBoxInfo(id, {...})`, `updateLaborCosts(id, items)`, `updateWarehouse(id, warehouseId)`
|
|
27
|
-
| `orders` returns | `manualReturnByPackageId(id)`, `manualReturnByTrackingNumber(trk)`, `getCompensationTickets({...})` (TEX)
|
|
28
|
-
| `claims` | `create({...})`, `createIssue(id, {...})` (multipart), `approveLineItems(id, {...})`, `list({...})`, `getIssueReasons()` ★, `getItemAudits(itemId)` ★
|
|
29
|
-
| `webhooks` | `create({...})`, `list()`, `update(id, {...})`, `delete(id)`, `activate(id)`, `deactivate(id)`
|
|
30
|
-
| `questions` | `get(id)`, `list({...})` ★, `answer(id, text)`
|
|
31
|
-
| `invoices` | `uploadFile({shipmentPackageId, file, ...})` (multipart), `sendLink({...})`, `deleteLink({...})`
|
|
32
|
-
| `finance` | `getSettlements({...})`, `getOtherFinancials({...})` — both return typed `FinancialTransaction[]` ★
|
|
33
|
-
| `labels` | `createCommon(trackingNumber, {format: 'ZPL', ...})`, `getCommon(trackingNumber)` ★
|
|
34
|
-
| `testOrders` | `create({...})`, `updateStatus(id, status)`, `setClaimsWaitingInAction()` — **STAGE-only utility**
|
|
35
|
-
| `locations` | `getCountries()` ★, `getTurkeyCities()` ★, `getTurkeyDistricts(cityCode)`, `getTurkeyNeighborhoods(cityCode, districtCode)`, `getAzerbaijanCities()`, `getAzerbaijanDistricts(...)`, `getCitiesByCountry/getDistrictsByCity(...)`
|
|
36
|
-
|
|
|
37
|
-
|
|
38
|
-
**
|
|
13
|
+
| Resource | Methods |
|
|
14
|
+
| ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
15
|
+
| `brands` | `list()`, `search(name)` ★ |
|
|
16
|
+
| `categories` | `list()`, `getAttributes(id)`, `getAttributeValues(catId, attrId)` ★, `getByBarcodes(barcodes)` (AutoFT) |
|
|
17
|
+
| `suppliers` | `getAddresses({forceRefresh?})` (1-hour cache; rate-limited 1 req/hour on Trendyol) |
|
|
18
|
+
| `products` read | `list({...})` ★, `listUnapproved({...})` ★, `getBase(barcode)` ★, `getBuyboxInfo(barcodes)` ★, `getBatchStatus(id)` ★ |
|
|
19
|
+
| `products` write | `create(items)`, `updateContent(items)`, `updateVariants(items)`, `updateUnapproved(items)` ★, `updateDeliveryInfo(items)` |
|
|
20
|
+
| `products` life | `delete(barcodes)`, `archive(barcodes)`, `unarchive(barcodes)`, `unlock(barcodes)` |
|
|
21
|
+
| `inventory` | `update(items)` ★ (stock + price, async batch) |
|
|
22
|
+
| `orders` read | `list({...})` ★, `listStream({...})` ★ (opaque cursor for >10K), `getCargoInvoiceItems(serial, {...})` |
|
|
23
|
+
| `orders` write | `updatePackageStatus(id, {...})`, `cancelPackageItem(id, {...})`, `extendDeliveryDate(id, 1\|2\|3)`, `processAlternativeDelivery(id, {...})` |
|
|
24
|
+
| `orders` split | `splitPackage`, `splitPackageByQuantity`, `multiSplitPackage`, `splitMultiPackagesByQuantity` (4 variants) |
|
|
25
|
+
| `orders` cargo | `changeCargoProvider(id, code)`, `manualDeliverByPackageId(id)`, `manualDeliverByTrackingNumber(trk)`, `markDeliveredByService(id)` |
|
|
26
|
+
| `orders` ops | `updateBoxInfo(id, {...})`, `updateLaborCosts(id, items)`, `updateWarehouse(id, warehouseId)` |
|
|
27
|
+
| `orders` returns | `manualReturnByPackageId(id)`, `manualReturnByTrackingNumber(trk)`, `getCompensationTickets({...})` (TEX) |
|
|
28
|
+
| `claims` | `create({...})`, `createIssue(id, {...})` (multipart), `approveLineItems(id, {...})`, `list({...})`, `getIssueReasons()` ★, `getItemAudits(itemId)` ★ |
|
|
29
|
+
| `webhooks` | `create({...})`, `list()`, `update(id, {...})`, `delete(id)`, `activate(id)`, `deactivate(id)` |
|
|
30
|
+
| `questions` | `get(id)`, `list({...})` ★, `answer(id, text)` |
|
|
31
|
+
| `invoices` | `uploadFile({shipmentPackageId, file, ...})` (multipart), `sendLink({...})`, `deleteLink({...})` |
|
|
32
|
+
| `finance` | `getSettlements({...})`, `getOtherFinancials({...})` — both return typed `FinancialTransaction[]` ★ |
|
|
33
|
+
| `labels` | `createCommon(trackingNumber, {format: 'ZPL', ...})`, `getCommon(trackingNumber)` ★ |
|
|
34
|
+
| `testOrders` | `create({...})`, `updateStatus(id, status)`, `setClaimsWaitingInAction()` — **STAGE-only utility** |
|
|
35
|
+
| `locations` | `getCountries()` ★, `getTurkeyCities()` ★, `getTurkeyDistricts(cityCode)`, `getTurkeyNeighborhoods(cityCode, districtCode)`, `getAzerbaijanCities()`, `getAzerbaijanDistricts(...)`, `getCitiesByCountry/getDistrictsByCity(...)` |
|
|
36
|
+
| `exportCenter` | `listProducts({...})`, `createProducts(items)`, `updatePrices(items)`, `updateStocks(items)`, `getBatchStatus(batchId)`, `listPackagesV2/V3({...})`, `getPackageItems({packageId, ...})`, `getCategoryAttributes(id)`, `getCareInstructions()`, `getCompositions()`, `getOrigins()` — **Trendyol Export Center / İhracat Merkezi** |
|
|
37
|
+
| `videos` | `create({contentId, url, ...})`, `list({id?, sellerIntegrationStatus?, ...})` — product-page video upload + status |
|
|
38
|
+
| **top-level** | `parseWebhookEvent(rawBody)`, `normalizeShipmentPackage(rawNode)` — for inbound webhook handlers |
|
|
39
|
+
|
|
40
|
+
**Intentionally excluded:** `processAlternativeDeliveryDigital` (digital products only). Note: V1 endpoint sunset is N/A — Trendyol's V2 docs serve the same paths as V1, and the SDK already emits the V2 response shape (`nextPageToken` pagination, content-based variants).
|
|
39
41
|
|
|
40
42
|
## Install
|
|
41
43
|
|
package/dist/index.cjs
CHANGED
|
@@ -397,6 +397,269 @@ var ClaimsResource = class {
|
|
|
397
397
|
return rows.map((row) => ({ raw: row }));
|
|
398
398
|
}
|
|
399
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
|
+
}
|
|
400
663
|
function toIso2(epochMs) {
|
|
401
664
|
if (typeof epochMs !== "number" || !Number.isFinite(epochMs) || epochMs === 0) {
|
|
402
665
|
return void 0;
|
|
@@ -442,11 +705,14 @@ var FinanceResource = class {
|
|
|
442
705
|
transport;
|
|
443
706
|
limiter;
|
|
444
707
|
async getSettlements(params = {}) {
|
|
445
|
-
return this.queryPage(
|
|
708
|
+
return this.queryPage(
|
|
709
|
+
`/integration/finance/che/sellers/${this.transport.sellerId}/settlements`,
|
|
710
|
+
params
|
|
711
|
+
);
|
|
446
712
|
}
|
|
447
713
|
async getOtherFinancials(params = {}) {
|
|
448
714
|
return this.queryPage(
|
|
449
|
-
`/integration/sellers/${this.transport.sellerId}/otherfinancials`,
|
|
715
|
+
`/integration/finance/che/sellers/${this.transport.sellerId}/otherfinancials`,
|
|
450
716
|
params
|
|
451
717
|
);
|
|
452
718
|
}
|
|
@@ -794,9 +1060,9 @@ function normalizeCustomer(node) {
|
|
|
794
1060
|
return out;
|
|
795
1061
|
}
|
|
796
1062
|
function normalizeShipmentPackage(rawNode) {
|
|
797
|
-
return
|
|
1063
|
+
return normalizePackage2(rawNode ?? {});
|
|
798
1064
|
}
|
|
799
|
-
function
|
|
1065
|
+
function normalizePackage2(node) {
|
|
800
1066
|
const pkgId = node.shipmentPackageId ?? node.id;
|
|
801
1067
|
const out = {
|
|
802
1068
|
id: pkgId !== void 0 ? String(pkgId) : "",
|
|
@@ -897,7 +1163,7 @@ var OrdersResource = class {
|
|
|
897
1163
|
query,
|
|
898
1164
|
rateLimiter: this.limiter
|
|
899
1165
|
});
|
|
900
|
-
const items = (data.content ?? []).map(
|
|
1166
|
+
const items = (data.content ?? []).map(normalizePackage2);
|
|
901
1167
|
const totalPages = typeof data.totalPages === "number" ? data.totalPages : 0;
|
|
902
1168
|
const result = { items };
|
|
903
1169
|
if (page + 1 < totalPages) {
|
|
@@ -1194,7 +1460,7 @@ var OrdersResource = class {
|
|
|
1194
1460
|
query,
|
|
1195
1461
|
rateLimiter: this.limiter
|
|
1196
1462
|
});
|
|
1197
|
-
const items = (data.content ?? []).map(
|
|
1463
|
+
const items = (data.content ?? []).map(normalizePackage2);
|
|
1198
1464
|
const result = { items };
|
|
1199
1465
|
if (data.hasMore && data.nextCursor) {
|
|
1200
1466
|
result.nextCursor = data.nextCursor;
|
|
@@ -2077,6 +2343,55 @@ var TestOrdersResource = class {
|
|
|
2077
2343
|
});
|
|
2078
2344
|
}
|
|
2079
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
|
+
};
|
|
2080
2395
|
function normalizeWebhook(node) {
|
|
2081
2396
|
const out = {
|
|
2082
2397
|
id: node.id !== void 0 ? String(node.id) : "",
|
|
@@ -2415,7 +2730,9 @@ function createTrendyolClient(opts) {
|
|
|
2415
2730
|
finance: new FinanceResource(transport),
|
|
2416
2731
|
labels: new LabelsResource(transport),
|
|
2417
2732
|
testOrders: new TestOrdersResource(transport),
|
|
2418
|
-
locations: new LocationsResource(transport)
|
|
2733
|
+
locations: new LocationsResource(transport),
|
|
2734
|
+
exportCenter: new ExportCenterResource(transport),
|
|
2735
|
+
videos: new VideosResource(transport)
|
|
2419
2736
|
};
|
|
2420
2737
|
}
|
|
2421
2738
|
function parseWebhookEvent(rawBody) {
|
|
@@ -2456,6 +2773,7 @@ function parseWebhookEvent(rawBody) {
|
|
|
2456
2773
|
exports.BrandsResource = BrandsResource;
|
|
2457
2774
|
exports.CategoriesResource = CategoriesResource;
|
|
2458
2775
|
exports.ClaimsResource = ClaimsResource;
|
|
2776
|
+
exports.ExportCenterResource = ExportCenterResource;
|
|
2459
2777
|
exports.FinanceResource = FinanceResource;
|
|
2460
2778
|
exports.InventoryResource = InventoryResource;
|
|
2461
2779
|
exports.InvoicesResource = InvoicesResource;
|
|
@@ -2466,6 +2784,7 @@ exports.ProductsResource = ProductsResource;
|
|
|
2466
2784
|
exports.QuestionsResource = QuestionsResource;
|
|
2467
2785
|
exports.SuppliersResource = SuppliersResource;
|
|
2468
2786
|
exports.TestOrdersResource = TestOrdersResource;
|
|
2787
|
+
exports.VideosResource = VideosResource;
|
|
2469
2788
|
exports.WebhooksResource = WebhooksResource;
|
|
2470
2789
|
exports.createTrendyolClient = createTrendyolClient;
|
|
2471
2790
|
exports.normalizeShipmentPackage = normalizeShipmentPackage;
|