fivehundred-friend
v0.0.1
Published
A REST API wrapper for communicating with the 500 friends API
Downloads
2
Maintainers
Readme
#500 Friends API
This library is used for making REST calls to the 500 Friends platform.
Making requests
var FivehundredFriends = require('fivehundred-friends');
// pass configurations
var ffriends = new FiveHundredFriends({
host: 'https://loyalty.500friends.com',
path: '/data',
secret_key: 'YOUSECRETKEY',
uuid: 'YOURUUID'
});
// make request
ffriends.customer.auth_token({
email: '[email protected]'
}, function(response){
console.log(arguments);
});
The above code will make a post request to 'https://loyalty.500friends.com/data/customer/auth_token'. The parameters will be included as part of a query string for GET requests and the post body for POST requests.
Adding new methods
To add new resources, create a new file in src/resources with the endpoint name as the file name.
Inside the the file export an object that contains sub ojects that will map to the endpoint method call. The example below in the src/resources/customer js file will map to the ffriends.customer.auth_token
method.
module.exports = {
auth_token: {
verb: 'get', // request type
/*
* You don't need to include the sig or uuid parameters here. They will be added
* automatically
*/
mandatory: 'email', // mandatory params
optional: 'external_customer_id' // optional params go here
}
};
All files in the resources directory will be mapped to the ffriends object using the file name and sub object keys as method names.