Skip to content

Commit 9dff018

Browse files
committed
modified Overledger.app to add instance selection between Sandbox and Live Overledger
1 parent 281f0d6 commit 9dff018

File tree

1 file changed

+27
-11
lines changed

1 file changed

+27
-11
lines changed

components/overledger/overledger.app.mjs

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,24 @@ import { axios } from "@pipedream/platform";
33
export default {
44
type: "app",
55
app: "overledger",
6+
props: { //Options to allow for instance selection of Overledger environment - Sanbox or Live Overledger ro determine BaseURL
7+
environment: {
8+
type: "string",
9+
label: "Overledger Instance",
10+
description: "Select the Overledger environment.",
11+
options: [
12+
{
13+
label: "Sandbox",
14+
value: "sandbox",
15+
},
16+
{
17+
label: "Overledger",
18+
value: "overledger",
19+
},
20+
],
21+
optional: false,
22+
},
23+
},
624
propDefinitions: {
725
smartContractId: {
826
type: "string",
@@ -11,20 +29,18 @@ export default {
1129
},
1230
},
1331
methods: {
14-
_baseUrl() {
15-
return "https://api.overledger.io";
16-
},
17-
//Sandbox base URL - allows for use on Sandbox environments
18-
_sandboxBaseUrl() {
19-
return "https://api.sandbox.overledger.io";
20-
},
2132
_headers() {
2233
return {
2334
"Authorization": `Bearer ${this.$auth.oauth_access_token}`,
2435
"Content-Type": "application/json",
2536
"API-Version": "3.0.0",
2637
};
2738
},
39+
_getBaseUrl() { //conditional to for environment selection.
40+
return this.environment === "sandbox"
41+
? "https://api.sandbox.overledger.io"
42+
: "https://api.overledger.io";
43+
},
2844
_makeRequest({
2945
$ = this, baseUrl, path, ...otherOpts
3046
}) {
@@ -37,31 +53,31 @@ export default {
3753
prepareSmartContractTransaction(opts = {}) {
3854
return this._makeRequest({
3955
method: "POST",
40-
baseUrl: this._sandboxBaseUrl(),
56+
baseUrl: this._getBaseUrl(),
4157
path: "/api/preparations/transactions/smart-contracts/write",
4258
...opts,
4359
});
4460
},
4561
readFromSmartContract(opts = {}) {
4662
return this._makeRequest({
4763
method: "POST",
48-
baseUrl: this._sanboxBaseUrl(),
64+
baseUrl: this._getBaseUrl(),
4965
path: "/api/smart-contracts/read",
5066
...opts,
5167
});
5268
},
5369
signTransaction(opts = {}) {
5470
return this._makeRequest({
5571
method: "POST",
56-
baseUrl: this._sandboxBaseUrl(),
72+
baseUrl: this._getBaseUrl(),
5773
path: "/api/transaction-signing-sandbox",
5874
...opts,
5975
});
6076
},
6177
executeSignedTransaction(opts = {}) {
6278
return this._makeRequest({
6379
method: "POST",
64-
baseUrl: this._sandboxBaseUrl(),
80+
baseUrl: this._getBaseUrl(),
6581
path: "/api/executions/transactions",
6682
...opts,
6783
});

0 commit comments

Comments
 (0)