Merge pull request #646 from clark800/api-options-doc

Add documentation for RippleAPI options
This commit is contained in:
Chris Clark
2015-11-23 12:47:43 -08:00
4 changed files with 43 additions and 6 deletions

View File

@@ -103,6 +103,18 @@ All the code snippets in this documentation assume that you have surrounded them
If you omit the "catch" section, errors may not be visible.
</aside>
### Parameters
Name | Type | Description
---- | ---- | -----------
authorization | string | *Optional* Username and password for HTTP basic authentication to the rippled server in the format **username:password**.
feeCushion | number | *Optional* Factor to multiply estimated fee by to provide a cushion in case the required fee rises during submission of a transaction. Defaults to `1.2`.
proxy | uri string | *Optional* URI for HTTP/HTTPS proxy to use to connect to the rippled server.
proxyAuthorization | string | *Optional* Username and password for HTTP basic authentication to the proxy in the format **username:password**.
servers | array\<uri string\> | *Optional* Array of rippled servers to connect to. Currently only one server is supported.
trace | boolean | *Optional* If true, log rippled requests and responses to stdout.
trustedCertificates | array\<string\> | *Optional* Array of PEM-formatted SSL certificates to trust when connecting to a proxy. This is useful if you want to use a self-signed certificate on the proxy server. Note: Each element must contain a single certificate; concatenated certificates are not valid.
### Installation ###

View File

@@ -27,6 +27,10 @@ All the code snippets in this documentation assume that you have surrounded them
If you omit the "catch" section, errors may not be visible.
</aside>
### Parameters
<%- renderSchema('input/api-options.json') %>
### Installation ###

View File

@@ -16,6 +16,7 @@ class Connection extends EventEmitter {
constructor(url, options = {}) {
super();
this._url = url;
this._trace = options.trace;
this._proxyURL = options.proxy;
this._proxyAuthorization = options.proxyAuthorization;
this._authorization = options.authorization;
@@ -52,6 +53,9 @@ class Connection extends EventEmitter {
_onMessage(message) {
let parameters;
if (this._trace) {
console.log(message);
}
try {
parameters = this._parseMessage(message);
} catch (error) {
@@ -191,6 +195,9 @@ class Connection extends EventEmitter {
}
_send(message) {
if (this._trace) {
console.log(message);
}
return new Promise((resolve, reject) => {
this._ws.send(message, undefined, (error, result) => {
if (error) {

View File

@@ -3,29 +3,43 @@
"title": "api-options",
"type": "object",
"properties": {
"trace": {"type": "boolean"},
"feeCushion": {"$ref": "value"},
"trace": {
"type": "boolean",
"description": "If true, log rippled requests and responses to stdout."
},
"feeCushion": {
"type": "number",
"minimum": 1,
"description": "Factor to multiply estimated fee by to provide a cushion in case the required fee rises during submission of a transaction. Defaults to `1.2`."
},
"servers": {
"type": "array",
"description": "Array of rippled servers to connect to. Currently only one server is supported.",
"items": {
"type": "string",
"description": "URI for rippled websocket port. Must start with `wss://` or `ws://`.",
"format": "uri",
"pattern": "^wss?://"
}
},
"proxy": {
"format": "uri"
"format": "uri",
"description": "URI for HTTP/HTTPS proxy to use to connect to the rippled server."
},
"proxyAuthorization": {
"type": "string"
"type": "string",
"description": "Username and password for HTTP basic authentication to the proxy in the format **username:password**."
},
"authorization": {
"type": "string"
"type": "string",
"description": "Username and password for HTTP basic authentication to the rippled server in the format **username:password**."
},
"trustedCertificates": {
"type": "array",
"description": "Array of PEM-formatted SSL certificates to trust when connecting to a proxy. This is useful if you want to use a self-signed certificate on the proxy server. Note: Each element must contain a single certificate; concatenated certificates are not valid.",
"items": {
"type": "string"
"type": "string",
"description": "A PEM-formatted SSL certificate to trust when connecting to a proxy."
}
}
},