Skip to content

Commit

Permalink
modified Overledger.app to add instance selection between Sandbox and…
Browse files Browse the repository at this point in the history
… Live Overledger
  • Loading branch information
philbuuza committed Oct 8, 2024
1 parent 281f0d6 commit 9dff018
Showing 1 changed file with 27 additions and 11 deletions.
38 changes: 27 additions & 11 deletions components/overledger/overledger.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,24 @@ import { axios } from "@pipedream/platform";
export default {
type: "app",
app: "overledger",
props: { //Options to allow for instance selection of Overledger environment - Sanbox or Live Overledger ro determine BaseURL
environment: {
type: "string",
label: "Overledger Instance",
description: "Select the Overledger environment.",
options: [
{
label: "Sandbox",
value: "sandbox",
},
{
label: "Overledger",
value: "overledger",
},
],
optional: false,
},
},
propDefinitions: {
smartContractId: {
type: "string",
Expand All @@ -11,20 +29,18 @@ export default {
},
},
methods: {
_baseUrl() {
return "https://api.overledger.io";
},
//Sandbox base URL - allows for use on Sandbox environments
_sandboxBaseUrl() {
return "https://api.sandbox.overledger.io";
},
_headers() {
return {
"Authorization": `Bearer ${this.$auth.oauth_access_token}`,
"Content-Type": "application/json",
"API-Version": "3.0.0",
};
},
_getBaseUrl() { //conditional to for environment selection.
return this.environment === "sandbox"
? "https://api.sandbox.overledger.io"
: "https://api.overledger.io";
},
_makeRequest({
$ = this, baseUrl, path, ...otherOpts
}) {
Expand All @@ -37,31 +53,31 @@ export default {
prepareSmartContractTransaction(opts = {}) {
return this._makeRequest({
method: "POST",
baseUrl: this._sandboxBaseUrl(),
baseUrl: this._getBaseUrl(),
path: "/api/preparations/transactions/smart-contracts/write",
...opts,
});
},
readFromSmartContract(opts = {}) {
return this._makeRequest({
method: "POST",
baseUrl: this._sanboxBaseUrl(),
baseUrl: this._getBaseUrl(),
path: "/api/smart-contracts/read",
...opts,
});
},
signTransaction(opts = {}) {
return this._makeRequest({
method: "POST",
baseUrl: this._sandboxBaseUrl(),
baseUrl: this._getBaseUrl(),
path: "/api/transaction-signing-sandbox",
...opts,
});
},
executeSignedTransaction(opts = {}) {
return this._makeRequest({
method: "POST",
baseUrl: this._sandboxBaseUrl(),
baseUrl: this._getBaseUrl(),
path: "/api/executions/transactions",
...opts,
});
Expand Down

0 comments on commit 9dff018

Please sign in to comment.