Static Method Summary
Static Public Methods | ||
public static |
formatResForCallback(res: Object): * Format response to documents model before passing to callback |
Static Private Methods | ||
private static |
Creates response body parser for application/jose+json content-type |
|
private static |
isEmptyResponseBody(body: *): * Helper function to check if the response body is an empty object |
Constructor Summary
Public Constructor | ||
public |
constructor(username: string, password: string, server: string, encryptionData: string) Create a instance of the API client |
Member Summary
Public Members | ||
public |
|
|
public |
contextId: * |
|
public |
encryption: * |
|
public |
|
Protected Members | ||
protected |
The flag shows if encryption is enabled |
|
protected |
The API password |
|
protected |
The API server to connect to |
|
protected |
The API username |
|
protected |
The Node SDK Version number |
Method Summary
Public Methods | ||
public |
doGet(partialUrl: string, params: Object, callback: api-callback) Do a GET call to the Hyperwallet API server |
|
public |
doPost(partialUrl: string, data: Object, params: Object, callback: api-callback) Do a POST call to the Hyperwallet API server |
|
public |
doPut(partialUrl: string, data: Object, params: Object, callback: api-callback) Do a PUT call to the Hyperwallet API server |
|
public |
doPutMultipart(partialUrl: string, data: Object, callback: api-callback) Do a PUT call to the Hyperwallet API server to upload documents |
Private Methods | ||
private |
processEncryptedResponse(httpMethod: string, err: Object, res: Object, callback: api-callback) Process encrypted response from server |
|
private |
processNonEncryptedResponse(err: Object, res: Object, callback: api-callback) Process non encrypted response from server |
|
private |
wrapCallback(httpMethod: string, callback: api-callback): function(err: Object, res: Object) Wrap a callback to process possible API and network errors |
Static Public Methods
public static formatResForCallback(res: Object): * source
Format response to documents model before passing to callback
Params:
Name | Type | Attribute | Description |
res | Object | Response object |
Return:
* |
Static Private Methods
private static createJoseJsonParser() source
Creates response body parser for application/jose+json content-type
private static isEmptyResponseBody(body: *): * source
Helper function to check if the response body is an empty object
Params:
Name | Type | Attribute | Description |
body | * |
Return:
* |
Public Constructors
Public Members
public clientPrivateKeySetPath: * source
public contextId: * source
public encryption: * source
public hyperwalletKeySetPath: * source
Protected Members
Public Methods
public doGet(partialUrl: string, params: Object, callback: api-callback) source
Do a GET call to the Hyperwallet API server
Params:
Name | Type | Attribute | Description |
partialUrl | string | The api endpoint to call (gets prefixed by |
|
params | Object | Query parameters to send in this call |
|
callback | api-callback | The callback for this call |
Test:
- utils/ApiClient doGet()
- utils/ApiClient doGet() should return response if call was successful (with query parameters)
- utils/ApiClient doGet() should return response if call was successful (with query parameters) and response body is empty
- utils/ApiClient doGet() should return response if call was successful (with query parameters) and response body is empty no content-type
- utils/ApiClient doGet() should return response if call was successful (with query parameters) when content type contains charset
- utils/ApiClient doGet() should return response if call was successful (with query parameters) when content type contains charset ahead
- utils/ApiClient doGet() should return response if call was successful (without query parameters)
- utils/ApiClient doGet() should return generic network error if no response was send by server
- utils/ApiClient doGet() should return error message if responses contains error
- utils/ApiClient doGet() should return error message from http status if empty error response
- utils/ApiClient doGet() should return error message if responses in unexpected format
- utils/ApiClient doGet() should return error message if client using encryption and responses in application/json
- utils/ApiClient doGet() should return encrypted response if encrypted GET call was successful (without query parameters)
- utils/ApiClient doGet() should return encrypted response if encrypted GET call was successful when content type contains charset
- utils/ApiClient doGet() should return response if call was successful (with query parameters and encryption) and response body is empty
- utils/ApiClient doGet() should return response if call was successful (with query parameters and encryption) and response body is empty no content-type
public doPost(partialUrl: string, data: Object, params: Object, callback: api-callback) source
Do a POST call to the Hyperwallet API server
Params:
Name | Type | Attribute | Description |
partialUrl | string | The api endpoint to call (gets prefixed by |
|
data | Object | The data to send to the server |
|
params | Object | Query parameters to send in this call |
|
callback | api-callback | The callback for this call |
Test:
- utils/ApiClient doPost()
- utils/ApiClient doPost() should return response if call was successful (with query parameters)
- utils/ApiClient doPost() should return response if call was successful (with query parameters) when content type contains charset
- utils/ApiClient doPost() should return response if call was successful (with query parameters) when content type contains charset ahead
- utils/ApiClient doPost() should return response if call was successful (without query parameters)
- utils/ApiClient doPost() should return response if call was successful (without query parameters) and response body is empty
- utils/ApiClient doPost() should return response if call was successful (without query parameters) and response body is empty no content type
- utils/ApiClient doPost() should return generic network error if no response was send by server
- utils/ApiClient doPost() should return error message if responses contains error
- utils/ApiClient doPost() should return error message from http status if empty error response
- utils/ApiClient doPost() should return error message if response in unexpected format
- utils/ApiClient doPost() should return error message if client using encryption and responses in application/json
- utils/ApiClient doPost() should return encrypted response if encrypted POST call was successful (without query parameters)
- utils/ApiClient doPost() should return encrypted response if encrypted POST call was successful when content type contains charset
- utils/ApiClient doPost() should not return error when encrypted response body is empty
- utils/ApiClient doPost() should return error when fail to encrypt POST request body
public doPut(partialUrl: string, data: Object, params: Object, callback: api-callback) source
Do a PUT call to the Hyperwallet API server
Params:
Name | Type | Attribute | Description |
partialUrl | string | The api endpoint to call (gets prefixed by server and /rest/v4/) |
|
data | Object | The data to send to the server |
|
params | Object | Query parameters to send in this call |
|
callback | api-callback | The callback for this call |
Test:
- utils/ApiClient doPut()
- utils/ApiClient doPut() should return response if call was successful (with query parameters)
- utils/ApiClient doPut() should return response if call was successful (with query parameters) when content type contains charset
- utils/ApiClient doPut() should return response if call was successful (with query parameters) when content type contains charset ahead
- utils/ApiClient doPut() should return response if call was successful (without query parameters)
- utils/ApiClient doPut() should return response if call was successful (without query parameters) and response body is empty
- utils/ApiClient doPut() should return response if call was successful (without query parameters) and response body is empty no content-type
- utils/ApiClient doPut() should return generic network error if no response was send by server
- utils/ApiClient doPut() should return error message if responses contains error
- utils/ApiClient doPut() should return error message from http status if empty error response
- utils/ApiClient doPut() should return error message if responses in unexpected format
- utils/ApiClient doPut() should return error message if client using encryption and responses in application/json
- utils/ApiClient doPut() should return encrypted response if encrypted PUT call was successful (without query parameters)
- utils/ApiClient doPut() should return encrypted response if encrypted PUT call was successful when content type contains charset
- utils/ApiClient doPut() should not return error response if encrypted PUT call was successful and response body is empty
- utils/ApiClient doPut() should return error when fail to encrypt PUT request body
- utils/ApiClient doPut() should return error when fail to decrypt PUT response body
- utils/ApiClient doPut() should return error when server responses with error on encrypted PUT request
public doPutMultipart(partialUrl: string, data: Object, callback: api-callback) source
Do a PUT call to the Hyperwallet API server to upload documents
Params:
Name | Type | Attribute | Description |
partialUrl | string | The api endpoint to call (gets prefixed by |
|
data | Object | The data to send to the server |
|
callback | api-callback | The callback for this call |
Private Methods
private processEncryptedResponse(httpMethod: string, err: Object, res: Object, callback: api-callback) source
Process encrypted response from server
Params:
Name | Type | Attribute | Description |
httpMethod | string | The http method that is currently processing |
|
err | Object | Error object |
|
res | Object | Response object |
|
callback | api-callback | The final callback |
private processNonEncryptedResponse(err: Object, res: Object, callback: api-callback) source
Process non encrypted response from server
Params:
Name | Type | Attribute | Description |
err | Object | Error object |
|
res | Object | Response object |
|
callback | api-callback | The final callback |
private wrapCallback(httpMethod: string, callback: api-callback): function(err: Object, res: Object) source
Wrap a callback to process possible API and network errors
Params:
Name | Type | Attribute | Description |
httpMethod | string | The http method that is currently processing |
|
callback | api-callback | The final callback |