All files methods.js

100% Statements 8/8
100% Branches 0/0
100% Functions 4/4
100% Lines 8/8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43                4x 1x                 4x 2x                   4x 1x                 4x 1x    
import createEndpoint from './http';
 
/**
 * Creates or updates a new user in the system
 * @param  {String} key  the agents api key
 * @param  {Object} data the data that should be sent with the request
 * @return {Promise}
 */
export const user = (key, data) => (
  createEndpoint()(key, Object.assign({ event: 'user' }, data))
);
 
/**
 * Logs a message into the system
 * @param  {String} key  the agents api key
 * @param  {Object} data the data that should be sent with the request
 * @return {Promise}
 */
export const message = (key, data) => (
  createEndpoint()(key, Object.assign({ event: 'message' }, data))
);
 
/**
 * Logs a custom event
 * @param  {String} e    the name of the custom event
 * @param  {String} key  the agents api key
 * @param  {Object} data the data that should be sent with the request
 * @return {Promise}
 */
export const event = (e, key, data) => (
  createEndpoint()(key, Object.assign({ event: e }, data))
);
 
/**
 * Logs an intent
 * @param  {String} key  the agents api key
 * @param  {Object} data the data that should be sent with the request
 * @return {Promise}
 */
export const intent = (i, key, data) => (
  createEndpoint('/v1/intent')(key, Object.assign({ event: 'intent', intent: i }, data))
);