Skip to content

Adds an example for Will #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const args = process.argv.slice(2);
// Secret key for HMAC
const SECRET_KEY = 'test_secret_key';
// const SERVER_URL = 'http://192.168.1.99:8675';
const SERVER_URL = 'http://localhost:8675';
const SERVER_URL = 'http://0.0.0.0:8675';

const calculateHMAC = (route, timestamp, body) => {
const stringifiedBody = body ? JSON.stringify(body) : "";
Expand Down Expand Up @@ -498,6 +498,30 @@ async function makeDenesterRequest() {
}
}

async function willRequest() {
// Construct the URL for the POST request
const route = '/command/submit';
const url = `${SERVER_URL}${route}`;

const body = {
commands: ['my/command/script.rs']
};

try {
console.time("My Call")
const response = await axios.post(url, body);
console.timeEnd("My Call")
console.log('Status:', response.status);
console.log('Data:', response.data);
} catch (error) {
console.timeEnd("My Call")
console.error('Error Message:', error.message);
console.error('status:', error.response.status);
console.error('statusText:', error.response.statusText);
console.error('data:', error.response.data);
}
}

const entreeId = args[1] || "<entreeId>"
const entree = {
externalOrderId: "12345",
Expand Down Expand Up @@ -565,6 +589,9 @@ switch (args[0]) {
case 'denester':
makeDenesterRequest();
break;
case 'will':
willRequest();
break;
default:
console.log('Unknown endpoint command');
}