This is a simple wrapper for the binto-api, so the api is alot easier to interface with in frontend applications.
Right now at its current state there is one requirement: jQuery
. It is also compatiable with amd modules.
// to import using requirejs
require.config({
paths: {
jquery : '//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min',
binto : 'path/to/binto-js.js'
}
});
first you will need to call binto.setUrl
to point towards a database if you dont there will be a warning everytime you make a call or try to.
binto.setUrl('http://localhost:3000');
then you can use all the other methods
binto.users.all( function( err, res) {
console.log( arguments );
})
// or using requirejs
require(['binto'], function ( binto ) {
binto.users.all( function( err, res) {
console.log( arguments );
})
})
Right now the api is very focus on users but hopefully in the near future we will be expanding it to more then just users.
The main object that holds the classes
of the api.
this is a function that allows you to set what api endpoint you want to run the sdk against. eg. http://localhost:3000/api/v0/
Currently the only class in the api. Harbors many endpoints.
Create a user, takes two params: email, password
. The api responds with a error or success. If response is successful api will return user
key with the users session_token
. The sdk will hold onto the users session_token
and use it with any new calls made.
binto.users.create({
email : 'test@example.com',
password : '123456'
}, function ( err, res ) {
if ( err ) console.warn( err );
console.log('user created', res.user );
})
Very similair to user create, takes two params: email, password
. The api responds with a error or success. If response is successful api will return user
key with the users session_token
. The sdk will hold onto the users session_token
and use it with any new calls made.
binto.users.login({
email : 'test@example.com',
password : '123456'
}, function ( err, res ) {
if ( err ) console.warn( err );
console.log('user logged in', res.user );
})
Gets a list of all current memebers that have signed up through system.
binto.users.get(function ( err, res ) {
if ( err ) console.warn( err );
console.log('list of users', res.users );
})
Update a users profile data, one parameter is required: id
. The api responds with a error or success. Requires user to have session_token
before usage.
binto.users.update({
id : '123',
name : 'Bob Hope'
}, function ( err, res ) {
if ( err ) console.warn( err );
console.log('user updated', res.user );
})
Shows a users profile data, one parameter is required: id
. The api responds with a error or success.
binto.users.show({
id : '123',
}, function ( err, res ) {
if ( err ) console.warn( err );
console.log('user', res.user );
})
Update a users card information, five parameters are required: id, card_number, card_cvc, card_exp_month, card_exp_year
. The api responds with a error or success. Requires user to have session_token
before usage.
binto.users.updateCard({
id : '123',
card_number : '4242424242424242',
card_cvc : '123',
card_exp_month : '03',
card_exp_year : '20'
}, function ( err, res ) {
if ( err ) console.warn( err );
console.log('card updated', res );
})
Checkin user, one parameters is required: id
. The api responds with a error or success.
binto.users.checkin({
id : '123'
}, function ( err, res ) {
if ( err ) console.warn( err );
console.log('checkedin', res );
})
Send an email to reset password, one parameters is required: email
. The api responds with a error or success.
binto.users.resetPassword({
email : 'bob@example.com'
}, function ( err, res ) {
if ( err ) console.warn( err );
console.log('reset requested', res );
})
more documentation can be found at riversideio/binto-api