newgistics

npm install newgistics

XML attributes are marked with the @ tag, while body attributes are marked with the # tag. For example,

<Name id="12345">Lou</Name>

would convert to

{
    Name: {
        '@': { id: '12345' },
        '#': 'Lou'
    }
}

All requests/responses are JS objects.

Important note: The outermost collection identifier is not required. Your API key provided by Newgistics is required. Environment options are 'production' and 'staging'.

var newgistics = require('newgistics');

var gateway = newgistics.connect({
    environment: newgistics.Environments.staging,
    apiKey: '12421412121255115221512521'
});

Posting a new shipment

var orderData =  {
    Order: {
           '@': { orderID: '12345' },
        CustomerInfo: {
            FirstName: 'Lou',
            LastName: 'Seal',
            Address1: '24 Willie Mays Plaza',
            City: 'San Francisco',
            State: 'CA',
            Zip: '94107',
            Country: 'USA',
            Email: 'louseal@sfgiants.com'
        },
        OrderDate: '11/10/2013',
        Items: {
            Item: [
                {
                    SKU: '1000',
                    Qty: '1'
                }
             ]
        }
    }
}

gateway.shipments.post(orderData, function(err, res) {
    // ...
});

Searching for an existing shipment

gateway.shipments.search({ id: 100001 }, function(err, res) {
               // ...
});

Licensed under the BSD license.