Skip to content
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

Add proxy voting sample #50

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions corporate-actions/proxyvoting/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Client-side Sample for Corporate Action Events

This is a demonstration on how to get corporate action events with different Corporate action types (Mandatory or Voluntary).

Live demo: https://saxobank.github.io/openapi-samples-js/corporate-actions/events
48 changes: 48 additions & 0 deletions corporate-actions/proxyvoting/demo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*jslint browser: true, long: true, unordered: true */
/*global window console demonstrationHelper */

(function () {
// Create a helper function to remove some boilerplate code from the example itself.
const demo = demonstrationHelper({
"responseElm": document.getElementById("idResponse"),
"javaScriptElm": document.getElementById("idJavaScript"),
"accessTokenElm": document.getElementById("idBearerToken"),
"retrieveTokenHref": document.getElementById("idHrefRetrieveToken"),
"tokenValidateButton": document.getElementById("idBtnValidate"),
"accountsList": document.getElementById("idCbxAccount"),
"footerElm": document.getElementById("idFooter")
});


/**
* This is an example of getting proxy voting events.
* @return {void}
*/
function getProxyVotingEvents() {
const clientKey = document.getElementById("idClientKey").value;
fetch(
demo.apiUrl + "/ca/v1/proxyvoting/events/?ClientKey=" + clientKey,
{
"method": "GET",
"headers": {
"Authorization": "Bearer " + document.getElementById("idBearerToken").value
}
}
).then(function (response) {
if (response.ok) {
response.json().then(function (responseJson) {
console.log("These are the details of this event:\n\n" + JSON.stringify(responseJson, null, 4));
});
} else {
demo.processError(response);
}
}).catch(function (error) {
console.error(error);
});
}

demo.setupEvents([
{"evt": "click", "elmId": "idBtnGetEvents", "func": getProxyVotingEvents, "funcsToDisplay": [getProxyVotingEvents]}
]);
demo.displayVersion("ref");
}());
49 changes: 49 additions & 0 deletions corporate-actions/proxyvoting/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="ROBOTS" content="INDEX, FOLLOW" />
<meta name="VIEWPORT" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="https://saxobank.github.io/openapi-samples-js/assets/css/style.css">
<script type="text/javascript" src="../../assets/js/boilerplate.js" defer></script>
<script type="text/javascript" src="demo.js" defer></script>
<title>Demo for Corporate Actions</title>
</head>
<body>
<section class="page-header">
<h1 class="project-name">Corporate Action Proxy Voting Events</h1>
<h2 class="project-tagline">This example shows how to get proxy voting CA events. (Requires separate license.)</h2>
<a href="https://saxobank.github.io/openapi-samples-js" class="btn">← Back to main page</a>
<a href="https://github.com/SaxoBank/openapi-samples-js" class="btn">View on GitHub</a>
</section>
<section class="main-content">
<div class="highlight">
<label><span>Add token <a href="https://www.developer.saxo/openapi/token" target="_blank" id="idHrefRetrieveToken">from here</a> to the box below:</span><br />
<input type="text" class="token-field" id="idBearerToken" value="" placeholder="Paste token here.." autofocus /></label>
<input type="button" class="action-button" value="Validate" id="idBtnValidate" /><br />
<label>
Account: <select class="selector" id="idCbxAccount">filters
<option value="-">Click Validate to populate</option>
</select>
</label>
</div>
<h1>Get Provy Voting Events for a Client</h1>
This example shows how to get proxy voting CA events for a specific client.<br />
Documentation about Corporate Actions can be found at the <a href="https://www.developer.saxo/openapi/learn/corporate-actions" target="_blank">Developer Portal</a>.
<br />
DISCLAIMER: the Corporate Action endpoints on SIM give 403 errors. The endpoints only work on Live.<br />
To test on production: add '?env=live' to the URL of this page.
<br />
<br />
<label>Client Key: <input type="text" class="text-field" id="idClientKey" value="" placeholder="Enter the client key..."></label>
<br />
<br />
<input type="button" class="action-button" value="Get Proxy Voting Events" id="idBtnGetEvents" />
<br />
Response: <pre class="highlight" id="idResponse">Click button to launch function.</pre>
<br />
JS code: <pre class="code-block" id="idJavaScript">Click button to show code.</pre>
<footer class="site-footer"><span class="site-footer-credits" id="idFooter"></span></footer>
</section>
</body>
</html>