diff --git a/components/fixer_io/actions/convert-currency/convert-currency.mjs b/components/fixer_io/actions/convert-currency/convert-currency.mjs new file mode 100644 index 0000000000000..14c8e86ac76c9 --- /dev/null +++ b/components/fixer_io/actions/convert-currency/convert-currency.mjs @@ -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; + }, +}; diff --git a/components/fixer_io/fixer_io.app.mjs b/components/fixer_io/fixer_io.app.mjs index 360a8ce94106e..34704530bef83 100644 --- a/components/fixer_io/fixer_io.app.mjs +++ b/components/fixer_io/fixer_io.app.mjs @@ -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, + }); }, }, }; diff --git a/components/fixer_io/package.json b/components/fixer_io/package.json index ff9dfcc3febf9..33a6e6a8917ba 100644 --- a/components/fixer_io/package.json +++ b/components/fixer_io/package.json @@ -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": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.1.0" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6af7438eb1f98..e16a28be6900d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -313,8 +313,7 @@ importers: specifier: ^3.0.1 version: 3.0.3 - components/add_to_calendar_pro: - specifiers: {} + components/add_to_calendar_pro: {} components/addevent: dependencies: @@ -4688,7 +4687,11 @@ importers: components/fivetran: {} - components/fixer_io: {} + components/fixer_io: + dependencies: + '@pipedream/platform': + specifier: ^3.1.0 + version: 3.1.0 components/flash_by_velora_ai: dependencies: @@ -15846,7 +15849,7 @@ importers: version: 3.1.7 ts-jest: specifier: ^29.2.5 - version: 29.2.5(@babel/core@8.0.0-alpha.13)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@8.0.0-alpha.13))(jest@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0))(typescript@5.7.2) + version: 29.2.5(@babel/core@7.26.0)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.26.0))(jest@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0))(typescript@5.7.2) tsup: specifier: ^8.3.6 version: 8.3.6(@microsoft/api-extractor@7.47.12(@types/node@20.17.30))(jiti@1.21.6)(postcss@8.4.49)(tsx@4.19.4)(typescript@5.7.2)(yaml@2.6.1) @@ -15889,7 +15892,7 @@ importers: version: 3.1.0 jest: specifier: ^29.1.2 - version: 29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0) + version: 29.7.0(@types/node@20.17.6)(babel-plugin-macros@3.1.0) type-fest: specifier: ^4.15.0 version: 4.27.0 @@ -49810,7 +49813,7 @@ snapshots: ts-interface-checker@0.1.13: {} - ts-jest@29.2.5(@babel/core@8.0.0-alpha.13)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@8.0.0-alpha.13))(jest@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0))(typescript@5.7.2): + ts-jest@29.2.5(@babel/core@7.26.0)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.26.0))(jest@29.7.0(@types/node@20.17.30)(babel-plugin-macros@3.1.0))(typescript@5.7.2): dependencies: bs-logger: 0.2.6 ejs: 3.1.10 @@ -49824,10 +49827,10 @@ snapshots: typescript: 5.7.2 yargs-parser: 21.1.1 optionalDependencies: - '@babel/core': 8.0.0-alpha.13 + '@babel/core': 7.26.0 '@jest/transform': 29.7.0 '@jest/types': 29.6.3 - babel-jest: 29.7.0(@babel/core@8.0.0-alpha.13) + babel-jest: 29.7.0(@babel/core@7.26.0) ts-jest@29.2.5(@babel/core@8.0.0-alpha.13)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@8.0.0-alpha.13))(jest@29.7.0(@types/node@20.17.6)(babel-plugin-macros@3.1.0))(typescript@5.6.3): dependencies: