Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 .gitattributes
Octocat-spinner-32 .gitignore
Octocat-spinner-32 Jakefile
Octocat-spinner-32 README.md
Octocat-spinner-32 api.js
Octocat-spinner-32 api.min.js
README.md

JavaScript API Wrapper

This JavaScript exposes the parts of the Ordr.in API that do not require user authentication and puts the API into ordrin.api. Every API function takes a callback function as the last argument, and finishes by calling callback(error, data)

It is initialized with ordrin.restaurantUrl (the URL to which restaurant API requests should be sent) and ordrin.orderUrl (the URL to which order API requests should be sent).

Data Classes

Address

Represents a street address for delivery and billing

new Address(addr, city, state, zip, phone, [addr2])

Fields:

  1. addr: The street address
  2. addr2: The second line of the street address
  3. city: The city the address is in
  4. state: The state the address is in
  5. zip: The zip code of the city
  6. phone: The phone number associated with the address

CreditCard

Represents all of the useful information associated with a credit card

new CreditCard(name, expiryMonth, expiryYear, billAddress, number, cvc)

Fields:

  1. name: The name on the card
  2. expriyMonth: The month in which the card expires
  3. expiryYear: The year in which the card expires
  4. billAddress: The billing address
  5. number: The credit card number
  6. cvc: The card verification code

Option

Represents an option on an item in the tray

new Option(id, [name], [price])

Fields:

  1. id: The menu id of the option
  2. name: The name of the option
  3. price: The price of the option in cents
  4. totalPrice: the price of the option multiplied by the item quantity in dollars

TrayItem

Represents an item in the tray

new TrayItem(id, quantity, options, [name], [price])

Fields:

  1. trayItemId: The tray id of the item (used for uniquely identifying items in the tray
  2. itemId: The menu id of the item
  3. itemName: The name of the item
  4. quantity: The selected quantity for the item in the tray
  5. options: The selected options for the item in the tray
  6. price: The base price of the item in cents
  7. quantityPrice: the price of the item (excluding options) in dollars

Methods:

  1. buildItemString(): Returns the part of the ordr.in API query string corresponding to this item
  2. hasOptionSelected(optionId): Returns true if this item has an option selected with this optionId and false otherwise
  3. getTotalPrice(): Returns the total price of this tray item, taking into account selected options and quantity

Tray

Represents a tray of food to be ordered.

new Tray([items])

Fields:

  1. items: A hash mapping tray item ids to items in the tray

Methods:

  1. addItem(item): Adds item to the tray
  2. removeItem(id): Removes the item with the tray id id from the tray
  3. buildTrayString(): Returns the part of the ordr.in API query string corresponding to the tray
  4. getSubtotal(): Returns the total price of all items in the tray

Restaurant API

This API is for retreiving information about restaurants. The documentation for the underlying API calls can be found at the Ordr.in Restaurant API documentation. All of these functions are in the restaurant object (ordrin.api.restaurant).

// Get the list of restaurants that will deliver to that address
getDeliveryList(dateTime, address, callback)

// Check whether the restaurant will deliver to that address at that
// time
getDeliveryCheck(restaurantId, dateTime, address, callback)

// Get the fee and tax for an order with the given price, as well as
// delivery check information
getFee(restaurantId, subtotal, tip, dateTime, address, callback)

// Get all information about the restaurant, including their menu
getDetails(restaurantId, callback)

Order API

This API is for placing orders. The documentation for the underlying API calls can be found at the Ordr.in Order API documentation. This function is in the order object (ordrin.api.order).

// Place an order
placeOrder(restaurantId, tray, tip, deliveryTime, firstName, lastName, address, creditCard, email, callback)
Something went wrong with that request. Please try again.