0.1.1 • Published 12 years ago

api-node v0.1.1

Weekly downloads
5
License
-
Repository
github
Last release
12 years ago

Ordr.in Node Library

About

A node library for the ordr.in API
See full API documantation at http://ordr.in/developers Also check out a working demo of all the api calls by running demo.js

Installation

The simplest way to install is with npm:

Usage

Initialization

Note that for the Urls https:// and the trailing / are all implied. DO NOT include them in the Url strings. The ordr.in API only supports https requests.

Callbacks

Because node is async every function call you make to the ordrin api includes a callback. This will be called when the api has finished your request. The format of this callback is always the same.
It takes two parameters: error and data.
If there's no error than error will be false, otherwise it will be an object.
Data is an object containing the data returned from the ordr.in api as described in the API documentation located at http://ordr.in/developers.

Example function callback:

Data Structures

The following classes are part of the library and are used whenever you need to pass an address, credit card, user, tray item, or tray to a library function.

You can create an object of one of these classes like so:

Validation

Each of the above Data Structers throw errors if you pass invalid values to their constructors. The errors are children of the javascript Error class, and include the additional property fieldErrors. This describes the different validation errors that occured. Example

User API

Order API

The Order API includes the ability to create a new user when you place the order. If you want to do that just pass in the new user's login credentials in the user object, and set createUser to true.

If you don't want the order to be associated with a user account then pass in false as the password inside the user object, and setCreateUser to false.