@pipedream/unirateapi 0.2.0 → 0.3.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/actions/convert-currency/convert-currency.mjs +2 -2
- package/actions/get-exchange-rates/get-exchange-rates.mjs +2 -2
- package/actions/get-vat-rates/get-vat-rates.mjs +56 -0
- package/actions/list-country-code-options/list-country-code-options.mjs +34 -0
- package/actions/list-currencies/list-currencies.mjs +30 -0
- package/actions/list-currency-code-options/list-currency-code-options.mjs +1 -1
- package/package.json +1 -1
- package/sources/new-rate-update/new-rate-update.mjs +2 -2
- package/unirateapi.app.mjs +18 -3
|
@@ -3,13 +3,13 @@ import app from "../../unirateapi.app.mjs";
|
|
|
3
3
|
export default {
|
|
4
4
|
key: "unirateapi-convert-currency",
|
|
5
5
|
name: "Convert Currency",
|
|
6
|
-
version: "0.0.
|
|
6
|
+
version: "0.0.2",
|
|
7
7
|
annotations: {
|
|
8
8
|
destructiveHint: false,
|
|
9
9
|
openWorldHint: true,
|
|
10
10
|
readOnlyHint: true,
|
|
11
11
|
},
|
|
12
|
-
description: "Convert an amount from one currency to another at the latest rate. [See the documentation](https://unirateapi.com/
|
|
12
|
+
description: "Convert an amount from one currency to another at the latest rate. [See the documentation](https://unirateapi.com/apidocs).",
|
|
13
13
|
type: "action",
|
|
14
14
|
props: {
|
|
15
15
|
app,
|
|
@@ -3,13 +3,13 @@ import app from "../../unirateapi.app.mjs";
|
|
|
3
3
|
export default {
|
|
4
4
|
key: "unirateapi-get-exchange-rates",
|
|
5
5
|
name: "Get Exchange Rates",
|
|
6
|
-
version: "0.0.
|
|
6
|
+
version: "0.0.2",
|
|
7
7
|
annotations: {
|
|
8
8
|
destructiveHint: false,
|
|
9
9
|
openWorldHint: true,
|
|
10
10
|
readOnlyHint: true,
|
|
11
11
|
},
|
|
12
|
-
description: "Get the latest exchange rate(s) for a base currency. Returns a single rate when a target is provided, or all rates keyed by currency code when omitted. [See the documentation](https://unirateapi.com/
|
|
12
|
+
description: "Get the latest exchange rate(s) for a base currency. Returns a single rate when a target is provided, or all rates keyed by currency code when omitted. [See the documentation](https://unirateapi.com/apidocs).",
|
|
13
13
|
type: "action",
|
|
14
14
|
props: {
|
|
15
15
|
app,
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import app from "../../unirateapi.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "unirateapi-get-vat-rates",
|
|
5
|
+
name: "Get VAT Rates",
|
|
6
|
+
version: "0.0.1",
|
|
7
|
+
annotations: {
|
|
8
|
+
destructiveHint: false,
|
|
9
|
+
openWorldHint: true,
|
|
10
|
+
readOnlyHint: true,
|
|
11
|
+
},
|
|
12
|
+
description: "Get VAT rates for a single country, or for all supported countries when no country is provided. Country codes follow the EU VAT convention rather than ISO 3166-1 alpha-2 — Greece is `EL` (not `GR`) and the United Kingdom is `UK` (not `GB`). Coverage is limited to EU member states plus `UK` and `XI` (Northern Ireland), so non-EU codes such as `US` are not supported. Use **List Country Code Options** to discover valid codes. [See the documentation](https://unirateapi.com/apidocs).",
|
|
13
|
+
type: "action",
|
|
14
|
+
props: {
|
|
15
|
+
app,
|
|
16
|
+
country: {
|
|
17
|
+
propDefinition: [
|
|
18
|
+
app,
|
|
19
|
+
"countryCode",
|
|
20
|
+
],
|
|
21
|
+
description: "An EU VAT country code (e.g. `DE`, `FR`, `UK`). If omitted, VAT rates for all supported countries are returned.",
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
async run({ $ }) {
|
|
25
|
+
const {
|
|
26
|
+
app, country,
|
|
27
|
+
} = this;
|
|
28
|
+
|
|
29
|
+
const trimmed = String(country ?? "").trim();
|
|
30
|
+
const countryCode = trimmed
|
|
31
|
+
? trimmed.toUpperCase()
|
|
32
|
+
: undefined;
|
|
33
|
+
|
|
34
|
+
const response = await app.getVatRates({
|
|
35
|
+
$,
|
|
36
|
+
country: countryCode,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
if (countryCode) {
|
|
40
|
+
const rate = response?.vat_data?.vat_rate;
|
|
41
|
+
$.export(
|
|
42
|
+
"$summary",
|
|
43
|
+
`Fetched VAT rate for ${countryCode}${rate === undefined
|
|
44
|
+
? ""
|
|
45
|
+
: `: ${rate}%`}`,
|
|
46
|
+
);
|
|
47
|
+
} else {
|
|
48
|
+
const total = response?.total_countries
|
|
49
|
+
?? Object.keys(response?.vat_rates ?? {}).length;
|
|
50
|
+
$.export("$summary", `Fetched VAT rates for ${total} countr${total === 1
|
|
51
|
+
? "y"
|
|
52
|
+
: "ies"}`);
|
|
53
|
+
}
|
|
54
|
+
return response;
|
|
55
|
+
},
|
|
56
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import unirateapi from "../../unirateapi.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "unirateapi-list-country-code-options",
|
|
5
|
+
name: "List Country Code Options",
|
|
6
|
+
description: "Retrieves the valid options for the Country Code field used by **Get VAT Rates**. Returns one entry per supported country as `{ label, value }`, where `value` is the code to pass as Country Code. These follow the EU VAT convention rather than ISO 3166-1 alpha-2 — Greece is `EL` (not `GR`) and the United Kingdom is `UK` (not `GB`) — so call this first rather than assuming an ISO code. [See the documentation](https://unirateapi.com/apidocs).",
|
|
7
|
+
version: "0.0.1",
|
|
8
|
+
type: "action",
|
|
9
|
+
annotations: {
|
|
10
|
+
destructiveHint: false,
|
|
11
|
+
openWorldHint: true,
|
|
12
|
+
readOnlyHint: true,
|
|
13
|
+
},
|
|
14
|
+
props: {
|
|
15
|
+
unirateapi,
|
|
16
|
+
},
|
|
17
|
+
async run({ $ }) {
|
|
18
|
+
const { vat_rates: vatRates = {} } = await this.unirateapi.getVatRates({
|
|
19
|
+
$,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const options = Object.values(vatRates).map(({
|
|
23
|
+
country_code: value, country_name: label,
|
|
24
|
+
}) => ({
|
|
25
|
+
label: label || value,
|
|
26
|
+
value,
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
$.export("$summary", `Successfully retrieved ${options.length} option${options.length === 1
|
|
30
|
+
? ""
|
|
31
|
+
: "s"}`);
|
|
32
|
+
return options;
|
|
33
|
+
},
|
|
34
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import app from "../../unirateapi.app.mjs";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
key: "unirateapi-list-currencies",
|
|
5
|
+
name: "List Currencies",
|
|
6
|
+
version: "0.0.1",
|
|
7
|
+
annotations: {
|
|
8
|
+
destructiveHint: false,
|
|
9
|
+
openWorldHint: true,
|
|
10
|
+
readOnlyHint: true,
|
|
11
|
+
},
|
|
12
|
+
description: "List every currency code supported by UniRate for exchange rate and conversion operations. Use this to discover valid values before calling **Convert Currency** or **Get Exchange Rates**, or to check whether a currency code you already have is supported. Takes no parameters and returns the full set in a single response as `{ currencies, count }` — codes only, without currency names or rates. These are currency codes (e.g. `USD`, `EUR`, `GBP`) and are unrelated to the EU VAT country codes used by **Get VAT Rates**. [See the documentation](https://unirateapi.com/apidocs).",
|
|
13
|
+
type: "action",
|
|
14
|
+
props: {
|
|
15
|
+
app,
|
|
16
|
+
},
|
|
17
|
+
async run({ $ }) {
|
|
18
|
+
const { app } = this;
|
|
19
|
+
|
|
20
|
+
const response = await app.listCurrencies({
|
|
21
|
+
$,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const count = response?.currencies?.length ?? 0;
|
|
25
|
+
$.export("$summary", `Retrieved ${count} supported currenc${count === 1
|
|
26
|
+
? "y"
|
|
27
|
+
: "ies"}`);
|
|
28
|
+
return response;
|
|
29
|
+
},
|
|
30
|
+
};
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "unirateapi-list-currency-code-options",
|
|
5
5
|
name: "List Currency Code Options",
|
|
6
6
|
description: "Retrieves available options for the Currency Code field.",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.2",
|
|
8
8
|
type: "action",
|
|
9
9
|
annotations: {
|
|
10
10
|
destructiveHint: false,
|
package/package.json
CHANGED
|
@@ -4,13 +4,13 @@ import app from "../../unirateapi.app.mjs";
|
|
|
4
4
|
export default {
|
|
5
5
|
key: "unirateapi-new-rate-update",
|
|
6
6
|
name: "New Rate Update",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.2",
|
|
8
8
|
annotations: {
|
|
9
9
|
destructiveHint: false,
|
|
10
10
|
openWorldHint: true,
|
|
11
11
|
readOnlyHint: true,
|
|
12
12
|
},
|
|
13
|
-
description: "Emit new event when the exchange rate between two currencies changes. [See the documentation](https://unirateapi.com/
|
|
13
|
+
description: "Emit new event when the exchange rate between two currencies changes. [See the documentation](https://unirateapi.com/apidocs).",
|
|
14
14
|
type: "source",
|
|
15
15
|
dedupe: "unique",
|
|
16
16
|
props: {
|
package/unirateapi.app.mjs
CHANGED
|
@@ -16,6 +16,12 @@ export default {
|
|
|
16
16
|
}));
|
|
17
17
|
},
|
|
18
18
|
},
|
|
19
|
+
countryCode: {
|
|
20
|
+
type: "string",
|
|
21
|
+
label: "Country Code",
|
|
22
|
+
description: "An EU VAT country code (e.g. `DE`, `FR`, `UK`). These follow the EU VAT convention rather than ISO 3166-1 alpha-2 — Greece is `EL` (not `GR`) and the United Kingdom is `UK` (not `GB`).",
|
|
23
|
+
optional: true,
|
|
24
|
+
},
|
|
19
25
|
},
|
|
20
26
|
methods: {
|
|
21
27
|
_apiUrl() {
|
|
@@ -53,9 +59,7 @@ export default {
|
|
|
53
59
|
path: "rates",
|
|
54
60
|
params: {
|
|
55
61
|
from,
|
|
56
|
-
|
|
57
|
-
to,
|
|
58
|
-
}),
|
|
62
|
+
to,
|
|
59
63
|
},
|
|
60
64
|
...args,
|
|
61
65
|
});
|
|
@@ -73,5 +77,16 @@ export default {
|
|
|
73
77
|
...args,
|
|
74
78
|
});
|
|
75
79
|
},
|
|
80
|
+
getVatRates({
|
|
81
|
+
country, ...args
|
|
82
|
+
} = {}) {
|
|
83
|
+
return this._makeRequest({
|
|
84
|
+
path: "vat/rates",
|
|
85
|
+
params: {
|
|
86
|
+
country,
|
|
87
|
+
},
|
|
88
|
+
...args,
|
|
89
|
+
});
|
|
90
|
+
},
|
|
76
91
|
},
|
|
77
92
|
};
|