ebay-mcp 1.17.0 → 1.18.2

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.
Files changed (178) hide show
  1. package/README.md +92 -53
  2. package/build/api/account-management/accountV2.js +347 -0
  3. package/build/api/account-management/finances.js +289 -0
  4. package/build/api/analytics-and-report/analytics.js +1 -1
  5. package/build/api/{client.js → client/ebayApiClient.js} +83 -36
  6. package/build/api/{clientTrading.js → client/tradingApiClient.js} +22 -22
  7. package/build/api/communication/feedback.js +21 -21
  8. package/build/api/communication/message.js +23 -23
  9. package/build/api/communication/negotiation.js +7 -7
  10. package/build/api/communication/notification.js +52 -52
  11. package/build/api/developer/developer.js +3 -3
  12. package/build/api/{index.js → ebaySellerApi.js} +28 -4
  13. package/build/api/listing-management/feed.js +91 -0
  14. package/build/api/listing-management/feedReportTasks.js +107 -0
  15. package/build/api/listing-management/feedRequest.js +91 -0
  16. package/build/api/listing-management/feedSchedules.js +95 -0
  17. package/build/api/listing-management/feedTasks.js +91 -0
  18. package/build/api/listing-management/items.js +22 -22
  19. package/build/api/listing-management/locations.js +4 -4
  20. package/build/api/listing-management/media.js +14 -14
  21. package/build/api/listing-management/mediaAttach.js +14 -14
  22. package/build/api/listing-management/mediaResources.js +22 -39
  23. package/build/api/listing-management/offerFormat.js +1 -1
  24. package/build/api/listing-management/offers.js +23 -23
  25. package/build/api/listing-management/stores.js +203 -0
  26. package/build/api/listing-metadata/charity.js +76 -0
  27. package/build/api/listing-metadata/metadata.js +31 -11
  28. package/build/api/listing-metadata/metadataShipping.js +117 -0
  29. package/build/api/listing-metadata/taxonomy.js +52 -7
  30. package/build/api/marketing-and-promotions/ads.js +34 -34
  31. package/build/api/marketing-and-promotions/campaigns.js +21 -21
  32. package/build/api/marketing-and-promotions/promotions.js +24 -24
  33. package/build/api/marketing-and-promotions/reports.js +7 -7
  34. package/build/api/marketing-and-promotions/shared.js +0 -3
  35. package/build/api/order-management/dispute.js +11 -9
  36. package/build/api/order-management/fulfillment.js +4 -4
  37. package/build/api/order-management/logistics.js +150 -0
  38. package/build/api/other/browseMappers.js +15 -13
  39. package/build/api/other/browseValidators.js +4 -4
  40. package/build/api/other/edelivery.js +19 -19
  41. package/build/api/other/finding.js +13 -13
  42. package/build/api/other/translation.js +2 -2
  43. package/build/api/other/vero.js +2 -2
  44. package/build/api/shared/download.js +79 -0
  45. package/build/api/shared/location.js +33 -0
  46. package/build/api/shared/request.js +69 -11
  47. package/build/api/trading/listingFormat.js +37 -30
  48. package/build/api/trading/trading.js +33 -33
  49. package/build/auth/credentialSession.js +5 -5
  50. package/build/auth/oauth.js +3 -3
  51. package/build/auth/oauthHelper.js +24 -24
  52. package/build/auth/oauthMetadata.js +4 -4
  53. package/build/auth/oauthMiddleware.js +16 -16
  54. package/build/auth/scopeUtils.js +24 -3
  55. package/build/auth/tokenVerifier.js +23 -23
  56. package/build/config/environment.js +10 -45
  57. package/build/config/oauthScopes.js +132 -0
  58. package/build/config/toolFamilies.js +4 -0
  59. package/build/index.js +5 -5
  60. package/build/mcp/httpTransport.js +32 -20
  61. package/build/mcp/runtime.js +12 -12
  62. package/build/mcp/toolGating.js +6 -12
  63. package/build/mcp/uiBridge.js +3 -3
  64. package/build/schemas/account-management/account.js +2 -52
  65. package/build/schemas/account-management/accountV2.js +294 -0
  66. package/build/schemas/account-management/finances.js +143 -0
  67. package/build/schemas/analytics/analytics.js +2 -48
  68. package/build/schemas/communication/messages.js +2 -46
  69. package/build/schemas/developer/developer.js +1 -27
  70. package/build/schemas/fulfillment/logistics.js +115 -0
  71. package/build/schemas/fulfillment/orders.js +2 -47
  72. package/build/schemas/inventory-management/feed.js +217 -0
  73. package/build/schemas/inventory-management/inventory.js +2 -50
  74. package/build/schemas/inventory-management/media.js +2 -2
  75. package/build/schemas/inventory-management/mediaDocuments.js +1 -1
  76. package/build/schemas/inventory-management/stores.js +42 -0
  77. package/build/schemas/marketing/ads.js +2 -2
  78. package/build/schemas/marketing/campaigns.js +2 -2
  79. package/build/schemas/marketing/common.js +2 -2
  80. package/build/schemas/marketing/marketing.js +0 -1
  81. package/build/schemas/marketing/promotions.js +2 -2
  82. package/build/schemas/marketing/reports.js +2 -2
  83. package/build/schemas/metadata/metadata.js +2 -90
  84. package/build/schemas/metadata/shipping.js +16 -0
  85. package/build/schemas/other/browse.js +2 -2
  86. package/build/schemas/other/finding.js +2 -2
  87. package/build/schemas/other/otherApis.js +2 -114
  88. package/build/schemas/taxonomy/categoryTree.js +8 -0
  89. package/build/schemas/taxonomy/charity.js +41 -0
  90. package/build/schemas/taxonomy/taxonomy.js +2 -69
  91. package/build/scripts/autoSetup.js +3 -3
  92. package/build/scripts/{buildUi.js → buildMcpApps.js} +13 -13
  93. package/build/scripts/devSync.js +34 -70
  94. package/build/scripts/diagnostics.js +15 -16
  95. package/build/scripts/interactiveSetup.js +25 -25
  96. package/build/scripts/scopeHelper.js +2 -2
  97. package/build/scripts/securityChecker.js +20 -20
  98. package/build/scripts/setup.js +76 -76
  99. package/build/scripts/setupShared.js +5 -30
  100. package/build/scripts/setupValidator.js +9 -9
  101. package/build/scripts/setupWizard.js +23 -23
  102. package/build/scripts/skills.js +14 -17
  103. package/build/scripts/specRefs.js +55 -0
  104. package/build/scripts/specSources.js +144 -0
  105. package/build/serverHttp.js +4 -7
  106. package/build/skills/content.js +13 -13
  107. package/build/skills/install.js +9 -9
  108. package/build/skills/registrySnapshot.js +7 -3
  109. package/build/skills/render.js +2 -2
  110. package/build/tools/categories/accountV2.js +106 -0
  111. package/build/tools/categories/charity.js +21 -0
  112. package/build/tools/categories/communication.js +1 -1
  113. package/build/tools/categories/connector.js +19 -16
  114. package/build/tools/categories/feed.js +183 -0
  115. package/build/tools/categories/finances.js +86 -0
  116. package/build/tools/categories/fulfillment.js +4 -4
  117. package/build/tools/categories/index.js +12 -2
  118. package/build/tools/categories/inventory.js +1 -1
  119. package/build/tools/categories/logistics.js +52 -0
  120. package/build/tools/categories/metadata.js +38 -1
  121. package/build/tools/categories/stores.js +64 -0
  122. package/build/tools/categories/taxonomy.js +18 -1
  123. package/build/tools/categories/tokenManagement.js +8 -8
  124. package/build/tools/contracts.js +2 -2
  125. package/build/tools/defineTool.js +27 -12
  126. package/build/tools/fileResult.js +30 -0
  127. package/build/tools/registry.js +2 -2
  128. package/build/tools/schemas.js +2 -2
  129. package/build/tools/ui/mapHelpers.js +12 -12
  130. package/build/tools/ui/maps.js +101 -97
  131. package/build/tools/ui/viewModels.js +2 -2
  132. package/build/utils/apiStatusFeed.js +12 -12
  133. package/build/utils/communication/feedback.js +3 -3
  134. package/build/utils/communication/message.js +3 -3
  135. package/build/utils/communication/negotiation.js +3 -3
  136. package/build/utils/communication/notification.js +3 -3
  137. package/build/utils/entryModule.js +33 -0
  138. package/build/utils/envFile.js +47 -0
  139. package/build/utils/envParser.js +5 -5
  140. package/build/utils/errors.js +4 -4
  141. package/build/utils/http.js +60 -41
  142. package/build/utils/localFeedFiles.js +61 -0
  143. package/build/utils/localMedia.js +18 -6
  144. package/build/utils/logRedaction.js +21 -0
  145. package/build/utils/logger.js +52 -33
  146. package/build/utils/other/compliance.js +3 -3
  147. package/build/utils/other/identity.js +3 -3
  148. package/build/utils/other/translation.js +3 -3
  149. package/build/utils/other/vero.js +3 -3
  150. package/build/utils/schemaHelpers.js +2 -2
  151. package/build/utils/tokenUtils.js +2 -2
  152. package/build/utils/trading/trading.js +1 -1
  153. package/build/utils/version.js +1 -1
  154. package/build/utils/zodIssues.js +14 -0
  155. package/package.json +9 -12
  156. package/README.de.md +0 -422
  157. package/README.es.md +0 -422
  158. package/README.fr.md +0 -422
  159. package/README.ja.md +0 -422
  160. package/README.ko.md +0 -422
  161. package/README.pt-BR.md +0 -422
  162. package/README.ru.md +0 -422
  163. package/README.zh-CN.md +0 -422
  164. package/build/schemas/index.js +0 -76
  165. package/build/schemas/marketing/jsonSchemas.js +0 -118
  166. package/build/scripts/downloadSpecs.js +0 -117
  167. package/build/scripts/updateApiStatusDoc.js +0 -71
  168. package/build/utils/effectSchema.js +0 -203
  169. package/build/utils/effectSchemaAdapter.js +0 -121
  170. package/build/utils/effectSchemaChainMethods.js +0 -146
  171. package/build/utils/effectSchemaRefinements.js +0 -104
  172. package/build/utils/effectSchemaStringMethods.js +0 -63
  173. package/build/utils/effectSchemaTypes.js +0 -47
  174. package/docs/auth/production_scopes.json +0 -111
  175. package/docs/auth/sandbox_scopes.json +0 -142
  176. /package/build/api/{clientRequestError.js → client/ebayClientRequestError.js} +0 -0
  177. /package/build/api/{rateLimitTracker.js → client/rateLimitTracker.js} +0 -0
  178. /package/build/api/{clientTradingError.js → client/tradingApiFailure.js} +0 -0
@@ -0,0 +1,347 @@
1
+ import { buildEndpointParams, marketplaceHeader, optionalStringEffect, requestGetEffect, requestPatchEffect, requestPostEffect, requireObjectEffect, requireStringEffect, } from '../../api/shared/request.js';
2
+ import { Effect } from 'effect';
3
+ /** Account API v2 - rate tables, payout settings, combined shipping rules, and user preferences. */
4
+ export class AccountV2Api {
5
+ basePath = '/sell/account/v2';
6
+ client;
7
+ constructor(client) {
8
+ this.client = client;
9
+ }
10
+ /**
11
+ * Retrieves one shipping rate table with its rates, so their rateIds can be updated.
12
+ *
13
+ * @param input - Rate table ID (path), from Account API v1 getRateTables.
14
+ * @returns An Effect that succeeds with eBay's generated RateTableDetails.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * const table = await Effect.runPromise(accountV2Api.getRateTable({ rateTableId: '5000000000' }));
19
+ * ```
20
+ *
21
+ * @see https://developer.ebay.com/api-docs/sell/account/v2/resources/rate_table/methods/getRateTable
22
+ */
23
+ getRateTable = (input) => {
24
+ const { client, basePath } = this;
25
+ return Effect.gen(function* () {
26
+ const validInput = yield* requireObjectEffect(input, 'input');
27
+ const rateTableId = yield* requireStringEffect(validInput.rateTableId, 'rateTableId');
28
+ return yield* requestGetEffect(client, `${basePath}/rate_table/${encodeURIComponent(rateTableId)}`);
29
+ });
30
+ };
31
+ /**
32
+ * Updates the shippingCost and/or additionalCost of rates in a shipping rate table.
33
+ *
34
+ * @param input - Rate table ID (path) and the RateTableUpdate body.
35
+ * @returns An Effect that succeeds when eBay returns 204 No Content.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * await Effect.runPromise(
40
+ * accountV2Api.updateShippingCost({
41
+ * rateTableId: '5000000000',
42
+ * rateTableUpdate: { rates: [{ rateId: 'R1', shippingCost: { currency: 'USD', value: '4.99' } }] },
43
+ * }),
44
+ * );
45
+ * ```
46
+ *
47
+ * @see https://developer.ebay.com/api-docs/sell/account/v2/resources/rate_table/methods/updateShippingCost
48
+ */
49
+ updateShippingCost = (input) => {
50
+ const { client, basePath } = this;
51
+ return Effect.gen(function* () {
52
+ const validInput = yield* requireObjectEffect(input, 'input');
53
+ const rateTableId = yield* requireStringEffect(validInput.rateTableId, 'rateTableId');
54
+ const rateTableUpdate = yield* requireObjectEffect(validInput.rateTableUpdate, 'rateTableUpdate');
55
+ const path = `${basePath}/rate_table/${encodeURIComponent(rateTableId)}/update_shipping_cost`;
56
+ return yield* requestPostEffect(client, path, rateTableUpdate);
57
+ });
58
+ };
59
+ /**
60
+ * Retrieves the seller's payout instruments and split-payout percentages
61
+ * (mainland China sellers only). Requires the sell.finances scope.
62
+ *
63
+ * @param _input - Empty object accepted for tool/API shape consistency.
64
+ * @returns An Effect that succeeds with eBay's generated PayoutSettingsResponse.
65
+ *
66
+ * @example
67
+ * ```ts
68
+ * const settings = await Effect.runPromise(accountV2Api.getPayoutSettings({}));
69
+ * ```
70
+ *
71
+ * @see https://developer.ebay.com/api-docs/sell/account/v2/resources/payout_settings/methods/getPayoutSettings
72
+ */
73
+ getPayoutSettings = (_input = {}) => requestGetEffect(this.client, `${this.basePath}/payout_settings`);
74
+ /**
75
+ * Sets the split-payout percentage across the seller's two payout instruments
76
+ * (mainland China sellers only; percentages must total 100). Requires sell.finances.
77
+ *
78
+ * @param input - UpdatePayoutPercentageRequest body under `payoutSplit`.
79
+ * @returns An Effect that succeeds when eBay returns 204 No Content.
80
+ *
81
+ * @example
82
+ * ```ts
83
+ * await Effect.runPromise(
84
+ * accountV2Api.updatePayoutPercentage({
85
+ * payoutSplit: {
86
+ * payoutInstruments: [
87
+ * { instrumentId: 'BANK-1', payoutPercentage: '70' },
88
+ * { instrumentId: 'PAYONEER-1', payoutPercentage: '30' },
89
+ * ],
90
+ * },
91
+ * }),
92
+ * );
93
+ * ```
94
+ *
95
+ * @see https://developer.ebay.com/api-docs/sell/account/v2/resources/payout_settings/methods/updatePayoutPercentage
96
+ */
97
+ updatePayoutPercentage = (input) => {
98
+ const { client } = this;
99
+ const path = `${this.basePath}/payout_settings/update_percentage`;
100
+ return Effect.gen(function* () {
101
+ const validInput = yield* requireObjectEffect(input, 'input');
102
+ const payoutSplit = yield* requireObjectEffect(validInput.payoutSplit, 'payoutSplit');
103
+ return yield* requestPostEffect(client, path, payoutSplit);
104
+ });
105
+ };
106
+ /**
107
+ * Creates calculated combined-shipping rules (and optional handling rule or
108
+ * combined payment window) for one marketplace.
109
+ *
110
+ * @param input - Marketplace header and the CreateCalculatedShippingRulesRequest body.
111
+ * @returns An Effect that succeeds when eBay returns 204 No Content.
112
+ *
113
+ * @example
114
+ * ```ts
115
+ * await Effect.runPromise(
116
+ * accountV2Api.createCalculatedShippingRules({
117
+ * marketplaceId: MarketplaceId.EBAY_US,
118
+ * shippingRules: { combinedDuration: 'DAYS_7' },
119
+ * }),
120
+ * );
121
+ * ```
122
+ *
123
+ * @see https://developer.ebay.com/api-docs/sell/account/v2/resources/combined_shipping_rules/methods/createCalculatedShippingRules
124
+ */
125
+ createCalculatedShippingRules = (input) => this.postCombinedShippingRules('create_calculated_shipping_rules', input, 'shippingRules');
126
+ /**
127
+ * Creates flat-rate combined-shipping rules for one marketplace.
128
+ *
129
+ * @param input - Marketplace header and the CreateFlatShippingRulesRequest body.
130
+ * @returns An Effect that succeeds when eBay returns 204 No Content.
131
+ *
132
+ * @example
133
+ * ```ts
134
+ * await Effect.runPromise(
135
+ * accountV2Api.createFlatShippingRules({
136
+ * marketplaceId: MarketplaceId.EBAY_US,
137
+ * shippingRules: { flatShippingRule: { combinedShippingRuleType: 'EACH_ADDITIONAL_AMOUNT' } },
138
+ * }),
139
+ * );
140
+ * ```
141
+ *
142
+ * @see https://developer.ebay.com/api-docs/sell/account/v2/resources/combined_shipping_rules/methods/createFlatShippingRules
143
+ */
144
+ createFlatShippingRules = (input) => this.postCombinedShippingRules('create_flat_shipping_rules', input, 'shippingRules');
145
+ /**
146
+ * Creates the promotional combined-shipping rule (discount or free shipping
147
+ * above an order amount or item count) for one marketplace.
148
+ *
149
+ * @param input - Marketplace header and the CreatePromotionalShippingRuleRequest body.
150
+ * @returns An Effect that succeeds when eBay returns 204 No Content.
151
+ *
152
+ * @example
153
+ * ```ts
154
+ * await Effect.runPromise(
155
+ * accountV2Api.createPromotionalShippingRule({
156
+ * marketplaceId: MarketplaceId.EBAY_US,
157
+ * shippingRules: { promotionalShippingRule: { itemCount: 3 } },
158
+ * }),
159
+ * );
160
+ * ```
161
+ *
162
+ * @see https://developer.ebay.com/api-docs/sell/account/v2/resources/combined_shipping_rules/methods/createPromotionalShippingRule
163
+ */
164
+ createPromotionalShippingRule = (input) => this.postCombinedShippingRules('create_promotional_shipping_rule', input, 'shippingRules');
165
+ /**
166
+ * Retrieves the seller's calculated, flat, and promotional combined-shipping
167
+ * rules and combined payment window for one marketplace.
168
+ *
169
+ * @param input - Marketplace sent as the X-EBAY-C-MARKETPLACE-ID header.
170
+ * @returns An Effect that succeeds with eBay's GetCombinedShippingRulesPublicApiResponse.
171
+ *
172
+ * @example
173
+ * ```ts
174
+ * const rules = await Effect.runPromise(
175
+ * accountV2Api.getCombinedShippingRules({ marketplaceId: MarketplaceId.EBAY_US }),
176
+ * );
177
+ * ```
178
+ *
179
+ * @see https://developer.ebay.com/api-docs/sell/account/v2/resources/combined_shipping_rules/methods/getCombinedShippingRules
180
+ */
181
+ getCombinedShippingRules = (input) => {
182
+ const { client } = this;
183
+ const path = `${this.basePath}/combined_shipping_rules`;
184
+ return Effect.gen(function* () {
185
+ const validInput = yield* requireObjectEffect(input, 'input');
186
+ const marketplaceId = yield* requireStringEffect(validInput.marketplaceId, 'marketplaceId');
187
+ return yield* requestGetEffect(client, path, undefined, marketplaceHeader(marketplaceId));
188
+ });
189
+ };
190
+ /**
191
+ * Updates existing calculated combined-shipping rules for one marketplace.
192
+ *
193
+ * @param input - Marketplace header and the UpdateCalculatedShippingRulesRequest body.
194
+ * @returns An Effect that succeeds when eBay returns 204 No Content.
195
+ *
196
+ * @example
197
+ * ```ts
198
+ * await Effect.runPromise(
199
+ * accountV2Api.updateCalculatedShippingRules({
200
+ * marketplaceId: MarketplaceId.EBAY_US,
201
+ * shippingRules: { combinedDuration: 'DAYS_14' },
202
+ * }),
203
+ * );
204
+ * ```
205
+ *
206
+ * @see https://developer.ebay.com/api-docs/sell/account/v2/resources/combined_shipping_rules/methods/updateCalculatedShippingRules
207
+ */
208
+ updateCalculatedShippingRules = (input) => this.postCombinedShippingRules('update_calculated_shipping_rules', input, 'shippingRules');
209
+ /**
210
+ * Changes the combined payment window for unpaid orders on one marketplace.
211
+ *
212
+ * @param input - Marketplace header and the UpdateCombinedPaymentsRequest body.
213
+ * @returns An Effect that succeeds when eBay returns 204 No Content.
214
+ *
215
+ * @example
216
+ * ```ts
217
+ * await Effect.runPromise(
218
+ * accountV2Api.updateCombinedPayments({
219
+ * marketplaceId: MarketplaceId.EBAY_US,
220
+ * combinedPayments: { combinedDuration: 'DAYS_30' },
221
+ * }),
222
+ * );
223
+ * ```
224
+ *
225
+ * @see https://developer.ebay.com/api-docs/sell/account/v2/resources/combined_shipping_rules/methods/updateCombinedPayments
226
+ */
227
+ updateCombinedPayments = (input) => this.postCombinedShippingRules('update_combined_payments', input, 'combinedPayments');
228
+ /**
229
+ * Updates existing flat-rate combined-shipping rules for one marketplace.
230
+ *
231
+ * @param input - Marketplace header and the UpdateFlatShippingRulesRequest body.
232
+ * @returns An Effect that succeeds when eBay returns 204 No Content.
233
+ *
234
+ * @example
235
+ * ```ts
236
+ * await Effect.runPromise(
237
+ * accountV2Api.updateFlatShippingRules({
238
+ * marketplaceId: MarketplaceId.EBAY_US,
239
+ * shippingRules: { combinedDuration: 'DAYS_5' },
240
+ * }),
241
+ * );
242
+ * ```
243
+ *
244
+ * @see https://developer.ebay.com/api-docs/sell/account/v2/resources/combined_shipping_rules/methods/updateFlatShippingRules
245
+ */
246
+ updateFlatShippingRules = (input) => this.postCombinedShippingRules('update_flat_shipping_rules', input, 'shippingRules');
247
+ /**
248
+ * Updates the existing promotional combined-shipping rule for one marketplace.
249
+ *
250
+ * @param input - Marketplace header and the UpdatePromotionalShippingRuleRequest body.
251
+ * @returns An Effect that succeeds when eBay returns 204 No Content.
252
+ *
253
+ * @example
254
+ * ```ts
255
+ * await Effect.runPromise(
256
+ * accountV2Api.updatePromotionalShippingRule({
257
+ * marketplaceId: MarketplaceId.EBAY_US,
258
+ * shippingRules: { promotionalShippingRule: { orderAmount: { currency: 'USD', value: '50.00' } } },
259
+ * }),
260
+ * );
261
+ * ```
262
+ *
263
+ * @see https://developer.ebay.com/api-docs/sell/account/v2/resources/combined_shipping_rules/methods/updatePromotionalShippingRule
264
+ */
265
+ updatePromotionalShippingRule = (input) => this.postCombinedShippingRules('update_promotional_shipping_rule', input, 'shippingRules');
266
+ /**
267
+ * Retrieves the seller's preferences for one marketplace, optionally limited to
268
+ * specific field groups.
269
+ *
270
+ * @param input - Marketplace header and optional comma-separated `fieldgroups`.
271
+ * @returns An Effect that succeeds with eBay's generated GetUserPreferencesResponse.
272
+ *
273
+ * @example
274
+ * ```ts
275
+ * const preferences = await Effect.runPromise(
276
+ * accountV2Api.getUserPreferences({
277
+ * marketplaceId: MarketplaceId.EBAY_US,
278
+ * fieldgroups: 'COMBINED_PAYMENT,DISPATCH_CUTOFF_TIME',
279
+ * }),
280
+ * );
281
+ * ```
282
+ *
283
+ * @see https://developer.ebay.com/api-docs/sell/account/v2/resources/user_preferences/methods/getUserPreferences
284
+ */
285
+ getUserPreferences = (input) => {
286
+ const { client } = this;
287
+ const path = `${this.basePath}/user_preferences`;
288
+ return Effect.gen(function* () {
289
+ const validInput = yield* requireObjectEffect(input, 'input');
290
+ const marketplaceId = yield* requireStringEffect(validInput.marketplaceId, 'marketplaceId');
291
+ const fieldgroups = yield* optionalStringEffect(validInput.fieldgroups, 'fieldgroups');
292
+ const params = buildEndpointParams({
293
+ fieldgroups: { wireName: 'fieldgroups', value: fieldgroups },
294
+ });
295
+ return yield* requestGetEffect(client, path, params, marketplaceHeader(marketplaceId));
296
+ });
297
+ };
298
+ /**
299
+ * Changes one or more seller preferences for one marketplace (PATCH: send only
300
+ * the preferences being changed).
301
+ *
302
+ * eBay's OAS3 spec references an undefined `SetUserPreferencesRequest`, so the
303
+ * generated body type is `unknown`. The body is typed from the tool schema,
304
+ * which mirrors the definition in eBay's published Account v2 spec: the
305
+ * `*PreferencesType` containers returned by getUserPreferences, with
306
+ * SetItemsAwaitingPaymentPreferencesType for unpaid-item settings.
307
+ *
308
+ * @param input - Marketplace header and the preferences PATCH body.
309
+ * @returns An Effect that succeeds when eBay returns 204 No Content.
310
+ *
311
+ * @example
312
+ * ```ts
313
+ * await Effect.runPromise(
314
+ * accountV2Api.setUserPreferences({
315
+ * marketplaceId: MarketplaceId.EBAY_US,
316
+ * preferences: { outOfStockControlPreference: true },
317
+ * }),
318
+ * );
319
+ * ```
320
+ *
321
+ * @see https://developer.ebay.com/api-docs/sell/account/v2/resources/user_preferences/methods/setUserPreferences
322
+ */
323
+ setUserPreferences = (input) => {
324
+ const { client } = this;
325
+ const path = `${this.basePath}/user_preferences`;
326
+ return Effect.gen(function* () {
327
+ const validInput = yield* requireObjectEffect(input, 'input');
328
+ const marketplaceId = yield* requireStringEffect(validInput.marketplaceId, 'marketplaceId');
329
+ const preferences = yield* requireObjectEffect(validInput.preferences, 'preferences');
330
+ return yield* requestPatchEffect(client, path, preferences, marketplaceHeader(marketplaceId));
331
+ });
332
+ };
333
+ /**
334
+ * Validates the marketplace header and body field, then POSTs one
335
+ * combined-shipping-rules request that eBay answers with 204 No Content.
336
+ */
337
+ postCombinedShippingRules = (operation, input, bodyField) => {
338
+ const { client } = this;
339
+ const path = `${this.basePath}/combined_shipping_rules/${operation}`;
340
+ return Effect.gen(function* () {
341
+ const validInput = yield* requireObjectEffect(input, 'input');
342
+ const marketplaceId = yield* requireStringEffect(validInput.marketplaceId, 'marketplaceId');
343
+ const rules = yield* requireObjectEffect(validInput[bodyField], bodyField);
344
+ return yield* requestPostEffect(client, path, rules, marketplaceHeader(marketplaceId));
345
+ });
346
+ };
347
+ }
@@ -0,0 +1,289 @@
1
+ import { buildEndpointParams, decodeEndpointInputEffect, EbayApiError, requestGetEffect, } from '../../api/shared/request.js';
2
+ import { getIdentityBaseUrl } from '../../config/environment.js';
3
+ import { getBillingActivitiesInputSchema, getOrderEarningsByIdInputSchema, getOrderEarningsInputSchema, getOrderEarningsSummaryInputSchema, getPayoutInputSchema, getPayoutSummaryInputSchema, getPayoutsInputSchema, getSellerFundsSummaryInputSchema, getTransactionSummaryInputSchema, getTransactionsInputSchema, getTransferInputSchema, } from '../../schemas/account-management/finances.js';
4
+ import { Effect } from 'effect';
5
+ const BASE_PATH = '/sell/finances/v1';
6
+ /** Maps the shared filter/limit/offset/sort fields to their eBay query names. */
7
+ const pageQuery = (input) => buildEndpointParams({
8
+ filter: { wireName: 'filter', value: input.filter },
9
+ limit: { wireName: 'limit', value: input.limit },
10
+ offset: { wireName: 'offset', value: input.offset },
11
+ sort: { wireName: 'sort', value: input.sort },
12
+ });
13
+ /** Maps the single filter field accepted by the Finances summary endpoints. */
14
+ const filterQuery = (filter) => buildEndpointParams({ filter: { wireName: 'filter', value: filter } });
15
+ /**
16
+ * Finances API - payouts, transactions, transfers, seller funds, billing activity, and order
17
+ * earnings. Every operation except getBillingActivities is served from the apiz host.
18
+ */
19
+ export class FinancesApi {
20
+ client;
21
+ constructor(client) {
22
+ this.client = client;
23
+ }
24
+ /**
25
+ * Sends a GET to the apiz host (or EBAY_MCP_API_BASE_URL) with an optional marketplace
26
+ * header, keeping the relative eBay path in the typed error.
27
+ */
28
+ getFromApiz = (path, params, marketplaceId) => {
29
+ const client = this.client;
30
+ const config = marketplaceId === undefined
31
+ ? { absolute: true }
32
+ : { absolute: true, headers: { 'X-EBAY-C-MARKETPLACE-ID': marketplaceId } };
33
+ return Effect.tryPromise({
34
+ try: () => {
35
+ const { environment, apiBaseUrl } = client.getConfig();
36
+ const url = `${getIdentityBaseUrl(environment, apiBaseUrl)}${path}`;
37
+ return client.get(url, params, config);
38
+ },
39
+ catch: (cause) => new EbayApiError({ method: 'GET', path, cause }), // allow-duplicate
40
+ });
41
+ };
42
+ /**
43
+ * Retrieves order-level earnings (gross amount, expenses, refunds, net earnings) for the
44
+ * seller's orders. Requires the optional sell.finances.earnings.read scope.
45
+ *
46
+ * @param input - Optional orderCreationDate filter, pagination, sort, and marketplace override.
47
+ * @returns An Effect that succeeds with eBay's OrderEarnings page.
48
+ *
49
+ * @example
50
+ * ```ts
51
+ * const earnings = await Effect.runPromise(
52
+ * financesApi.getOrderEarnings({
53
+ * filter: 'orderCreationDate:[2024-10-23T00:00:01.000Z..2024-11-09T00:00:01.000Z]',
54
+ * limit: 50,
55
+ * }),
56
+ * );
57
+ * ```
58
+ *
59
+ * @see https://developer.ebay.com/api-docs/sell/finances/resources/order_earnings/methods/getOrderEarnings
60
+ */
61
+ getOrderEarnings = (input = {}) => {
62
+ const getFromApiz = this.getFromApiz;
63
+ return Effect.gen(function* () {
64
+ const validatedInput = yield* decodeEndpointInputEffect(getOrderEarningsInputSchema, input);
65
+ return yield* getFromApiz(`${BASE_PATH}/order_earnings`, pageQuery(validatedInput), validatedInput.marketplaceId);
66
+ });
67
+ };
68
+ /**
69
+ * Retrieves earnings for one order. Requires the optional sell.finances.earnings.read scope.
70
+ *
71
+ * @param input - eBay order ID plus optional marketplace override.
72
+ * @returns An Effect that succeeds with eBay's OrderEarning.
73
+ *
74
+ * @example
75
+ * ```ts
76
+ * const earning = await Effect.runPromise(
77
+ * financesApi.getOrderEarningsById({ orderId: '12-12345-12345' }),
78
+ * );
79
+ * ```
80
+ *
81
+ * @see https://developer.ebay.com/api-docs/sell/finances/resources/order_earnings/methods/getOrderEarningsById
82
+ */
83
+ getOrderEarningsById = (input) => {
84
+ const getFromApiz = this.getFromApiz;
85
+ return Effect.gen(function* () {
86
+ const { orderId, marketplaceId } = yield* decodeEndpointInputEffect(getOrderEarningsByIdInputSchema, input);
87
+ return yield* getFromApiz(`${BASE_PATH}/order_earnings/${encodeURIComponent(orderId)}`, undefined, marketplaceId);
88
+ });
89
+ };
90
+ /**
91
+ * Retrieves aggregated order earnings for orders created in a date range. Requires the
92
+ * optional sell.finances.earnings.read scope.
93
+ *
94
+ * @param input - Optional orderCreationDate filter and marketplace override.
95
+ * @returns An Effect that succeeds with eBay's OrderEarningsSummary.
96
+ *
97
+ * @example
98
+ * ```ts
99
+ * const summary = await Effect.runPromise(financesApi.getOrderEarningsSummary({}));
100
+ * ```
101
+ *
102
+ * @see https://developer.ebay.com/api-docs/sell/finances/resources/order_earnings/methods/getOrderEarningsSummary
103
+ */
104
+ getOrderEarningsSummary = (input = {}) => {
105
+ const getFromApiz = this.getFromApiz;
106
+ return Effect.gen(function* () {
107
+ const { filter, marketplaceId } = yield* decodeEndpointInputEffect(getOrderEarningsSummaryInputSchema, input);
108
+ return yield* getFromApiz(`${BASE_PATH}/order_earnings_summary`, filterQuery(filter), marketplaceId);
109
+ });
110
+ };
111
+ /**
112
+ * Retrieves one seller payout by ID.
113
+ *
114
+ * @param input - Payout ID (not a split-payout payoutReference) plus optional marketplace override.
115
+ * @returns An Effect that succeeds with eBay's Payout.
116
+ *
117
+ * @example
118
+ * ```ts
119
+ * const payout = await Effect.runPromise(financesApi.getPayout({ payoutId: '5000000001' }));
120
+ * ```
121
+ *
122
+ * @see https://developer.ebay.com/api-docs/sell/finances/resources/payout/methods/getPayout
123
+ */
124
+ getPayout = (input) => {
125
+ const getFromApiz = this.getFromApiz;
126
+ return Effect.gen(function* () {
127
+ const { payoutId, marketplaceId } = yield* decodeEndpointInputEffect(getPayoutInputSchema, input);
128
+ return yield* getFromApiz(`${BASE_PATH}/payout/${encodeURIComponent(payoutId)}`, undefined, marketplaceId);
129
+ });
130
+ };
131
+ /**
132
+ * Retrieves seller payouts with optional date/status filtering, pagination, and sorting.
133
+ *
134
+ * @param input - Optional payout filter, pagination, sort, and marketplace override.
135
+ * @returns An Effect that succeeds with eBay's Payouts page, or undefined on HTTP 204.
136
+ *
137
+ * @example
138
+ * ```ts
139
+ * const payouts = await Effect.runPromise(
140
+ * financesApi.getPayouts({ filter: 'payoutStatus:{SUCCEEDED}', limit: 20 }),
141
+ * );
142
+ * ```
143
+ *
144
+ * @see https://developer.ebay.com/api-docs/sell/finances/resources/payout/methods/getPayouts
145
+ */
146
+ getPayouts = (input = {}) => {
147
+ const getFromApiz = this.getFromApiz;
148
+ return Effect.gen(function* () {
149
+ const validatedInput = yield* decodeEndpointInputEffect(getPayoutsInputSchema, input);
150
+ return yield* getFromApiz(`${BASE_PATH}/payout`, pageQuery(validatedInput), validatedInput.marketplaceId);
151
+ });
152
+ };
153
+ /**
154
+ * Retrieves cumulative payout counts and amounts, optionally filtered by date and status.
155
+ *
156
+ * @param input - Optional payoutDate/payoutStatus filter and marketplace override.
157
+ * @returns An Effect that succeeds with eBay's PayoutSummaryResponse.
158
+ *
159
+ * @example
160
+ * ```ts
161
+ * const summary = await Effect.runPromise(
162
+ * financesApi.getPayoutSummary({ filter: 'payoutStatus:{SUCCEEDED}' }),
163
+ * );
164
+ * ```
165
+ *
166
+ * @see https://developer.ebay.com/api-docs/sell/finances/resources/payout/methods/getPayoutSummary
167
+ */
168
+ getPayoutSummary = (input = {}) => {
169
+ const getFromApiz = this.getFromApiz;
170
+ return Effect.gen(function* () {
171
+ const { filter, marketplaceId } = yield* decodeEndpointInputEffect(getPayoutSummaryInputSchema, input);
172
+ return yield* getFromApiz(`${BASE_PATH}/payout_summary`, filterQuery(filter), marketplaceId);
173
+ });
174
+ };
175
+ /**
176
+ * Retrieves funds not yet paid out: available, processing, and on-hold amounts.
177
+ *
178
+ * @param input - Optional marketplace override.
179
+ * @returns An Effect that succeeds with eBay's SellerFundsSummaryResponse, or undefined on
180
+ * HTTP 204 when no funds are pending.
181
+ *
182
+ * @example
183
+ * ```ts
184
+ * const funds = await Effect.runPromise(financesApi.getSellerFundsSummary({}));
185
+ * ```
186
+ *
187
+ * @see https://developer.ebay.com/api-docs/sell/finances/resources/seller_funds_summary/methods/getSellerFundsSummary
188
+ */
189
+ getSellerFundsSummary = (input = {}) => {
190
+ const getFromApiz = this.getFromApiz;
191
+ return Effect.gen(function* () {
192
+ const { marketplaceId } = yield* decodeEndpointInputEffect(getSellerFundsSummaryInputSchema, input);
193
+ return yield* getFromApiz(`${BASE_PATH}/seller_funds_summary`, undefined, marketplaceId);
194
+ });
195
+ };
196
+ /**
197
+ * Retrieves monetary transactions (sales, refunds, credits, fees, transfers, and more).
198
+ *
199
+ * @param input - Optional transaction filter, pagination, sort, and marketplace override.
200
+ * @returns An Effect that succeeds with eBay's Transactions page, or undefined on HTTP 204.
201
+ *
202
+ * @example
203
+ * ```ts
204
+ * const sales = await Effect.runPromise(
205
+ * financesApi.getTransactions({ filter: 'transactionType:{SALE}', limit: 100 }),
206
+ * );
207
+ * ```
208
+ *
209
+ * @see https://developer.ebay.com/api-docs/sell/finances/resources/transaction/methods/getTransactions
210
+ */
211
+ getTransactions = (input = {}) => {
212
+ const getFromApiz = this.getFromApiz;
213
+ return Effect.gen(function* () {
214
+ const validatedInput = yield* decodeEndpointInputEffect(getTransactionsInputSchema, input);
215
+ return yield* getFromApiz(`${BASE_PATH}/transaction`, pageQuery(validatedInput), validatedInput.marketplaceId);
216
+ });
217
+ };
218
+ /**
219
+ * Retrieves cumulative counts and amounts for monetary transactions, including on-hold funds.
220
+ *
221
+ * @param input - Transaction filter (eBay requires a transactionStatus criterion) and optional
222
+ * marketplace override.
223
+ * @returns An Effect that succeeds with eBay's TransactionSummaryResponse.
224
+ *
225
+ * @example
226
+ * ```ts
227
+ * const summary = await Effect.runPromise(
228
+ * financesApi.getTransactionSummary({ filter: 'transactionStatus:{PAYOUT}' }),
229
+ * );
230
+ * ```
231
+ *
232
+ * @see https://developer.ebay.com/api-docs/sell/finances/resources/transaction/methods/getTransactionSummary
233
+ */
234
+ getTransactionSummary = (input) => {
235
+ const getFromApiz = this.getFromApiz;
236
+ return Effect.gen(function* () {
237
+ const { filter, marketplaceId } = yield* decodeEndpointInputEffect(getTransactionSummaryInputSchema, input);
238
+ return yield* getFromApiz(`${BASE_PATH}/transaction_summary`, filterQuery(filter), marketplaceId);
239
+ });
240
+ };
241
+ /**
242
+ * Retrieves one TRANSFER transaction (a seller reimbursing eBay for charges such as refunds).
243
+ *
244
+ * @param input - TRANSFER transaction ID plus optional marketplace override.
245
+ * @returns An Effect that succeeds with eBay's Transfer.
246
+ *
247
+ * @example
248
+ * ```ts
249
+ * const transfer = await Effect.runPromise(
250
+ * financesApi.getTransfer({ transferId: '0-00000-00000' }),
251
+ * );
252
+ * ```
253
+ *
254
+ * @see https://developer.ebay.com/api-docs/sell/finances/resources/transfer/methods/getTransfer
255
+ */
256
+ getTransfer = (input) => {
257
+ const getFromApiz = this.getFromApiz;
258
+ return Effect.gen(function* () {
259
+ const { transferId, marketplaceId } = yield* decodeEndpointInputEffect(getTransferInputSchema, input);
260
+ return yield* getFromApiz(`${BASE_PATH}/transfer/${encodeURIComponent(transferId)}`, undefined, marketplaceId);
261
+ });
262
+ };
263
+ /**
264
+ * Retrieves the seller's billing activities (fees and credits) for one activity, listing,
265
+ * order, or date range. Unlike the rest of the Finances API this is served from the api host.
266
+ *
267
+ * @param input - Billing filter, pagination, sort, and optional Accept-Language override.
268
+ * @returns An Effect that succeeds with eBay's BillingActivityResponse.
269
+ *
270
+ * @example
271
+ * ```ts
272
+ * const activities = await Effect.runPromise(
273
+ * financesApi.getBillingActivities({ filter: 'orderId:{12-12345-12345}' }),
274
+ * );
275
+ * ```
276
+ *
277
+ * @see https://developer.ebay.com/api-docs/sell/finances/resources/billing_activity/methods/getBillingActivities
278
+ */
279
+ getBillingActivities = (input) => {
280
+ const client = this.client;
281
+ return Effect.gen(function* () {
282
+ const validatedInput = yield* decodeEndpointInputEffect(getBillingActivitiesInputSchema, input);
283
+ const config = validatedInput.acceptLanguage === undefined
284
+ ? undefined
285
+ : { headers: { 'Accept-Language': validatedInput.acceptLanguage } };
286
+ return yield* requestGetEffect(client, `${BASE_PATH}/billing_activity`, pageQuery(validatedInput), config);
287
+ });
288
+ };
289
+ }
@@ -2,7 +2,7 @@ import { buildEndpointParams, optionalStringEffect, requestGetEffect, requireObj
2
2
  import { Effect } from 'effect';
3
3
  /**
4
4
  * Analytics API - Sales and traffic analytics
5
- * Based on: docs/sell-apps/analytics-and-report/sell_analytics_v1_oas3.json
5
+ * Based on: sell_analytics_v1_oas3.json
6
6
  */
7
7
  export class AnalyticsApi {
8
8
  basePath = '/sell/analytics/v1';