@lonca/trendyol 0.3.0 → 0.5.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 +172 -14
- package/dist/index.cjs +1182 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +959 -1
- package/dist/index.d.ts +959 -1
- package/dist/index.js +1175 -49
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -246,6 +246,297 @@ declare class CategoriesResource {
|
|
|
246
246
|
getByBarcodes(barcodes: string[]): Promise<BarcodeCategoryLookup>;
|
|
247
247
|
}
|
|
248
248
|
|
|
249
|
+
/**
|
|
250
|
+
* Trendyol claim ("iade" / return-claim) types.
|
|
251
|
+
*
|
|
252
|
+
* A claim is a customer-initiated return on a delivered order. The
|
|
253
|
+
* seller can also open a `createClaimIssue` (a rejection) against a
|
|
254
|
+
* customer-filed claim, and either party can have line items approved
|
|
255
|
+
* via `approveClaimLineItems`.
|
|
256
|
+
*/
|
|
257
|
+
|
|
258
|
+
/** One item inside `claims.create()`. */
|
|
259
|
+
interface CreateClaimItemInput {
|
|
260
|
+
/** Barcode of the ordered SKU. */
|
|
261
|
+
barcode: string;
|
|
262
|
+
/** Number of units being returned. */
|
|
263
|
+
quantity: number;
|
|
264
|
+
/**
|
|
265
|
+
* Numeric reason code customers select on trendyol.com.
|
|
266
|
+
* Trendyol's docs note `401` ("Vazgectim" — changed my mind) as a
|
|
267
|
+
* safe default when you don't have a more specific code.
|
|
268
|
+
*/
|
|
269
|
+
reasonId: number;
|
|
270
|
+
/** Free-text note from the customer. */
|
|
271
|
+
customerNote?: string;
|
|
272
|
+
}
|
|
273
|
+
/** Payload for `claims.create()`. */
|
|
274
|
+
interface CreateClaimInput {
|
|
275
|
+
/** The order to file the claim against. */
|
|
276
|
+
orderNumber: string;
|
|
277
|
+
claimItems: CreateClaimItemInput[];
|
|
278
|
+
/** Trendyol customer ID (the one who placed the order). */
|
|
279
|
+
customerId?: number;
|
|
280
|
+
/** Suppress this claim from listing pages. */
|
|
281
|
+
excludeListing?: boolean;
|
|
282
|
+
/** Force a new shipment package to be created for the return. */
|
|
283
|
+
forcePackageCreation?: boolean;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Payload for `claims.createIssue()` — file a seller-side rejection
|
|
287
|
+
* ("ret talebi") against a customer claim. Wire format is
|
|
288
|
+
* `multipart/form-data` because optional `files` are PDF / JPEG
|
|
289
|
+
* supporting documents.
|
|
290
|
+
*/
|
|
291
|
+
interface CreateClaimIssueInput {
|
|
292
|
+
/** Numeric reason ID from `claims.getIssueReasons()`. */
|
|
293
|
+
claimIssueReasonId: number;
|
|
294
|
+
/** Per-line claim item IDs being rejected. SDK joins with commas. */
|
|
295
|
+
claimItemIdList: string[];
|
|
296
|
+
/** Free-text explanation (≤500 chars). */
|
|
297
|
+
description: string;
|
|
298
|
+
/** Optional supporting documents (Blob / File). */
|
|
299
|
+
files?: Blob[];
|
|
300
|
+
}
|
|
301
|
+
/** Payload for `claims.approveLineItems()`. */
|
|
302
|
+
interface ApproveClaimLineItemsInput {
|
|
303
|
+
/** Claim line-item IDs to approve. */
|
|
304
|
+
claimLineItemIdList: string[];
|
|
305
|
+
/** Optional extra params Trendyol forwards verbatim. */
|
|
306
|
+
params?: Record<string, string>;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Claim item lifecycle state. Open enum — Trendyol can add new states
|
|
310
|
+
* without breaking callers.
|
|
311
|
+
*/
|
|
312
|
+
type ClaimItemStatus = 'Created' | 'WaitingInAction' | 'WaitingFraudCheck' | 'Accepted' | 'Unresolved' | 'Rejected' | (string & {});
|
|
313
|
+
/** Filter / pagination for `claims.list()`. */
|
|
314
|
+
interface ListClaimsParams extends CursorPaginationParams {
|
|
315
|
+
startDate?: Date;
|
|
316
|
+
endDate?: Date;
|
|
317
|
+
/** Filter claims by item-level status. */
|
|
318
|
+
claimItemStatus?: ClaimItemStatus;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* A return claim. Trendyol returns ~20 fields; the SDK surfaces the
|
|
322
|
+
* stable subset and keeps everything else on `raw`.
|
|
323
|
+
*/
|
|
324
|
+
interface Claim {
|
|
325
|
+
/** Claim ID (Trendyol returns it under both `id` and `claimId` — same value). */
|
|
326
|
+
id: string;
|
|
327
|
+
orderNumber: string;
|
|
328
|
+
/** ISO 8601 UTC (from ms-epoch `orderDate`). */
|
|
329
|
+
orderDate?: string;
|
|
330
|
+
/** ISO 8601 UTC (from ms-epoch `claimDate`). */
|
|
331
|
+
claimDate?: string;
|
|
332
|
+
customerFirstName?: string;
|
|
333
|
+
customerLastName?: string;
|
|
334
|
+
/** Untouched raw claim — pull undocumented fields from here. */
|
|
335
|
+
raw: Record<string, unknown>;
|
|
336
|
+
}
|
|
337
|
+
/** Rejection-reason catalog row from `claims.getIssueReasons()`. */
|
|
338
|
+
interface ClaimIssueReason {
|
|
339
|
+
id: number;
|
|
340
|
+
name: string;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Audit entry for a single claim item, returned by `claims.getItemAudits()`.
|
|
344
|
+
* Trendyol's response shape varies; only `raw` is guaranteed.
|
|
345
|
+
*/
|
|
346
|
+
interface ClaimItemAudit {
|
|
347
|
+
/** Untouched raw audit row. */
|
|
348
|
+
raw: Record<string, unknown>;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Trendyol claims (return / iade) endpoints.
|
|
353
|
+
*
|
|
354
|
+
* Rate limit (per Trendyol service limits): shares the order service bucket;
|
|
355
|
+
* the SDK provisions its own 1000 req/min limiter that the caller can override.
|
|
356
|
+
*/
|
|
357
|
+
declare class ClaimsResource {
|
|
358
|
+
private readonly transport;
|
|
359
|
+
private readonly sellerId;
|
|
360
|
+
private readonly limiter;
|
|
361
|
+
constructor(transport: TrendyolTransport, sellerId: number, limiter?: TokenBucketRateLimiter);
|
|
362
|
+
/**
|
|
363
|
+
* Create a return claim against an order. Use this to file a return on
|
|
364
|
+
* behalf of a customer (e.g. when they called your CS line). For
|
|
365
|
+
* customer-initiated returns coming from trendyol.com, you receive them
|
|
366
|
+
* via `claims.list()` — no need to call `create`.
|
|
367
|
+
*
|
|
368
|
+
* Returns whatever Trendyol returns (typically the new claim's identifier).
|
|
369
|
+
*
|
|
370
|
+
* @throws {ValidationError} when `claimItems` is empty.
|
|
371
|
+
*/
|
|
372
|
+
create(input: CreateClaimInput): Promise<unknown>;
|
|
373
|
+
/**
|
|
374
|
+
* File a seller-side rejection ("ret talebi") against a customer claim.
|
|
375
|
+
*
|
|
376
|
+
* **Wire format: `multipart/form-data`** — the SDK builds the FormData
|
|
377
|
+
* internally from the typed input. `claimItemIdList` is joined with
|
|
378
|
+
* commas (Trendyol expects a single comma-separated string field).
|
|
379
|
+
* Attach supporting docs (PDF / JPEG) via `files: [Blob, ...]`.
|
|
380
|
+
*/
|
|
381
|
+
createIssue(claimId: string, input: CreateClaimIssueInput): Promise<unknown>;
|
|
382
|
+
/**
|
|
383
|
+
* Approve specific claim line items. After approval, Trendyol moves
|
|
384
|
+
* those line items into the post-approval refund / return-shipping flow.
|
|
385
|
+
*
|
|
386
|
+
* @throws {ValidationError} when `claimLineItemIdList` is empty.
|
|
387
|
+
*/
|
|
388
|
+
approveLineItems(claimId: string, input: ApproveClaimLineItemsInput): Promise<unknown>;
|
|
389
|
+
/**
|
|
390
|
+
* List claims (page-based; SDK exposes opaque cursor convention).
|
|
391
|
+
*
|
|
392
|
+
* @example
|
|
393
|
+
* ```ts
|
|
394
|
+
* import { paginate } from '@lonca/core';
|
|
395
|
+
* for await (const c of paginate((p) =>
|
|
396
|
+
* client.claims.list({ ...p, claimItemStatus: 'WaitingInAction' }),
|
|
397
|
+
* )) {
|
|
398
|
+
* console.log(c.id, c.orderNumber, c.claimDate);
|
|
399
|
+
* }
|
|
400
|
+
* ```
|
|
401
|
+
*/
|
|
402
|
+
list(params?: ListClaimsParams): Promise<CursorPage<Claim>>;
|
|
403
|
+
/**
|
|
404
|
+
* Fetch the catalog of rejection-reason IDs the seller can use on
|
|
405
|
+
* `claims.createIssue()`. Cache the result — it changes rarely.
|
|
406
|
+
*
|
|
407
|
+
* Note: this endpoint is **not seller-scoped** (no `sellerId` in path).
|
|
408
|
+
*/
|
|
409
|
+
getIssueReasons(): Promise<ClaimIssueReason[]>;
|
|
410
|
+
/**
|
|
411
|
+
* Fetch the audit log for a single claim item (state transitions,
|
|
412
|
+
* actor, timestamp). Trendyol's response shape varies — the SDK
|
|
413
|
+
* surfaces each row as `{ raw }` and leaves field extraction to the
|
|
414
|
+
* caller until we observe a stable shape on the wire.
|
|
415
|
+
*/
|
|
416
|
+
getItemAudits(claimItemId: string): Promise<ClaimItemAudit[]>;
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* Misc types for Trendyol's smaller surfaces — invoices, finance,
|
|
421
|
+
* common labels, test orders, and location lookups. Most shapes are
|
|
422
|
+
* loosely typed (`Record<string, unknown>`) because the Trendyol response
|
|
423
|
+
* shapes here are wide and seldom-evolved; callers drill into `raw` for
|
|
424
|
+
* fields beyond the stable surface.
|
|
425
|
+
*/
|
|
426
|
+
|
|
427
|
+
interface UploadInvoiceFileInput {
|
|
428
|
+
/** Trendyol shipment package ID (required). */
|
|
429
|
+
shipmentPackageId: number;
|
|
430
|
+
/** Invoice file (PDF / JPEG / PNG, max 10 MB). */
|
|
431
|
+
file: Blob;
|
|
432
|
+
/** ms-epoch — mandatory for micro-export orders, optional otherwise. */
|
|
433
|
+
invoiceDateTime?: number;
|
|
434
|
+
/**
|
|
435
|
+
* Invoice number — mandatory for micro-export orders. Format:
|
|
436
|
+
* `[A-Za-z0-9]{3}(20[2-9][0-9])\d{9}`.
|
|
437
|
+
*/
|
|
438
|
+
invoiceNumber?: string;
|
|
439
|
+
}
|
|
440
|
+
interface SendInvoiceLinkInput {
|
|
441
|
+
invoiceLink: string;
|
|
442
|
+
shipmentPackageId: number;
|
|
443
|
+
invoiceDateTime?: number;
|
|
444
|
+
invoiceNumber?: string;
|
|
445
|
+
}
|
|
446
|
+
interface DeleteInvoiceLinkInput {
|
|
447
|
+
serviceSourceId?: number;
|
|
448
|
+
channelId?: number;
|
|
449
|
+
customerId?: number;
|
|
450
|
+
/** Forward-compatible: pass any extra fields Trendyol may add. */
|
|
451
|
+
[key: string]: unknown;
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* One row from `finance.getSettlements()` — loosely typed because the
|
|
455
|
+
* settlement schema is broad. Drill into `raw` for any field.
|
|
456
|
+
*/
|
|
457
|
+
interface SettlementRow {
|
|
458
|
+
raw: Record<string, unknown>;
|
|
459
|
+
}
|
|
460
|
+
interface OtherFinancialRow {
|
|
461
|
+
raw: Record<string, unknown>;
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Shared filter shape for both finance endpoints.
|
|
465
|
+
* `transactionType` lets you scope to one settlement category.
|
|
466
|
+
*/
|
|
467
|
+
interface ListFinanceParams extends CursorPaginationParams {
|
|
468
|
+
startDate?: Date;
|
|
469
|
+
endDate?: Date;
|
|
470
|
+
transactionType?: string;
|
|
471
|
+
}
|
|
472
|
+
interface CreateCommonLabelInput {
|
|
473
|
+
/** Currently the only documented format Trendyol accepts. */
|
|
474
|
+
format: 'ZPL' | (string & {});
|
|
475
|
+
boxQuantity?: number;
|
|
476
|
+
/** Volumetric height (height × width × depth / 3000 → desi). */
|
|
477
|
+
volumetricHeight?: number;
|
|
478
|
+
}
|
|
479
|
+
interface CommonLabel {
|
|
480
|
+
raw: Record<string, unknown>;
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Payload for `testOrders.create()`. Top-level requireds are
|
|
484
|
+
* `customer`, `invoiceAddress`, `lines`, `seller`, `shippingAddress`;
|
|
485
|
+
* each sub-object has its own field rules (see Trendyol's
|
|
486
|
+
* `createTestOrder` reference). Kept loose because the inner schema is
|
|
487
|
+
* deep and used only in STAGE.
|
|
488
|
+
*/
|
|
489
|
+
interface CreateTestOrderInput {
|
|
490
|
+
customer: Record<string, unknown>;
|
|
491
|
+
invoiceAddress: Record<string, unknown>;
|
|
492
|
+
shippingAddress: Record<string, unknown>;
|
|
493
|
+
seller: Record<string, unknown>;
|
|
494
|
+
lines: Array<Record<string, unknown>>;
|
|
495
|
+
[key: string]: unknown;
|
|
496
|
+
}
|
|
497
|
+
type TestOrderStatus = 'Created' | 'Picking' | 'Invoiced' | 'Shipped' | 'Delivered' | 'Cancelled' | 'Returned' | 'UnDelivered' | (string & {});
|
|
498
|
+
interface Country {
|
|
499
|
+
/** ISO country code (e.g. `'TR'`, `'AZ'`). */
|
|
500
|
+
code: string;
|
|
501
|
+
name?: string;
|
|
502
|
+
raw: Record<string, unknown>;
|
|
503
|
+
}
|
|
504
|
+
interface City {
|
|
505
|
+
code: string;
|
|
506
|
+
name?: string;
|
|
507
|
+
countryCode?: string;
|
|
508
|
+
raw: Record<string, unknown>;
|
|
509
|
+
}
|
|
510
|
+
interface District {
|
|
511
|
+
code: string;
|
|
512
|
+
name?: string;
|
|
513
|
+
cityCode?: string;
|
|
514
|
+
raw: Record<string, unknown>;
|
|
515
|
+
}
|
|
516
|
+
interface Neighborhood {
|
|
517
|
+
code: string;
|
|
518
|
+
name?: string;
|
|
519
|
+
districtCode?: string;
|
|
520
|
+
raw: Record<string, unknown>;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
/**
|
|
524
|
+
* Trendyol finance endpoints — current-account-statement settlements and
|
|
525
|
+
* "other financials" (cargo invoices, labor cost adjustments, etc.).
|
|
526
|
+
*
|
|
527
|
+
* Both rows are kept as `{ raw }` because the schemas are wide and
|
|
528
|
+
* evolve frequently; drill into `raw` for any field.
|
|
529
|
+
*/
|
|
530
|
+
declare class FinanceResource {
|
|
531
|
+
private readonly transport;
|
|
532
|
+
private readonly sellerId;
|
|
533
|
+
private readonly limiter;
|
|
534
|
+
constructor(transport: TrendyolTransport, sellerId: number, limiter?: TokenBucketRateLimiter);
|
|
535
|
+
getSettlements(params?: ListFinanceParams): Promise<CursorPage<SettlementRow>>;
|
|
536
|
+
getOtherFinancials(params?: ListFinanceParams): Promise<CursorPage<OtherFinancialRow>>;
|
|
537
|
+
private queryPage;
|
|
538
|
+
}
|
|
539
|
+
|
|
249
540
|
/**
|
|
250
541
|
* A single price / stock update entry.
|
|
251
542
|
*
|
|
@@ -300,6 +591,75 @@ declare class InventoryResource {
|
|
|
300
591
|
update(items: PriceInventoryUpdate[]): Promise<UpdatePriceInventoryResponse>;
|
|
301
592
|
}
|
|
302
593
|
|
|
594
|
+
/**
|
|
595
|
+
* Trendyol invoice endpoints — upload PDF/JPEG/PNG invoice files or
|
|
596
|
+
* register/delete invoice links. Pair these with `orders.updatePackageStatus(_, { status: 'Invoiced' })`
|
|
597
|
+
* after invoice issuance.
|
|
598
|
+
*/
|
|
599
|
+
declare class InvoicesResource {
|
|
600
|
+
private readonly transport;
|
|
601
|
+
private readonly sellerId;
|
|
602
|
+
private readonly limiter;
|
|
603
|
+
constructor(transport: TrendyolTransport, sellerId: number, limiter?: TokenBucketRateLimiter);
|
|
604
|
+
/**
|
|
605
|
+
* Upload an invoice file for a shipment package. **Multipart**: the
|
|
606
|
+
* SDK builds the FormData internally from the typed input.
|
|
607
|
+
*
|
|
608
|
+
* Max 10 MB. Accepted formats: PDF, JPEG, PNG.
|
|
609
|
+
*/
|
|
610
|
+
uploadFile(input: UploadInvoiceFileInput): Promise<unknown>;
|
|
611
|
+
/** Register an invoice URL with Trendyol (alternative to uploading the file). */
|
|
612
|
+
sendLink(input: SendInvoiceLinkInput): Promise<unknown>;
|
|
613
|
+
/** Remove a previously-registered invoice link. */
|
|
614
|
+
deleteLink(input: DeleteInvoiceLinkInput): Promise<unknown>;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* Common-label (ortak etiket) endpoints — request and retrieve a
|
|
619
|
+
* combined ZPL shipping label for a cargo tracking number.
|
|
620
|
+
*/
|
|
621
|
+
declare class LabelsResource {
|
|
622
|
+
private readonly transport;
|
|
623
|
+
private readonly sellerId;
|
|
624
|
+
private readonly limiter;
|
|
625
|
+
constructor(transport: TrendyolTransport, sellerId: number, limiter?: TokenBucketRateLimiter);
|
|
626
|
+
/**
|
|
627
|
+
* Request a common ZPL label for a cargo tracking number. After this
|
|
628
|
+
* returns, call `getCommon()` with the same `cargoTrackingNumber` to
|
|
629
|
+
* retrieve the generated label.
|
|
630
|
+
*
|
|
631
|
+
* @throws {ValidationError} when `format` is missing.
|
|
632
|
+
*/
|
|
633
|
+
createCommon(cargoTrackingNumber: string | number, input: CreateCommonLabelInput): Promise<unknown>;
|
|
634
|
+
/** Retrieve the previously-created common label. */
|
|
635
|
+
getCommon(cargoTrackingNumber: string | number): Promise<CommonLabel>;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* Trendyol location lookups for building shipment / invoice addresses
|
|
640
|
+
* with the correct city / district / neighborhood codes.
|
|
641
|
+
*
|
|
642
|
+
* Trendyol exposes these under a different prefix (`/integration/member/`)
|
|
643
|
+
* — not under `/integration/order/` or `/integration/product/`.
|
|
644
|
+
*/
|
|
645
|
+
declare class LocationsResource {
|
|
646
|
+
private readonly transport;
|
|
647
|
+
private readonly limiter;
|
|
648
|
+
constructor(transport: TrendyolTransport, limiter?: TokenBucketRateLimiter);
|
|
649
|
+
/** List all supported countries (Türkiye + AZ + GULF + CEE). */
|
|
650
|
+
getCountries(): Promise<Country[]>;
|
|
651
|
+
getTurkeyCities(): Promise<City[]>;
|
|
652
|
+
getTurkeyDistricts(cityCode: string | number): Promise<District[]>;
|
|
653
|
+
getTurkeyNeighborhoods(cityCode: string | number, districtCode: string | number): Promise<Neighborhood[]>;
|
|
654
|
+
getAzerbaijanCities(): Promise<City[]>;
|
|
655
|
+
getAzerbaijanDistricts(cityCode: string | number): Promise<District[]>;
|
|
656
|
+
getCitiesByCountry(countryCode: string): Promise<City[]>;
|
|
657
|
+
getDistrictsByCity(countryCode: string, cityId: string | number): Promise<District[]>;
|
|
658
|
+
private cities;
|
|
659
|
+
private districts;
|
|
660
|
+
private neighborhoods;
|
|
661
|
+
}
|
|
662
|
+
|
|
303
663
|
/**
|
|
304
664
|
* Trendyol shipment-package status.
|
|
305
665
|
*
|
|
@@ -391,6 +751,145 @@ interface PackageHistoryEntry {
|
|
|
391
751
|
createdAt?: string;
|
|
392
752
|
raw: Record<string, unknown>;
|
|
393
753
|
}
|
|
754
|
+
/**
|
|
755
|
+
* A package line update tuple used by `updatePackageStatus` and
|
|
756
|
+
* `cancelPackageItem`. `lineId` is the per-line ID from `ShipmentPackage.lines[].lineId`.
|
|
757
|
+
*/
|
|
758
|
+
interface PackageLineUpdate {
|
|
759
|
+
lineId: number;
|
|
760
|
+
quantity: number;
|
|
761
|
+
}
|
|
762
|
+
/**
|
|
763
|
+
* Input for `orders.updatePackageStatus`. Trendyol restricts the seller-side
|
|
764
|
+
* status push to `Picking` (mark as being prepared) and `Invoiced`
|
|
765
|
+
* (invoice issued); other transitions are driven by Trendyol / the cargo
|
|
766
|
+
* provider. `lines` is optional and only used when transitioning subset of
|
|
767
|
+
* line items.
|
|
768
|
+
*/
|
|
769
|
+
interface UpdatePackageStatusInput {
|
|
770
|
+
status: 'Picking' | 'Invoiced';
|
|
771
|
+
lines?: PackageLineUpdate[];
|
|
772
|
+
}
|
|
773
|
+
/**
|
|
774
|
+
* Input for `orders.cancelPackageItem` — Trendyol's "supply failure" notification.
|
|
775
|
+
* Marks specific line items as un-suppliable. `reasonId` is a numeric code
|
|
776
|
+
* Trendyol publishes separately (e.g. `577` = "tedarik edemiyorum"); consult
|
|
777
|
+
* Trendyol's seller panel or the "Tedarik Edememe" docs for current values.
|
|
778
|
+
*/
|
|
779
|
+
interface CancelPackageItemInput {
|
|
780
|
+
lines: PackageLineUpdate[];
|
|
781
|
+
reasonId: number;
|
|
782
|
+
}
|
|
783
|
+
/**
|
|
784
|
+
* One row from `orders.getCargoInvoiceItems` — a cargo invoice line item
|
|
785
|
+
* that ties a parcel ID to its cargo fee. Useful for reconciling Trendyol's
|
|
786
|
+
* cargo deductions against your shipped packages.
|
|
787
|
+
*/
|
|
788
|
+
interface CargoInvoiceItem {
|
|
789
|
+
/** e.g. "Gönderi Kargo Bedeli" (outbound) or "İade Kargo Bedeli" (return). */
|
|
790
|
+
shipmentPackageType?: string;
|
|
791
|
+
/** Cargo parcel unique ID. */
|
|
792
|
+
parcelUniqueId?: number | string;
|
|
793
|
+
orderNumber?: string;
|
|
794
|
+
/** Fee charged in this row. */
|
|
795
|
+
amount?: number;
|
|
796
|
+
/** Desi value used to compute the fee. */
|
|
797
|
+
desi?: number;
|
|
798
|
+
/** Untouched raw row. */
|
|
799
|
+
raw: Record<string, unknown>;
|
|
800
|
+
}
|
|
801
|
+
/**
|
|
802
|
+
* Filter params for `orders.listStream` — the streaming alternative to
|
|
803
|
+
* `orders.list`. Uses Trendyol's opaque `nextCursor` (forwarded as the
|
|
804
|
+
* `@lonca/core` `CursorPaginationParams.cursor`) instead of page-index
|
|
805
|
+
* pagination.
|
|
806
|
+
*/
|
|
807
|
+
interface ListOrdersStreamParams {
|
|
808
|
+
cursor?: string;
|
|
809
|
+
limit?: number;
|
|
810
|
+
/**
|
|
811
|
+
* CSV of package-item statuses to filter by (e.g.
|
|
812
|
+
* `'Created,Picking,Invoiced'`). Trendyol accepts the same status
|
|
813
|
+
* vocabulary as `ShipmentPackageStatus`.
|
|
814
|
+
*/
|
|
815
|
+
packageItemStatuses?: string;
|
|
816
|
+
/** Lower bound for `lastModified` (Trendyol expects ms-epoch). */
|
|
817
|
+
lastModifiedStartDate?: Date;
|
|
818
|
+
/** Upper bound for `lastModified`. */
|
|
819
|
+
lastModifiedEndDate?: Date;
|
|
820
|
+
}
|
|
821
|
+
/**
|
|
822
|
+
* Box / packaging metadata for `orders.updateBoxInfo`. Both fields are
|
|
823
|
+
* optional but at least one should be set for the call to be meaningful.
|
|
824
|
+
*/
|
|
825
|
+
interface UpdateBoxInfoInput {
|
|
826
|
+
/** Desi value (volumetric weight used by Trendyol for shipping cost). */
|
|
827
|
+
deci?: number;
|
|
828
|
+
/** Number of physical boxes in the shipment. */
|
|
829
|
+
boxQuantity?: number;
|
|
830
|
+
}
|
|
831
|
+
/**
|
|
832
|
+
* Per-line labor cost for `orders.updateLaborCosts`. The Trendyol API
|
|
833
|
+
* accepts a raw array of these (no envelope) — the SDK forwards as-is.
|
|
834
|
+
*/
|
|
835
|
+
interface LaborCostInput {
|
|
836
|
+
orderLineId: number;
|
|
837
|
+
/** Labor cost charged per single unit of this line. */
|
|
838
|
+
laborCostPerItem: number;
|
|
839
|
+
}
|
|
840
|
+
/**
|
|
841
|
+
* Trendyol cargo provider codes accepted by `orders.changeCargoProvider`.
|
|
842
|
+
* Use the string union for autocomplete; `(string & {})` keeps unknown
|
|
843
|
+
* codes type-compatible so Trendyol can add providers without breaking
|
|
844
|
+
* callers.
|
|
845
|
+
*/
|
|
846
|
+
type TrendyolCargoProvider = 'YKMP' | 'ARASMP' | 'SURATMP' | 'HOROZMP' | 'DHLECOMMP' | 'PTTMP' | 'CEVAMP' | 'TEXMP' | 'KOLAYGELSINMP' | 'CEVATEDARIK' | (string & {});
|
|
847
|
+
/**
|
|
848
|
+
* Per-line quantity split for `orders.splitPackageByQuantity`. Each item
|
|
849
|
+
* in `quantities` becomes its own new package containing that many units
|
|
850
|
+
* of `orderLineId`.
|
|
851
|
+
*
|
|
852
|
+
* @example
|
|
853
|
+
* // splits 5 units of line 100 into 3 packages: 2 + 2 + 1
|
|
854
|
+
* { orderLineId: 100, quantities: [2, 2, 1] }
|
|
855
|
+
*/
|
|
856
|
+
interface QuantitySplit {
|
|
857
|
+
orderLineId: number;
|
|
858
|
+
quantities: number[];
|
|
859
|
+
}
|
|
860
|
+
/**
|
|
861
|
+
* A group of line IDs that should become a new package together,
|
|
862
|
+
* for `orders.multiSplitPackage`.
|
|
863
|
+
*/
|
|
864
|
+
interface SplitGroup {
|
|
865
|
+
orderLineIds: number[];
|
|
866
|
+
}
|
|
867
|
+
/**
|
|
868
|
+
* One package's contents for `orders.splitMultiPackagesByQuantity`. Each
|
|
869
|
+
* element of the outer array becomes a new package; each `packageDetails`
|
|
870
|
+
* entry carries an `orderLineId` and the **single** quantity assigned to
|
|
871
|
+
* that package (note: singular `quantities`, despite the field name).
|
|
872
|
+
*/
|
|
873
|
+
interface PackageDetail {
|
|
874
|
+
orderLineId: number;
|
|
875
|
+
/** Quantity of this line to include in this package (singular integer). */
|
|
876
|
+
quantities: number;
|
|
877
|
+
}
|
|
878
|
+
interface SplitPackagePlan {
|
|
879
|
+
packageDetails: PackageDetail[];
|
|
880
|
+
}
|
|
881
|
+
/**
|
|
882
|
+
* Input for `orders.processAlternativeDelivery`. Used when the seller is
|
|
883
|
+
* shipping via a non-Trendyol cargo provider — provide either a phone number
|
|
884
|
+
* (which Trendyol SMSes the tracking link to) or a direct tracking URL.
|
|
885
|
+
*/
|
|
886
|
+
interface ProcessAlternativeDeliveryInput {
|
|
887
|
+
/** When true, `trackingInfo` is a phone number; when false, a tracking URL. */
|
|
888
|
+
isPhoneNumber: boolean;
|
|
889
|
+
trackingInfo: string;
|
|
890
|
+
/** Provider-specific extra parameters (Trendyol forwards verbatim). */
|
|
891
|
+
params: Record<string, string>;
|
|
892
|
+
}
|
|
394
893
|
/**
|
|
395
894
|
* A Trendyol order — Trendyol models orders as "shipment packages". A single
|
|
396
895
|
* customer order may produce multiple shipment packages (one per warehouse,
|
|
@@ -452,6 +951,63 @@ interface ShipmentPackage {
|
|
|
452
951
|
raw: Record<string, unknown>;
|
|
453
952
|
}
|
|
454
953
|
|
|
954
|
+
/**
|
|
955
|
+
* Returns + compensation types for Trendyol orders.
|
|
956
|
+
*
|
|
957
|
+
* Trendyol distinguishes two separate concepts:
|
|
958
|
+
* - **Manual return** — seller-side notification that a package was
|
|
959
|
+
* received back (no body, just a state flip on the package).
|
|
960
|
+
* - **Compensation ticket** — Trendyol Express-specific dispute filed
|
|
961
|
+
* when a shipment is lost or damaged. Multi-state lifecycle with up to
|
|
962
|
+
* ~18 documented states.
|
|
963
|
+
*/
|
|
964
|
+
|
|
965
|
+
/**
|
|
966
|
+
* Lifecycle state of a Trendyol Express compensation ticket. Trendyol
|
|
967
|
+
* documents 18 distinct states (`Empty`, `MarkInCompensation`,
|
|
968
|
+
* `CompensationApproved`, etc.) — kept as an open enum so unknown future
|
|
969
|
+
* values still type-check.
|
|
970
|
+
*
|
|
971
|
+
* Verified against the official spec on 2026-05-25.
|
|
972
|
+
*/
|
|
973
|
+
type CompensationTicketState = 'Empty' | 'MarkInCompensation' | 'OpenedForRefund' | 'StartCompensationFinanceProgress' | 'StartCompensationInApprovalProgress' | 'CompensationApproved' | 'CompensationRejected' | 'FoundAfterCompensationComplete' | 'NotCompensationCase' | 'FoundInCompensation' | 'FoundInvestigationProgress' | 'MarkCompensationCancel' | 'CreateCompensationTicket' | 'FinalizeCompensation' | 'CloseCompensationTicket' | 'FoundInvestigationProgressDeliveredToCustomer' | 'FoundInCompensationDeliveredToCustomer' | 'FoundAfterCompensationCompleteDeliveredToCustomer' | (string & {});
|
|
974
|
+
/** One line item under a compensation ticket. */
|
|
975
|
+
interface CompensationItemDetail {
|
|
976
|
+
/** Amount (e.g. unit price). */
|
|
977
|
+
itemAmount?: number;
|
|
978
|
+
itemCode?: string;
|
|
979
|
+
/** Item count (number of units claimed). */
|
|
980
|
+
itemCount?: number;
|
|
981
|
+
itemName?: string;
|
|
982
|
+
}
|
|
983
|
+
/**
|
|
984
|
+
* A Trendyol Express compensation ticket — filed when a shipment is lost
|
|
985
|
+
* or damaged in transit. Returned by `orders.getCompensationTickets()`.
|
|
986
|
+
*/
|
|
987
|
+
interface CompensationTicket {
|
|
988
|
+
cargoProvider?: string;
|
|
989
|
+
compensateReason?: string;
|
|
990
|
+
/** ISO 8601 UTC string (converted from `createDate` ms-epoch). */
|
|
991
|
+
createdAt?: string;
|
|
992
|
+
currentState?: CompensationTicketState;
|
|
993
|
+
deliveryNumber?: string;
|
|
994
|
+
itemDetails: CompensationItemDetail[];
|
|
995
|
+
orderNumber?: string;
|
|
996
|
+
requestedBy?: string;
|
|
997
|
+
stateMessage?: string;
|
|
998
|
+
/** Total amount across items — Trendyol returns this as a string. */
|
|
999
|
+
totalItemsAmount?: string;
|
|
1000
|
+
/** Untouched raw ticket response. */
|
|
1001
|
+
raw: Record<string, unknown>;
|
|
1002
|
+
}
|
|
1003
|
+
/** Filter / pagination params for `orders.getCompensationTickets()`. */
|
|
1004
|
+
interface ListCompensationTicketsParams extends CursorPaginationParams {
|
|
1005
|
+
/** Lower bound on `createDate` (Trendyol expects ms-epoch). */
|
|
1006
|
+
startDate?: Date;
|
|
1007
|
+
/** Upper bound on `createDate`. */
|
|
1008
|
+
endDate?: Date;
|
|
1009
|
+
}
|
|
1010
|
+
|
|
455
1011
|
interface ListOrdersParams extends CursorPaginationParams {
|
|
456
1012
|
status?: ShipmentPackageStatus;
|
|
457
1013
|
orderNumber?: string;
|
|
@@ -488,6 +1044,199 @@ declare class OrdersResource {
|
|
|
488
1044
|
* ```
|
|
489
1045
|
*/
|
|
490
1046
|
list(params?: ListOrdersParams): Promise<CursorPage<ShipmentPackage>>;
|
|
1047
|
+
/**
|
|
1048
|
+
* Push a shipment-package status update.
|
|
1049
|
+
*
|
|
1050
|
+
* Trendyol restricts the seller-side push to two transitions:
|
|
1051
|
+
* - `Picking` — order picked up from the shelf / being prepared
|
|
1052
|
+
* - `Invoiced` — invoice issued, ready for cargo handoff
|
|
1053
|
+
*
|
|
1054
|
+
* Other transitions (`Shipped`, `Delivered`, etc.) are driven by Trendyol
|
|
1055
|
+
* or the cargo provider — call `processAlternativeDelivery` or
|
|
1056
|
+
* `manualDeliverByPackageId` if you ship outside Trendyol's cargo
|
|
1057
|
+
* network.
|
|
1058
|
+
*
|
|
1059
|
+
* Returns void; Trendyol responds with 200 + empty body on success.
|
|
1060
|
+
*/
|
|
1061
|
+
updatePackageStatus(packageId: string | number, input: UpdatePackageStatusInput): Promise<void>;
|
|
1062
|
+
/**
|
|
1063
|
+
* Notify Trendyol that one or more line items cannot be supplied
|
|
1064
|
+
* ("Tedarik Edememe Bildirimi"). Marks the listed line IDs as
|
|
1065
|
+
* `UnSupplied`. Trendyol cancels those quantities and notifies the
|
|
1066
|
+
* customer.
|
|
1067
|
+
*
|
|
1068
|
+
* `reasonId` is a numeric code Trendyol publishes separately — consult
|
|
1069
|
+
* the seller panel or the "Tedarik Edememe" docs for current values.
|
|
1070
|
+
*
|
|
1071
|
+
* Returns void; Trendyol responds with 200 + empty body on success.
|
|
1072
|
+
*/
|
|
1073
|
+
cancelPackageItem(packageId: string | number, input: CancelPackageItemInput): Promise<void>;
|
|
1074
|
+
/**
|
|
1075
|
+
* Extend the agreed delivery date for a shipment package by 1, 2, or 3 days.
|
|
1076
|
+
* Trendyol enforces the [1, 3] range server-side; the SDK validates client-side
|
|
1077
|
+
* to fail fast.
|
|
1078
|
+
*
|
|
1079
|
+
* Returns void; Trendyol responds with 200 + empty body on success.
|
|
1080
|
+
*/
|
|
1081
|
+
extendDeliveryDate(packageId: string | number, extendedDayCount: 1 | 2 | 3): Promise<void>;
|
|
1082
|
+
/**
|
|
1083
|
+
* Notify Trendyol of an alternative delivery channel — used when the
|
|
1084
|
+
* seller is shipping via a non-Trendyol cargo provider. Trendyol then
|
|
1085
|
+
* either SMSes the customer the tracking link (when `isPhoneNumber` is
|
|
1086
|
+
* `true`) or stores the tracking URL on the package directly.
|
|
1087
|
+
*
|
|
1088
|
+
* Returns void; Trendyol responds with 200 + empty body on success.
|
|
1089
|
+
*/
|
|
1090
|
+
processAlternativeDelivery(packageId: string | number, input: ProcessAlternativeDeliveryInput): Promise<void>;
|
|
1091
|
+
/**
|
|
1092
|
+
* Split a shipment package by moving a set of line IDs into a new
|
|
1093
|
+
* package. The original package keeps the remaining lines.
|
|
1094
|
+
*
|
|
1095
|
+
* @param packageId The package to split.
|
|
1096
|
+
* @param orderLineIds Line IDs to move into the new package (1+).
|
|
1097
|
+
* @throws {ValidationError} when `orderLineIds` is empty.
|
|
1098
|
+
*/
|
|
1099
|
+
splitPackage(packageId: string | number, orderLineIds: number[]): Promise<void>;
|
|
1100
|
+
/**
|
|
1101
|
+
* Split a shipment package by quantity. Each `QuantitySplit` entry
|
|
1102
|
+
* carves a single line into multiple packages — e.g. `{ orderLineId: 100,
|
|
1103
|
+
* quantities: [2, 2, 1] }` splits 5 units of line 100 into three packages
|
|
1104
|
+
* of 2 + 2 + 1.
|
|
1105
|
+
*
|
|
1106
|
+
* @throws {ValidationError} when `quantitySplit` is empty.
|
|
1107
|
+
*/
|
|
1108
|
+
splitPackageByQuantity(packageId: string | number, quantitySplit: QuantitySplit[]): Promise<void>;
|
|
1109
|
+
/**
|
|
1110
|
+
* Split a shipment package into multiple new packages by grouping line
|
|
1111
|
+
* IDs. Each `SplitGroup` becomes one new package containing the listed
|
|
1112
|
+
* line IDs.
|
|
1113
|
+
*
|
|
1114
|
+
* @throws {ValidationError} when `splitGroups` is empty.
|
|
1115
|
+
*/
|
|
1116
|
+
multiSplitPackage(packageId: string | number, splitGroups: SplitGroup[]): Promise<void>;
|
|
1117
|
+
/**
|
|
1118
|
+
* Split a shipment package into multiple new packages, each containing a
|
|
1119
|
+
* mix of line items at specific quantities. This is the most expressive
|
|
1120
|
+
* split — use it when you need fine-grained control over which line IDs
|
|
1121
|
+
* and how many of each end up in each new package.
|
|
1122
|
+
*
|
|
1123
|
+
* @throws {ValidationError} when `splitPackages` is empty.
|
|
1124
|
+
*/
|
|
1125
|
+
splitMultiPackagesByQuantity(packageId: string | number, splitPackages: SplitPackagePlan[]): Promise<void>;
|
|
1126
|
+
/**
|
|
1127
|
+
* Change the cargo provider on an existing shipment package. Use one of
|
|
1128
|
+
* Trendyol's documented marketplace cargo codes (`'YKMP'`, `'ARASMP'`,
|
|
1129
|
+
* `'SURATMP'`, etc.) — see `TrendyolCargoProvider` for the full list.
|
|
1130
|
+
*/
|
|
1131
|
+
changeCargoProvider(packageId: string | number, cargoProvider: TrendyolCargoProvider): Promise<void>;
|
|
1132
|
+
/**
|
|
1133
|
+
* Mark a shipment package as manually delivered via its package ID.
|
|
1134
|
+
* Used when the seller delivered the order outside Trendyol's cargo
|
|
1135
|
+
* network and needs to flip the package to `Delivered` after handover.
|
|
1136
|
+
*
|
|
1137
|
+
* No request body; Trendyol responds with 200 + empty body on success.
|
|
1138
|
+
*/
|
|
1139
|
+
manualDeliverByPackageId(packageId: string | number): Promise<void>;
|
|
1140
|
+
/**
|
|
1141
|
+
* Manual-deliver variant that takes the cargo tracking number instead
|
|
1142
|
+
* of the package ID. Useful when you only have the tracking number on
|
|
1143
|
+
* hand (e.g., from a cargo provider webhook).
|
|
1144
|
+
*
|
|
1145
|
+
* Note the path structure: tracking number sits at a sibling location,
|
|
1146
|
+
* not under `/shipment-packages/{id}/...`.
|
|
1147
|
+
*/
|
|
1148
|
+
manualDeliverByTrackingNumber(cargoTrackingNumber: string | number): Promise<void>;
|
|
1149
|
+
/**
|
|
1150
|
+
* Mark a package as delivered through an authorized service ("yetkili
|
|
1151
|
+
* servis"). For appliance / installation-required products that are
|
|
1152
|
+
* delivered + installed by a third-party service partner.
|
|
1153
|
+
*/
|
|
1154
|
+
markDeliveredByService(packageId: string | number): Promise<void>;
|
|
1155
|
+
/**
|
|
1156
|
+
* Update box / packaging metadata on a shipment package (desi value
|
|
1157
|
+
* and/or number of boxes). Either field can be sent alone.
|
|
1158
|
+
*/
|
|
1159
|
+
updateBoxInfo(packageId: string | number, input: UpdateBoxInfoInput): Promise<void>;
|
|
1160
|
+
/**
|
|
1161
|
+
* Update labor costs for one or more order lines.
|
|
1162
|
+
*
|
|
1163
|
+
* **Wire note:** Trendyol's request body is a raw array (no envelope),
|
|
1164
|
+
* not `{ items: [...] }`. The SDK forwards `items` verbatim.
|
|
1165
|
+
*
|
|
1166
|
+
* @throws {ValidationError} when `items` is empty.
|
|
1167
|
+
*/
|
|
1168
|
+
updateLaborCosts(packageId: string | number, items: LaborCostInput[]): Promise<void>;
|
|
1169
|
+
/**
|
|
1170
|
+
* Reassign a shipment package to a different warehouse. `warehouseId`
|
|
1171
|
+
* comes from `client.suppliers.getAddresses()` (filter by `isShipmentAddress`).
|
|
1172
|
+
*/
|
|
1173
|
+
updateWarehouse(packageId: string | number, warehouseId: number): Promise<void>;
|
|
1174
|
+
/**
|
|
1175
|
+
* Stream variant of `list()`. Trendyol's `getShipmentPackagesStream`
|
|
1176
|
+
* returns the same `ShipmentPackage` shape but paginates with an opaque
|
|
1177
|
+
* cursor — useful when the dataset is large and page-based pagination
|
|
1178
|
+
* would hit the 10 000-record cap.
|
|
1179
|
+
*
|
|
1180
|
+
* @example
|
|
1181
|
+
* ```ts
|
|
1182
|
+
* import { paginate } from '@lonca/core';
|
|
1183
|
+
* for await (const pkg of paginate((p) =>
|
|
1184
|
+
* client.orders.listStream({ ...p, packageItemStatuses: 'Created,Picking' }),
|
|
1185
|
+
* )) {
|
|
1186
|
+
* console.log(pkg.id, pkg.status);
|
|
1187
|
+
* }
|
|
1188
|
+
* ```
|
|
1189
|
+
*/
|
|
1190
|
+
listStream(params?: ListOrdersStreamParams): Promise<CursorPage<ShipmentPackage>>;
|
|
1191
|
+
/**
|
|
1192
|
+
* Fetch the per-parcel cargo-fee breakdown for a single cargo invoice
|
|
1193
|
+
* (Trendyol's `getCargoInvoiceItems`). Useful for reconciling Trendyol's
|
|
1194
|
+
* cargo deductions against your shipped packages.
|
|
1195
|
+
*
|
|
1196
|
+
* `invoiceSerialNumber` is sourced from the Current Account Statement
|
|
1197
|
+
* ("Cari Hesap Ekstresi") with `transactionType=DeductionInvoices`.
|
|
1198
|
+
*
|
|
1199
|
+
* Page-based pagination internally (cursor encodes the page index).
|
|
1200
|
+
*/
|
|
1201
|
+
getCargoInvoiceItems(invoiceSerialNumber: string, params?: CursorPaginationParams): Promise<CursorPage<CargoInvoiceItem>>;
|
|
1202
|
+
/**
|
|
1203
|
+
* Notify Trendyol that a shipped package was returned to you (manual
|
|
1204
|
+
* return flow, e.g. customer dropped it at your address or you got the
|
|
1205
|
+
* package back without going through Trendyol's return cargo).
|
|
1206
|
+
*
|
|
1207
|
+
* No body; Trendyol responds with 200 + empty body on success.
|
|
1208
|
+
*/
|
|
1209
|
+
manualReturnByPackageId(packageId: string | number): Promise<void>;
|
|
1210
|
+
/**
|
|
1211
|
+
* Manual-return variant that takes the cargo tracking number instead of
|
|
1212
|
+
* the package ID. Useful when the cargo provider's webhook only carries
|
|
1213
|
+
* the tracking number.
|
|
1214
|
+
*
|
|
1215
|
+
* Sibling path (not under `/{packageId}/...`).
|
|
1216
|
+
*/
|
|
1217
|
+
manualReturnByTrackingNumber(cargoTrackingNumber: string | number): Promise<void>;
|
|
1218
|
+
/**
|
|
1219
|
+
* Fetch Trendyol Express compensation tickets (claims filed when a
|
|
1220
|
+
* shipment is lost or damaged in transit). Page-based pagination
|
|
1221
|
+
* internally; the SDK exposes the cursor convention.
|
|
1222
|
+
*
|
|
1223
|
+
* Note the different base path — `/integration/tex/compensation/...`,
|
|
1224
|
+
* not the regular `/integration/order/...`.
|
|
1225
|
+
*
|
|
1226
|
+
* @example
|
|
1227
|
+
* ```ts
|
|
1228
|
+
* import { paginate } from '@lonca/core';
|
|
1229
|
+
* const tickets = await client.orders.getCompensationTickets({
|
|
1230
|
+
* startDate: new Date('2026-01-01'),
|
|
1231
|
+
* endDate: new Date('2026-02-01'),
|
|
1232
|
+
* });
|
|
1233
|
+
* for (const t of tickets.items) {
|
|
1234
|
+
* console.log(t.orderNumber, t.currentState, t.stateMessage);
|
|
1235
|
+
* }
|
|
1236
|
+
* ```
|
|
1237
|
+
*/
|
|
1238
|
+
getCompensationTickets(params?: ListCompensationTicketsParams): Promise<CursorPage<CompensationTicket>>;
|
|
1239
|
+
private packagePath;
|
|
491
1240
|
}
|
|
492
1241
|
|
|
493
1242
|
/** A `{ id, name }` reference object used in product/category/brand wire types. */
|
|
@@ -1050,6 +1799,86 @@ declare class ProductsResource {
|
|
|
1050
1799
|
unlock(barcodes: string[]): Promise<BatchAcceptedResponse>;
|
|
1051
1800
|
}
|
|
1052
1801
|
|
|
1802
|
+
/**
|
|
1803
|
+
* Trendyol customer Q&A types.
|
|
1804
|
+
*
|
|
1805
|
+
* Customers can post product questions on Trendyol; sellers reply via
|
|
1806
|
+
* `questions.answer()`. Status lifecycle:
|
|
1807
|
+
* `WAITING_FOR_ANSWER` → seller replies → `ANSWERED`
|
|
1808
|
+
* → reported by another seller / Trendyol → `REPORTED`
|
|
1809
|
+
* → rejected by Trendyol moderation → `REJECTED`
|
|
1810
|
+
*/
|
|
1811
|
+
|
|
1812
|
+
type QuestionStatus = 'WAITING_FOR_ANSWER' | 'ANSWERED' | 'REJECTED' | 'REPORTED' | (string & {});
|
|
1813
|
+
interface QuestionAnswer {
|
|
1814
|
+
text?: string;
|
|
1815
|
+
/** ISO 8601 UTC (converted from `creationDate` ms-epoch). */
|
|
1816
|
+
createdAt?: string;
|
|
1817
|
+
status?: string;
|
|
1818
|
+
}
|
|
1819
|
+
interface Question {
|
|
1820
|
+
id: string;
|
|
1821
|
+
text?: string;
|
|
1822
|
+
customerId?: string;
|
|
1823
|
+
/** Masked customer display name. */
|
|
1824
|
+
userName?: string;
|
|
1825
|
+
showUserName?: boolean;
|
|
1826
|
+
status?: QuestionStatus;
|
|
1827
|
+
/** Whether the question is visible publicly. */
|
|
1828
|
+
public?: boolean;
|
|
1829
|
+
productMainId?: string;
|
|
1830
|
+
productName?: string;
|
|
1831
|
+
imageUrl?: string;
|
|
1832
|
+
webUrl?: string;
|
|
1833
|
+
/** ISO 8601 UTC (from ms-epoch). */
|
|
1834
|
+
createdAt?: string;
|
|
1835
|
+
/** Trendyol's pre-formatted "answered on ..." message (Turkish). */
|
|
1836
|
+
answeredDateMessage?: string;
|
|
1837
|
+
answer?: QuestionAnswer;
|
|
1838
|
+
rejectedAnswer?: QuestionAnswer;
|
|
1839
|
+
/** ISO 8601 UTC if the question was rejected. */
|
|
1840
|
+
rejectedAt?: string;
|
|
1841
|
+
reason?: string;
|
|
1842
|
+
reportReason?: string;
|
|
1843
|
+
/** ISO 8601 UTC if the question was reported. */
|
|
1844
|
+
reportedAt?: string;
|
|
1845
|
+
/** Untouched raw response. */
|
|
1846
|
+
raw: Record<string, unknown>;
|
|
1847
|
+
}
|
|
1848
|
+
interface ListQuestionsParams extends CursorPaginationParams {
|
|
1849
|
+
/** Filter to questions about a specific product barcode. */
|
|
1850
|
+
barcode?: string;
|
|
1851
|
+
startDate?: Date;
|
|
1852
|
+
endDate?: Date;
|
|
1853
|
+
/** Filter by current status. */
|
|
1854
|
+
status?: QuestionStatus;
|
|
1855
|
+
}
|
|
1856
|
+
|
|
1857
|
+
/**
|
|
1858
|
+
* Trendyol customer Q&A management. Customers post product questions on
|
|
1859
|
+
* Trendyol; sellers reply with `questions.answer()`.
|
|
1860
|
+
*/
|
|
1861
|
+
declare class QuestionsResource {
|
|
1862
|
+
private readonly transport;
|
|
1863
|
+
private readonly sellerId;
|
|
1864
|
+
private readonly limiter;
|
|
1865
|
+
constructor(transport: TrendyolTransport, sellerId: number, limiter?: TokenBucketRateLimiter);
|
|
1866
|
+
/** Fetch a single question by its numeric ID. */
|
|
1867
|
+
get(questionId: string | number): Promise<Question>;
|
|
1868
|
+
/**
|
|
1869
|
+
* Filter questions by barcode / date range / status. Page-based
|
|
1870
|
+
* pagination internally; SDK exposes the opaque-cursor convention.
|
|
1871
|
+
*/
|
|
1872
|
+
list(params?: ListQuestionsParams): Promise<CursorPage<Question>>;
|
|
1873
|
+
/**
|
|
1874
|
+
* Reply to a question. Trendyol enforces 10–2000 characters on the
|
|
1875
|
+
* answer text; the SDK pre-validates client-side.
|
|
1876
|
+
*
|
|
1877
|
+
* @throws {ValidationError} when `text` is outside the 10–2000 char range.
|
|
1878
|
+
*/
|
|
1879
|
+
answer(questionId: string | number, text: string): Promise<unknown>;
|
|
1880
|
+
}
|
|
1881
|
+
|
|
1053
1882
|
/**
|
|
1054
1883
|
* The role an address plays in the seller's logistics flow.
|
|
1055
1884
|
*
|
|
@@ -1122,6 +1951,127 @@ declare class SuppliersResource {
|
|
|
1122
1951
|
private fetchFresh;
|
|
1123
1952
|
}
|
|
1124
1953
|
|
|
1954
|
+
/**
|
|
1955
|
+
* STAGE-only helper endpoints for creating + driving test orders /
|
|
1956
|
+
* test claims through their state machine. **Do not use in PROD** —
|
|
1957
|
+
* Trendyol's test endpoints are scoped to the test environment.
|
|
1958
|
+
*/
|
|
1959
|
+
declare class TestOrdersResource {
|
|
1960
|
+
private readonly transport;
|
|
1961
|
+
private readonly sellerId;
|
|
1962
|
+
private readonly limiter;
|
|
1963
|
+
constructor(transport: TrendyolTransport, sellerId: number, limiter?: TokenBucketRateLimiter);
|
|
1964
|
+
/**
|
|
1965
|
+
* Create a test order with the given customer / addresses / lines. The
|
|
1966
|
+
* SDK forwards the typed payload verbatim — drill into Trendyol's
|
|
1967
|
+
* `createTestOrder` doc for inner field rules.
|
|
1968
|
+
*
|
|
1969
|
+
* @throws {ValidationError} when required top-level fields are missing.
|
|
1970
|
+
*/
|
|
1971
|
+
create(input: CreateTestOrderInput): Promise<unknown>;
|
|
1972
|
+
/** Push a test shipment package to the given status. */
|
|
1973
|
+
updateStatus(packageId: string | number, status: TestOrderStatus): Promise<unknown>;
|
|
1974
|
+
/** Move test claims to the `WaitingInAction` state. */
|
|
1975
|
+
setClaimsWaitingInAction(): Promise<unknown>;
|
|
1976
|
+
}
|
|
1977
|
+
|
|
1978
|
+
/**
|
|
1979
|
+
* Trendyol webhook subscription types.
|
|
1980
|
+
*
|
|
1981
|
+
* Webhooks let Trendyol push shipment-package status events to a URL you
|
|
1982
|
+
* own instead of polling. Max 15 active webhooks per seller. Trendyol
|
|
1983
|
+
* itself authenticates against your endpoint (you don't sign Trendyol's
|
|
1984
|
+
* request) — pick `BASIC_AUTHENTICATION` (username+password) or `API_KEY`
|
|
1985
|
+
* (rotatable; recommended).
|
|
1986
|
+
*/
|
|
1987
|
+
|
|
1988
|
+
/** Auth method Trendyol uses when calling your webhook URL. */
|
|
1989
|
+
type WebhookAuthenticationType = 'BASIC_AUTHENTICATION' | 'API_KEY';
|
|
1990
|
+
/**
|
|
1991
|
+
* Payload for `webhooks.create` / `webhooks.update`. Same shape for both.
|
|
1992
|
+
*/
|
|
1993
|
+
interface WebhookInput {
|
|
1994
|
+
/** Your endpoint URL (must accept POST JSON from Trendyol). */
|
|
1995
|
+
url: string;
|
|
1996
|
+
/** Auth scheme Trendyol will use to call your endpoint. */
|
|
1997
|
+
authenticationType: WebhookAuthenticationType;
|
|
1998
|
+
/** Username (only when `authenticationType === 'BASIC_AUTHENTICATION'`). */
|
|
1999
|
+
username?: string;
|
|
2000
|
+
/** Password (only when `authenticationType === 'BASIC_AUTHENTICATION'`). */
|
|
2001
|
+
password?: string;
|
|
2002
|
+
/** API key (only when `authenticationType === 'API_KEY'`). */
|
|
2003
|
+
apiKey?: string;
|
|
2004
|
+
/**
|
|
2005
|
+
* Order statuses you want events for. Empty/omitted = all statuses.
|
|
2006
|
+
* Trendyol accepts the same vocabulary as `ShipmentPackageStatus`
|
|
2007
|
+
* (the upper-snake-case variants — `'CREATED'`, `'PICKING'`, etc. — see
|
|
2008
|
+
* Trendyol docs for the exact wire spelling, which sometimes differs
|
|
2009
|
+
* from the read-side `'Created'`/`'Picking'`).
|
|
2010
|
+
*/
|
|
2011
|
+
subscribedStatuses?: string[];
|
|
2012
|
+
}
|
|
2013
|
+
/** A registered webhook subscription as returned by `webhooks.list`. */
|
|
2014
|
+
interface Webhook {
|
|
2015
|
+
id: string;
|
|
2016
|
+
url?: string;
|
|
2017
|
+
authenticationType?: WebhookAuthenticationType;
|
|
2018
|
+
username?: string;
|
|
2019
|
+
apiKey?: string;
|
|
2020
|
+
subscribedStatuses?: string[];
|
|
2021
|
+
/** Active vs deactivated. */
|
|
2022
|
+
active?: boolean;
|
|
2023
|
+
/** Untouched raw webhook entry. */
|
|
2024
|
+
raw: Record<string, unknown>;
|
|
2025
|
+
}
|
|
2026
|
+
|
|
2027
|
+
/**
|
|
2028
|
+
* Trendyol webhook subscription management.
|
|
2029
|
+
*
|
|
2030
|
+
* Max **15 active webhooks per seller** (Trendyol-enforced). Webhooks
|
|
2031
|
+
* fire on shipment-package status events only — there is no webhook
|
|
2032
|
+
* support for product / stock changes.
|
|
2033
|
+
*
|
|
2034
|
+
* Trendyol's gateway authenticates **against your endpoint** with the
|
|
2035
|
+
* `authenticationType` you configure. Pick `API_KEY` over
|
|
2036
|
+
* `BASIC_AUTHENTICATION` so you can rotate the secret without redeploying.
|
|
2037
|
+
*
|
|
2038
|
+
* No HMAC signature — security relies entirely on the auth method you
|
|
2039
|
+
* pick + the secret you store with Trendyol.
|
|
2040
|
+
*/
|
|
2041
|
+
declare class WebhooksResource {
|
|
2042
|
+
private readonly transport;
|
|
2043
|
+
private readonly sellerId;
|
|
2044
|
+
private readonly limiter;
|
|
2045
|
+
constructor(transport: TrendyolTransport, sellerId: number, limiter?: TokenBucketRateLimiter);
|
|
2046
|
+
/**
|
|
2047
|
+
* Create a new webhook subscription. Trendyol caps subscriptions at 15
|
|
2048
|
+
* per seller — the SDK does NOT pre-check (you'd need to call `list()`
|
|
2049
|
+
* first), but Trendyol returns 400 when the cap is exceeded.
|
|
2050
|
+
*
|
|
2051
|
+
* @throws {ValidationError} when `url` or `authenticationType` is missing.
|
|
2052
|
+
*/
|
|
2053
|
+
create(input: WebhookInput): Promise<unknown>;
|
|
2054
|
+
/** List all registered webhook subscriptions. */
|
|
2055
|
+
list(): Promise<Webhook[]>;
|
|
2056
|
+
/**
|
|
2057
|
+
* Update a webhook subscription. Same input shape as `create`; replaces
|
|
2058
|
+
* the whole subscription (Trendyol does NOT partially update).
|
|
2059
|
+
*/
|
|
2060
|
+
update(webhookId: string | number, input: WebhookInput): Promise<unknown>;
|
|
2061
|
+
/** Permanently delete a webhook subscription. */
|
|
2062
|
+
delete(webhookId: string | number): Promise<unknown>;
|
|
2063
|
+
/** Re-activate a previously-deactivated webhook subscription. */
|
|
2064
|
+
activate(webhookId: string | number): Promise<unknown>;
|
|
2065
|
+
/**
|
|
2066
|
+
* Deactivate a webhook subscription. Trendyol automatically deactivates
|
|
2067
|
+
* a subscription after persistent delivery failures (and sends 2 emails);
|
|
2068
|
+
* use `activate()` to bring it back online once your endpoint is healthy.
|
|
2069
|
+
*/
|
|
2070
|
+
deactivate(webhookId: string | number): Promise<unknown>;
|
|
2071
|
+
private validateInput;
|
|
2072
|
+
private webhookPath;
|
|
2073
|
+
}
|
|
2074
|
+
|
|
1125
2075
|
interface CreateClientOptions {
|
|
1126
2076
|
/** Trendyol seller (supplier) ID — visible in Partner Panel → Account Info. */
|
|
1127
2077
|
sellerId: number;
|
|
@@ -1155,6 +2105,14 @@ interface TrendyolClient {
|
|
|
1155
2105
|
products: ProductsResource;
|
|
1156
2106
|
inventory: InventoryResource;
|
|
1157
2107
|
orders: OrdersResource;
|
|
2108
|
+
claims: ClaimsResource;
|
|
2109
|
+
webhooks: WebhooksResource;
|
|
2110
|
+
questions: QuestionsResource;
|
|
2111
|
+
invoices: InvoicesResource;
|
|
2112
|
+
finance: FinanceResource;
|
|
2113
|
+
labels: LabelsResource;
|
|
2114
|
+
testOrders: TestOrdersResource;
|
|
2115
|
+
locations: LocationsResource;
|
|
1158
2116
|
}
|
|
1159
2117
|
/**
|
|
1160
2118
|
* Create a Trendyol Marketplace SDK client.
|
|
@@ -1175,4 +2133,4 @@ interface TrendyolClient {
|
|
|
1175
2133
|
*/
|
|
1176
2134
|
declare function createTrendyolClient(opts: CreateClientOptions): TrendyolClient;
|
|
1177
2135
|
|
|
1178
|
-
export { type BarcodeCategoryLookup, type BatchAcceptedResponse, type BatchRequestItemResult, type BatchRequestResult, type BatchRequestStatus, type Brand, BrandsResource, type BuyboxInfo, CategoriesResource, type Category, type CategoryAttribute, type CategoryAttributeValue, type CreateClientOptions, type CreateProductV2Input, type DeliveryOptionInput, InventoryResource, type ListCategoryAttributeValuesParams, type ListOrdersParams, type ListProductsParams, type ListUnapprovedProductsParams, type NamedRef, type OrderAddress, type OrderAddressLines, type OrderCustomer, type OrderLine, type OrderLineDiscountDetail, OrdersResource, type PackageHistoryEntry, type PriceInventoryUpdate, type Product, type ProductAttribute, type ProductAttributeV2Input, type ProductBase, type ProductImageInput, type ProductVariant, ProductsResource, type ShipmentPackage, type ShipmentPackageStatus, type SupplierAddress, type SupplierAddressType, SuppliersResource, type SuppliersResourceOptions, type TrendyolClient, type TrendyolEnvironment, type UnapprovedDateQueryType, type UnapprovedProduct, type UnapprovedProductRejectReason, type UnapprovedProductStatus, type UpdateContentInput, type UpdateDeliveryInfoInput, type UpdatePriceInventoryResponse, type UpdateUnapprovedInput, type UpdateVariantInput, createTrendyolClient };
|
|
2136
|
+
export { type ApproveClaimLineItemsInput, type BarcodeCategoryLookup, type BatchAcceptedResponse, type BatchRequestItemResult, type BatchRequestResult, type BatchRequestStatus, type Brand, BrandsResource, type BuyboxInfo, type CancelPackageItemInput, type CargoInvoiceItem, CategoriesResource, type Category, type CategoryAttribute, type CategoryAttributeValue, type City, type Claim, type ClaimIssueReason, type ClaimItemAudit, type ClaimItemStatus, ClaimsResource, type CommonLabel, type CompensationItemDetail, type CompensationTicket, type CompensationTicketState, type Country, type CreateClaimInput, type CreateClaimIssueInput, type CreateClaimItemInput, type CreateClientOptions, type CreateCommonLabelInput, type CreateProductV2Input, type CreateTestOrderInput, type DeleteInvoiceLinkInput, type DeliveryOptionInput, type District, FinanceResource, InventoryResource, InvoicesResource, LabelsResource, type LaborCostInput, type ListCategoryAttributeValuesParams, type ListClaimsParams, type ListCompensationTicketsParams, type ListFinanceParams, type ListOrdersParams, type ListOrdersStreamParams, type ListProductsParams, type ListQuestionsParams, type ListUnapprovedProductsParams, LocationsResource, type NamedRef, type Neighborhood, type OrderAddress, type OrderAddressLines, type OrderCustomer, type OrderLine, type OrderLineDiscountDetail, OrdersResource, type OtherFinancialRow, type PackageDetail, type PackageHistoryEntry, type PackageLineUpdate, type PriceInventoryUpdate, type ProcessAlternativeDeliveryInput, type Product, type ProductAttribute, type ProductAttributeV2Input, type ProductBase, type ProductImageInput, type ProductVariant, ProductsResource, type QuantitySplit, type Question, type QuestionAnswer, type QuestionStatus, QuestionsResource, type SendInvoiceLinkInput, type SettlementRow, type ShipmentPackage, type ShipmentPackageStatus, type SplitGroup, type SplitPackagePlan, type SupplierAddress, type SupplierAddressType, SuppliersResource, type SuppliersResourceOptions, type TestOrderStatus, TestOrdersResource, type TrendyolCargoProvider, type TrendyolClient, type TrendyolEnvironment, type UnapprovedDateQueryType, type UnapprovedProduct, type UnapprovedProductRejectReason, type UnapprovedProductStatus, type UpdateBoxInfoInput, type UpdateContentInput, type UpdateDeliveryInfoInput, type UpdatePackageStatusInput, type UpdatePriceInventoryResponse, type UpdateUnapprovedInput, type UpdateVariantInput, type UploadInvoiceFileInput, type Webhook, type WebhookAuthenticationType, type WebhookInput, WebhooksResource, createTrendyolClient };
|