Giter Club home page Giter Club logo

node-shipstation's Introduction

node-shipstation

A small node module that helps integrate your application with shipstation. There are still several API endpoints with shipstation that are not implemented. Feel free to fork and make pull requests, or add issues as you please.

Install

npm install node-shipstation

Usage

After having installed it, simply require it, set it up with your own apiKey and apiSecret, and start calling methods!

var shipstationAPI = require('node-shipstation');
var shipstation = new shipstationAPI(
  'apiKey',
  'apiSecret');

shipstation.callMethods();

Functions and responses

Functions Returns to callback Explanation
get (link, options, callback) callback(err, res, body) Base function for using get on shipstation API. Can be used if non-implemented API call needed.
put (link, data, callback) callback(err, res, body) Base function for using put on shipstation API. Can be used if non-implemented API call needed.
post (link, data, callback) callback(err, res, body) Base function for using post on shipstation API. Can be used if non-implemented API call needed.
del (link, options, callback) callback(err, res, body) Base function for using delete on shipstation API. Can be used if non-implemented API call needed.
addAccount (account, callback) callback(err, res, body) Registers a new account and generates an apiKey and apiSecret. account
getTags (callback) callback(err, res, body) Gets all tags in the account.
getCarriers ([options], callback) callback(err, res, body) Gets all carriers.
getCarrier (carrier_code, callback) callback(err, res, body) Gets a carrier by carrier_code.
addFunds ({carrierCode, amount}, callback) callback(err, res, body) Adds the specified amount of funds to the carrier by carrier_code.
getPackages (carrierCode, callback) callback(err, res, body) Gets all packages for the carrier by carrier_code.
getServices (carrierCode, callback) callback(err, res, body) Gets all services for the carrier by carrier_code.
getCustomers ([options], callback) callback(err, res, body) Gets all customers.
getCustomer (id, callback) callback(err, res, body) Gets a customer by id.
getOrders ([options], callback) callback(err, res, body) Gets all orders. options
getOrdersByTag ({orderStatus, tagId}, callback) callback(err, res, body) Gets all orders with the specified orderStatus and tagId.
getOrder (id, callback) callback(err, res, body) Gets an order by id.
addOrder (order, callback) callback(err, res, body) Adds an order. order
updateOrder (id, changes, callback) callback(err, res, body) Updates an order with the changes passed to the method.
deleteOrder (id, callback) callback(err, res, body) Deletes an order by id.
setOrderHold ({orderId, holdUntilDate}, callback) callback(err, res, body) Sets a hold on the specified order until the specified date string.
setLabelForOrder (label, callback) callback(err, res, body) Sets the label for the specified order. label
setOrderShipped (details, callback) callback(err, res, body) Sets the specified order as shipped. details
addTagToOrder ({orderId, tagId}, callback) callback(err, res, body) Adds the specified tag to the specified order.
removeTagFromOrder ({orderId, tagId}, callback) callback(err, res, body) Removes the specified tag from the specified order.
getProducts ([options], callback) callback(err, res, body) Gets all products.
getProduct (id, callback) callback(err, res, body) Gets a product by id.
getShipments ([options], callback) callback(err, res, body) Gets all shipments.
addShippingLabel (label, callback) callback(err, res, body) Creates a shipping label/shipment. label
getShippingRates (request, callback) callback(err, res, body) Gets shipping rates for the specified request. request
voidShippingLabel (id, callback) callback(err, res, body) Voids the specified shipping label/shipment.
getStores ([options], callback) callback(err, res, body) Gets all stores.
getStore (id, callback) callback(err, res, body) Gets a store by id.
updateStore (id, store, callback) callback(err, res, body) Updates the specified store. store
getStoreRefreshStatus (id, callback) callback(err, res, body) Gets the specified store's refresh status
refreshStore (id, callback) callback(err, res, body) Refreshes the specified store
deactivateStore (id, callback) callback(err, res, body) Deactivates the specified store
reactivateStore (id, callback) callback(err, res, body) Reactivates the specified store
getMarketplaces (callback) callback(err, res, body) Lists the marketplaces that can be integrated with ShipStation.
getWarehouses ([options], callback) callback(err, res, body) Get all warehouses.
getWarehouse (id, callback) callback(err, res, body) Gets a warehouse by id.
updateWarehouse (id, warehouse, callback) callback(err, res, body) Updates the specified warehouse. warehouse
addWarehouse (warehouse, callback) callback(err, res, body) Adds a new warehouse. warehouse

Helpers

node-shipstation has a few helpers that make it easier to make several different requests for the same target using chaining. Check the example below to see one in action. Operations will not be run in the order they are chained in

Helper Methods
carrier(id) addFunds(amount, callback) packages(callback) services(callback)
order(id) get(callback) delete(callback) hold(date, callback) update({changes}, callback) addTag(tagId, callback) removeTag(tagId, callback) shipped(data, callback) label(data, callback)
store(id) update(data, callback) status(callback) refresh(callback) deactivate(callback) reactivate(callback)

Examples

Getting An Order

shipstation.getOrder(12345, function(err, res, body){
  if(err) throw err;
  console.log('Got order');
  console.log(body);
});

Marking an Order Shipped

var orderShipped = {
  orderId: 12345,
  carrierCode: 'express_1',
  shipDate: '02/10/2015',
  trackingNumber: 'ZLU2342323',
  notifyCustomer: false,
  notifySalesChannel: false
}

shipstation.setOrderShipped(orderShipped, function(err, res, body){
  //Handle the callback.
});

Tag manipulation with Order Helper

var handler = function(err, res, body){
	console.log(body);
};

shipstation.order(12345)
	.addTag(9432, handler)
	.addTag(9554, handler)
	.removeTag(1233, handler);

node-shipstation's People

Contributors

justmaier avatar t3chguy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

node-shipstation's Issues

Please publish the 0.1.3 to npm

Thank you for the library.

Super frustrating thing happened.

I thought I was using the rate limiting functionality that's in the latest version, but turns out v0.1.1 which is on npm doesn't have the rate limiting functionality included. So, this whole time I was wondering why I was getting "Too many requests" from ShipStation.

Would you mind publishing the latest version to npm? It would really help a lot.

ES6 Promise compatibility

I think this would be a lot more useful if it was compatible with promises, so instead of passing in the callback directly, you'd pass it through .then(), this way it can be wrapped directly in a promise without having to implement promises into it directly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.