ebay-mcp 1.13.2 → 1.14.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.
Files changed (169) hide show
  1. package/README.de.md +3 -3
  2. package/README.es.md +3 -3
  3. package/README.fr.md +3 -3
  4. package/README.ja.md +3 -3
  5. package/README.ko.md +3 -3
  6. package/README.md +163 -41
  7. package/README.pt-BR.md +3 -3
  8. package/README.ru.md +3 -3
  9. package/README.zh-CN.md +3 -3
  10. package/build/api/account-management/account.js +633 -297
  11. package/build/api/analytics-and-report/analytics.js +111 -65
  12. package/build/api/client.js +199 -140
  13. package/build/api/clientRequestError.js +23 -0
  14. package/build/api/clientTrading.js +213 -0
  15. package/build/api/clientTradingError.js +4 -0
  16. package/build/api/communication/feedback.js +147 -59
  17. package/build/api/communication/message.js +134 -81
  18. package/build/api/communication/negotiation.js +65 -53
  19. package/build/api/communication/notification.js +458 -164
  20. package/build/api/developer/developer.js +99 -45
  21. package/build/api/index.js +23 -8
  22. package/build/api/listing-management/inventory.js +884 -338
  23. package/build/api/listing-metadata/metadata.js +416 -170
  24. package/build/api/listing-metadata/taxonomy.js +187 -42
  25. package/build/api/marketing-and-promotions/marketing.js +1392 -598
  26. package/build/api/marketing-and-promotions/recommendation.js +49 -24
  27. package/build/api/order-management/dispute.js +226 -45
  28. package/build/api/order-management/fulfillment.js +144 -71
  29. package/build/api/order-management/orderIssueHelpers.js +61 -0
  30. package/build/api/other/compliance.js +50 -38
  31. package/build/api/other/edelivery.js +603 -159
  32. package/build/api/other/finding.js +280 -0
  33. package/build/api/other/identity.js +30 -15
  34. package/build/api/other/translation.js +29 -14
  35. package/build/api/other/vero.js +113 -27
  36. package/build/api/rateLimitTracker.js +55 -0
  37. package/build/api/shared/request.js +189 -98
  38. package/build/api/trading/trading.js +154 -87
  39. package/build/auth/credentialSession.js +250 -0
  40. package/build/auth/oauth.js +298 -171
  41. package/build/auth/{oauth-metadata.js → oauthMetadata.js} +22 -6
  42. package/build/auth/oauthMiddleware.js +104 -0
  43. package/build/auth/{scope-utils.js → scopeUtils.js} +101 -28
  44. package/build/auth/tokenVerifier.js +243 -0
  45. package/build/auth/tokenVerifierError.js +21 -0
  46. package/build/config/environment.js +148 -113
  47. package/build/config/{tool-families.js → toolFamilies.js} +30 -14
  48. package/build/index.js +25 -19
  49. package/build/mcp/{http-transport.js → httpTransport.js} +102 -52
  50. package/build/mcp/readOnlyFilter.js +67 -0
  51. package/build/mcp/runtime.js +31 -13
  52. package/build/mcp/{tool-gating.js → toolGating.js} +77 -49
  53. package/build/mcp/{ui-bridge.js → uiBridge.js} +80 -23
  54. package/build/schemas/account-management/account.js +144 -6
  55. package/build/schemas/analytics/analytics.js +33 -19
  56. package/build/schemas/communication/messages.js +12 -42
  57. package/build/schemas/developer/developer.js +135 -0
  58. package/build/schemas/fulfillment/orders.js +183 -21
  59. package/build/schemas/index.js +27 -19
  60. package/build/schemas/inventory-management/inventory.js +17 -9
  61. package/build/schemas/marketing/marketing.js +480 -25
  62. package/build/schemas/metadata/metadata.js +11 -6
  63. package/build/schemas/other/finding.js +27 -0
  64. package/build/schemas/other/otherApis.js +424 -0
  65. package/build/schemas/taxonomy/taxonomy.js +11 -5
  66. package/build/scripts/{auto-setup.js → autoSetup.js} +87 -74
  67. package/build/scripts/{build-ui.js → buildUi.js} +6 -1
  68. package/build/scripts/{dev-sync.js → devSync.js} +169 -110
  69. package/build/scripts/diagnostics.js +52 -44
  70. package/build/scripts/{download-specs.js → downloadSpecs.js} +29 -21
  71. package/build/scripts/{interactive-setup.js → interactiveSetup.js} +84 -78
  72. package/build/scripts/setup.js +241 -178
  73. package/build/scripts/{setup-shared.js → setupShared.js} +29 -7
  74. package/build/scripts/skills.js +35 -27
  75. package/build/scripts/updateApiStatusDoc.js +71 -0
  76. package/build/serverHttp.js +90 -0
  77. package/build/skills/content.js +124 -118
  78. package/build/skills/index.js +22 -10
  79. package/build/skills/install.js +21 -10
  80. package/build/skills/markers.js +50 -15
  81. package/build/skills/{registry-snapshot.js → registrySnapshot.js} +8 -2
  82. package/build/skills/render.js +41 -14
  83. package/build/skills/targets.js +49 -17
  84. package/build/tools/categories/account.js +166 -264
  85. package/build/tools/categories/analytics.js +11 -22
  86. package/build/tools/categories/browse.js +17 -0
  87. package/build/tools/categories/communication.js +124 -399
  88. package/build/tools/categories/connector.js +23 -20
  89. package/build/tools/categories/developer.js +46 -159
  90. package/build/tools/categories/fulfillment.js +84 -215
  91. package/build/tools/categories/index.js +6 -14
  92. package/build/tools/categories/inventory.js +238 -293
  93. package/build/tools/categories/marketing.js +677 -39
  94. package/build/tools/categories/metadata.js +190 -117
  95. package/build/tools/categories/other.js +81 -208
  96. package/build/tools/categories/taxonomy.js +29 -20
  97. package/build/tools/categories/{token-management.js → tokenManagement.js} +187 -192
  98. package/build/tools/categories/trading.js +16 -47
  99. package/build/tools/contracts.js +34 -24
  100. package/build/tools/{define-tool.js → defineTool.js} +44 -29
  101. package/build/tools/registry.js +87 -29
  102. package/build/tools/schemas.js +3 -57
  103. package/build/tools/ui/archetypes.js +1 -0
  104. package/build/tools/ui/{map-helpers.js → mapHelpers.js} +69 -19
  105. package/build/tools/ui/maps.js +294 -80
  106. package/build/types/index.js +1 -1
  107. package/build/ui/card.html +14 -14
  108. package/build/ui/chart.html +14 -14
  109. package/build/ui/stat.html +87 -0
  110. package/build/ui/table.html +14 -14
  111. package/build/utils/apiStatusFeed.js +95 -0
  112. package/build/utils/cliOutput.js +15 -0
  113. package/build/utils/cliUi.js +108 -0
  114. package/build/utils/communication/feedback.js +57 -77
  115. package/build/utils/communication/message.js +69 -98
  116. package/build/utils/communication/negotiation.js +30 -57
  117. package/build/utils/communication/notification.js +112 -252
  118. package/build/utils/{date-converter.js → dateConverter.js} +62 -30
  119. package/build/utils/effectSchema.js +203 -0
  120. package/build/utils/effectSchemaAdapter.js +121 -0
  121. package/build/utils/effectSchemaChainMethods.js +146 -0
  122. package/build/utils/effectSchemaRefinements.js +104 -0
  123. package/build/utils/effectSchemaStringMethods.js +63 -0
  124. package/build/utils/effectSchemaTypes.js +47 -0
  125. package/build/utils/{env-parser.js → envParser.js} +10 -2
  126. package/build/utils/errors.js +7 -3
  127. package/build/utils/http.js +148 -89
  128. package/build/utils/{llm-client-detector.js → llmClientDetector.js} +295 -274
  129. package/build/utils/logger.js +127 -51
  130. package/build/utils/{oauth-helper.js → oauthHelper.js} +127 -90
  131. package/build/utils/other/compliance.js +18 -38
  132. package/build/utils/other/identity.js +2 -2
  133. package/build/utils/other/translation.js +4 -4
  134. package/build/utils/other/vero.js +36 -20
  135. package/build/utils/schemaHelpers.js +22 -0
  136. package/build/utils/scopeHelper.js +270 -0
  137. package/build/utils/securityChecker.js +316 -0
  138. package/build/utils/{setup-validator.js → setupValidator.js} +113 -94
  139. package/build/utils/{setup-wizard.js → setupWizard.js} +57 -46
  140. package/build/utils/{token-utils.js → tokenUtils.js} +2 -2
  141. package/build/utils/trading/trading.js +35 -0
  142. package/build/utils/typeGuards.js +12 -0
  143. package/build/utils/version.js +65 -29
  144. package/package.json +10 -8
  145. package/build/api/client-trading.js +0 -124
  146. package/build/api/communication/shared.js +0 -59
  147. package/build/api/shared/query-params.js +0 -16
  148. package/build/auth/credential-session.js +0 -166
  149. package/build/auth/oauth-middleware.js +0 -100
  150. package/build/auth/token-verifier.js +0 -186
  151. package/build/schemas/other/other-apis.js +0 -390
  152. package/build/scripts/update-api-status-doc.js +0 -44
  153. package/build/server-http.js +0 -85
  154. package/build/tools/definitions/marketing.js +0 -1381
  155. package/build/tools/tool-handlers/marketing.js +0 -312
  156. package/build/utils/account-management/account.js +0 -818
  157. package/build/utils/api-status-feed.js +0 -84
  158. package/build/utils/cli-ui.js +0 -47
  159. package/build/utils/order-management/dispute.js +0 -369
  160. package/build/utils/order-management/fulfillment.js +0 -205
  161. package/build/utils/other/edelivery.js +0 -235
  162. package/build/utils/schema-helpers.js +0 -13
  163. package/build/utils/scope-helper.js +0 -207
  164. package/build/utils/security-checker.js +0 -248
  165. package/build/utils/type-guards.js +0 -6
  166. /package/build/auth/{oauth-types.js → oauthTypes.js} +0 -0
  167. /package/build/{server-http.d.ts → serverHttp.d.ts} +0 -0
  168. /package/build/tools/ui/{view-models.js → viewModels.js} +0 -0
  169. /package/build/types/{ebay-enums.js → ebayEnums.js} +0 -0
@@ -0,0 +1,23 @@
1
+ import { Data } from 'effect';
2
+ /** Tagged failure raised inside the REST client's request/retry Effect. */
3
+ export class EbayClientRequestError extends Data.TaggedError('EbayClientRequestError') {
4
+ }
5
+ /**
6
+ * Builds a tagged REST-client request error while omitting absent optional fields.
7
+ *
8
+ * @param input - Request failure fields captured by the REST client.
9
+ * @returns Tagged client request error used as the internal request Effect failure.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * clientRequestError({ kind: 'httpStatus', method: 'GET', url, message, status: 429 });
14
+ * ```
15
+ */
16
+ export const clientRequestError = ({ kind, method, url, message, status, cause, }) => new EbayClientRequestError({
17
+ kind,
18
+ method,
19
+ url,
20
+ message,
21
+ ...(status === undefined ? {} : { status }),
22
+ ...(cause === undefined ? {} : { cause }),
23
+ });
@@ -0,0 +1,213 @@
1
+ import XmlBuilder from 'fast-xml-builder';
2
+ import { XMLParser } from 'fast-xml-parser';
3
+ import { TradingApiFailure } from '../api/clientTradingError.js';
4
+ import { EbayApiError } from '../api/shared/request.js';
5
+ import { getBaseUrl } from '../config/environment.js';
6
+ import { getErrorMessage } from '../utils/errors.js';
7
+ import { httpRequestEffect } from '../utils/http.js';
8
+ import { apiLogger } from '../utils/logger.js';
9
+ import { isRecord } from '../utils/typeGuards.js';
10
+ import { Effect } from 'effect';
11
+ const COMPAT_LEVEL = '1451';
12
+ const SITE_ID = '0';
13
+ const TRADING_ENDPOINT_PATH = '/ws/api.dll';
14
+ const TRADING_XMLNS = 'urn:ebay:apis:eBLBaseComponents';
15
+ const buildTradingPath = (baseUrl) => `${baseUrl}${TRADING_ENDPOINT_PATH}`;
16
+ const buildTradingHeaders = (callName) => ({
17
+ 'X-EBAY-API-SITEID': SITE_ID,
18
+ 'X-EBAY-API-COMPATIBILITY-LEVEL': COMPAT_LEVEL,
19
+ 'X-EBAY-API-CALL-NAME': callName,
20
+ 'Content-Type': 'text/xml',
21
+ });
22
+ const buildTradingXmlBody = (builder, requestTag, params) => {
23
+ const xmlObject = {
24
+ [requestTag]: {
25
+ '@_xmlns': TRADING_XMLNS,
26
+ ...params,
27
+ },
28
+ };
29
+ return `<?xml version="1.0" encoding="utf-8"?>\n${builder.build(xmlObject)}`;
30
+ };
31
+ const createTradingApiError = ({ callName, path }, message, cause) => new EbayApiError({
32
+ method: 'POST',
33
+ path,
34
+ cause: new TradingApiFailure({
35
+ callName,
36
+ path,
37
+ message: `Trading API ${callName} ${message}`,
38
+ ...(cause === undefined ? {} : { cause }),
39
+ }),
40
+ });
41
+ const authorizeTradingHeaders = ({ restClient, headers, callName, path, }) => {
42
+ if (restClient.getConfig().disableAuthHeader) {
43
+ return Effect.succeed(headers);
44
+ }
45
+ return restClient
46
+ .getOAuthClient()
47
+ .getAccessToken()
48
+ .pipe(Effect.mapError((error) => createTradingApiError({ callName, path }, `token acquisition failed: ${getErrorMessage(error)}`)), Effect.map((token) => ({ ...headers, 'X-EBAY-API-IAF-TOKEN': token })));
49
+ };
50
+ const postTradingXml = ({ path, headers, xmlBody, callName, }) => httpRequestEffect({
51
+ method: 'POST',
52
+ url: path,
53
+ headers,
54
+ body: xmlBody,
55
+ timeoutMs: 30_000,
56
+ responseType: 'text',
57
+ }).pipe(Effect.mapError((error) => createTradingApiError({ callName, path }, `request failed: ${getErrorMessage(error)}`)));
58
+ const parseTradingXml = ({ parser, responseText, callName, path, }) => Effect.try({
59
+ try: () => parser.parse(responseText),
60
+ catch: (error) => new EbayApiError({
61
+ method: 'POST',
62
+ path,
63
+ cause: new TradingApiFailure({
64
+ callName,
65
+ path,
66
+ message: `Failed to parse Trading API ${callName} response: ${getErrorMessage(error)}`,
67
+ cause: error,
68
+ }),
69
+ }),
70
+ }).pipe(Effect.flatMap((parsedValue) => {
71
+ if (isRecord(parsedValue)) {
72
+ return Effect.succeed(parsedValue);
73
+ }
74
+ return Effect.fail(createTradingApiError({ callName, path }, 'response must be an object'));
75
+ }));
76
+ const readTradingPayload = (parsed, responseTag, { callName, path }) => {
77
+ const resultValue = parsed[responseTag] === undefined ? parsed : parsed[responseTag];
78
+ if (isRecord(resultValue)) {
79
+ return Effect.succeed(resultValue);
80
+ }
81
+ return Effect.fail(createTradingApiError({ callName, path }, 'response payload is not an object'));
82
+ };
83
+ const extractTradingErrorMessage = (errors) => {
84
+ const firstError = Array.isArray(errors) ? errors[0] : errors;
85
+ if (!isRecord(firstError)) {
86
+ return 'Trading API returned a failure without an error message';
87
+ }
88
+ const shortMessage = firstError.ShortMessage;
89
+ if (typeof shortMessage === 'string' && shortMessage !== '') {
90
+ return shortMessage;
91
+ }
92
+ const longMessage = firstError.LongMessage;
93
+ if (typeof longMessage === 'string' && longMessage !== '') {
94
+ return longMessage;
95
+ }
96
+ return 'Trading API returned a failure without an error message';
97
+ };
98
+ const validateTradingAck = (result, { callName, path }) => {
99
+ if (result.Ack === 'Warning') {
100
+ apiLogger.warn(`Trading API ${callName} returned warnings`, {
101
+ errors: result.Errors,
102
+ });
103
+ }
104
+ if (result.Ack === 'Failure' || result.Ack === 'PartialFailure') {
105
+ return Effect.fail(new EbayApiError({
106
+ method: 'POST',
107
+ path,
108
+ cause: new TradingApiFailure({
109
+ callName,
110
+ path,
111
+ message: extractTradingErrorMessage(result.Errors),
112
+ cause: result.Errors,
113
+ }),
114
+ }));
115
+ }
116
+ return Effect.succeed(result);
117
+ };
118
+ /**
119
+ * XML-based client for eBay Trading API calls that are not covered by REST APIs.
120
+ */
121
+ export class TradingApiClient {
122
+ restClient;
123
+ baseUrl;
124
+ parser;
125
+ builder;
126
+ constructor(restClient) {
127
+ this.restClient = restClient;
128
+ const config = restClient.getConfig();
129
+ this.baseUrl = getBaseUrl(config.environment, config.apiBaseUrl);
130
+ this.parser = new XMLParser({
131
+ ignoreAttributes: false,
132
+ removeNSPrefix: true,
133
+ parseTagValue: true,
134
+ isArray: (_name) => {
135
+ const arrayTags = [
136
+ 'Item',
137
+ 'Errors',
138
+ 'Error',
139
+ 'NameValueList',
140
+ 'Value',
141
+ 'ShippingServiceOptions',
142
+ 'InternationalShippingServiceOption',
143
+ 'PaymentMethods',
144
+ 'PictureURL',
145
+ 'CompatibilityList',
146
+ 'Variation',
147
+ ];
148
+ return arrayTags.includes(_name);
149
+ },
150
+ });
151
+ this.builder = new XmlBuilder({
152
+ ignoreAttributes: false,
153
+ format: true,
154
+ suppressEmptyNode: true,
155
+ });
156
+ }
157
+ /**
158
+ * Return the Trading API base URL for the configured eBay environment.
159
+ *
160
+ * @returns The Trading API base URL derived from the configured environment.
161
+ *
162
+ * @example
163
+ * ```ts
164
+ * const baseUrl = tradingClient.getTradingBaseUrl();
165
+ * ```
166
+ */
167
+ getTradingBaseUrl = () => this.baseUrl;
168
+ /**
169
+ * Execute a named Trading API call with XML request/response conversion.
170
+ *
171
+ * @param callName - Trading API call name, such as GetItem or AddFixedPriceItem.
172
+ * @param params - XML request payload fields nested under the generated request tag.
173
+ * @returns An Effect that succeeds with the parsed response payload.
174
+ *
175
+ * @example
176
+ * ```ts
177
+ * const result = await Effect.runPromise(
178
+ * tradingClient.execute('GetItem', { ItemID: '12345' }),
179
+ * );
180
+ * ```
181
+ */
182
+ execute = (callName, params) => {
183
+ const tradingClient = this;
184
+ const requestTag = `${callName}Request`;
185
+ const responseTag = `${callName}Response`;
186
+ const path = buildTradingPath(tradingClient.baseUrl);
187
+ const headers = buildTradingHeaders(callName);
188
+ const xmlBody = buildTradingXmlBody(tradingClient.builder, requestTag, params);
189
+ apiLogger.debug(`Trading API ${callName}`, { xmlBody });
190
+ return Effect.gen(function* () {
191
+ const authorizedHeaders = yield* authorizeTradingHeaders({
192
+ restClient: tradingClient.restClient,
193
+ headers,
194
+ callName,
195
+ path,
196
+ });
197
+ const response = yield* postTradingXml({
198
+ path,
199
+ headers: authorizedHeaders,
200
+ xmlBody,
201
+ callName,
202
+ });
203
+ const parsed = yield* parseTradingXml({
204
+ parser: tradingClient.parser,
205
+ responseText: response.data,
206
+ callName,
207
+ path,
208
+ });
209
+ const result = yield* readTradingPayload(parsed, responseTag, { callName, path });
210
+ return yield* validateTradingAck(result, { callName, path });
211
+ });
212
+ };
213
+ }
@@ -0,0 +1,4 @@
1
+ import { Data } from 'effect';
2
+ /** Tagged cause attached to `EbayApiError` for Trading XML failures. */
3
+ export class TradingApiFailure extends Data.TaggedError('TradingApiFailure') {
4
+ }
@@ -1,5 +1,5 @@
1
- import { getPaginatedWithContextError, getPathWithContextError } from './shared.js';
2
- import { withApiError } from '../../api/shared/request.js';
1
+ import { buildEndpointParams, optionalNonNegativeNumberEffect, optionalPositiveNumberEffect, optionalStringEffect, requestGetEffect, requestPostEffect, requireObjectEffect, requireStringEffect, } from '../../api/shared/request.js';
2
+ import { Effect } from 'effect';
3
3
  /**
4
4
  * Feedback API - Manage buyer and seller feedback
5
5
  * Based on: docs/sell-apps/communication/commerce_feedback_v1_beta_oas3.json
@@ -11,70 +11,158 @@ export class FeedbackApi {
11
11
  this.client = client;
12
12
  }
13
13
  /**
14
- * Get items awaiting feedback
15
- * Endpoint: GET /awaiting_feedback
16
- * @param filter API filter expression.
17
- * @param limit Maximum number of records to return.
18
- * @param offset Zero-based pagination offset.
19
- * @throws Error if the request fails
14
+ * Retrieves line items awaiting feedback.
15
+ *
16
+ * @param input - Optional filter, pagination, and sort query parameters.
17
+ * @returns An Effect that succeeds with eBay's generated AwaitingFeedbackResponse.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * const awaiting = await Effect.runPromise(
22
+ * feedbackApi.getAwaitingFeedback({ filter: 'userRole:SELLER', limit: 25 }),
23
+ * );
24
+ * ```
25
+ *
26
+ * @see https://developer.ebay.com/api-docs/commerce/feedback/resources/awaiting_feedback/methods/getItemsAwaitingFeedback
20
27
  */
21
- async getAwaitingFeedback(filter, limit, offset) {
22
- return await getPaginatedWithContextError(this.client, `${this.basePath}/awaiting_feedback`, 'Failed to get awaiting feedback', filter, limit, offset);
23
- }
24
- /**
25
- * Get feedback for a transaction
26
- * Endpoint: GET /feedback
27
- * @throws Error if required parameters are missing or invalid
28
- */
29
- async getFeedback(transactionId) {
30
- if (!transactionId || typeof transactionId !== 'string') {
31
- throw new Error('transactionId is required and must be a string');
32
- }
33
- return await withApiError('Failed to get feedback', () => this.client.get(`${this.basePath}/feedback`, {
34
- transaction_id: transactionId,
35
- }));
36
- }
28
+ getAwaitingFeedback = (input = {}) => {
29
+ const client = this.client;
30
+ const path = `${this.basePath}/awaiting_feedback`;
31
+ return Effect.gen(function* () {
32
+ const filter = yield* optionalStringEffect(input.filter, 'filter');
33
+ const limit = yield* optionalPositiveNumberEffect(input.limit, 'limit');
34
+ const offset = yield* optionalNonNegativeNumberEffect(input.offset, 'offset');
35
+ const sort = yield* optionalStringEffect(input.sort, 'sort');
36
+ const params = buildEndpointParams({
37
+ filter: { wireName: 'filter', value: filter },
38
+ limit: { wireName: 'limit', value: limit },
39
+ offset: { wireName: 'offset', value: offset },
40
+ sort: { wireName: 'sort', value: sort },
41
+ });
42
+ return yield* requestGetEffect(client, path, params);
43
+ });
44
+ };
37
45
  /**
38
- * Get feedback rating summary
39
- * Endpoint: GET /feedback_rating_summary
40
- * @throws Error if the request fails
46
+ * Retrieves feedback for a specified eBay user.
47
+ *
48
+ * @param input - Required user and feedback type plus optional endpoint filters.
49
+ * @returns An Effect that succeeds with eBay's generated GetFeedbackResponse.
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * const feedback = await Effect.runPromise(
54
+ * feedbackApi.getFeedback({ userId: 'seller_123', feedbackType: 'FEEDBACK_RECEIVED' }),
55
+ * );
56
+ * ```
57
+ *
58
+ * @see https://developer.ebay.com/api-docs/commerce/feedback/resources/feedback/methods/getFeedback
41
59
  */
42
- async getFeedbackRatingSummary() {
43
- return await getPathWithContextError(this.client, `${this.basePath}/feedback_rating_summary`, 'Failed to get feedback rating summary');
44
- }
60
+ getFeedback = (input) => {
61
+ const client = this.client;
62
+ const path = `${this.basePath}/feedback`;
63
+ return Effect.gen(function* () {
64
+ const request = yield* requireObjectEffect(input, 'input');
65
+ const userId = yield* requireStringEffect(request.userId, 'userId');
66
+ const feedbackType = yield* requireStringEffect(request.feedbackType, 'feedbackType');
67
+ const feedbackId = yield* optionalStringEffect(request.feedbackId, 'feedbackId');
68
+ const filter = yield* optionalStringEffect(request.filter, 'filter');
69
+ const limit = yield* optionalPositiveNumberEffect(request.limit, 'limit');
70
+ const listingId = yield* optionalStringEffect(request.listingId, 'listingId');
71
+ const offset = yield* optionalNonNegativeNumberEffect(request.offset, 'offset');
72
+ const orderLineItemId = yield* optionalStringEffect(request.orderLineItemId, 'orderLineItemId');
73
+ const sort = yield* optionalStringEffect(request.sort, 'sort');
74
+ const transactionId = yield* optionalStringEffect(request.transactionId, 'transactionId');
75
+ const params = buildEndpointParams({
76
+ userId: { wireName: 'user_id', value: userId },
77
+ feedbackType: { wireName: 'feedback_type', value: feedbackType },
78
+ feedbackId: { wireName: 'feedback_id', value: feedbackId },
79
+ filter: { wireName: 'filter', value: filter },
80
+ limit: { wireName: 'limit', value: limit },
81
+ listingId: { wireName: 'listing_id', value: listingId },
82
+ offset: { wireName: 'offset', value: offset },
83
+ orderLineItemId: { wireName: 'order_line_item_id', value: orderLineItemId },
84
+ sort: { wireName: 'sort', value: sort },
85
+ transactionId: { wireName: 'transaction_id', value: transactionId },
86
+ });
87
+ return yield* requestGetEffect(client, path, params);
88
+ });
89
+ };
45
90
  /**
46
- * Leave feedback for a buyer
47
- * Endpoint: POST /feedback
48
- * @throws Error if required parameters are missing or invalid
91
+ * Retrieves a feedback rating summary for a user.
92
+ *
93
+ * @param input - Required eBay user ID and rating summary filter.
94
+ * @returns An Effect that succeeds with eBay's generated GetFeedbackRatingSummaryResponse.
95
+ *
96
+ * @example
97
+ * ```ts
98
+ * const summary = await Effect.runPromise(
99
+ * feedbackApi.getFeedbackRatingSummary({
100
+ * userId: 'seller_123',
101
+ * filter: 'ratingType:OVERALL_EXPERIENCE',
102
+ * }),
103
+ * );
104
+ * ```
105
+ *
106
+ * @see https://developer.ebay.com/api-docs/commerce/feedback/resources/feedback_rating_summary/methods/getFeedbackRatingSummary
49
107
  */
50
- async leaveFeedbackForBuyer(feedbackData) {
51
- if (!feedbackData || typeof feedbackData !== 'object') {
52
- throw new Error('feedbackData is required and must be an object');
53
- }
54
- return await withApiError('Failed to leave feedback', () => this.client.post(`${this.basePath}/feedback`, feedbackData));
55
- }
108
+ getFeedbackRatingSummary = (input) => {
109
+ const client = this.client;
110
+ const path = `${this.basePath}/feedback_rating_summary`;
111
+ return Effect.gen(function* () {
112
+ const request = yield* requireObjectEffect(input, 'input');
113
+ const userId = yield* requireStringEffect(request.userId, 'userId');
114
+ const filter = yield* requireStringEffect(request.filter, 'filter');
115
+ const params = buildEndpointParams({
116
+ userId: { wireName: 'user_id', value: userId },
117
+ filter: { wireName: 'filter', value: filter },
118
+ });
119
+ return yield* requestGetEffect(client, path, params);
120
+ });
121
+ };
56
122
  /**
57
- * Respond to feedback
58
- * Endpoint: POST /respond_to_feedback
59
- * @throws Error if required parameters are missing or invalid
123
+ * Leaves feedback for the user's order partner.
124
+ *
125
+ * @param feedbackData - Generated LeaveFeedbackRequest body.
126
+ * @returns An Effect that succeeds with eBay's generated LeaveFeedbackResponse.
127
+ *
128
+ * @example
129
+ * ```ts
130
+ * const feedback = await Effect.runPromise(
131
+ * feedbackApi.leaveFeedbackForBuyer({ commentText: 'Great buyer', commentType: 'POSITIVE' }),
132
+ * );
133
+ * ```
134
+ *
135
+ * @see https://developer.ebay.com/api-docs/commerce/feedback/resources/feedback/methods/leaveFeedback
60
136
  */
61
- async respondToFeedback(feedbackId, responseText) {
62
- if (!feedbackId || typeof feedbackId !== 'string') {
63
- throw new Error('feedbackId is required and must be a string');
64
- }
65
- if (!responseText || typeof responseText !== 'string') {
66
- throw new Error('responseText is required and must be a string');
67
- }
68
- return await withApiError('Failed to respond to feedback', () => this.client.post(`${this.basePath}/respond_to_feedback`, {
69
- feedback_id: feedbackId,
70
- response_text: responseText,
71
- }));
72
- }
137
+ leaveFeedbackForBuyer = (feedbackData) => {
138
+ const client = this.client;
139
+ const path = `${this.basePath}/feedback`;
140
+ return Effect.gen(function* () {
141
+ const body = yield* requireObjectEffect(feedbackData, 'feedbackData');
142
+ return yield* requestPostEffect(client, path, body);
143
+ });
144
+ };
73
145
  /**
74
- * Get feedback summary
75
- * @deprecated Use getFeedbackRatingSummary() instead
146
+ * Responds to feedback received from another eBay user.
147
+ *
148
+ * @param response - Generated RespondToFeedbackRequest body.
149
+ * @returns An Effect that succeeds with eBay's generated empty response.
150
+ *
151
+ * @example
152
+ * ```ts
153
+ * await Effect.runPromise(
154
+ * feedbackApi.respondToFeedback({ feedbackId: 'feedback-1', responseText: 'Thank you' }),
155
+ * );
156
+ * ```
157
+ *
158
+ * @see https://developer.ebay.com/api-docs/commerce/feedback/resources/respond_to_feedback/methods/respondToFeedback
76
159
  */
77
- async getFeedbackSummary() {
78
- return await this.getFeedbackRatingSummary();
79
- }
160
+ respondToFeedback = (response) => {
161
+ const client = this.client;
162
+ const path = `${this.basePath}/respond_to_feedback`;
163
+ return Effect.gen(function* () {
164
+ const body = yield* requireObjectEffect(response, 'response');
165
+ return yield* requestPostEffect(client, path, body);
166
+ });
167
+ };
80
168
  }