fidem
Fidem node module provides an easy access to Fidem API.
Install
npm install fidem
Usage
var fidem = ; // Create a client.var client = fidem; // Log action.client // Authenticate a user.client// Retrieve a user by token.;
fidem.createClient(config)
Create a new API client.
* @param {object} config
* @param {string} config.key API key.
* @param {string} config.secret API secret.
* @param {string} [config.hostname="services.fidemapps.com"] Hostname.
* @param {string} [config.protocol=http] Protocol (http or https).
* @param {string} [config.port=80|443] Port.
* @returns {Client}
var client = fidem;
client.authenticate(credentials, [cb])
Get an authentication token for the credentials provided.
* @param {object} credentials
* @param {string} credentials.username Username.
* @param {string} credentials.password Password.
* @param {Function} [cb] Optional callback.
* @returns {Promise}
client;
client.request(options, [cb])
Make a custom request to the API.
* @param {object} options
will use a session token request.
* @param {string} options.path Path of the request.
* @param {string} [options.token=null] Session token. If provided,
* @param {boolean} [options.sign=true] Sign the request
using key and secret of the client.
* @param {string} [options.method=GET] HTTP method.
* @param {object} [options.body=null] HTTP body of the request for methods
that supports it (POST, PUT, ...).
* @param {object} [options.headers={}] Additional headers.
* @param {object} [options.requestOptions={}] Custom options of the internal
[request](https://github.com/mikeal/request#requestoptions-callback).
* @param {Function} [cb] Optional callback.
* @returns {Promise}
client;
client.getUserByToken(token, [cb])
Retrieve a user by token.
* @param {string} token Token of the user.
* @param {Function} [cb] Optional callback.
* @returns {Promise}
client;
client.logAction(action, [cb])
Log an action.
* @param {string} action Action.
* @param {Function} [cb] Optional callback.
* @returns {Promise}
client;
client.createMember(accountId, [cb])
Create a member.
* @param {string} accountId If of the account.
* @param {Function} [cb] Optional callback.
* @returns {Promise}
client;
client.startSession(memberId, [cb])
Start a new session.
* @param {string} memberId If of the member.
* @param {Function} [cb] Optional callback.
* @returns {Promise}
client;
client.assignMemberToSession(memberId, sessionId, [cb])
Assign a member to an existing session.
* @param {string} sessionId If of the session.
* @param {string} memberId If of the member.
* @param {Function} [cb] Optional callback.
* @returns {Promise}
client;
License
MIT