Skip to content

Commit a17fa52

Browse files
authored
New Component - fixer_io (#17178)
* new action convert-currency * pnpm-lock.yaml * pnpm-lock.yaml * pnpm-lock.yaml
1 parent 25275d3 commit a17fa52

File tree

4 files changed

+84
-5
lines changed

4 files changed

+84
-5
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import fixerIo from "../../fixer_io.app.mjs";
2+
import { ConfigurationError } from "@pipedream/platform";
3+
4+
export default {
5+
key: "fixer_io-convert-currency",
6+
name: "Convert Currency",
7+
description: "Convert amount from one currency to another using real-time exchange rates. [See the documentation](https://fixer.io/documentation)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
fixerIo,
12+
from: {
13+
type: "string",
14+
label: "From Currency",
15+
description: "The three-letter currency code of the currency you would like to convert from",
16+
},
17+
to: {
18+
type: "string",
19+
label: "To Currency",
20+
description: "The three-letter currency code of the currency you would like to convert to",
21+
},
22+
amount: {
23+
type: "string",
24+
label: "Amount",
25+
description: "The amount to be converted",
26+
},
27+
date: {
28+
type: "string",
29+
label: "Date",
30+
description: "Specify a date (format YYYY-MM-DD) to use historical rates for this conversion",
31+
optional: true,
32+
},
33+
},
34+
async run({ $ }) {
35+
const response = await this.fixerIo.convertCurrency({
36+
$,
37+
params: {
38+
from: this.from,
39+
to: this.to,
40+
amount: this.amount,
41+
date: this.date,
42+
},
43+
});
44+
if (response.error) {
45+
throw new ConfigurationError(response.error.info);
46+
}
47+
$.export("$summary", `Successfully converted ${this.amount} ${this.from} to ${this.to}`);
48+
return response;
49+
},
50+
};
Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,33 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "fixer_io",
46
propDefinitions: {},
57
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
8+
_baseUrl() {
9+
return "https://data.fixer.io/api";
10+
},
11+
_makeRequest({
12+
$ = this, path, params, ...opts
13+
}) {
14+
return axios($, {
15+
url: `${this._baseUrl()}${path}`,
16+
headers: {
17+
Accept: "application/json",
18+
},
19+
params: {
20+
...params,
21+
access_key: `${this.$auth.api_key}`,
22+
},
23+
...opts,
24+
});
25+
},
26+
convertCurrency(opts = {}) {
27+
return this._makeRequest({
28+
path: "/convert",
29+
...opts,
30+
});
931
},
1032
},
1133
};

components/fixer_io/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/fixer_io",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Fixer Components",
55
"main": "fixer_io.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.1.0"
1417
}
1518
}

pnpm-lock.yaml

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)