@lonca/trendyol 0.4.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/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
  *
@@ -591,6 +951,63 @@ interface ShipmentPackage {
591
951
  raw: Record<string, unknown>;
592
952
  }
593
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
+
594
1011
  interface ListOrdersParams extends CursorPaginationParams {
595
1012
  status?: ShipmentPackageStatus;
596
1013
  orderNumber?: string;
@@ -782,6 +1199,43 @@ declare class OrdersResource {
782
1199
  * Page-based pagination internally (cursor encodes the page index).
783
1200
  */
784
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>>;
785
1239
  private packagePath;
786
1240
  }
787
1241
 
@@ -1345,6 +1799,86 @@ declare class ProductsResource {
1345
1799
  unlock(barcodes: string[]): Promise<BatchAcceptedResponse>;
1346
1800
  }
1347
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
+
1348
1882
  /**
1349
1883
  * The role an address plays in the seller's logistics flow.
1350
1884
  *
@@ -1417,6 +1951,127 @@ declare class SuppliersResource {
1417
1951
  private fetchFresh;
1418
1952
  }
1419
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
+
1420
2075
  interface CreateClientOptions {
1421
2076
  /** Trendyol seller (supplier) ID — visible in Partner Panel → Account Info. */
1422
2077
  sellerId: number;
@@ -1450,6 +2105,14 @@ interface TrendyolClient {
1450
2105
  products: ProductsResource;
1451
2106
  inventory: InventoryResource;
1452
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;
1453
2116
  }
1454
2117
  /**
1455
2118
  * Create a Trendyol Marketplace SDK client.
@@ -1470,4 +2133,4 @@ interface TrendyolClient {
1470
2133
  */
1471
2134
  declare function createTrendyolClient(opts: CreateClientOptions): TrendyolClient;
1472
2135
 
1473
- export { 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 CreateClientOptions, type CreateProductV2Input, type DeliveryOptionInput, InventoryResource, type LaborCostInput, type ListCategoryAttributeValuesParams, type ListOrdersParams, type ListOrdersStreamParams, type ListProductsParams, type ListUnapprovedProductsParams, type NamedRef, type OrderAddress, type OrderAddressLines, type OrderCustomer, type OrderLine, type OrderLineDiscountDetail, OrdersResource, 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 ShipmentPackage, type ShipmentPackageStatus, type SplitGroup, type SplitPackagePlan, type SupplierAddress, type SupplierAddressType, SuppliersResource, type SuppliersResourceOptions, 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, 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 };