@lonca/trendyol 0.14.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-CtygosAW.d.cts → client-Dnfjvwah.d.cts} +143 -19
- package/dist/{client-CtygosAW.d.ts → client-Dnfjvwah.d.ts} +143 -19
- package/dist/index.cjs +91 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +92 -19
- package/dist/index.js.map +1 -1
- package/dist/testing.cjs +91 -18
- 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 +92 -19
- package/dist/testing.js.map +1 -1
- package/package.json +5 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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
5
|
export { CursorPage, CursorPaginationParams, MutationResult, OffsetPage, OffsetPaginationParams, paginate, paginateOffset } from '@lonca/core';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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
5
|
export { CursorPage, CursorPaginationParams, MutationResult, OffsetPage, OffsetPaginationParams, paginate, paginateOffset } from '@lonca/core';
|
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
|
|
@@ -953,18 +953,23 @@ var LabelsResource = class {
|
|
|
953
953
|
* returns, call `getCommon()` with the same `cargoTrackingNumber` to
|
|
954
954
|
* retrieve the generated label.
|
|
955
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
|
+
*
|
|
956
960
|
* @throws {ValidationError} when `format` is missing.
|
|
957
961
|
*/
|
|
958
962
|
async createCommon(cargoTrackingNumber, input) {
|
|
959
963
|
if (!input?.format) {
|
|
960
964
|
throw new ValidationError({ message: "labels.createCommon: format is required" });
|
|
961
965
|
}
|
|
962
|
-
|
|
966
|
+
const raw = await this.transport.request({
|
|
963
967
|
method: "POST",
|
|
964
968
|
path: `/integration/sellers/${this.transport.sellerId}/common-label/${encodeURIComponent(String(cargoTrackingNumber))}`,
|
|
965
969
|
body: input,
|
|
966
970
|
rateLimiter: this.limiter
|
|
967
971
|
});
|
|
972
|
+
return { raw };
|
|
968
973
|
}
|
|
969
974
|
/**
|
|
970
975
|
* Retrieve the previously-created common label. Trendyol returns
|
|
@@ -2414,6 +2419,9 @@ var QuestionsResource = class {
|
|
|
2414
2419
|
* Reply to a question. Trendyol enforces 10–2000 characters on the
|
|
2415
2420
|
* answer text; the SDK pre-validates client-side.
|
|
2416
2421
|
*
|
|
2422
|
+
* Trendyol documents the response as `{ answerId: number }`; the SDK
|
|
2423
|
+
* surfaces it as `answerId` and keeps the untouched body on `raw`.
|
|
2424
|
+
*
|
|
2417
2425
|
* @throws {ValidationError} when `text` is outside the 10–2000 char range.
|
|
2418
2426
|
*/
|
|
2419
2427
|
async answer(questionId, text) {
|
|
@@ -2427,12 +2435,15 @@ var QuestionsResource = class {
|
|
|
2427
2435
|
message: `questions.answer: text must be at most 2000 chars (got ${text.length})`
|
|
2428
2436
|
});
|
|
2429
2437
|
}
|
|
2430
|
-
|
|
2438
|
+
const raw = await this.transport.request({
|
|
2431
2439
|
method: "POST",
|
|
2432
2440
|
path: `/integration/qna/sellers/${this.transport.sellerId}/questions/${encodeURIComponent(String(questionId))}/answers`,
|
|
2433
2441
|
body: { text },
|
|
2434
2442
|
rateLimiter: this.limiter
|
|
2435
2443
|
});
|
|
2444
|
+
const out = { raw };
|
|
2445
|
+
if (typeof raw?.answerId === "number") out.answerId = raw.answerId;
|
|
2446
|
+
return out;
|
|
2436
2447
|
}
|
|
2437
2448
|
};
|
|
2438
2449
|
var VALID_TYPES = /* @__PURE__ */ new Set([
|
|
@@ -2525,6 +2536,9 @@ var TestOrdersResource = class {
|
|
|
2525
2536
|
* SDK forwards the typed payload verbatim — drill into Trendyol's
|
|
2526
2537
|
* `createTestOrder` doc for inner field rules.
|
|
2527
2538
|
*
|
|
2539
|
+
* Trendyol documents the response as `{ orderNumber: string }`; the SDK
|
|
2540
|
+
* surfaces it as `orderNumber` and keeps the untouched body on `raw`.
|
|
2541
|
+
*
|
|
2528
2542
|
* @throws {ValidationError} when required top-level fields are missing.
|
|
2529
2543
|
*/
|
|
2530
2544
|
async create(input) {
|
|
@@ -2533,29 +2547,52 @@ var TestOrdersResource = class {
|
|
|
2533
2547
|
throw new ValidationError({ message: `testOrders.create: ${k} is required` });
|
|
2534
2548
|
}
|
|
2535
2549
|
}
|
|
2536
|
-
|
|
2550
|
+
const raw = await this.transport.request({
|
|
2537
2551
|
method: "POST",
|
|
2538
2552
|
path: `/integration/test/order/orders/core`,
|
|
2539
2553
|
body: input,
|
|
2540
2554
|
rateLimiter: this.limiter
|
|
2541
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;
|
|
2542
2560
|
}
|
|
2543
|
-
/**
|
|
2544
|
-
|
|
2545
|
-
|
|
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({
|
|
2546
2570
|
method: "PUT",
|
|
2547
2571
|
path: `/integration/test/order/sellers/${this.transport.sellerId}/shipment-packages/${encodeURIComponent(String(packageId))}/status`,
|
|
2548
|
-
body: {
|
|
2572
|
+
body: {
|
|
2573
|
+
...options.lines !== void 0 ? { lines: options.lines } : {},
|
|
2574
|
+
...options.params !== void 0 ? { params: options.params } : {},
|
|
2575
|
+
status
|
|
2576
|
+
},
|
|
2549
2577
|
rateLimiter: this.limiter
|
|
2550
2578
|
});
|
|
2579
|
+
return { raw };
|
|
2551
2580
|
}
|
|
2552
|
-
/**
|
|
2553
|
-
|
|
2554
|
-
|
|
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({
|
|
2555
2590
|
method: "PUT",
|
|
2556
2591
|
path: `/integration/test/order/sellers/${this.transport.sellerId}/claims/waiting-in-action`,
|
|
2592
|
+
...input ? { body: input } : {},
|
|
2557
2593
|
rateLimiter: this.limiter
|
|
2558
2594
|
});
|
|
2595
|
+
return { raw };
|
|
2559
2596
|
}
|
|
2560
2597
|
};
|
|
2561
2598
|
var VideosResource = class {
|
|
@@ -2571,18 +2608,25 @@ var VideosResource = class {
|
|
|
2571
2608
|
* Queue a video for upload. Trendyol downloads from the URL in the
|
|
2572
2609
|
* body asynchronously; poll `list()` (filtered by id) for status.
|
|
2573
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
|
+
*
|
|
2574
2615
|
* @throws {ValidationError} when `input` is empty / not an object.
|
|
2575
2616
|
*/
|
|
2576
2617
|
async create(input) {
|
|
2577
2618
|
if (!input || typeof input !== "object") {
|
|
2578
2619
|
throw new ValidationError({ message: "videos.create: input is required" });
|
|
2579
2620
|
}
|
|
2580
|
-
|
|
2621
|
+
const raw = await this.transport.request({
|
|
2581
2622
|
method: "POST",
|
|
2582
2623
|
path: `/integration/video/sellers/${this.transport.sellerId}/videos`,
|
|
2583
2624
|
body: input,
|
|
2584
2625
|
rateLimiter: this.createLimiter
|
|
2585
2626
|
});
|
|
2627
|
+
const out = { raw };
|
|
2628
|
+
if (typeof raw?.videoId === "string") out.videoId = raw.videoId;
|
|
2629
|
+
return out;
|
|
2586
2630
|
}
|
|
2587
2631
|
/** List the seller's integration videos (optionally filtered by id / status). */
|
|
2588
2632
|
async list(params = {}) {
|
|
@@ -2634,16 +2678,24 @@ var WebhooksResource = class {
|
|
|
2634
2678
|
* per seller — the SDK does NOT pre-check (you'd need to call `list()`
|
|
2635
2679
|
* first), but Trendyol returns 400 when the cap is exceeded.
|
|
2636
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
|
+
*
|
|
2637
2685
|
* @throws {ValidationError} when `url` or `authenticationType` is missing.
|
|
2638
2686
|
*/
|
|
2639
2687
|
async create(input) {
|
|
2640
2688
|
this.validateInput(input, "create");
|
|
2641
|
-
|
|
2689
|
+
const raw = await this.transport.request({
|
|
2642
2690
|
method: "POST",
|
|
2643
2691
|
path: `/integration/sellers/${this.transport.sellerId}/webhooks`,
|
|
2644
2692
|
body: input,
|
|
2645
2693
|
rateLimiter: this.limiter
|
|
2646
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;
|
|
2647
2699
|
}
|
|
2648
2700
|
/** List all registered webhook subscriptions. */
|
|
2649
2701
|
async list() {
|
|
@@ -2658,43 +2710,57 @@ var WebhooksResource = class {
|
|
|
2658
2710
|
/**
|
|
2659
2711
|
* Update a webhook subscription. Same input shape as `create`; replaces
|
|
2660
2712
|
* the whole subscription (Trendyol does NOT partially update).
|
|
2713
|
+
*
|
|
2714
|
+
* Documented response is a bare `200 OK` (no body), hence `MutationResult`.
|
|
2661
2715
|
*/
|
|
2662
2716
|
async update(webhookId, input) {
|
|
2663
2717
|
this.validateInput(input, "update");
|
|
2664
|
-
|
|
2718
|
+
const raw = await this.transport.request({
|
|
2665
2719
|
method: "PUT",
|
|
2666
2720
|
path: this.webhookPath(webhookId),
|
|
2667
2721
|
body: input,
|
|
2668
2722
|
rateLimiter: this.limiter
|
|
2669
2723
|
});
|
|
2724
|
+
return { raw };
|
|
2670
2725
|
}
|
|
2671
|
-
/**
|
|
2726
|
+
/**
|
|
2727
|
+
* Permanently delete a webhook subscription. Documented response is a
|
|
2728
|
+
* bare `200 OK` (no body), hence `MutationResult`.
|
|
2729
|
+
*/
|
|
2672
2730
|
async delete(webhookId) {
|
|
2673
|
-
|
|
2731
|
+
const raw = await this.transport.request({
|
|
2674
2732
|
method: "DELETE",
|
|
2675
2733
|
path: this.webhookPath(webhookId),
|
|
2676
2734
|
rateLimiter: this.limiter
|
|
2677
2735
|
});
|
|
2736
|
+
return { raw };
|
|
2678
2737
|
}
|
|
2679
|
-
/**
|
|
2738
|
+
/**
|
|
2739
|
+
* Re-activate a previously-deactivated webhook subscription. Documented
|
|
2740
|
+
* response is a bare `200 OK` (no body), hence `MutationResult`.
|
|
2741
|
+
*/
|
|
2680
2742
|
async activate(webhookId) {
|
|
2681
|
-
|
|
2743
|
+
const raw = await this.transport.request({
|
|
2682
2744
|
method: "PUT",
|
|
2683
2745
|
path: `${this.webhookPath(webhookId)}/activate`,
|
|
2684
2746
|
rateLimiter: this.limiter
|
|
2685
2747
|
});
|
|
2748
|
+
return { raw };
|
|
2686
2749
|
}
|
|
2687
2750
|
/**
|
|
2688
2751
|
* Deactivate a webhook subscription. Trendyol automatically deactivates
|
|
2689
2752
|
* a subscription after persistent delivery failures (and sends 2 emails);
|
|
2690
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`.
|
|
2691
2756
|
*/
|
|
2692
2757
|
async deactivate(webhookId) {
|
|
2693
|
-
|
|
2758
|
+
const raw = await this.transport.request({
|
|
2694
2759
|
method: "PUT",
|
|
2695
2760
|
path: `${this.webhookPath(webhookId)}/deactivate`,
|
|
2696
2761
|
rateLimiter: this.limiter
|
|
2697
2762
|
});
|
|
2763
|
+
return { raw };
|
|
2698
2764
|
}
|
|
2699
2765
|
validateInput(input, method) {
|
|
2700
2766
|
if (!input?.url || typeof input.url !== "string") {
|
|
@@ -2742,6 +2808,13 @@ function buildUserAgent(sellerId, integratorName) {
|
|
|
2742
2808
|
return `${sellerId} - ${integratorName}`;
|
|
2743
2809
|
}
|
|
2744
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
|
+
}
|
|
2745
2818
|
const data = { body };
|
|
2746
2819
|
const issues = normalizeErrorIssues(body);
|
|
2747
2820
|
switch (status) {
|