1.0.2 • Published 7 years ago

starbucks-api v1.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

Starbucks

A Javascript interface to the (private) Starbucks ordering API

Installing

Using npm:

$ npm install starbucks-api

Usage

Creating an instance

Once you've obtained your client_id, client_secret, you can create an instance and authenticate yourself:

const Client = require('starbucks-api');
const sbux = new Client('<client id>', '<client secret>');

sbux.authenticate('<username>', '<password>').then(result => {
	console.log(result.access_token);
});

Example

Every method on the client returns a promise, so they can be chained together. You can order stuff, like this:

const Client = require('starbucks-api');
const Bluebird = require('bluebird');

const sbux = new Client('<client id>', '<client secret>');

sbux.authenticate('<username>', '<password>').then(result => {
	return Bluebird.props({
		stores: sbux.nearby_stores(),
		last_order: sbux.last_order()
	}).then(result => {
		const new_cart = sbux.convert_order_to_cart(result.last_order);
		return sbux.price_order(result.stores[0].storeNumber, new_cart);
	}).then(priced => {
		return sbux.cards().then(cards => {
			return sbux.place_order(priced, cards[0].cardId);
		});
	}).then(result => {
		console.log(result);
	}).catch(err => {
		console.log('Something went wrong!', err);
	});
});

License

MIT