Skip to content

riversideio/binto-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 

Repository files navigation

binto-js

This is a simple wrapper for the binto-api, so the api is alot easier to interface with in frontend applications.

Requirements

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'
    }
});

To Use

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 );	
	})
})

Api

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.

binto

The main object that holds the classes of the api.

binto.setUrl(<api_url>)

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/

binto.users

Currently the only class in the api. Harbors many endpoints.

users.create

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 : '[email protected]',
	password : '123456'
}, function ( err, res ) {
	if ( err ) console.warn( err );
	console.log('user created', res.user );
})
users.login

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 : '[email protected]',
	password : '123456'
}, function ( err, res ) {
	if ( err ) console.warn( err );
	console.log('user logged in', res.user );
})
users.read

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 );
})
users.update

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 );
})
users.show

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 );
})
users.updateCard

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 );
})
users.checkin

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 );
})
users.resetPassword

Send an email to reset password, one parameters is required: email. The api responds with a error or success.

binto.users.resetPassword({
	email : '[email protected]'
}, function ( err, res ) {
	if ( err ) console.warn( err );
	console.log('reset requested', res );
})

more documentation can be found at riversideio/binto-api

About

A simple wrapper for Riverside.io's Api

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published