New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

abs-client

Package Overview
Dependencies
Maintainers
11
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

abs-client - npm Package Compare versions

Comparing version 0.0.2-alpha to 0.0.3-beta

120

lib/index.js

@@ -1,32 +0,110 @@

const fetch = require('node-fetch')
const rp = require('request-promise-native')
const defaultConfig = {
apiServerAddress: 'http://localhost:9443',
headers: {
Accept: 'application/json',
'Content-Type': 'application/json'
}
}
const URL = require('url').URL
const fetchJson = async (uri, options) => await (await fetch(uri, options)).json()
function init(receivedConfig) {
const config = {
...defaultConfig,
...receivedConfig
}
const balances = async (basepath, customerId) => (
await fetchJson(
basepath + '/account',
{
async function doGet(route, query = {}, additionalHeaders = {}) {
let uri = new URL(config.apiServerAddress + route)
if (query !== {}) {
for (let key in query) {
uri.searchParams.append(key, query[key])
}
}
const options = {
method: 'GET',
uri: uri.href,
json: true,
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'X-USERID': customerId
...config.headers,
...additionalHeaders
}
}
)
).items
const balance = async (basepath, customerId, accountId) => (
await fetchJson(
basepath + '/account/' + accountId,
{
method: 'GET',
try {
return await rp(options)
} catch (err) {
return { result: false, route, err }
}
}
async function doPost(route, body = {}, additionalHeaders = {}) {
const options = {
method: 'POST',
uri: config.apiServerAddress + route,
json: true,
body,
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'X-USERID': customerId
...config.headers,
...additionalHeaders
}
}
)
)
try {
return await rp(options)
} catch (err) {
return { result: false, route, err }
}
}
async function doPut(route, body = {}, additionalHeaders = {}) {
const options = {
method: 'PUT',
uri: config.apiServerAddress + route,
json: true,
body,
headers: {
...config.headers,
...additionalHeaders
}
}
try {
return await rp(options)
} catch (err) {
return { result: false, route, err }
}
}
// {"originAccount":"OCBC002","description":"TTT","value":"1000","currency":"SGD"}"
async function transferToOmnibus(originAccount, description, value, currency) {
return await doPost('/transfers:toOmnibus', { originAccount, description, value, currency })
}
// {"remoteAccount":"OCBC002","description":"aaaaaaa","value":"1000","currency":"SGD"}"
async function transferFromOmnibus(remoteAccount, description, value, currency) {
return await doPost('/transfers:fromOmnibus', { remoteAccount, description, value, currency })
}
// {"description":"aaaaaaa","value":"1000","currency":"SGD"}"
async function addBalanceToOmnibus(description, value, currency) {
return await doPost('/omnibus:addBalance', description, value, currency)
}
async function balances(customerId) {
return (
await doGet('/account', {}, { 'X-USERID': customerId })
).items
}
async function balance(customerId, accountId) {
return await doGet('/account/' + accountId, {}, { 'X-USERID': customerId })
}
return {
transferToOmnibus,
transferFromOmnibus,
addBalanceToOmnibus,
balances,
balance
}
}
module.exports = {

@@ -33,0 +111,0 @@ balances,

4

package.json
{
"name": "abs-client",
"version": "0.0.2-alpha",
"version": "0.0.3-beta",
"description": "Client that interacts functions for the abs.",

@@ -10,4 +10,4 @@ "main": "lib/index.js",

"dependencies": {
"node-fetch": "^2.1.2"
"request-promise-native": "^1.0.7"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc