Update schema

This commit is contained in:
wltsmrz
2015-10-05 12:16:25 -07:00
parent 806a4e823f
commit 772f79ae21
3 changed files with 18 additions and 27 deletions

View File

@@ -1,6 +1,6 @@
{ {
"$schema": "http://json-schema.org/draft-04/schema#", "$schema": "http://json-schema.org/draft-04/schema#",
"title": "get-balance-sheet", "title": "getBalanceSheet",
"description": "getBalanceSheet response", "description": "getBalanceSheet response",
"type": "object", "type": "object",
"properties": { "properties": {
@@ -8,17 +8,17 @@
"type": "array", "type": "array",
"items": { "items": {
"type": "object", "type": "object",
"properties": {
"required": ["counterparty", "balances"], "required": ["counterparty", "balances"],
"additionalProperties": false, "additionalProperties": false,
"properties": {
"counterparty": {"$ref": "address"}, "counterparty": {"$ref": "address"},
"balances": { "balances": {
"type": "array", "type": "array",
"items": { "items": {
"type": "object", "type": "object",
"properties": {
"required": ["currency", "value"], "required": ["currency", "value"],
"additionalProperties": false, "additionalProperties": false,
"properties": {
"currency": {"$ref": "currency"}, "currency": {"$ref": "currency"},
"value": {"$ref": "value"} "value": {"$ref": "value"}
} }
@@ -31,17 +31,17 @@
"type": "array", "type": "array",
"items": { "items": {
"type": "object", "type": "object",
"properties": {
"required": ["counterparty", "assets"], "required": ["counterparty", "assets"],
"additionalProperties": false, "additionalProperties": false,
"properties": {
"counterparty": {"$ref": "address"}, "counterparty": {"$ref": "address"},
"assets": { "assets": {
"type": "array", "type": "array",
"items": { "items": {
"type": "object", "type": "object",
"properties": {
"required": ["currency", "value"], "required": ["currency", "value"],
"additionalProperties": false, "additionalProperties": false,
"properties": {
"currency": {"$ref": "currency"}, "currency": {"$ref": "currency"},
"value": {"$ref": "value"} "value": {"$ref": "value"}
} }
@@ -54,9 +54,9 @@
"type": "array", "type": "array",
"items": { "items": {
"type": "object", "type": "object",
"properties": {
"required": ["currency", "value"], "required": ["currency", "value"],
"additionalProperties": false, "additionalProperties": false,
"properties": {
"currency": {"$ref": "currency"}, "currency": {"$ref": "currency"},
"value": {"$ref": "value"} "value": {"$ref": "value"}
} }

View File

@@ -10,25 +10,16 @@ function formatBalanceSheet({balances, obligations, assets}) {
const result = {}; const result = {};
if (!_.isUndefined(balances)) { if (!_.isUndefined(balances)) {
result.balances = Object.keys(balances).map((k) => { result.balances = _.map(balances, (balances, counterparty) =>
return { ({counterparty, balances}));
counterparty: k,
balances: balances[k]
};
});
} }
if (!_.isUndefined(assets)) { if (!_.isUndefined(assets)) {
result.assets = Object.keys(assets).map((k) => { result.assets = _.map(assets, (assets, counterparty) =>
return { ({counterparty, assets}));
counterparty: k,
assets: assets[k]
};
});
} }
if (!_.isUndefined(obligations)) { if (!_.isUndefined(obligations)) {
result.obligations = Object.keys(obligations).map((k) => { result.obligations = _.map(obligations, (value, currency) =>
return {currency: k, value: obligations[k]}; ({currency, value}));
});
} }
return result; return result;

View File

@@ -203,7 +203,7 @@ describe('RippleAPI', function() {
it('getBalanceSheet', function() { it('getBalanceSheet', function() {
return this.api.getBalanceSheet(address).then( return this.api.getBalanceSheet(address).then(
_.partial(checkResult, responses.getBalanceSheet, undefined)); _.partial(checkResult, responses.getBalanceSheet, 'getBalanceSheet'));
}); });
describe('getTransaction', () => { describe('getTransaction', () => {