**UPDATE: This reached the front page of HackerNews (thank you!): time for appropiate documentation**
Emacs companion to order salads without leaving your editor.
This idea evolved from a joke a friend told me that goes like: “You spend everyday in your editor, and you eat salad everyday, you might as well eat it with Emacs”.
I took that too seriously and created this package. It does authentication and orders the salad you tell it to order for you, I had to reverse engineer the Internal API from Sweetgreen to make this work but it was worth it.
Install this package either by using MELPA or copying the sweetgreen.el
file
and putting it into your load path. Then to have it it’s as simple as:
(require 'sweetgreen)
(global-set-key (kbd "C-c M-s") 'sweetgreen)
You may of course change the keybinding to whatever you like, or just do M-x
sweetgreen
as I do in the following GIF.
Once you put your username and password once, it will not ask for it again
during your emacs session, of course you can customize the variables
sweetgreen--username
and sweetgreen--password
.
(sweetgreen ARGS)
Order salad from http://sweetgreen.com
(sweetgreen//auth &optional USERNAME PASSWORD)
Authenticate USERNAME with PASSWORD to sweetgreen and get all cookies
(sweetgreen/confirm-product PRODUCT)
Build prompt with random pun and interactively confirm order
(sweetgreen/helm-restaurants ZIP_CODE)
Helm Interface to select Sweetgreen Restaurants
(=> ALIST &rest KEYS)
Accessor that makes it easy to traverse nested alists
(sweetgreen//add-to-cart PRODUCT)
Add PRODUCT to CURR-BASKET and to the online Shopping Cart
(sweetgreen//cancel-item ID)
Cancel Item with ID
(sweetgreen//cancel-orders ORDER)
Cancel all items from ORDER
(sweetgreen//checkout BASKET WANTED_TIME)
Checkout BASKET to be picked up at WANTED_TIME
(sweetgreen//fetch-auth-cookie USERNAME PASSWORD)
Login to get a session cookie
(sweetgreen//fetch-basket ORDER-ID)
Get CURR-BASKET out of ORDER-ID
(sweetgreen//fetch-csrf-token)
Parse CSRF-Token out of Sweetgreen’s Homepage
(sweetgreen//get-menu RESTAURANT_ID)
Get the MENU available at RESTAURANT_id
(sweetgreen//get-restaurants ZIP_CODE)
Get Restaurants alist out of your zip code
(sweetgreen//helm-select-time ORDER)
Select time to pickup order
(sweetgreen//logout CURR-USER)
Logout CURR-USER and reset Session Cookie to nil
.
(sweetgreen//make-helm-menu-sources RESTAURANT_ID)
Sources for SWEETGREEN/HELM-MENU
(sweetgreen//order-product PRODUCT)
Contact Sweetgreen server to order product
(sweetgreen/helm-menu RESTAURANT_ID)
Helm Interface to select Items from the Menu of a Sweetgreen Restaurant
Sweetgreen Account Password
Sweetgreen Accounr Username
Lis of times for current order
Regular expression to get the Session ID from the response’s headers
Cookies for http://orders.sweetgreen.com
CSRF Token for http://orders.sweetgreen.com
Regular Expression used to grab the CSRF Token from the index page.
Current Basket or Shopping Cart
Current Basket or Shopping Cart ID
Last order (product added to cart) we’ve done
Current Restaurant
Current logged in USER
Items available in the menu for the current RESTAURANT
Menu for Current restaurant
Menu for Current restaurant
Nearby Restaurants alist