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-alpha

221

lib/index.js

@@ -1,35 +0,208 @@

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 }
}
}
module.exports = {
balances,
balance,
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 })
}
async function balance(customerID, accountID) {
return await doGet(`/account/${accountID}`, {}, { 'X-USERID': customerID })
}
async function setBankInfo(name, branch, BIC, address, countryCode, defaultCurrency, description) {
return await doPost(`/bankInfo`, { name, branch, BIC, address, countryCode, defaultCurrency, description })
}
async function getBankInfo() {
return await doGet(`/bankInfo`)
}
async function createCustomer({
firstName,
lastName,
companyName,
customerId,
customerType,
description,
countryCode,
natLegalIdentifier,
intlLegalIdentifier,
}) {
return await doPost(`/customer`, {
firstName,
lastName,
companyName,
customerId,
customerType,
description,
countryCode,
natLegalIdentifier,
intlLegalIdentifier,
}, { 'X-USERID': customerId })
}
async function createCustomer({
firstName,
lastName,
companyName,
customerId,
customerType,
description,
countryCode,
natLegalIdentifier,
intlLegalIdentifier,
}) {
return await doPost(`/customer`, {
firstName,
lastName,
companyName,
customerId,
customerType,
description,
countryCode,
natLegalIdentifier,
intlLegalIdentifier,
}, { 'X-USERID': customerId })
}
async function getCustomer(queryObj, customerID) {
return await doGet(`/customer`, queryObj, { 'X-USERID': customerID })
}
async function createAccount({
customerID,
accountID,
accountNumber,
balance,
currency,
description,
// type,
}) {
return await doPost(`/account`, {
customerID,
accountID,
accountNumber,
balance,
currency,
description,
// type,
})
}
async function linkAccount({
customerID,
accountID,
}) {
console.log({
customerID,
accountID,
})
return await doPost(`/account:link`, {
customerID,
accountID,
// customerID: accountID,
// accountID: customerID,
})
}
return {
transferToOmnibus,
transferFromOmnibus,
addBalanceToOmnibus,
balances,
balance,
setBankInfo,
getBankInfo,
createCustomer,
getCustomer,
createAccount,
linkAccount,
}
}
module.exports = init

5

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

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

"dependencies": {
"node-fetch": "^2.1.2"
"request": "^2.88.0",
"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