Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions components/fixer_io/actions/convert-currency/convert-currency.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import fixerIo from "../../fixer_io.app.mjs";
import { ConfigurationError } from "@pipedream/platform";

export default {
key: "fixer_io-convert-currency",
name: "Convert Currency",
description: "Convert amount from one currency to another using real-time exchange rates. [See the documentation](https://fixer.io/documentation)",
version: "0.0.1",
type: "action",
props: {
fixerIo,
from: {
type: "string",
label: "From Currency",
description: "The three-letter currency code of the currency you would like to convert from",
},
to: {
type: "string",
label: "To Currency",
description: "The three-letter currency code of the currency you would like to convert to",
},
amount: {
type: "string",
label: "Amount",
description: "The amount to be converted",
},
date: {
type: "string",
label: "Date",
description: "Specify a date (format YYYY-MM-DD) to use historical rates for this conversion",
optional: true,
},
},
async run({ $ }) {
const response = await this.fixerIo.convertCurrency({
$,
params: {
from: this.from,
to: this.to,
amount: this.amount,
date: this.date,
},
});
if (response.error) {
throw new ConfigurationError(response.error.info);
}
$.export("$summary", `Successfully converted ${this.amount} ${this.from} to ${this.to}`);
return response;
},
};
28 changes: 25 additions & 3 deletions components/fixer_io/fixer_io.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,33 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "fixer_io",
propDefinitions: {},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://data.fixer.io/api";
},
_makeRequest({
$ = this, path, params, ...opts
}) {
return axios($, {
url: `${this._baseUrl()}${path}`,
headers: {
Accept: "application/json",
},
params: {
...params,
access_key: `${this.$auth.api_key}`,
},
...opts,
});
},
convertCurrency(opts = {}) {
return this._makeRequest({
path: "/convert",
...opts,
});
},
},
};
5 changes: 4 additions & 1 deletion components/fixer_io/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/fixer_io",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Fixer Components",
"main": "fixer_io.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.1.0"
}
}
19 changes: 11 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading