@allratestoday/sdk 1.0.0 → 1.1.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.
- package/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +8 -3
- package/dist/index.mjs +8 -3
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -38,10 +38,14 @@ declare class AllRatesToday {
|
|
|
38
38
|
private apiKey?;
|
|
39
39
|
private baseUrl;
|
|
40
40
|
private timeout;
|
|
41
|
+
/**
|
|
42
|
+
* Create an AllRatesToday client.
|
|
43
|
+
* @param options - API key is required. Register for free at https://allratestoday.com/register
|
|
44
|
+
*/
|
|
41
45
|
constructor(options?: AllRatesTodayOptions);
|
|
42
46
|
private request;
|
|
43
47
|
/**
|
|
44
|
-
* Get exchange rate between two currencies (
|
|
48
|
+
* Get exchange rate between two currencies (requires API key)
|
|
45
49
|
*/
|
|
46
50
|
getRate(from: string, to: string, amount?: number): Promise<RateResponse>;
|
|
47
51
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -38,10 +38,14 @@ declare class AllRatesToday {
|
|
|
38
38
|
private apiKey?;
|
|
39
39
|
private baseUrl;
|
|
40
40
|
private timeout;
|
|
41
|
+
/**
|
|
42
|
+
* Create an AllRatesToday client.
|
|
43
|
+
* @param options - API key is required. Register for free at https://allratestoday.com/register
|
|
44
|
+
*/
|
|
41
45
|
constructor(options?: AllRatesTodayOptions);
|
|
42
46
|
private request;
|
|
43
47
|
/**
|
|
44
|
-
* Get exchange rate between two currencies (
|
|
48
|
+
* Get exchange rate between two currencies (requires API key)
|
|
45
49
|
*/
|
|
46
50
|
getRate(from: string, to: string, amount?: number): Promise<RateResponse>;
|
|
47
51
|
/**
|
package/dist/index.js
CHANGED
|
@@ -27,6 +27,10 @@ __export(index_exports, {
|
|
|
27
27
|
module.exports = __toCommonJS(index_exports);
|
|
28
28
|
var BASE_URL = "https://allratestoday.com";
|
|
29
29
|
var AllRatesToday = class {
|
|
30
|
+
/**
|
|
31
|
+
* Create an AllRatesToday client.
|
|
32
|
+
* @param options - API key is required. Register for free at https://allratestoday.com/register
|
|
33
|
+
*/
|
|
30
34
|
constructor(options = {}) {
|
|
31
35
|
this.apiKey = options.apiKey;
|
|
32
36
|
this.baseUrl = options.baseUrl || BASE_URL;
|
|
@@ -55,12 +59,13 @@ var AllRatesToday = class {
|
|
|
55
59
|
return response.json();
|
|
56
60
|
}
|
|
57
61
|
/**
|
|
58
|
-
* Get exchange rate between two currencies (
|
|
62
|
+
* Get exchange rate between two currencies (requires API key)
|
|
59
63
|
*/
|
|
60
64
|
async getRate(from, to, amount) {
|
|
61
|
-
|
|
65
|
+
if (!this.apiKey) throw new AllRatesTodayError("API key required. Register for free at https://allratestoday.com/register");
|
|
66
|
+
const params = { source: from, target: to };
|
|
62
67
|
if (amount !== void 0) params.amount = String(amount);
|
|
63
|
-
return this.request("/api/
|
|
68
|
+
return this.request("/api/v1/rates", params);
|
|
64
69
|
}
|
|
65
70
|
/**
|
|
66
71
|
* Get authenticated exchange rate (requires API key)
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
var BASE_URL = "https://allratestoday.com";
|
|
3
3
|
var AllRatesToday = class {
|
|
4
|
+
/**
|
|
5
|
+
* Create an AllRatesToday client.
|
|
6
|
+
* @param options - API key is required. Register for free at https://allratestoday.com/register
|
|
7
|
+
*/
|
|
4
8
|
constructor(options = {}) {
|
|
5
9
|
this.apiKey = options.apiKey;
|
|
6
10
|
this.baseUrl = options.baseUrl || BASE_URL;
|
|
@@ -29,12 +33,13 @@ var AllRatesToday = class {
|
|
|
29
33
|
return response.json();
|
|
30
34
|
}
|
|
31
35
|
/**
|
|
32
|
-
* Get exchange rate between two currencies (
|
|
36
|
+
* Get exchange rate between two currencies (requires API key)
|
|
33
37
|
*/
|
|
34
38
|
async getRate(from, to, amount) {
|
|
35
|
-
|
|
39
|
+
if (!this.apiKey) throw new AllRatesTodayError("API key required. Register for free at https://allratestoday.com/register");
|
|
40
|
+
const params = { source: from, target: to };
|
|
36
41
|
if (amount !== void 0) params.amount = String(amount);
|
|
37
|
-
return this.request("/api/
|
|
42
|
+
return this.request("/api/v1/rates", params);
|
|
38
43
|
}
|
|
39
44
|
/**
|
|
40
45
|
* Get authenticated exchange rate (requires API key)
|