Get your salad from https://order.sweetgreen.com directly from Emacs
Emacs Lisp
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
el-get
melpa
.gitignore
README.org
sweetgreen.el
sweetgreen.gif
sweetgreen.png

README.org

Sweetgreen.el

https://cdn.rawgit.com/syl20bnr/spacemacs/442d025779da2f62fc86c2082703697714db6514/assets/spacemacs-badge.svg

**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.

Usage?

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.

sweetgreen.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.

Functions & macros

Interactive Functions

sweetgreen

(sweetgreen ARGS)

Order salad from http://sweetgreen.com

sweetgreen//auth

(sweetgreen//auth &optional USERNAME PASSWORD)

Authenticate USERNAME with PASSWORD to sweetgreen and get all cookies

sweetgreen/confirm-product

(sweetgreen/confirm-product PRODUCT)

Build prompt with random pun and interactively confirm order

sweetgreen/helm-restaurants

(sweetgreen/helm-restaurants ZIP_CODE)

Helm Interface to select Sweetgreen Restaurants

Internal Functions

=>

(=> ALIST &rest KEYS)

Accessor that makes it easy to traverse nested alists

sweetgreen//add-to-cart

(sweetgreen//add-to-cart PRODUCT)

Add PRODUCT to CURR-BASKET and to the online Shopping Cart

sweetgreen//cancel-item

(sweetgreen//cancel-item ID)

Cancel Item with ID

sweetgreen//cancel-orders

(sweetgreen//cancel-orders ORDER)

Cancel all items from ORDER

sweetgreen//checkout

(sweetgreen//checkout BASKET WANTED_TIME)

Checkout BASKET to be picked up at WANTED_TIME

sweetgreen//fetch-auth-cookie

(sweetgreen//fetch-auth-cookie USERNAME PASSWORD)

Login to get a session cookie

sweetgreen//fetch-basket

(sweetgreen//fetch-basket ORDER-ID)

Get CURR-BASKET out of ORDER-ID

sweetgreen//fetch-csrf-token

(sweetgreen//fetch-csrf-token)

Parse CSRF-Token out of Sweetgreen’s Homepage

sweetgreen//get-menu

(sweetgreen//get-menu RESTAURANT_ID)

Get the MENU available at RESTAURANT_id

sweetgreen//get-restaurants

(sweetgreen//get-restaurants ZIP_CODE)

Get Restaurants alist out of your zip code

sweetgreen//helm-select-time

(sweetgreen//helm-select-time ORDER)

Select time to pickup order

sweetgreen//logout

(sweetgreen//logout CURR-USER)

Logout CURR-USER and reset Session Cookie to nil.

sweetgreen//make-helm-menu-sources

(sweetgreen//make-helm-menu-sources RESTAURANT_ID)

Sources for SWEETGREEN/HELM-MENU

sweetgreen//order-product

(sweetgreen//order-product PRODUCT)

Contact Sweetgreen server to order product

sweetgreen/helm-menu

(sweetgreen/helm-menu RESTAURANT_ID)

Helm Interface to select Items from the Menu of a Sweetgreen Restaurant

Macros

Variables

Customizable Variables

sweetgreen–password

Sweetgreen Account Password

sweetgreen–username

Sweetgreen Accounr Username

Internal Variables

sweetgreen–available-times

Lis of times for current order

sweetgreen–cookie-regexp

Regular expression to get the Session ID from the response’s headers

sweetgreen–cookie-string

Cookies for http://orders.sweetgreen.com

sweetgreen–csrf-token

CSRF Token for http://orders.sweetgreen.com

sweetgreen–csrf-token-regexp

Regular Expression used to grab the CSRF Token from the index page.

sweetgreen–curr-basket

Current Basket or Shopping Cart

sweetgreen–curr-basket-id

Current Basket or Shopping Cart ID

sweetgreen–curr-order-id

Last order (product added to cart) we’ve done

sweetgreen–curr-restaurant

Current Restaurant

sweetgreen–curr-user

Current logged in USER

sweetgreen–items-alist

Items available in the menu for the current RESTAURANT

sweetgreen–menu-alist

Menu for Current restaurant

sweetgreen–products-alist

Menu for Current restaurant

sweetgreen–restaurants-alist

Nearby Restaurants alist