swapped-commerce-sdk 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -166,12 +166,12 @@ async function request(config, method, path, options) {
166
166
 
167
167
  // src/resources/orders.ts
168
168
  async function listOrders(httpConfig, params) {
169
- return request(httpConfig.config, "GET", "/v1/merchants/orders", {
169
+ return request(httpConfig.config, "GET", "/v1/orders", {
170
170
  params
171
171
  });
172
172
  }
173
173
  async function getOrder(httpConfig, orderId) {
174
- return request(httpConfig.config, "GET", `/v1/merchants/orders/${encodeURIComponent(orderId)}`);
174
+ return request(httpConfig.config, "GET", `/v1/orders/${encodeURIComponent(orderId)}`);
175
175
  }
176
176
  async function refundOrder(httpConfig, orderId, params) {
177
177
  return request(httpConfig.config, "POST", `/v1/merchants/orders/${encodeURIComponent(orderId)}/refund`, {
@@ -188,7 +188,7 @@ async function createPaymentLink(httpConfig, params) {
188
188
 
189
189
  // src/resources/paymentRoutes.ts
190
190
  async function createPaymentRoute(httpConfig, params) {
191
- return request(httpConfig.config, "POST", "/v1/merchants/payment-routes", {
191
+ return request(httpConfig.config, "POST", "/v1/payment-routes", {
192
192
  body: params
193
193
  });
194
194
  }
@@ -200,42 +200,47 @@ async function getPayment(httpConfig, paymentId) {
200
200
 
201
201
  // src/resources/balances.ts
202
202
  async function listBalances(httpConfig, params) {
203
- return request(httpConfig.config, "GET", "/v1/merchants/balances", {
203
+ return request(httpConfig.config, "GET", "/v1/balances", {
204
204
  params
205
205
  });
206
206
  }
207
207
  async function getBalance(httpConfig, currencyId) {
208
- return request(httpConfig.config, "GET", `/v1/merchants/balances/${encodeURIComponent(currencyId)}`);
208
+ return request(httpConfig.config, "GET", `/v1/balances/${encodeURIComponent(currencyId)}`);
209
209
  }
210
210
 
211
211
  // src/resources/quotes.ts
212
212
  async function getQuote(httpConfig, params) {
213
- return request(httpConfig.config, "POST", "/v1/merchants/quotes", {
214
- body: params
213
+ return request(httpConfig.config, "GET", "/v1/quotes", {
214
+ params: {
215
+ fromAmount: String(params.fromAmount),
216
+ fromFiatCurrency: params.fromFiatCurrency,
217
+ toCurrency: params.toCurrency,
218
+ toBlockchain: params.toBlockchain
219
+ }
215
220
  });
216
221
  }
217
222
 
218
223
  // src/resources/payouts.ts
219
224
  async function createPayout(httpConfig, params) {
220
- return request(httpConfig.config, "POST", "/v1/merchants/payouts", {
225
+ return request(httpConfig.config, "POST", "/v1/payouts", {
221
226
  body: params
222
227
  });
223
228
  }
224
229
  async function listPayouts(httpConfig, params) {
225
- return request(httpConfig.config, "GET", "/v1/merchants/payouts", {
230
+ return request(httpConfig.config, "GET", "/v1/payouts", {
226
231
  params
227
232
  });
228
233
  }
229
234
  async function getPayout(httpConfig, payoutId) {
230
- return request(httpConfig.config, "GET", `/v1/merchants/payouts/${encodeURIComponent(payoutId)}`);
235
+ return request(httpConfig.config, "GET", `/v1/payouts/${encodeURIComponent(payoutId)}`);
231
236
  }
232
237
 
233
238
  // src/resources/kyc.ts
234
239
  async function getKYCStatus(httpConfig, customerId) {
235
- return request(httpConfig.config, "GET", `/v1/merchants/kyc/${encodeURIComponent(customerId)}`);
240
+ return request(httpConfig.config, "GET", `/v1/kyc/${encodeURIComponent(customerId)}`);
236
241
  }
237
242
  async function submitKYC(httpConfig, params) {
238
- return request(httpConfig.config, "POST", "/v1/merchants/kyc", {
243
+ return request(httpConfig.config, "POST", "/v1/kyc", {
239
244
  body: params
240
245
  });
241
246
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swapped-commerce-sdk",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "TypeScript SDK for Swapped Commerce Integration API - Functional, performant, and fully typed",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -17,7 +17,7 @@ export async function listBalances(
17
17
  return request<BalancesResponse>(
18
18
  httpConfig.config,
19
19
  'GET',
20
- '/v1/merchants/balances',
20
+ '/v1/balances',
21
21
  {
22
22
  params,
23
23
  }
@@ -34,6 +34,6 @@ export async function getBalance(
34
34
  return request<Balance>(
35
35
  httpConfig.config,
36
36
  'GET',
37
- `/v1/merchants/balances/${encodeURIComponent(currencyId)}`
37
+ `/v1/balances/${encodeURIComponent(currencyId)}`
38
38
  )
39
39
  }
@@ -17,7 +17,7 @@ export async function getKYCStatus(
17
17
  return request<KYCStatusResponse>(
18
18
  httpConfig.config,
19
19
  'GET',
20
- `/v1/merchants/kyc/${encodeURIComponent(customerId)}`
20
+ `/v1/kyc/${encodeURIComponent(customerId)}`
21
21
  )
22
22
  }
23
23
 
@@ -31,7 +31,7 @@ export async function submitKYC(
31
31
  return request<SubmitKYCResponse>(
32
32
  httpConfig.config,
33
33
  'POST',
34
- '/v1/merchants/kyc',
34
+ '/v1/kyc',
35
35
  {
36
36
  body: params,
37
37
  }
@@ -16,7 +16,7 @@ export async function listOrders(
16
16
  httpConfig: HttpConfig,
17
17
  params?: Readonly<ListOrdersParams>
18
18
  ): Promise<ApiResponse<OrdersResponse>> {
19
- return request<OrdersResponse>(httpConfig.config, 'GET', '/v1/merchants/orders', {
19
+ return request<OrdersResponse>(httpConfig.config, 'GET', '/v1/orders', {
20
20
  params,
21
21
  })
22
22
  }
@@ -31,7 +31,7 @@ export async function getOrder(
31
31
  return request<Order>(
32
32
  httpConfig.config,
33
33
  'GET',
34
- `/v1/merchants/orders/${encodeURIComponent(orderId)}`
34
+ `/v1/orders/${encodeURIComponent(orderId)}`
35
35
  )
36
36
  }
37
37
 
@@ -16,7 +16,7 @@ export async function createPaymentRoute(
16
16
  return request<PaymentRouteResponse>(
17
17
  httpConfig.config,
18
18
  'POST',
19
- '/v1/merchants/payment-routes',
19
+ '/v1/payment-routes',
20
20
  {
21
21
  body: params,
22
22
  }
@@ -19,7 +19,7 @@ export async function createPayout(
19
19
  return request<CreatePayoutResponse>(
20
20
  httpConfig.config,
21
21
  'POST',
22
- '/v1/merchants/payouts',
22
+ '/v1/payouts',
23
23
  {
24
24
  body: params,
25
25
  }
@@ -36,7 +36,7 @@ export async function listPayouts(
36
36
  return request<PayoutsResponse>(
37
37
  httpConfig.config,
38
38
  'GET',
39
- '/v1/merchants/payouts',
39
+ '/v1/payouts',
40
40
  {
41
41
  params,
42
42
  }
@@ -53,6 +53,6 @@ export async function getPayout(
53
53
  return request<Payout>(
54
54
  httpConfig.config,
55
55
  'GET',
56
- `/v1/merchants/payouts/${encodeURIComponent(payoutId)}`
56
+ `/v1/payouts/${encodeURIComponent(payoutId)}`
57
57
  )
58
58
  }
@@ -8,17 +8,29 @@ import { request } from '../utils/http'
8
8
 
9
9
  /**
10
10
  * Get a quote for currency conversion
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * const response = await client.quotes.get({
15
+ * fromAmount: 25,
16
+ * fromFiatCurrency: 'EUR',
17
+ * toCurrency: 'TRX',
18
+ * toBlockchain: 'tron',
19
+ * })
20
+ *
21
+ * console.log(response.data.toAmount.afterFees) // "103.802"
22
+ * ```
11
23
  */
12
24
  export async function getQuote(
13
25
  httpConfig: HttpConfig,
14
26
  params: Readonly<GetQuoteParams>
15
27
  ): Promise<ApiResponse<QuoteResponse>> {
16
- return request<QuoteResponse>(
17
- httpConfig.config,
18
- 'POST',
19
- '/v1/merchants/quotes',
20
- {
21
- body: params,
22
- }
23
- )
28
+ return request<QuoteResponse>(httpConfig.config, 'GET', '/v1/quotes', {
29
+ params: {
30
+ fromAmount: String(params.fromAmount),
31
+ fromFiatCurrency: params.fromFiatCurrency,
32
+ toCurrency: params.toCurrency,
33
+ toBlockchain: params.toBlockchain,
34
+ },
35
+ })
24
36
  }
@@ -22,7 +22,10 @@ export type {
22
22
 
23
23
  // Quote types
24
24
  export type {
25
+ QuoteCurrency,
25
26
  MoneyAmount,
27
+ QuoteFromAmount,
28
+ QuoteToAmount,
26
29
  Fee,
27
30
  Quote,
28
31
  GetQuoteParams,
@@ -1,13 +1,40 @@
1
- import type { Currency } from './currencies'
1
+ import type { Blockchain, Currency } from './currencies'
2
2
 
3
3
  /**
4
- * Money amount with currency
4
+ * Simplified currency info returned in quote responses
5
+ */
6
+ export interface QuoteCurrency {
7
+ readonly symbol: string
8
+ readonly precision: number
9
+ readonly type: 'FIAT' | 'CRYPTO'
10
+ readonly blockchain: { readonly name: string } | null
11
+ }
12
+
13
+ /**
14
+ * Money amount with currency (used in orders and other contexts)
5
15
  */
6
16
  export interface MoneyAmount {
7
17
  readonly amount: string
8
18
  readonly currency: Currency
9
19
  }
10
20
 
21
+ /**
22
+ * Quote from amount with currency
23
+ */
24
+ export interface QuoteFromAmount {
25
+ readonly amount: string
26
+ readonly currency: QuoteCurrency
27
+ }
28
+
29
+ /**
30
+ * Quote to amount with before/after fees
31
+ */
32
+ export interface QuoteToAmount {
33
+ readonly beforeFees: string
34
+ readonly afterFees: string
35
+ readonly currency: QuoteCurrency
36
+ }
37
+
11
38
  /**
12
39
  * Fee information
13
40
  */
@@ -21,7 +48,7 @@ export interface Fee {
21
48
  }
22
49
 
23
50
  /**
24
- * Exchange quote
51
+ * Exchange quote (used in orders)
25
52
  */
26
53
  export interface Quote {
27
54
  readonly fromAmount: MoneyAmount
@@ -34,16 +61,21 @@ export interface Quote {
34
61
  * Parameters for getting a quote
35
62
  */
36
63
  export interface GetQuoteParams {
37
- readonly fromCurrency: string
64
+ /** Amount to convert from */
65
+ readonly fromAmount: string | number
66
+ /** Source fiat currency symbol (e.g., 'EUR', 'USD') */
67
+ readonly fromFiatCurrency: string
68
+ /** Target currency symbol (e.g., 'TRX', 'USDT') */
38
69
  readonly toCurrency: string
39
- readonly amount: string
40
- readonly amountType: 'FROM' | 'TO'
70
+ /** Target blockchain name (e.g., 'tron', 'ethereum') */
71
+ readonly toBlockchain: string
41
72
  }
42
73
 
43
74
  /**
44
75
  * Response for getting a quote
45
76
  */
46
77
  export interface QuoteResponse {
47
- readonly quote: Quote
48
- readonly expiresAt: string
78
+ readonly exchangeRateSnapshotId: string
79
+ readonly fromAmount: QuoteFromAmount
80
+ readonly toAmount: QuoteToAmount
49
81
  }