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
@@ -1,5 +1,5 @@
1
- import { assertRequiredString, buildPaginatedQueryParams, getPathWithContextError, getWithContextError, } 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
  * Message API - Buyer-seller messaging
5
5
  * Based on: docs/sell-apps/communication/commerce_message_v1_oas3.json
@@ -11,94 +11,147 @@ export class MessageApi {
11
11
  this.client = client;
12
12
  }
13
13
  /**
14
- * Bulk update conversation
15
- * Endpoint: POST /bulk_update_conversation
16
- * @throws Error if required parameters are missing or invalid
17
- */
18
- async bulkUpdateConversation(updateData) {
19
- if (!updateData || typeof updateData !== 'object') {
20
- throw new Error('updateData is required and must be an object');
21
- }
22
- return await withApiError('Failed to bulk update conversation', () => this.client.post(`${this.basePath}/bulk_update_conversation`, updateData));
23
- }
24
- /**
25
- * Get conversations
26
- * Endpoint: GET /conversation
27
- * @param filter API filter expression.
28
- * @param limit Maximum number of records to return.
29
- * @param offset Zero-based pagination offset.
30
- * @throws Error if the request fails
31
- */
32
- async getConversations(filter, limit, offset) {
33
- const conversationPath = `${this.basePath}/conversation`;
34
- const queryParams = this.buildConversationQueryParams(filter, limit, offset);
35
- return await getWithContextError(this.client, conversationPath, queryParams, 'Failed to get conversations');
36
- }
37
- /**
38
- * Build query params used by conversation listing endpoints.
14
+ * Updates multiple conversations in one request.
39
15
  *
40
- * @param filter API filter expression.
41
- * @param limit Maximum number of records to return.
42
- * @param offset Zero-based pagination offset.
43
- * @returns Validated conversation query params.
44
- */
45
- buildConversationQueryParams(filter, limit, offset) {
46
- return buildPaginatedQueryParams(filter, limit, offset);
47
- }
48
- /**
49
- * Get a specific conversation
50
- * Endpoint: GET /conversation/{conversation_id}
51
- * @param conversationId Conversation identifier.
52
- * @throws Error if required parameters are missing or invalid
53
- */
54
- async getConversation(conversationId) {
55
- assertRequiredString(conversationId, 'conversationId');
56
- return await getPathWithContextError(this.client, `${this.basePath}/conversation/${conversationId}`, 'Failed to get conversation');
57
- }
58
- /**
59
- * Send a message
60
- * Endpoint: POST /send_message
61
- * @throws Error if required parameters are missing or invalid
16
+ * @param updateData - Generated BulkUpdateConversationsRequest body.
17
+ * @returns An Effect that succeeds with eBay's generated bulk update response.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * const result = await Effect.runPromise(
22
+ * messageApi.bulkUpdateConversation({ conversations: [{ conversationId: 'c1' }] }),
23
+ * );
24
+ * ```
25
+ *
26
+ * @see https://developer.ebay.com/api-docs/commerce/message/resources/bulk_update_conversation/methods/bulkUpdateConversation
62
27
  */
63
- async sendMessage(messageData) {
64
- if (!messageData || typeof messageData !== 'object') {
65
- throw new Error('messageData is required and must be an object');
66
- }
67
- return await withApiError('Failed to send message', () => this.client.post(`${this.basePath}/send_message`, messageData));
68
- }
28
+ bulkUpdateConversation = (updateData) => {
29
+ const client = this.client;
30
+ const path = `${this.basePath}/bulk_update_conversation`;
31
+ return Effect.gen(function* () {
32
+ const body = yield* requireObjectEffect(updateData, 'updateData');
33
+ return yield* requestPostEffect(client, path, body);
34
+ });
35
+ };
69
36
  /**
70
- * Update a conversation
71
- * Endpoint: POST /update_conversation
72
- * @throws Error if required parameters are missing or invalid
37
+ * Retrieves buyer-seller conversations.
38
+ *
39
+ * @param input - Required conversation type plus optional filters and pagination.
40
+ * @returns An Effect that succeeds with eBay's generated conversation collection response.
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * const conversations = await Effect.runPromise(
45
+ * messageApi.getConversations({ conversationType: 'FROM_MEMBERS', limit: 25 }),
46
+ * );
47
+ * ```
48
+ *
49
+ * @see https://developer.ebay.com/api-docs/commerce/message/resources/conversation/methods/getConversations
73
50
  */
74
- async updateConversation(updateData) {
75
- if (!updateData || typeof updateData !== 'object') {
76
- throw new Error('updateData is required and must be an object');
77
- }
78
- return await withApiError('Failed to update conversation', () => this.client.post(`${this.basePath}/update_conversation`, updateData));
79
- }
51
+ getConversations = (input) => {
52
+ const client = this.client;
53
+ const path = `${this.basePath}/conversation`;
54
+ return Effect.gen(function* () {
55
+ const request = yield* requireObjectEffect(input, 'input');
56
+ const conversationType = yield* requireStringEffect(request.conversationType, 'conversationType');
57
+ const conversationStatus = yield* optionalStringEffect(request.conversationStatus, 'conversationStatus');
58
+ const endTime = yield* optionalStringEffect(request.endTime, 'endTime');
59
+ const limit = yield* optionalPositiveNumberEffect(request.limit, 'limit');
60
+ const offset = yield* optionalNonNegativeNumberEffect(request.offset, 'offset');
61
+ const otherPartyUsername = yield* optionalStringEffect(request.otherPartyUsername, 'otherPartyUsername');
62
+ const referenceId = yield* optionalStringEffect(request.referenceId, 'referenceId');
63
+ const referenceType = yield* optionalStringEffect(request.referenceType, 'referenceType');
64
+ const startTime = yield* optionalStringEffect(request.startTime, 'startTime');
65
+ const params = buildEndpointParams({
66
+ conversationType: { wireName: 'conversation_type', value: conversationType },
67
+ conversationStatus: { wireName: 'conversation_status', value: conversationStatus },
68
+ endTime: { wireName: 'end_time', value: endTime },
69
+ limit: { wireName: 'limit', value: limit },
70
+ offset: { wireName: 'offset', value: offset },
71
+ otherPartyUsername: { wireName: 'other_party_username', value: otherPartyUsername },
72
+ referenceId: { wireName: 'reference_id', value: referenceId },
73
+ referenceType: { wireName: 'reference_type', value: referenceType },
74
+ startTime: { wireName: 'start_time', value: startTime },
75
+ });
76
+ return yield* requestGetEffect(client, path, params);
77
+ });
78
+ };
80
79
  /**
81
- * Search for messages
82
- * @deprecated Use getConversations() instead
80
+ * Retrieves messages in a specific conversation.
81
+ *
82
+ * @param input - Conversation path ID plus required type and optional pagination.
83
+ * @returns An Effect that succeeds with eBay's generated conversation message response.
84
+ *
85
+ * @example
86
+ * ```ts
87
+ * const conversation = await Effect.runPromise(
88
+ * messageApi.getConversation({ conversationId: 'c1', conversationType: 'FROM_MEMBERS' }),
89
+ * );
90
+ * ```
91
+ *
92
+ * @see https://developer.ebay.com/api-docs/commerce/message/resources/conversation/methods/getConversation
83
93
  */
84
- async searchMessages(filter, limit, offset) {
85
- return await this.getConversations(filter, limit, offset);
86
- }
94
+ getConversation = (input) => {
95
+ const client = this.client;
96
+ const basePath = this.basePath;
97
+ return Effect.gen(function* () {
98
+ const request = yield* requireObjectEffect(input, 'input');
99
+ const conversationId = yield* requireStringEffect(request.conversationId, 'conversationId');
100
+ const conversationType = yield* requireStringEffect(request.conversationType, 'conversationType');
101
+ const limit = yield* optionalPositiveNumberEffect(request.limit, 'limit');
102
+ const offset = yield* optionalNonNegativeNumberEffect(request.offset, 'offset');
103
+ const params = buildEndpointParams({
104
+ conversationType: { wireName: 'conversation_type', value: conversationType },
105
+ limit: { wireName: 'limit', value: limit },
106
+ offset: { wireName: 'offset', value: offset },
107
+ });
108
+ return yield* requestGetEffect(client, `${basePath}/conversation/${conversationId}`, params);
109
+ });
110
+ };
87
111
  /**
88
- * Get a specific message
89
- * @deprecated Use getConversation() instead
112
+ * Sends a message to another eBay user.
113
+ *
114
+ * @param messageData - Generated SendMessageRequest body.
115
+ * @returns An Effect that succeeds with eBay's generated SendMessageResponse.
116
+ *
117
+ * @example
118
+ * ```ts
119
+ * const sent = await Effect.runPromise(
120
+ * messageApi.sendMessage({ messageText: 'Hello', otherPartyUsername: 'buyer_123' }),
121
+ * );
122
+ * ```
123
+ *
124
+ * @see https://developer.ebay.com/api-docs/commerce/message/resources/send_message/methods/sendMessage
90
125
  */
91
- async getMessage(messageId) {
92
- return await this.getConversation(messageId);
93
- }
126
+ sendMessage = (messageData) => {
127
+ const client = this.client;
128
+ const path = `${this.basePath}/send_message`;
129
+ return Effect.gen(function* () {
130
+ const body = yield* requireObjectEffect(messageData, 'messageData');
131
+ return yield* requestPostEffect(client, path, body);
132
+ });
133
+ };
94
134
  /**
95
- * Reply to a message
96
- * @deprecated Use sendMessage() instead
135
+ * Updates a conversation status.
136
+ *
137
+ * @param updateData - Generated UpdateConversationRequest body.
138
+ * @returns An Effect that succeeds when eBay accepts the update.
139
+ *
140
+ * @example
141
+ * ```ts
142
+ * await Effect.runPromise(
143
+ * messageApi.updateConversation({ conversationId: 'c1', conversationStatus: 'READ' }),
144
+ * );
145
+ * ```
146
+ *
147
+ * @see https://developer.ebay.com/api-docs/commerce/message/resources/update_conversation/methods/updateConversation
97
148
  */
98
- async replyToMessage(messageId, messageContent) {
99
- return await this.sendMessage({
100
- conversation_id: messageId,
101
- message_content: messageContent,
149
+ updateConversation = (updateData) => {
150
+ const client = this.client;
151
+ const path = `${this.basePath}/update_conversation`;
152
+ return Effect.gen(function* () {
153
+ const body = yield* requireObjectEffect(updateData, 'updateData');
154
+ return yield* requestPostEffect(client, path, body);
102
155
  });
103
- }
156
+ };
104
157
  }
@@ -1,67 +1,79 @@
1
- import { assertRequiredString, buildPaginatedQueryParams, getPathWithContextError, getWithContextError, } from './shared.js';
2
- import { buildTruthyPaginatedParams } from '../shared/query-params.js';
3
- import { withApiError } from '../../api/shared/request.js';
1
+ import { buildEndpointParams, optionalNonNegativeNumberEffect, optionalPositiveNumberEffect, optionalStringEffect, requestGetEffect, requestPostEffect, requireObjectEffect, } from '../../api/shared/request.js';
2
+ import { Effect } from 'effect';
4
3
  /**
5
4
  * Negotiation API - Buyer-seller negotiations and offers
6
5
  * Based on: docs/sell-apps/communication/sell_negotiation_v1_oas3.json
7
6
  */
8
7
  export class NegotiationApi {
9
- client;
10
8
  basePath = '/sell/negotiation/v1';
9
+ client;
11
10
  constructor(client) {
12
11
  this.client = client;
13
12
  }
14
13
  /**
15
- * Find eligible items for a seller-initiated offer
16
- * Endpoint: GET /find_eligible_items
17
- * @param filter API filter expression.
18
- * @param limit Maximum number of records to return.
19
- * @param offset Zero-based pagination offset.
20
- * @throws Error if the request fails
14
+ * Finds listings eligible for a seller-initiated offer.
15
+ *
16
+ * @param input - Optional marketplace header override plus pagination query parameters.
17
+ * @returns An Effect that succeeds with eBay's generated PagedEligibleItemCollection.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * const eligible = await Effect.runPromise(
22
+ * negotiationApi.findEligibleItems({ marketplaceId: 'EBAY_US', limit: 10 }),
23
+ * );
24
+ * ```
25
+ *
26
+ * @see https://developer.ebay.com/api-docs/sell/negotiation/resources/offer/methods/findEligibleItems
21
27
  */
22
- async findEligibleItems(filter, limit, offset) {
23
- const eligibleItemsPath = `${this.basePath}/find_eligible_items`;
24
- const queryParams = buildPaginatedQueryParams(filter, limit, offset);
25
- return await withApiError('Failed to find eligible items', () => this.client.get(eligibleItemsPath, queryParams));
26
- }
28
+ findEligibleItems = (input = {}) => {
29
+ const apiClient = this.client;
30
+ const path = `${this.basePath}/find_eligible_items`;
31
+ return Effect.gen(function* () {
32
+ const request = yield* requireObjectEffect(input, 'input');
33
+ const { marketplaceId: inputMarketplaceId, limit: inputLimit, offset: inputOffset } = request;
34
+ const marketplaceId = yield* optionalStringEffect(inputMarketplaceId, 'marketplaceId');
35
+ const limit = yield* optionalPositiveNumberEffect(inputLimit, 'limit');
36
+ const offset = yield* optionalNonNegativeNumberEffect(inputOffset, 'offset');
37
+ const params = buildEndpointParams({
38
+ limit: { wireName: 'limit', value: limit },
39
+ offset: { wireName: 'offset', value: offset },
40
+ });
41
+ const config = marketplaceId === undefined
42
+ ? undefined
43
+ : { headers: { 'X-EBAY-C-MARKETPLACE-ID': marketplaceId } };
44
+ return yield* requestGetEffect(apiClient, path, params, config);
45
+ });
46
+ };
27
47
  /**
28
- * Send offer to interested buyers
29
- * Endpoint: POST /send_offer_to_interested_buyers
30
- * @throws Error if required parameters are missing or invalid
48
+ * Sends an offer to buyers interested in a listing.
49
+ *
50
+ * @param input - Offer body fields plus optional marketplace header override.
51
+ * @returns An Effect that succeeds with eBay's generated offer collection response.
52
+ *
53
+ * @example
54
+ * ```ts
55
+ * const offers = await Effect.runPromise(
56
+ * negotiationApi.sendOfferToInterestedBuyers({
57
+ * marketplaceId: 'EBAY_US',
58
+ * message: 'Limited offer',
59
+ * }),
60
+ * );
61
+ * ```
62
+ *
63
+ * @see https://developer.ebay.com/api-docs/sell/negotiation/resources/offer/methods/sendOfferToInterestedBuyers
31
64
  */
32
- async sendOfferToInterestedBuyers(offerData) {
33
- if (!offerData || typeof offerData !== 'object') {
34
- throw new Error('offerData is required and must be an object');
35
- }
36
- return await withApiError('Failed to send offer to interested buyers', () => this.client.post(`${this.basePath}/send_offer_to_interested_buyers`, offerData));
37
- }
38
- /**
39
- * Get offers to buyers (Best Offers)
40
- * @param filter API filter expression.
41
- * @param limit Maximum number of records to return.
42
- * @param offset Zero-based pagination offset.
43
- * @deprecated This method does not match any endpoint in the OpenAPI spec
44
- */
45
- async getOffersToBuyers(filter, limit, offset) {
46
- const params = buildTruthyPaginatedParams(filter, limit, offset);
47
- return await getWithContextError(this.client, `${this.basePath}/offer`, params, 'Failed to get offers to buyers');
48
- }
49
- /**
50
- * Get offers for listing (alias for getOffersToBuyers)
51
- * Endpoint: GET /offer
52
- * @throws Error if the request fails
53
- */
54
- async getOffersForListing(filter, limit, offset) {
55
- return await this.getOffersToBuyers(filter, limit, offset);
56
- }
57
- /**
58
- * Get a specific offer
59
- * Endpoint: GET /offer/{offerId}
60
- * @param offerId Offer identifier.
61
- * @throws Error if required parameters are missing or invalid
62
- */
63
- async getOffer(offerId) {
64
- assertRequiredString(offerId, 'offerId');
65
- return await getPathWithContextError(this.client, `${this.basePath}/offer/${offerId}`, 'Failed to get offer');
66
- }
65
+ sendOfferToInterestedBuyers = (input) => {
66
+ const apiClient = this.client;
67
+ const path = `${this.basePath}/send_offer_to_interested_buyers`;
68
+ return Effect.gen(function* () {
69
+ const request = yield* requireObjectEffect(input, 'input');
70
+ const { marketplaceId, ...offerData } = request;
71
+ const body = yield* requireObjectEffect(offerData, 'offerData');
72
+ const validatedMarketplaceId = yield* optionalStringEffect(marketplaceId, 'marketplaceId');
73
+ const config = validatedMarketplaceId === undefined
74
+ ? undefined
75
+ : { headers: { 'X-EBAY-C-MARKETPLACE-ID': validatedMarketplaceId } };
76
+ return yield* requestPostEffect(apiClient, path, body, config);
77
+ });
78
+ };
67
79
  }