swapped-commerce-sdk 1.0.2 → 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
@@ -210,8 +210,13 @@ async function getBalance(httpConfig, currencyId) {
210
210
 
211
211
  // src/resources/quotes.ts
212
212
  async function getQuote(httpConfig, params) {
213
- return request(httpConfig.config, "POST", "/v1/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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swapped-commerce-sdk",
3
- "version": "1.0.2",
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",
@@ -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/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
  }