diff --git a/source/images/images/api_integration.png b/source/images/images/api_integration.png new file mode 100644 index 00000000..c257245b Binary files /dev/null and b/source/images/images/api_integration.png differ diff --git a/source/includes/_account_inquiry.md b/source/includes/_account_inquiry.md index 95e93e98..cbb467ae 100644 --- a/source/includes/_account_inquiry.md +++ b/source/includes/_account_inquiry.md @@ -110,28 +110,45 @@ Request request = new Request.Builder() Response response = client.newCall(request).execute(); ``` -```javascript +```nodejs +const https = require('https'); + var data = JSON.stringify({ "bank_code": "014", "account_number": "1280259361" }); -var xhr = new XMLHttpRequest(); -xhr.withCredentials = true; - -xhr.addEventListener("readystatechange", function() { - if(this.readyState === 4) { - console.log(this.responseText); +var options = { + host: '%7B%7Bbase_url%7D%7D', + path: '/api/account-inquiry', + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Accept':'application/json', + 'x-oy-username':'{{username}}', + 'x-api-key':'{{api-key}}' } -}); +} -xhr.open("POST", "%7B%7Bbase_url%7D%7D/api/account-inquiry"); -xhr.setRequestHeader("Content-Type", "application/json"); -xhr.setRequestHeader("Accept", "application/json"); -xhr.setRequestHeader("x-oy-username", "{{username}}"); -xhr.setRequestHeader("x-api-key", "{{api-key}}"); +const req = https.request(options, (resp) => { + let data = ''; + + // A chunk of data has been received. + resp.on('data', (chunk) => { + data += chunk; + }); + + // The whole response has been received. Print out the result. + resp.on('end', () => { + console.log(JSON.parse(data).explanation); + }); + +}).on("error", (err) => { + console.log("Error: " + err.message); +}); -xhr.send(data); +req.write(data) +req.end ``` ```php diff --git a/source/index.html.md.erb b/source/index.html.md.erb index 0f8f0142..9f487049 100644 --- a/source/index.html.md.erb +++ b/source/index.html.md.erb @@ -6,7 +6,7 @@ language_tabs: # must be one of https://git.io/vQNgJ - dart - go - java - - javascript + - nodejs - php - python @@ -40,6 +40,9 @@ code_clipboard: true Welcome to OY! API Documentation. Our API services are organized around [REST](https://en.wikipedia.org/wiki/Representational_state_transfer), accepts [form-encoded](https://en.wikipedia.org/wiki/POST_(HTTP)#Use_for_submitting_web_forms) request bodies and returns [JSON-encoded](https://www.json.org/json-en.html) responses. + +![API Integration](images/images/api_integration.png) + # Definition For the purpose of standardization and to prevent any misunderstanding, below our the terms we are going to use in this documentation: