Skip to content

Commit da73bbd

Browse files
committed
Added actions
1 parent 0c007db commit da73bbd

File tree

6 files changed

+171
-25
lines changed

6 files changed

+171
-25
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import app from "../../finage.app.mjs";
2+
3+
export default {
4+
key: "finage-forex-last-quote",
5+
name: "Forex Last Quote",
6+
description: "Get the last quote for the specified forex symbol. [See the documentation](https://finage.co.uk/docs/api/forex/forex-last-quote)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
symbol: {
12+
propDefinition: [
13+
app,
14+
"symbol",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const response = await this.app.forexLastQuote({
20+
$,
21+
symbol: this.symbol,
22+
});
23+
$.export("$summary", "Successfully retrieved the last quote for " + this.symbol);
24+
return response;
25+
},
26+
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import app from "../../finage.app.mjs";
2+
3+
export default {
4+
key: "finage-forex-last-trade",
5+
name: "Forex Last Trade",
6+
description: "Get the last trade for the specified forex symbol. [See the documentation](https://finage.co.uk/docs/api/forex/forex-last-trade)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
symbol: {
12+
propDefinition: [
13+
app,
14+
"symbol",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const response = await this.app.forexLastTrade({
20+
$,
21+
symbol: this.symbol,
22+
});
23+
$.export("$summary", "Successfully retrieved the last trade for " + this.symbol);
24+
return response;
25+
},
26+
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import app from "../../finage.app.mjs";
2+
3+
export default {
4+
key: "finage-forex-previous-close",
5+
name: "Forex Previous Close",
6+
description: "Get the previous close for the specified forex symbol. [See the documentation](https://finage.co.uk/docs/api/forex/forex-previous-close)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
symbol: {
12+
propDefinition: [
13+
app,
14+
"symbol",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const response = await this.app.forexPreviousClose({
20+
$,
21+
symbol: this.symbol,
22+
});
23+
$.export("$summary", "Successfully retrieved the previous close for " + this.symbol);
24+
return response;
25+
},
26+
};

components/finage/finage.app.mjs

Lines changed: 71 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,77 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "finage",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
symbol: {
8+
type: "string",
9+
label: "symbol",
10+
description: "Description for symbol",
11+
async options() {
12+
const response = await this.getSymbols();
13+
const symbols = response.symbols;
14+
return symbols.map(({
15+
symbol, name,
16+
}) => ({
17+
value: symbol,
18+
label: name,
19+
}));
20+
},
21+
},
22+
},
523
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
24+
_baseUrl() {
25+
return "https://api.finage.co.uk";
26+
},
27+
async _makeRequest(opts = {}) {
28+
const {
29+
$ = this,
30+
path,
31+
params,
32+
...otherOpts
33+
} = opts;
34+
return axios($, {
35+
...otherOpts,
36+
url: this._baseUrl() + path,
37+
params: {
38+
apikey: `${this.$auth.api_key}`,
39+
...params,
40+
},
41+
});
42+
},
43+
async forexLastQuote({
44+
symbol,
45+
...args
46+
}) {
47+
return this._makeRequest({
48+
path: `/last/forex/${symbol}`,
49+
...args,
50+
});
51+
},
52+
async forexLastTrade({
53+
symbol,
54+
...args
55+
}) {
56+
return this._makeRequest({
57+
path: `/last/trade/forex/${symbol}`,
58+
...args,
59+
});
60+
},
61+
async forexPreviousClose({
62+
symbol,
63+
...args
64+
}) {
65+
return this._makeRequest({
66+
path: `/agg/forex/prev-close/${symbol}`,
67+
...args,
68+
});
69+
},
70+
async getSymbols(args = {}) {
71+
return this._makeRequest({
72+
path: "/symbol-list/forex",
73+
...args,
74+
});
975
},
1076
},
11-
};
77+
};

components/finage/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/finage",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Finage Components",
55
"main": "finage.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: 18 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)