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,8 +1,6 @@
1
- import { withApiError } from '../../api/shared/request.js';
2
- /**
3
- * Recommendation API - Listing recommendations
4
- * Based on: docs/sell-apps/marketing-and-promotions/sell_recommendation_v1_oas3.json
5
- */
1
+ import { buildEndpointParams, optionalNonNegativeNumberEffect, optionalPositiveNumberEffect, optionalStringEffect, requestPostEffect, requireObjectEffect, requireStringEffect, } from '../../api/shared/request.js';
2
+ import { Effect } from 'effect';
3
+ /** Recommendation API - Promoted Listings recommendation discovery. */
6
4
  export class RecommendationApi {
7
5
  client;
8
6
  basePath = '/sell/recommendation/v1';
@@ -10,24 +8,51 @@ export class RecommendationApi {
10
8
  this.client = client;
11
9
  }
12
10
  /**
13
- * Find listing recommendations
14
- * Endpoint: POST /find
11
+ * Finds listing recommendations for active listings in one marketplace.
12
+ *
13
+ * @param input - Request body, recommendation filter, pagination, and marketplace header.
14
+ * @returns An Effect that succeeds with eBay's PagedListingRecommendationCollection.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * const recommendations = await Effect.runPromise(
19
+ * recommendationApi.findListingRecommendations({
20
+ * marketplaceId: 'EBAY_US',
21
+ * requestBody: { listingIds: ['110000000000'] },
22
+ * limit: 10,
23
+ * }),
24
+ * );
25
+ * ```
26
+ *
27
+ * @see https://developer.ebay.com/api-docs/sell/recommendation/resources/find/methods/findListingRecommendations
15
28
  */
16
- async findListingRecommendations(requestBody, filter, limit, offset, marketplaceId) {
17
- const params = {};
18
- if (filter)
19
- params.filter = filter;
20
- if (limit)
21
- params.limit = limit;
22
- if (offset)
23
- params.offset = offset;
24
- const headers = {};
25
- if (marketplaceId) {
26
- headers['X-EBAY-C-MARKETPLACE-ID'] = marketplaceId;
27
- }
28
- return await withApiError('Failed to find listing recommendations', () => this.client.post(`${this.basePath}/find`, requestBody || {}, {
29
- params,
30
- headers,
31
- }));
32
- }
29
+ findListingRecommendations = (input) => {
30
+ const client = this.client;
31
+ const path = `${this.basePath}/find`;
32
+ return Effect.gen(function* () {
33
+ const validatedInput = yield* requireObjectEffect(input, 'input');
34
+ const marketplaceId = yield* requireStringEffect(validatedInput.marketplaceId, 'marketplaceId');
35
+ const filter = yield* optionalStringEffect(validatedInput.filter, 'filter');
36
+ const limit = yield* optionalPositiveNumberEffect(validatedInput.limit, 'limit');
37
+ const offset = yield* optionalNonNegativeNumberEffect(validatedInput.offset, 'offset');
38
+ let requestBody = {};
39
+ if (validatedInput.requestBody !== undefined) {
40
+ requestBody = yield* requireObjectEffect(validatedInput.requestBody, 'requestBody');
41
+ }
42
+ const params = buildEndpointParams({
43
+ filter: { wireName: 'filter', value: filter },
44
+ limit: { wireName: 'limit', value: limit === undefined ? undefined : String(limit) },
45
+ offset: { wireName: 'offset', value: offset === undefined ? undefined : String(offset) },
46
+ });
47
+ const config = {
48
+ headers: {
49
+ 'X-EBAY-C-MARKETPLACE-ID': marketplaceId,
50
+ },
51
+ };
52
+ if (params !== undefined) {
53
+ config.params = params;
54
+ }
55
+ return yield* requestPostEffect(client, path, requestBody, config);
56
+ });
57
+ };
33
58
  }
@@ -1,8 +1,16 @@
1
- import { withApiError } from '../../api/shared/request.js';
2
- /**
3
- * Dispute API - Manage payment disputes
4
- * Based on: docs/sell-apps/order-management/sell_fulfillment_v1_oas3.json
5
- */
1
+ import { buildEndpointParams, EndpointInputError, optionalNonNegativeNumberEffect, optionalPositiveNumberEffect, optionalStringEffect, requestGetEffect, requestPostEffect, requireObjectEffect, requireStringEffect, } from '../../api/shared/request.js';
2
+ import { isRecord } from '../../utils/typeGuards.js';
3
+ import { Effect } from 'effect';
4
+ const requireUploadEvidenceFileBodyEffect = (value) => {
5
+ if (value instanceof ArrayBuffer || value instanceof Uint8Array || isRecord(value)) {
6
+ return Effect.succeed(value);
7
+ }
8
+ return Effect.fail(new EndpointInputError({
9
+ parameter: 'body',
10
+ message: 'body is required and must be binary data or a multipart-compatible object',
11
+ }));
12
+ };
13
+ /** eBay Fulfillment payment dispute endpoints. */
6
14
  export class DisputeApi {
7
15
  client;
8
16
  basePath = '/sell/fulfillment/v1';
@@ -10,61 +18,234 @@ export class DisputeApi {
10
18
  this.client = client;
11
19
  }
12
20
  /**
13
- * Get payment dispute details
21
+ * Retrieves one payment dispute.
22
+ *
23
+ * @param input - Payment dispute identifier to retrieve.
24
+ * @returns An Effect that succeeds with eBay's generated PaymentDispute response.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * const dispute = await Effect.runPromise(
29
+ * disputeApi.getPaymentDispute({ paymentDisputeId: '5001234567' }),
30
+ * );
31
+ * ```
32
+ *
33
+ * @see https://developer.ebay.com/api-docs/sell/fulfillment/resources/payment_dispute/methods/getPaymentDispute
14
34
  */
15
- async getPaymentDispute(paymentDisputeId) {
16
- return await withApiError('Failed to get payment dispute', () => this.client.get(`${this.basePath}/payment_dispute/${paymentDisputeId}`));
17
- }
35
+ getPaymentDispute = (input) => Effect.gen(this, function* () {
36
+ const paymentDisputeId = yield* requireStringEffect(input.paymentDisputeId, 'paymentDisputeId');
37
+ const path = `${this.basePath}/payment_dispute/${paymentDisputeId}`;
38
+ return yield* requestGetEffect(this.client, path);
39
+ });
18
40
  /**
19
- * Get payment dispute evidence file
41
+ * Downloads one evidence file attached to a payment dispute.
42
+ *
43
+ * @param input - Payment dispute, evidence set, and evidence file identifiers.
44
+ * @returns An Effect that succeeds with the downloaded binary evidence content.
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * const content = await Effect.runPromise(
49
+ * disputeApi.fetchEvidenceContent({
50
+ * paymentDisputeId: '5001234567',
51
+ * evidenceId: 'EVIDENCE-1',
52
+ * fileId: 'FILE-1',
53
+ * }),
54
+ * );
55
+ * ```
56
+ *
57
+ * @see https://developer.ebay.com/api-docs/sell/fulfillment/resources/payment_dispute/methods/fetchEvidenceContent
20
58
  */
21
- async fetchEvidenceContent(paymentDisputeId, evidenceId, fileId) {
22
- const params = {
23
- evidence_id: evidenceId,
24
- file_id: fileId,
25
- };
26
- return await withApiError('Failed to fetch evidence content', () => this.client.get(`${this.basePath}/payment_dispute/${paymentDisputeId}/fetch_evidence_content`, params));
27
- }
59
+ fetchEvidenceContent = (input) => Effect.gen(this, function* () {
60
+ const paymentDisputeId = yield* requireStringEffect(input.paymentDisputeId, 'paymentDisputeId');
61
+ const evidenceId = yield* requireStringEffect(input.evidenceId, 'evidenceId');
62
+ const fileId = yield* requireStringEffect(input.fileId, 'fileId');
63
+ const path = `${this.basePath}/payment_dispute/${paymentDisputeId}/fetch_evidence_content`;
64
+ const params = buildEndpointParams({
65
+ evidenceId: { wireName: 'evidence_id', value: evidenceId },
66
+ fileId: { wireName: 'file_id', value: fileId },
67
+ });
68
+ return yield* requestGetEffect(this.client, path, params, {
69
+ headers: { Accept: 'application/octet-stream' },
70
+ responseType: 'arraybuffer',
71
+ });
72
+ });
28
73
  /**
29
- * Get payment dispute activity
74
+ * Retrieves the activity history for one payment dispute.
75
+ *
76
+ * @param input - Payment dispute identifier whose activity history is requested.
77
+ * @returns An Effect that succeeds with eBay's generated PaymentDisputeActivityHistory.
78
+ *
79
+ * @example
80
+ * ```ts
81
+ * const activity = await Effect.runPromise(
82
+ * disputeApi.getActivities({ paymentDisputeId: '5001234567' }),
83
+ * );
84
+ * ```
85
+ *
86
+ * @see https://developer.ebay.com/api-docs/sell/fulfillment/resources/payment_dispute/methods/getActivities
30
87
  */
31
- async getActivities(paymentDisputeId) {
32
- return await withApiError('Failed to get activities', () => this.client.get(`${this.basePath}/payment_dispute/${paymentDisputeId}/activity`));
33
- }
88
+ getActivities = (input) => Effect.gen(this, function* () {
89
+ const paymentDisputeId = yield* requireStringEffect(input.paymentDisputeId, 'paymentDisputeId');
90
+ const path = `${this.basePath}/payment_dispute/${paymentDisputeId}/activity`;
91
+ return yield* requestGetEffect(this.client, path);
92
+ });
34
93
  /**
35
- * Search for payment disputes
94
+ * Searches payment disputes using the filters supported by eBay.
95
+ *
96
+ * @param input - Optional dispute summary filters and pagination controls.
97
+ * @returns An Effect that succeeds with eBay's generated DisputeSummaryResponse.
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * const disputes = await Effect.runPromise(
102
+ * disputeApi.getPaymentDisputeSummaries({ orderId: 'ORDER-1', limit: 25 }),
103
+ * );
104
+ * ```
105
+ *
106
+ * @see https://developer.ebay.com/api-docs/sell/fulfillment/resources/payment_dispute/methods/getPaymentDisputeSummaries
36
107
  */
37
- async getPaymentDisputeSummaries(params) {
38
- return await withApiError('Failed to get payment dispute summaries', () => this.client.get(`${this.basePath}/payment_dispute_summary`, params));
39
- }
108
+ getPaymentDisputeSummaries = (input = {}) => Effect.gen(this, function* () {
109
+ const orderId = yield* optionalStringEffect(input.orderId, 'orderId');
110
+ const buyerUsername = yield* optionalStringEffect(input.buyerUsername, 'buyerUsername');
111
+ const openDateFrom = yield* optionalStringEffect(input.openDateFrom, 'openDateFrom');
112
+ const openDateTo = yield* optionalStringEffect(input.openDateTo, 'openDateTo');
113
+ const paymentDisputeStatus = yield* optionalStringEffect(input.paymentDisputeStatus, 'paymentDisputeStatus');
114
+ const limit = yield* optionalPositiveNumberEffect(input.limit, 'limit');
115
+ const offset = yield* optionalNonNegativeNumberEffect(input.offset, 'offset');
116
+ const path = `${this.basePath}/payment_dispute_summary`;
117
+ const params = buildEndpointParams({
118
+ orderId: { wireName: 'order_id', value: orderId },
119
+ buyerUsername: { wireName: 'buyer_username', value: buyerUsername },
120
+ openDateFrom: { wireName: 'open_date_from', value: openDateFrom },
121
+ openDateTo: { wireName: 'open_date_to', value: openDateTo },
122
+ paymentDisputeStatus: {
123
+ wireName: 'payment_dispute_status',
124
+ value: paymentDisputeStatus,
125
+ },
126
+ limit: { wireName: 'limit', value: limit === undefined ? undefined : String(limit) },
127
+ offset: { wireName: 'offset', value: offset === undefined ? undefined : String(offset) },
128
+ });
129
+ return yield* requestGetEffect(this.client, path, params);
130
+ });
40
131
  /**
41
- * Contest a payment dispute
132
+ * Accepts one payment dispute.
133
+ *
134
+ * @param input - Payment dispute identifier and optional generated accept payload.
135
+ * @returns An Effect that succeeds when eBay accepts the dispute action.
136
+ *
137
+ * @example
138
+ * ```ts
139
+ * await Effect.runPromise(
140
+ * disputeApi.acceptPaymentDispute({
141
+ * paymentDisputeId: '5001234567',
142
+ * body: { revision: 3 },
143
+ * }),
144
+ * );
145
+ * ```
146
+ *
147
+ * @see https://developer.ebay.com/api-docs/sell/fulfillment/resources/payment_dispute/methods/acceptPaymentDispute
42
148
  */
43
- async contestPaymentDispute(paymentDisputeId, body) {
44
- return await withApiError('Failed to contest payment dispute', () => this.client.post(`${this.basePath}/payment_dispute/${paymentDisputeId}/contest`, body));
45
- }
149
+ acceptPaymentDispute = (input) => Effect.gen(this, function* () {
150
+ const paymentDisputeId = yield* requireStringEffect(input.paymentDisputeId, 'paymentDisputeId');
151
+ const path = `${this.basePath}/payment_dispute/${paymentDisputeId}/accept`;
152
+ return yield* requestPostEffect(this.client, path, input.body);
153
+ });
46
154
  /**
47
- * Accept a payment dispute
155
+ * Contests one payment dispute.
156
+ *
157
+ * @param input - Payment dispute identifier and optional generated contest payload.
158
+ * @returns An Effect that succeeds when eBay accepts the contest action.
159
+ *
160
+ * @example
161
+ * ```ts
162
+ * await Effect.runPromise(
163
+ * disputeApi.contestPaymentDispute({
164
+ * paymentDisputeId: '5001234567',
165
+ * body: { note: 'Proof of delivery is attached.', revision: 3 },
166
+ * }),
167
+ * );
168
+ * ```
169
+ *
170
+ * @see https://developer.ebay.com/api-docs/sell/fulfillment/resources/payment_dispute/methods/contestPaymentDispute
48
171
  */
49
- async acceptPaymentDispute(paymentDisputeId, body) {
50
- return await withApiError('Failed to accept payment dispute', () => this.client.post(`${this.basePath}/payment_dispute/${paymentDisputeId}/accept`, body));
51
- }
172
+ contestPaymentDispute = (input) => Effect.gen(this, function* () {
173
+ const paymentDisputeId = yield* requireStringEffect(input.paymentDisputeId, 'paymentDisputeId');
174
+ const path = `${this.basePath}/payment_dispute/${paymentDisputeId}/contest`;
175
+ return yield* requestPostEffect(this.client, path, input.body);
176
+ });
52
177
  /**
53
- * Upload an evidence file
178
+ * Uploads one evidence file for a payment dispute.
179
+ *
180
+ * @param input - Payment dispute identifier and multipart-compatible evidence file body.
181
+ * @returns An Effect that succeeds with eBay's generated FileEvidence response.
182
+ *
183
+ * @example
184
+ * ```ts
185
+ * const file = await Effect.runPromise(
186
+ * disputeApi.uploadEvidenceFile({
187
+ * paymentDisputeId: '5001234567',
188
+ * body: new ArrayBuffer(8),
189
+ * }),
190
+ * );
191
+ * ```
192
+ *
193
+ * @see https://developer.ebay.com/api-docs/sell/fulfillment/resources/payment_dispute/methods/uploadEvidenceFile
54
194
  */
55
- async uploadEvidenceFile(paymentDisputeId, body) {
56
- return await withApiError('Failed to upload evidence file', () => this.client.post(`${this.basePath}/payment_dispute/${paymentDisputeId}/upload_evidence_file`, body, { headers: { 'Content-Type': 'multipart/form-data' } }));
57
- }
195
+ uploadEvidenceFile = (input) => Effect.gen(this, function* () {
196
+ const paymentDisputeId = yield* requireStringEffect(input.paymentDisputeId, 'paymentDisputeId');
197
+ const body = yield* requireUploadEvidenceFileBodyEffect(input.body);
198
+ const path = `${this.basePath}/payment_dispute/${paymentDisputeId}/upload_evidence_file`;
199
+ return yield* requestPostEffect(this.client, path, body, {
200
+ headers: { 'Content-Type': 'multipart/form-data' },
201
+ });
202
+ });
58
203
  /**
59
- * Add an evidence file
204
+ * Adds evidence to one payment dispute.
205
+ *
206
+ * @param input - Payment dispute identifier and generated add-evidence payload.
207
+ * @returns An Effect that succeeds with eBay's generated AddEvidencePaymentDisputeResponse.
208
+ *
209
+ * @example
210
+ * ```ts
211
+ * const evidence = await Effect.runPromise(
212
+ * disputeApi.addEvidence({
213
+ * paymentDisputeId: '5001234567',
214
+ * body: { evidenceType: 'PROOF_OF_DELIVERY', files: [{ fileId: 'FILE-1' }] },
215
+ * }),
216
+ * );
217
+ * ```
218
+ *
219
+ * @see https://developer.ebay.com/api-docs/sell/fulfillment/resources/payment_dispute/methods/addEvidence
60
220
  */
61
- async addEvidence(paymentDisputeId, body) {
62
- return await withApiError('Failed to add evidence', () => this.client.post(`${this.basePath}/payment_dispute/${paymentDisputeId}/add_evidence`, body));
63
- }
221
+ addEvidence = (input) => Effect.gen(this, function* () {
222
+ const paymentDisputeId = yield* requireStringEffect(input.paymentDisputeId, 'paymentDisputeId');
223
+ const body = yield* requireObjectEffect(input.body, 'body');
224
+ const path = `${this.basePath}/payment_dispute/${paymentDisputeId}/add_evidence`;
225
+ return yield* requestPostEffect(this.client, path, body);
226
+ });
64
227
  /**
65
- * Update an evidence file
228
+ * Updates evidence on one payment dispute.
229
+ *
230
+ * @param input - Payment dispute identifier and generated update-evidence payload.
231
+ * @returns An Effect that succeeds when eBay accepts the evidence update.
232
+ *
233
+ * @example
234
+ * ```ts
235
+ * await Effect.runPromise(
236
+ * disputeApi.updateEvidence({
237
+ * paymentDisputeId: '5001234567',
238
+ * body: { evidenceId: 'EVIDENCE-1', files: [{ fileId: 'FILE-2' }] },
239
+ * }),
240
+ * );
241
+ * ```
242
+ *
243
+ * @see https://developer.ebay.com/api-docs/sell/fulfillment/resources/payment_dispute/methods/updateEvidence
66
244
  */
67
- async updateEvidence(paymentDisputeId, body) {
68
- return await withApiError('Failed to update evidence', () => this.client.post(`${this.basePath}/payment_dispute/${paymentDisputeId}/update_evidence`, body));
69
- }
245
+ updateEvidence = (input) => Effect.gen(this, function* () {
246
+ const paymentDisputeId = yield* requireStringEffect(input.paymentDisputeId, 'paymentDisputeId');
247
+ const body = yield* requireObjectEffect(input.body, 'body');
248
+ const path = `${this.basePath}/payment_dispute/${paymentDisputeId}/update_evidence`;
249
+ return yield* requestPostEffect(this.client, path, body);
250
+ });
70
251
  }
@@ -1,8 +1,6 @@
1
- import { withApiError } from '../../api/shared/request.js';
2
- /**
3
- * Fulfillment API - Order processing and shipping
4
- * Based on: docs/sell-apps/order-management/sell_fulfillment_v1_oas3.json
5
- */
1
+ import { buildEndpointParams, optionalNonNegativeNumberEffect, optionalPositiveNumberEffect, optionalStringEffect, requestGetEffect, requestPostEffect, requireObjectEffect, requireStringEffect, } from '../../api/shared/request.js';
2
+ import { Effect } from 'effect';
3
+ /** eBay Fulfillment order, shipping fulfillment, and refund endpoints. */
6
4
  export class FulfillmentApi {
7
5
  client;
8
6
  basePath = '/sell/fulfillment/v1';
@@ -10,81 +8,156 @@ export class FulfillmentApi {
10
8
  this.client = client;
11
9
  }
12
10
  /**
13
- * Get orders for the seller
11
+ * Retrieves seller orders.
12
+ *
13
+ * @param input - Optional order filters, field groups, and pagination controls.
14
+ * @returns An Effect that succeeds with eBay's generated OrderSearchPagedCollection.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * const orders = await Effect.runPromise(
19
+ * fulfillmentApi.getOrders({
20
+ * filter: 'orderfulfillmentstatus:{NOT_STARTED|IN_PROGRESS}',
21
+ * limit: 50,
22
+ * }),
23
+ * );
24
+ * ```
25
+ *
26
+ * @see https://developer.ebay.com/api-docs/sell/fulfillment/resources/order/methods/getOrders
14
27
  */
15
- async getOrders(filter, limit, offset) {
16
- const params = {};
17
- if (filter)
18
- params.filter = filter;
19
- if (limit)
20
- params.limit = limit;
21
- if (offset)
22
- params.offset = offset;
23
- return await withApiError('Failed to get orders', () => this.client.get(`${this.basePath}/order`, params));
24
- }
28
+ getOrders = (input = {}) => Effect.gen(this, function* () {
29
+ const fieldGroups = yield* optionalStringEffect(input.fieldGroups, 'fieldGroups');
30
+ const filter = yield* optionalStringEffect(input.filter, 'filter');
31
+ const limit = yield* optionalPositiveNumberEffect(input.limit, 'limit');
32
+ const offset = yield* optionalNonNegativeNumberEffect(input.offset, 'offset');
33
+ const orderIds = yield* optionalStringEffect(input.orderIds, 'orderIds');
34
+ const path = `${this.basePath}/order`;
35
+ const params = buildEndpointParams({
36
+ fieldGroups: { wireName: 'fieldGroups', value: fieldGroups },
37
+ filter: { wireName: 'filter', value: filter },
38
+ limit: { wireName: 'limit', value: limit === undefined ? undefined : String(limit) },
39
+ offset: { wireName: 'offset', value: offset === undefined ? undefined : String(offset) },
40
+ orderIds: { wireName: 'orderIds', value: orderIds },
41
+ });
42
+ return yield* requestGetEffect(this.client, path, params);
43
+ });
25
44
  /**
26
- * Get a specific order
45
+ * Retrieves one order.
46
+ *
47
+ * @param input - Order identifier and optional field group.
48
+ * @returns An Effect that succeeds with eBay's generated Order response.
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * const order = await Effect.runPromise(
53
+ * fulfillmentApi.getOrder({ orderId: '01-12345-67890' }),
54
+ * );
55
+ * ```
56
+ *
57
+ * @see https://developer.ebay.com/api-docs/sell/fulfillment/resources/order/methods/getOrder
27
58
  */
28
- async getOrder(orderId) {
29
- return await withApiError('Failed to get order', () => this.client.get(`${this.basePath}/order/${orderId}`));
30
- }
59
+ getOrder = (input) => Effect.gen(this, function* () {
60
+ const orderId = yield* requireStringEffect(input.orderId, 'orderId');
61
+ const fieldGroups = yield* optionalStringEffect(input.fieldGroups, 'fieldGroups');
62
+ const path = `${this.basePath}/order/${orderId}`;
63
+ const params = buildEndpointParams({
64
+ fieldGroups: { wireName: 'fieldGroups', value: fieldGroups },
65
+ });
66
+ return yield* requestGetEffect(this.client, path, params);
67
+ });
31
68
  /**
32
- * Create a shipping fulfillment
69
+ * Creates a shipping fulfillment for one order.
70
+ *
71
+ * @param input - Order identifier and generated shipping fulfillment payload.
72
+ * @returns An Effect that succeeds with eBay's generated create response object.
73
+ *
74
+ * @example
75
+ * ```ts
76
+ * await Effect.runPromise(
77
+ * fulfillmentApi.createShippingFulfillment({
78
+ * orderId: '01-12345-67890',
79
+ * body: { lineItems: [{ lineItemId: 'LINE-1', quantity: 1 }] },
80
+ * }),
81
+ * );
82
+ * ```
83
+ *
84
+ * @see https://developer.ebay.com/api-docs/sell/fulfillment/resources/order/shipping_fulfillment/methods/createShippingFulfillment
33
85
  */
34
- async createShippingFulfillment(orderId, fulfillment) {
35
- return await withApiError('Failed to create shipping fulfillment', () => this.client.post(`${this.basePath}/order/${orderId}/shipping_fulfillment`, fulfillment));
36
- }
86
+ createShippingFulfillment = (input) => Effect.gen(this, function* () {
87
+ const orderId = yield* requireStringEffect(input.orderId, 'orderId');
88
+ const body = yield* requireObjectEffect(input.body, 'body');
89
+ const path = `${this.basePath}/order/${orderId}/shipping_fulfillment`;
90
+ return yield* requestPostEffect(this.client, path, body);
91
+ });
37
92
  /**
38
- * Get shipping fulfillments for an order
93
+ * Retrieves all shipping fulfillments for one order.
94
+ *
95
+ * @param input - Order identifier whose shipping fulfillments are requested.
96
+ * @returns An Effect that succeeds with eBay's generated ShippingFulfillmentPagedCollection.
97
+ *
98
+ * @example
99
+ * ```ts
100
+ * const fulfillments = await Effect.runPromise(
101
+ * fulfillmentApi.getShippingFulfillments({ orderId: '01-12345-67890' }),
102
+ * );
103
+ * ```
104
+ *
105
+ * @see https://developer.ebay.com/api-docs/sell/fulfillment/resources/order/shipping_fulfillment/methods/getShippingFulfillments
39
106
  */
40
- async getShippingFulfillments(orderId) {
41
- return await withApiError('Failed to get shipping fulfillments', () => this.client.get(`${this.basePath}/order/${orderId}/shipping_fulfillment`));
42
- }
107
+ getShippingFulfillments = (input) => Effect.gen(this, function* () {
108
+ const orderId = yield* requireStringEffect(input.orderId, 'orderId');
109
+ const path = `${this.basePath}/order/${orderId}/shipping_fulfillment`;
110
+ return yield* requestGetEffect(this.client, path);
111
+ });
43
112
  /**
44
- * Get a specific shipping fulfillment
45
- * @param orderId The unique identifier of the order.
46
- * @param fulfillmentId The unique identifier of the fulfillment.
113
+ * Retrieves one shipping fulfillment for one order.
114
+ *
115
+ * @param input - Order identifier and shipping fulfillment identifier.
116
+ * @returns An Effect that succeeds with eBay's generated ShippingFulfillment response.
117
+ *
118
+ * @example
119
+ * ```ts
120
+ * const fulfillment = await Effect.runPromise(
121
+ * fulfillmentApi.getShippingFulfillment({
122
+ * orderId: '01-12345-67890',
123
+ * fulfillmentId: '9405509699937003457459',
124
+ * }),
125
+ * );
126
+ * ```
127
+ *
128
+ * @see https://developer.ebay.com/api-docs/sell/fulfillment/resources/order/shipping_fulfillment/methods/getShippingFulfillment
47
129
  */
48
- async getShippingFulfillment(orderId, fulfillmentId) {
49
- return await withApiError('Failed to get shipping fulfillment', () => this.client.get(`${this.basePath}/order/${orderId}/shipping_fulfillment/${fulfillmentId}`));
50
- }
51
- /**
52
- * Issue a refund
53
- */
54
- async issueRefund(orderId, refund) {
55
- return await withApiError('Failed to issue refund', () => this.client.post(`${this.basePath}/order/${orderId}/issue_refund`, refund));
56
- }
57
- /**
58
- * Get payment dispute summaries
59
- * Note: This method delegates to the DisputeApi
60
- */
61
- async getPaymentDisputeSummaries(params) {
62
- return await withApiError('Failed to get payment dispute summaries', () => this.client.get(`${this.basePath}/payment_dispute_summary`, params));
63
- }
130
+ getShippingFulfillment = (input) => Effect.gen(this, function* () {
131
+ const orderId = yield* requireStringEffect(input.orderId, 'orderId');
132
+ const fulfillmentId = yield* requireStringEffect(input.fulfillmentId, 'fulfillmentId');
133
+ const path = `${this.basePath}/order/${orderId}/shipping_fulfillment/${fulfillmentId}`;
134
+ return yield* requestGetEffect(this.client, path);
135
+ });
64
136
  /**
65
- * Get payment dispute activities
66
- * Note: This method delegates to the DisputeApi
137
+ * Issues a full or partial refund for one order.
138
+ *
139
+ * @param input - Order identifier and generated refund request payload.
140
+ * @returns An Effect that succeeds with eBay's generated Refund response.
141
+ *
142
+ * @example
143
+ * ```ts
144
+ * const refund = await Effect.runPromise(
145
+ * fulfillmentApi.issueRefund({
146
+ * orderId: '01-12345-67890',
147
+ * body: {
148
+ * reasonForRefund: 'BUYER_CANCEL',
149
+ * orderLevelRefundAmount: { value: '10.00', currency: 'USD' },
150
+ * },
151
+ * }),
152
+ * );
153
+ * ```
154
+ *
155
+ * @see https://developer.ebay.com/api-docs/sell/fulfillment/resources/order/methods/issueRefund
67
156
  */
68
- async getActivities(paymentDisputeId) {
69
- return await withApiError('Failed to get activities', () => this.client.get(`${this.basePath}/payment_dispute/${paymentDisputeId}/activity`));
70
- }
71
- /**
72
- * Get payment dispute details
73
- * Note: This method delegates to the DisputeApi
74
- */
75
- async getPaymentDispute(paymentDisputeId) {
76
- return await withApiError('Failed to get payment dispute', () => this.client.get(`${this.basePath}/payment_dispute/${paymentDisputeId}`));
77
- }
78
- /**
79
- * Get shipping quote
80
- */
81
- async getShippingQuote(request) {
82
- return await withApiError('Failed to get shipping quote', () => this.client.post(`${this.basePath}/shipping_quote`, request));
83
- }
84
- /**
85
- * Get cancellation details for an order
86
- */
87
- async getCancellation(orderId, cancellationId) {
88
- return await withApiError('Failed to get cancellation', () => this.client.get(`${this.basePath}/order/${orderId}/cancellation/${cancellationId}`));
89
- }
157
+ issueRefund = (input) => Effect.gen(this, function* () {
158
+ const orderId = yield* requireStringEffect(input.orderId, 'orderId');
159
+ const body = yield* requireObjectEffect(input.body, 'body');
160
+ const path = `${this.basePath}/order/${orderId}/issue_refund`;
161
+ return yield* requestPostEffect(this.client, path, body);
162
+ });
90
163
  }