@narative/oanda-v20
Advanced tools
Comparing version 3.0.43 to 3.0.44
@@ -44,2 +44,13 @@ "use strict"; | ||
Definition.prototype.toJSON = function () { | ||
var recursiveConvert = function (value) { | ||
if (Array.isArray(value)) { | ||
return value.map(function (v) { return recursiveConvert(v); }); | ||
} | ||
else if (value.toJSON) { | ||
return value.toJSON(); | ||
} | ||
else { | ||
return value; | ||
} | ||
}; | ||
return Object.entries(this) | ||
@@ -52,3 +63,3 @@ .filter(function (_a) { | ||
var k = _a[0], v = _a[1]; | ||
acc[k] = v; | ||
acc[k] = recursiveConvert(v); | ||
return acc; | ||
@@ -73,6 +84,4 @@ }, {}); | ||
var matches = summaryStr.match(re); | ||
console.log('AAAAA', matches); | ||
for (var _i = 0, _a = matches || []; _i < _a.length; _i++) { | ||
var match = _a[_i]; | ||
console.log('BBBBBBB', match); | ||
var key = match.slice(1, -1); | ||
@@ -79,0 +88,0 @@ var value = this[key] || match; |
@@ -0,1 +1,3 @@ | ||
/// <reference types="node" /> | ||
import * as http from 'http'; | ||
import * as account from './account'; | ||
@@ -39,3 +41,2 @@ import * as user from './user'; | ||
token: string; | ||
http: any; | ||
account: account.EntitySpec; | ||
@@ -55,5 +56,5 @@ position: position.EntitySpec; | ||
'OANDA-Agent': string; | ||
}, token?: string, http?: any); | ||
}, token?: string); | ||
setToken(token: any): void; | ||
request(method: any, path: any, body: any, streamChunkHandler: any, responseHandler: any): any; | ||
request(method: string, path: string, body: string, streamChunkHandler: any, responseHandler: any): http.ClientRequest; | ||
} |
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var http = require("http"); | ||
var https = require("https"); | ||
var account = require("./account"); | ||
@@ -46,12 +59,9 @@ var user = require("./user"); | ||
var Context = /** @class */ (function () { | ||
function Context(hostname, port, ssl, application, username, headers, token, | ||
// @ts-ignore | ||
http) { | ||
function Context(hostname, port, ssl, application, username, headers, token) { | ||
if (username === void 0) { username = ''; } | ||
if (headers === void 0) { headers = { | ||
'Content-Type': 'application/json', | ||
'OANDA-Agent': "v20-javascript/3.0.25 (" + application + ")", | ||
'OANDA-Agent': "narative-oanda-v20/3.x (" + application + ")", | ||
}; } | ||
if (token === void 0) { token = ''; } | ||
if (http === void 0) { http = ssl ? require('https') : require('http'); } | ||
this.hostname = hostname; | ||
@@ -64,3 +74,2 @@ this.port = port; | ||
this.token = token; | ||
this.http = http; | ||
this.account = new account.EntitySpec(this); | ||
@@ -85,3 +94,3 @@ this.position = new position.EntitySpec(this); | ||
var _this = this; | ||
var headers = JSON.parse(JSON.stringify(this.headers)); | ||
var headers = __assign({}, this.headers); | ||
var postData = ''; | ||
@@ -99,3 +108,3 @@ if (Object.keys(body).length > 0) { | ||
}; | ||
var req = this.http.request(options, function (response) { | ||
var req = (this.ssl ? https : http).request(options, function (response) { | ||
var responseBody = ''; | ||
@@ -102,0 +111,0 @@ response.on('data', function (d) { |
{ | ||
"name": "@narative/oanda-v20", | ||
"description": "OANDA v20 bindings for Javascript", | ||
"version": "3.0.43", | ||
"version": "3.0.44", | ||
"author": "OANDA Corporation", | ||
@@ -6,0 +6,0 @@ "repository": "https://github.com/narative/v20-javascript", |
@@ -1,2 +0,2 @@ | ||
// import * as oanda from '../src' | ||
import * as oanda from '../src' | ||
@@ -8,3 +8,3 @@ import { parseAll as parseAllDefinitions } from './definitions' | ||
// const client = new oanda.Rest('test', process.env.OANDA_TOKEN, true) | ||
// const accountIDs = await client.account.list() | ||
// const accountIDs = await client.account.list({}) | ||
@@ -16,5 +16,7 @@ // if (accountIDs.accounts.length === 0) { | ||
// const accounts = await Promise.all(accountIDs.accounts.map((a) => client.account.summary(a.id))) | ||
// const accounts = await Promise.all( | ||
// accountIDs.accounts.map((a) => client.account.summary({ accountID: a.id })), | ||
// ) | ||
// console.log(`Your list of accounts`) | ||
// accounts.forEach((a) => { | ||
// accounts.forEach((a: any) => { | ||
// console.log( | ||
@@ -25,9 +27,17 @@ // `• ${a.account.id} balance=${a.account.balance} transactions=${a.lastTransactionID}`, | ||
// const accountID = accountIDs.accounts[0].id | ||
// const trades = await client.trade.list(accountID, { state: ['ALL'], count: 10 } as any) | ||
// console.log(`Trades for ${accountID}`) | ||
// trades.trades.forEach((t) => { | ||
// console.log(`• ${t.instrument} (${t.clientExtensions?.id})`) | ||
// const transactions = await client.transaction.range({ | ||
// accountID: `101-002-12706983-001`, | ||
// query: { from: '1365', to: '1367' }, | ||
// }) | ||
// console.log(`Last transaction`) | ||
// transactions.transactions.forEach((t) => { | ||
// const jsonObj: any = t.toJSON() | ||
// console.log( | ||
// `• ${t.id} ${jsonObj.type} ${ | ||
// jsonObj.type === 'ORDER_FILL' ? Object.keys(jsonObj.fullPrice) : '' | ||
// }`, | ||
// ) | ||
// }) | ||
await parseAllDefinitions() | ||
@@ -34,0 +44,0 @@ await parseAllEndpoints() |
@@ -47,6 +47,6 @@ export class Property { | ||
const recursiveConvert = (value: any) => { | ||
if (value.toJSON) { | ||
if (Array.isArray(value)) { | ||
return value.map((v) => recursiveConvert(v)) | ||
} else if (value.toJSON) { | ||
return value.toJSON() | ||
} else if (Array.isArray(value)) { | ||
return value.map((v) => recursiveConvert(v)) | ||
} else { | ||
@@ -53,0 +53,0 @@ return value |
@@ -1,2 +0,1 @@ | ||
import * as pkg from '../package.json' | ||
import * as http from 'http' | ||
@@ -73,3 +72,3 @@ import * as https from 'https' | ||
'Content-Type': 'application/json', | ||
'OANDA-Agent': `${pkg.name.replace('@', '')}/${pkg.version} (${application})`, | ||
'OANDA-Agent': `narative-oanda-v20/3.x (${application})`, | ||
}, | ||
@@ -76,0 +75,0 @@ public token = '', |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
70359
3960135
244