@lonca/trendyol 0.13.0 → 0.15.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 +26 -8
- package/dist/{client-DMndJSb0.d.cts → client-Dnfjvwah.d.cts} +173 -40
- package/dist/{client-DMndJSb0.d.ts → client-Dnfjvwah.d.ts} +173 -40
- package/dist/index.cjs +144 -54
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +145 -55
- package/dist/index.js.map +1 -1
- package/dist/testing.cjs +144 -54
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +145 -55
- package/dist/testing.js.map +1 -1
- package/package.json +6 -4
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { A as
|
|
1
|
+
import { aZ as ShipmentPackage, a7 as KnownShipmentPackageStatus } from './client-Dnfjvwah.cjs';
|
|
2
|
+
export { A as AnswerQuestionResult, a as ApproveClaimLineItemsInput, b as ApprovedProductStatus, B as BarcodeCategoryLookup, c as BatchAcceptedResponse, d as BatchPollOptions, e as BatchRequestItemResult, f as BatchRequestResult, g as BatchRequestStatus, h as Brand, i as BrandsResource, j as BuyboxInfo, C as CancelPackageItemInput, k as CareInstruction, l as CargoInvoiceItem, m as CategoriesResource, n as Category, o as CategoryAttribute, p as CategoryAttributeValue, q as City, r as Claim, s as ClaimIssueReason, t as ClaimItemAudit, u as ClaimItemStatus, v as ClaimsResource, w as CommonLabel, x as CommonLabelEntry, y as CompensationItemDetail, z as CompensationTicket, D as CompensationTicketState, E as Country, F as CreateClaimInput, G as CreateClaimIssueInput, H as CreateClaimItemInput, I as CreateClientOptions, J as CreateCommonLabelInput, K as CreateProductV2Input, L as CreateTestOrderInput, M as CreateTestOrderResult, N as CreateVideoInput, O as CreateVideoResult, P as CreateWebhookResult, Q as DeleteInvoiceLinkInput, R as DeliveryOptionInput, S as District, T as ExportBatchAcceptedResponse, U as ExportBatchStatus, V as ExportCategoryAttribute, W as ExportCenterResource, X as ExportPackage, Y as ExportPackageItem, Z as ExportPackageStatus, _ as ExportPriceUpdateInput, $ as ExportProduct, a0 as ExportProductInput, a1 as ExportStockUpdateInput, a2 as FinanceResource, a3 as FinancialTransaction, a4 as GetExportPackageItemsParams, a5 as InventoryResource, a6 as InvoicesResource, a8 as LabelsResource, a9 as LaborCostInput, aa as ListCategoryAttributeValuesParams, ab as ListClaimsParams, ac as ListCompensationTicketsParams, ad as ListExportPackagesV2Params, ae as ListExportPackagesV3Params, af as ListExportProductsParams, ag as ListFinanceParams, ah as ListInventoryAndPriceParams, ai as ListOrdersParams, aj as ListOrdersStreamParams, ak as ListProductsParams, al as ListQuestionsParams, am as ListUnapprovedProductsParams, an as ListVideosParams, ao as LocationsResource, ap as NamedRef, aq as Neighborhood, ar as OrderAddress, as as OrderAddressLines, at as OrderCustomer, au as OrderLine, av as OrderLineDiscountDetail, aw as OrdersResource, ax as OtherFinancialRow, ay as PackageDetail, az as PackageHistoryEntry, aA as PackageLineUpdate, aB as PriceInventoryUpdate, aC as ProcessAlternativeDeliveryInput, aD as Product, aE as ProductAttribute, aF as ProductAttributeV2Input, aG as ProductBase, aH as ProductComposition, aI as ProductContentBase, aJ as ProductImageInput, aK as ProductOrigin, aL as ProductStockPrice, aM as ProductStockPriceVariant, aN as ProductVariant, aO as ProductsResource, aP as QuantitySplit, aQ as Question, aR as QuestionAnswer, aS as QuestionStatus, aT as QuestionsResource, aU as SellerIntegrationStatus, aV as SellerVideo, aW as SendInvoiceLinkInput, aX as SetClaimsWaitingInActionInput, aY as SettlementRow, a_ as ShipmentPackageStatus, a$ as SplitGroup, b0 as SplitPackagePlan, b1 as SupplierAddress, b2 as SupplierAddressType, b3 as SuppliersResource, b4 as SuppliersResourceOptions, b5 as TestOrderStatus, b6 as TestOrderStatusLine, b7 as TestOrdersResource, b8 as TrendyolCapabilities, b9 as TrendyolCargoProvider, ba as TrendyolClient, bb as TrendyolEnvironment, bc as UnapprovedDateQueryType, bd as UnapprovedProduct, be as UnapprovedProductRejectReason, bf as UnapprovedProductStatus, bg as UpdateBoxInfoInput, bh as UpdateContentInput, bi as UpdateDeliveryInfoInput, bj as UpdatePackageStatusInput, bk as UpdatePriceInventoryResponse, bl as UpdateTestOrderStatusOptions, bm as UpdateUnapprovedInput, bn as UpdateVariantInput, bo as UploadInvoiceFileInput, bp as VideoContentType, bq as VideosResource, br as Webhook, bs as WebhookAuthenticationType, bt as WebhookInput, bu as WebhooksResource, bv as createTrendyolClient, bw as normalizeShipmentPackage, bx as pollBatchStatus, by as trendyolCapabilities } from './client-Dnfjvwah.cjs';
|
|
3
3
|
import * as _lonca_core from '@lonca/core';
|
|
4
4
|
import { NormalizedOrderStatus } from '@lonca/core';
|
|
5
|
-
export { CursorPage, CursorPaginationParams, OffsetPage, OffsetPaginationParams, paginate, paginateOffset } from '@lonca/core';
|
|
5
|
+
export { CursorPage, CursorPaginationParams, MutationResult, OffsetPage, OffsetPaginationParams, paginate, paginateOffset } from '@lonca/core';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Inbound webhook event payloads — what Trendyol POSTs to YOUR endpoint
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { A as
|
|
1
|
+
import { aZ as ShipmentPackage, a7 as KnownShipmentPackageStatus } from './client-Dnfjvwah.js';
|
|
2
|
+
export { A as AnswerQuestionResult, a as ApproveClaimLineItemsInput, b as ApprovedProductStatus, B as BarcodeCategoryLookup, c as BatchAcceptedResponse, d as BatchPollOptions, e as BatchRequestItemResult, f as BatchRequestResult, g as BatchRequestStatus, h as Brand, i as BrandsResource, j as BuyboxInfo, C as CancelPackageItemInput, k as CareInstruction, l as CargoInvoiceItem, m as CategoriesResource, n as Category, o as CategoryAttribute, p as CategoryAttributeValue, q as City, r as Claim, s as ClaimIssueReason, t as ClaimItemAudit, u as ClaimItemStatus, v as ClaimsResource, w as CommonLabel, x as CommonLabelEntry, y as CompensationItemDetail, z as CompensationTicket, D as CompensationTicketState, E as Country, F as CreateClaimInput, G as CreateClaimIssueInput, H as CreateClaimItemInput, I as CreateClientOptions, J as CreateCommonLabelInput, K as CreateProductV2Input, L as CreateTestOrderInput, M as CreateTestOrderResult, N as CreateVideoInput, O as CreateVideoResult, P as CreateWebhookResult, Q as DeleteInvoiceLinkInput, R as DeliveryOptionInput, S as District, T as ExportBatchAcceptedResponse, U as ExportBatchStatus, V as ExportCategoryAttribute, W as ExportCenterResource, X as ExportPackage, Y as ExportPackageItem, Z as ExportPackageStatus, _ as ExportPriceUpdateInput, $ as ExportProduct, a0 as ExportProductInput, a1 as ExportStockUpdateInput, a2 as FinanceResource, a3 as FinancialTransaction, a4 as GetExportPackageItemsParams, a5 as InventoryResource, a6 as InvoicesResource, a8 as LabelsResource, a9 as LaborCostInput, aa as ListCategoryAttributeValuesParams, ab as ListClaimsParams, ac as ListCompensationTicketsParams, ad as ListExportPackagesV2Params, ae as ListExportPackagesV3Params, af as ListExportProductsParams, ag as ListFinanceParams, ah as ListInventoryAndPriceParams, ai as ListOrdersParams, aj as ListOrdersStreamParams, ak as ListProductsParams, al as ListQuestionsParams, am as ListUnapprovedProductsParams, an as ListVideosParams, ao as LocationsResource, ap as NamedRef, aq as Neighborhood, ar as OrderAddress, as as OrderAddressLines, at as OrderCustomer, au as OrderLine, av as OrderLineDiscountDetail, aw as OrdersResource, ax as OtherFinancialRow, ay as PackageDetail, az as PackageHistoryEntry, aA as PackageLineUpdate, aB as PriceInventoryUpdate, aC as ProcessAlternativeDeliveryInput, aD as Product, aE as ProductAttribute, aF as ProductAttributeV2Input, aG as ProductBase, aH as ProductComposition, aI as ProductContentBase, aJ as ProductImageInput, aK as ProductOrigin, aL as ProductStockPrice, aM as ProductStockPriceVariant, aN as ProductVariant, aO as ProductsResource, aP as QuantitySplit, aQ as Question, aR as QuestionAnswer, aS as QuestionStatus, aT as QuestionsResource, aU as SellerIntegrationStatus, aV as SellerVideo, aW as SendInvoiceLinkInput, aX as SetClaimsWaitingInActionInput, aY as SettlementRow, a_ as ShipmentPackageStatus, a$ as SplitGroup, b0 as SplitPackagePlan, b1 as SupplierAddress, b2 as SupplierAddressType, b3 as SuppliersResource, b4 as SuppliersResourceOptions, b5 as TestOrderStatus, b6 as TestOrderStatusLine, b7 as TestOrdersResource, b8 as TrendyolCapabilities, b9 as TrendyolCargoProvider, ba as TrendyolClient, bb as TrendyolEnvironment, bc as UnapprovedDateQueryType, bd as UnapprovedProduct, be as UnapprovedProductRejectReason, bf as UnapprovedProductStatus, bg as UpdateBoxInfoInput, bh as UpdateContentInput, bi as UpdateDeliveryInfoInput, bj as UpdatePackageStatusInput, bk as UpdatePriceInventoryResponse, bl as UpdateTestOrderStatusOptions, bm as UpdateUnapprovedInput, bn as UpdateVariantInput, bo as UploadInvoiceFileInput, bp as VideoContentType, bq as VideosResource, br as Webhook, bs as WebhookAuthenticationType, bt as WebhookInput, bu as WebhooksResource, bv as createTrendyolClient, bw as normalizeShipmentPackage, bx as pollBatchStatus, by as trendyolCapabilities } from './client-Dnfjvwah.js';
|
|
3
3
|
import * as _lonca_core from '@lonca/core';
|
|
4
4
|
import { NormalizedOrderStatus } from '@lonca/core';
|
|
5
|
-
export { CursorPage, CursorPaginationParams, OffsetPage, OffsetPaginationParams, paginate, paginateOffset } from '@lonca/core';
|
|
5
|
+
export { CursorPage, CursorPaginationParams, MutationResult, OffsetPage, OffsetPaginationParams, paginate, paginateOffset } from '@lonca/core';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Inbound webhook event payloads — what Trendyol POSTs to YOUR endpoint
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createStatusNormalizer, TokenBucketRateLimiter, ValidationError, TimeoutError, ServerError, createRequester, LoncaError, RateLimitError, NotFoundError,
|
|
1
|
+
import { createStatusNormalizer, TokenBucketRateLimiter, ValidationError, TimeoutError, ServerError, createRequester, AuthError, LoncaError, RateLimitError, NotFoundError, normalizeIssueEntries } from '@lonca/core';
|
|
2
2
|
export { paginate, paginateOffset } from '@lonca/core';
|
|
3
3
|
|
|
4
4
|
// src/resources/brands.ts
|
|
@@ -264,12 +264,14 @@ var ClaimsResource = class {
|
|
|
264
264
|
if (!Array.isArray(input?.claimItems) || input.claimItems.length === 0) {
|
|
265
265
|
throw new ValidationError({ message: "claims.create: claimItems must not be empty" });
|
|
266
266
|
}
|
|
267
|
-
return
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
267
|
+
return {
|
|
268
|
+
raw: await this.transport.request({
|
|
269
|
+
method: "POST",
|
|
270
|
+
path: `/integration/order/sellers/${this.transport.sellerId}/claims/create`,
|
|
271
|
+
body: input,
|
|
272
|
+
rateLimiter: this.limiter
|
|
273
|
+
})
|
|
274
|
+
};
|
|
273
275
|
}
|
|
274
276
|
/**
|
|
275
277
|
* File a seller-side rejection ("ret talebi") against a customer claim.
|
|
@@ -302,12 +304,14 @@ var ClaimsResource = class {
|
|
|
302
304
|
form.append("files", file);
|
|
303
305
|
}
|
|
304
306
|
}
|
|
305
|
-
return
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
307
|
+
return {
|
|
308
|
+
raw: await this.transport.request({
|
|
309
|
+
method: "POST",
|
|
310
|
+
path: `/integration/order/sellers/${this.transport.sellerId}/claims/${encodeURIComponent(claimId)}/issue`,
|
|
311
|
+
body: form,
|
|
312
|
+
rateLimiter: this.limiter
|
|
313
|
+
})
|
|
314
|
+
};
|
|
311
315
|
}
|
|
312
316
|
/**
|
|
313
317
|
* Approve specific claim line items. After approval, Trendyol moves
|
|
@@ -321,12 +325,14 @@ var ClaimsResource = class {
|
|
|
321
325
|
message: "claims.approveLineItems: claimLineItemIdList must not be empty"
|
|
322
326
|
});
|
|
323
327
|
}
|
|
324
|
-
return
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
328
|
+
return {
|
|
329
|
+
raw: await this.transport.request({
|
|
330
|
+
method: "PUT",
|
|
331
|
+
path: `/integration/order/sellers/${this.transport.sellerId}/claims/${encodeURIComponent(claimId)}/items/approve`,
|
|
332
|
+
body: input,
|
|
333
|
+
rateLimiter: this.limiter
|
|
334
|
+
})
|
|
335
|
+
};
|
|
330
336
|
}
|
|
331
337
|
/**
|
|
332
338
|
* List claims (page-based; SDK exposes opaque cursor convention).
|
|
@@ -900,33 +906,39 @@ var InvoicesResource = class {
|
|
|
900
906
|
if (input.invoiceNumber !== void 0) {
|
|
901
907
|
form.append("invoiceNumber", input.invoiceNumber);
|
|
902
908
|
}
|
|
903
|
-
return
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
+
return {
|
|
910
|
+
raw: await this.transport.request({
|
|
911
|
+
method: "POST",
|
|
912
|
+
path: `/integration/sellers/${this.transport.sellerId}/seller-invoice-file`,
|
|
913
|
+
body: form,
|
|
914
|
+
rateLimiter: this.limiter
|
|
915
|
+
})
|
|
916
|
+
};
|
|
909
917
|
}
|
|
910
918
|
/** Register an invoice URL with Trendyol (alternative to uploading the file). */
|
|
911
919
|
async sendLink(input) {
|
|
912
920
|
if (!input?.invoiceLink) {
|
|
913
921
|
throw new ValidationError({ message: "invoices.sendLink: invoiceLink is required" });
|
|
914
922
|
}
|
|
915
|
-
return
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
923
|
+
return {
|
|
924
|
+
raw: await this.transport.request({
|
|
925
|
+
method: "POST",
|
|
926
|
+
path: `/integration/sellers/${this.transport.sellerId}/seller-invoice-links`,
|
|
927
|
+
body: input,
|
|
928
|
+
rateLimiter: this.limiter
|
|
929
|
+
})
|
|
930
|
+
};
|
|
921
931
|
}
|
|
922
932
|
/** Remove a previously-registered invoice link. */
|
|
923
933
|
async deleteLink(input) {
|
|
924
|
-
return
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
934
|
+
return {
|
|
935
|
+
raw: await this.transport.request({
|
|
936
|
+
method: "POST",
|
|
937
|
+
path: `/integration/sellers/${this.transport.sellerId}/seller-invoice-links/delete`,
|
|
938
|
+
body: input,
|
|
939
|
+
rateLimiter: this.limiter
|
|
940
|
+
})
|
|
941
|
+
};
|
|
930
942
|
}
|
|
931
943
|
};
|
|
932
944
|
var LabelsResource = class {
|
|
@@ -941,18 +953,23 @@ var LabelsResource = class {
|
|
|
941
953
|
* returns, call `getCommon()` with the same `cargoTrackingNumber` to
|
|
942
954
|
* retrieve the generated label.
|
|
943
955
|
*
|
|
956
|
+
* Trendyol documents this endpoint (`createCommonLabel`) as a bare
|
|
957
|
+
* `200 OK` with no response body, so the SDK returns a `MutationResult`
|
|
958
|
+
* whose `raw` is whatever the gateway sent (normally `undefined`).
|
|
959
|
+
*
|
|
944
960
|
* @throws {ValidationError} when `format` is missing.
|
|
945
961
|
*/
|
|
946
962
|
async createCommon(cargoTrackingNumber, input) {
|
|
947
963
|
if (!input?.format) {
|
|
948
964
|
throw new ValidationError({ message: "labels.createCommon: format is required" });
|
|
949
965
|
}
|
|
950
|
-
|
|
966
|
+
const raw = await this.transport.request({
|
|
951
967
|
method: "POST",
|
|
952
968
|
path: `/integration/sellers/${this.transport.sellerId}/common-label/${encodeURIComponent(String(cargoTrackingNumber))}`,
|
|
953
969
|
body: input,
|
|
954
970
|
rateLimiter: this.limiter
|
|
955
971
|
});
|
|
972
|
+
return { raw };
|
|
956
973
|
}
|
|
957
974
|
/**
|
|
958
975
|
* Retrieve the previously-created common label. Trendyol returns
|
|
@@ -1962,6 +1979,11 @@ var ProductsResource = class {
|
|
|
1962
1979
|
* List approved products. Use `paginate()` from `@lonca/core` to iterate
|
|
1963
1980
|
* lazily across pages.
|
|
1964
1981
|
*
|
|
1982
|
+
* **Approved only:** this endpoint silently excludes products still in review
|
|
1983
|
+
* or rejected — use {@link listUnapproved} for those. Date fields on the
|
|
1984
|
+
* returned {@link Product} (`createdAt` / `updatedAt`) are ISO 8601 UTC
|
|
1985
|
+
* **strings**, not `Date` objects.
|
|
1986
|
+
*
|
|
1965
1987
|
* Trendyol exposes both page-based and `nextPageToken`-based pagination
|
|
1966
1988
|
* (the latter required when the dataset exceeds 10,000 items). The SDK
|
|
1967
1989
|
* picks the right strategy automatically — pass our opaque `cursor` from
|
|
@@ -2397,6 +2419,9 @@ var QuestionsResource = class {
|
|
|
2397
2419
|
* Reply to a question. Trendyol enforces 10–2000 characters on the
|
|
2398
2420
|
* answer text; the SDK pre-validates client-side.
|
|
2399
2421
|
*
|
|
2422
|
+
* Trendyol documents the response as `{ answerId: number }`; the SDK
|
|
2423
|
+
* surfaces it as `answerId` and keeps the untouched body on `raw`.
|
|
2424
|
+
*
|
|
2400
2425
|
* @throws {ValidationError} when `text` is outside the 10–2000 char range.
|
|
2401
2426
|
*/
|
|
2402
2427
|
async answer(questionId, text) {
|
|
@@ -2410,12 +2435,15 @@ var QuestionsResource = class {
|
|
|
2410
2435
|
message: `questions.answer: text must be at most 2000 chars (got ${text.length})`
|
|
2411
2436
|
});
|
|
2412
2437
|
}
|
|
2413
|
-
|
|
2438
|
+
const raw = await this.transport.request({
|
|
2414
2439
|
method: "POST",
|
|
2415
2440
|
path: `/integration/qna/sellers/${this.transport.sellerId}/questions/${encodeURIComponent(String(questionId))}/answers`,
|
|
2416
2441
|
body: { text },
|
|
2417
2442
|
rateLimiter: this.limiter
|
|
2418
2443
|
});
|
|
2444
|
+
const out = { raw };
|
|
2445
|
+
if (typeof raw?.answerId === "number") out.answerId = raw.answerId;
|
|
2446
|
+
return out;
|
|
2419
2447
|
}
|
|
2420
2448
|
};
|
|
2421
2449
|
var VALID_TYPES = /* @__PURE__ */ new Set([
|
|
@@ -2508,6 +2536,9 @@ var TestOrdersResource = class {
|
|
|
2508
2536
|
* SDK forwards the typed payload verbatim — drill into Trendyol's
|
|
2509
2537
|
* `createTestOrder` doc for inner field rules.
|
|
2510
2538
|
*
|
|
2539
|
+
* Trendyol documents the response as `{ orderNumber: string }`; the SDK
|
|
2540
|
+
* surfaces it as `orderNumber` and keeps the untouched body on `raw`.
|
|
2541
|
+
*
|
|
2511
2542
|
* @throws {ValidationError} when required top-level fields are missing.
|
|
2512
2543
|
*/
|
|
2513
2544
|
async create(input) {
|
|
@@ -2516,29 +2547,52 @@ var TestOrdersResource = class {
|
|
|
2516
2547
|
throw new ValidationError({ message: `testOrders.create: ${k} is required` });
|
|
2517
2548
|
}
|
|
2518
2549
|
}
|
|
2519
|
-
|
|
2550
|
+
const raw = await this.transport.request({
|
|
2520
2551
|
method: "POST",
|
|
2521
2552
|
path: `/integration/test/order/orders/core`,
|
|
2522
2553
|
body: input,
|
|
2523
2554
|
rateLimiter: this.limiter
|
|
2524
2555
|
});
|
|
2556
|
+
const out = { raw };
|
|
2557
|
+
if (typeof raw?.orderNumber === "string") out.orderNumber = raw.orderNumber;
|
|
2558
|
+
else if (typeof raw?.orderNumber === "number") out.orderNumber = String(raw.orderNumber);
|
|
2559
|
+
return out;
|
|
2525
2560
|
}
|
|
2526
|
-
/**
|
|
2527
|
-
|
|
2528
|
-
|
|
2561
|
+
/**
|
|
2562
|
+
* Push a test shipment package to the given status. Trendyol's
|
|
2563
|
+
* `status-updates-on-test-orders` doc shows a `{ lines, params, status }`
|
|
2564
|
+
* body — pass `options` to send the documented `lines` / `params`;
|
|
2565
|
+
* omitted, the body stays `{ status }` alone as before. Documented
|
|
2566
|
+
* response is a bare `200 OK` (no body), hence `MutationResult`.
|
|
2567
|
+
*/
|
|
2568
|
+
async updateStatus(packageId, status, options = {}) {
|
|
2569
|
+
const raw = await this.transport.request({
|
|
2529
2570
|
method: "PUT",
|
|
2530
2571
|
path: `/integration/test/order/sellers/${this.transport.sellerId}/shipment-packages/${encodeURIComponent(String(packageId))}/status`,
|
|
2531
|
-
body: {
|
|
2572
|
+
body: {
|
|
2573
|
+
...options.lines !== void 0 ? { lines: options.lines } : {},
|
|
2574
|
+
...options.params !== void 0 ? { params: options.params } : {},
|
|
2575
|
+
status
|
|
2576
|
+
},
|
|
2532
2577
|
rateLimiter: this.limiter
|
|
2533
2578
|
});
|
|
2579
|
+
return { raw };
|
|
2534
2580
|
}
|
|
2535
|
-
/**
|
|
2536
|
-
|
|
2537
|
-
|
|
2581
|
+
/**
|
|
2582
|
+
* Move test claims to the `WaitingInAction` state. Trendyol's
|
|
2583
|
+
* `updateTestOrderStatus` doc shows a `{ shipmentPackageId }` body (the
|
|
2584
|
+
* `orderShipmentPackageId` from `claims.list`); pass `input` to send it —
|
|
2585
|
+
* omitted, the request goes out body-less as before. Documented response
|
|
2586
|
+
* is a bare `200 OK` (no body), hence `MutationResult`.
|
|
2587
|
+
*/
|
|
2588
|
+
async setClaimsWaitingInAction(input) {
|
|
2589
|
+
const raw = await this.transport.request({
|
|
2538
2590
|
method: "PUT",
|
|
2539
2591
|
path: `/integration/test/order/sellers/${this.transport.sellerId}/claims/waiting-in-action`,
|
|
2592
|
+
...input ? { body: input } : {},
|
|
2540
2593
|
rateLimiter: this.limiter
|
|
2541
2594
|
});
|
|
2595
|
+
return { raw };
|
|
2542
2596
|
}
|
|
2543
2597
|
};
|
|
2544
2598
|
var VideosResource = class {
|
|
@@ -2554,18 +2608,25 @@ var VideosResource = class {
|
|
|
2554
2608
|
* Queue a video for upload. Trendyol downloads from the URL in the
|
|
2555
2609
|
* body asynchronously; poll `list()` (filtered by id) for status.
|
|
2556
2610
|
*
|
|
2611
|
+
* Trendyol documents the response as `{ videoId: string }`; the SDK
|
|
2612
|
+
* surfaces it as `videoId` (pass it to `list({ id })`) and keeps the
|
|
2613
|
+
* untouched body on `raw`.
|
|
2614
|
+
*
|
|
2557
2615
|
* @throws {ValidationError} when `input` is empty / not an object.
|
|
2558
2616
|
*/
|
|
2559
2617
|
async create(input) {
|
|
2560
2618
|
if (!input || typeof input !== "object") {
|
|
2561
2619
|
throw new ValidationError({ message: "videos.create: input is required" });
|
|
2562
2620
|
}
|
|
2563
|
-
|
|
2621
|
+
const raw = await this.transport.request({
|
|
2564
2622
|
method: "POST",
|
|
2565
2623
|
path: `/integration/video/sellers/${this.transport.sellerId}/videos`,
|
|
2566
2624
|
body: input,
|
|
2567
2625
|
rateLimiter: this.createLimiter
|
|
2568
2626
|
});
|
|
2627
|
+
const out = { raw };
|
|
2628
|
+
if (typeof raw?.videoId === "string") out.videoId = raw.videoId;
|
|
2629
|
+
return out;
|
|
2569
2630
|
}
|
|
2570
2631
|
/** List the seller's integration videos (optionally filtered by id / status). */
|
|
2571
2632
|
async list(params = {}) {
|
|
@@ -2617,16 +2678,24 @@ var WebhooksResource = class {
|
|
|
2617
2678
|
* per seller — the SDK does NOT pre-check (you'd need to call `list()`
|
|
2618
2679
|
* first), but Trendyol returns 400 when the cap is exceeded.
|
|
2619
2680
|
*
|
|
2681
|
+
* Trendyol documents the response as `{ id: string }` — the webhook ID
|
|
2682
|
+
* you need for `update` / `delete` / `activate` / `deactivate`. The SDK
|
|
2683
|
+
* surfaces it as `id` and keeps the untouched body on `raw`.
|
|
2684
|
+
*
|
|
2620
2685
|
* @throws {ValidationError} when `url` or `authenticationType` is missing.
|
|
2621
2686
|
*/
|
|
2622
2687
|
async create(input) {
|
|
2623
2688
|
this.validateInput(input, "create");
|
|
2624
|
-
|
|
2689
|
+
const raw = await this.transport.request({
|
|
2625
2690
|
method: "POST",
|
|
2626
2691
|
path: `/integration/sellers/${this.transport.sellerId}/webhooks`,
|
|
2627
2692
|
body: input,
|
|
2628
2693
|
rateLimiter: this.limiter
|
|
2629
2694
|
});
|
|
2695
|
+
const out = { raw };
|
|
2696
|
+
if (typeof raw?.id === "string") out.id = raw.id;
|
|
2697
|
+
else if (typeof raw?.id === "number") out.id = String(raw.id);
|
|
2698
|
+
return out;
|
|
2630
2699
|
}
|
|
2631
2700
|
/** List all registered webhook subscriptions. */
|
|
2632
2701
|
async list() {
|
|
@@ -2641,43 +2710,57 @@ var WebhooksResource = class {
|
|
|
2641
2710
|
/**
|
|
2642
2711
|
* Update a webhook subscription. Same input shape as `create`; replaces
|
|
2643
2712
|
* the whole subscription (Trendyol does NOT partially update).
|
|
2713
|
+
*
|
|
2714
|
+
* Documented response is a bare `200 OK` (no body), hence `MutationResult`.
|
|
2644
2715
|
*/
|
|
2645
2716
|
async update(webhookId, input) {
|
|
2646
2717
|
this.validateInput(input, "update");
|
|
2647
|
-
|
|
2718
|
+
const raw = await this.transport.request({
|
|
2648
2719
|
method: "PUT",
|
|
2649
2720
|
path: this.webhookPath(webhookId),
|
|
2650
2721
|
body: input,
|
|
2651
2722
|
rateLimiter: this.limiter
|
|
2652
2723
|
});
|
|
2724
|
+
return { raw };
|
|
2653
2725
|
}
|
|
2654
|
-
/**
|
|
2726
|
+
/**
|
|
2727
|
+
* Permanently delete a webhook subscription. Documented response is a
|
|
2728
|
+
* bare `200 OK` (no body), hence `MutationResult`.
|
|
2729
|
+
*/
|
|
2655
2730
|
async delete(webhookId) {
|
|
2656
|
-
|
|
2731
|
+
const raw = await this.transport.request({
|
|
2657
2732
|
method: "DELETE",
|
|
2658
2733
|
path: this.webhookPath(webhookId),
|
|
2659
2734
|
rateLimiter: this.limiter
|
|
2660
2735
|
});
|
|
2736
|
+
return { raw };
|
|
2661
2737
|
}
|
|
2662
|
-
/**
|
|
2738
|
+
/**
|
|
2739
|
+
* Re-activate a previously-deactivated webhook subscription. Documented
|
|
2740
|
+
* response is a bare `200 OK` (no body), hence `MutationResult`.
|
|
2741
|
+
*/
|
|
2663
2742
|
async activate(webhookId) {
|
|
2664
|
-
|
|
2743
|
+
const raw = await this.transport.request({
|
|
2665
2744
|
method: "PUT",
|
|
2666
2745
|
path: `${this.webhookPath(webhookId)}/activate`,
|
|
2667
2746
|
rateLimiter: this.limiter
|
|
2668
2747
|
});
|
|
2748
|
+
return { raw };
|
|
2669
2749
|
}
|
|
2670
2750
|
/**
|
|
2671
2751
|
* Deactivate a webhook subscription. Trendyol automatically deactivates
|
|
2672
2752
|
* a subscription after persistent delivery failures (and sends 2 emails);
|
|
2673
2753
|
* use `activate()` to bring it back online once your endpoint is healthy.
|
|
2754
|
+
*
|
|
2755
|
+
* Documented response is a bare `200 OK` (no body), hence `MutationResult`.
|
|
2674
2756
|
*/
|
|
2675
2757
|
async deactivate(webhookId) {
|
|
2676
|
-
|
|
2758
|
+
const raw = await this.transport.request({
|
|
2677
2759
|
method: "PUT",
|
|
2678
2760
|
path: `${this.webhookPath(webhookId)}/deactivate`,
|
|
2679
2761
|
rateLimiter: this.limiter
|
|
2680
2762
|
});
|
|
2763
|
+
return { raw };
|
|
2681
2764
|
}
|
|
2682
2765
|
validateInput(input, method) {
|
|
2683
2766
|
if (!input?.url || typeof input.url !== "string") {
|
|
@@ -2725,6 +2808,13 @@ function buildUserAgent(sellerId, integratorName) {
|
|
|
2725
2808
|
return `${sellerId} - ${integratorName}`;
|
|
2726
2809
|
}
|
|
2727
2810
|
function mapHttpError(status, body, retryAfterMs) {
|
|
2811
|
+
if ((status === 401 || status === 403) && typeof body === "string") {
|
|
2812
|
+
return new AuthError({
|
|
2813
|
+
message: `Trendyol rejected the request before it reached the API (HTTP ${status}, non-JSON body) \u2014 check IP allowlisting / credentials / User-Agent`,
|
|
2814
|
+
status,
|
|
2815
|
+
data: { bodyKind: /^\s*</.test(body) ? "html" : "text", bodyLength: body.length }
|
|
2816
|
+
});
|
|
2817
|
+
}
|
|
2728
2818
|
const data = { body };
|
|
2729
2819
|
const issues = normalizeErrorIssues(body);
|
|
2730
2820
|
switch (status) {
|