Git Product home page Git Product logo

uShip

A uShip API wrapper for Node.js. See the API documentation at https://developer.uship.com/docs

Installation

npm install uship

Testing

Get an API key from your settings page: https://developer.uship.com/apps/mykeys. You may need to contact [email protected]. See: https://developer.uship.com/docs.

Copy config.json.sample to config.json and update the file with your account settings.

npm i -g mocha
npm test

Usage

The module wraps the api and returns when.js promises.

Estimate:

var uShip = require("uship");
var uship = new uShip(API_KEY, API_SECRET, USHIP_USERNAME, USHIP_PASSWORD);
var data = {
  route: {
    items: [
      {
        address: {
          postalCode: "78704",
          country: "US"
        }
      },
      {
        address: {
          postalCode: "85704",
          country: "US"
        }
      }
    ]
  },
  items: [
    {
      commodity: "CarsLightTrucks",
      year: "1998",
      makeName: "Ford",
      modelName: "Ranger"
    }
  ]
};
uship.estimate(data).then(function(result){
  console.log(JSON.stringify(result));
});

/*

Outputs: 

{
   "route":{
      "distance":{
         "kilometers":1445.1873,
         "label":"898 mi.",
         "shortLabel":"898 mi."
      },
      "items":[
         {
            "address":{
               "majorMunicipality":"Austin",
               "postalCode":"78704",
               "stateProvince":"TX",
               "stateProvinceLabel":"Texas",
               "country":"US",
               "countryLabel":"United States",
               "latitude":30.244144,
               "longitude":-97.76286,
               "label":"Austin, TX",
               "shortLabel":"Austin, TX"
            }
         },
         {
            "address":{
               "majorMunicipality":"Tucson",
               "postalCode":"85704",
               "stateProvince":"AZ",
               "stateProvinceLabel":"Arizona",
               "country":"US",
               "countryLabel":"United States",
               "latitude":32.32818,
               "longitude":-110.98608,
               "label":"Tucson, AZ",
               "shortLabel":"Tucson, AZ"
            }
         }
      ]
   },
   "price":{
      "value":631.21,
      "label":"$631.21",
      "shortLabel":"$632"
   }
}
*/

RateRequest:

var shipmentDetails = {
  route: {
    items: [
      {
        address: {
          postalCode: "78703",
          country: "US"
        },
        timeFrame: {
            earliestArrival: "2015/07/07",
            latestArrival: "2015/07/07",
            timeFrameType: "on"
        }
      },
      {
        address: {
            postalCode: "78653",
            country: "US"
        },
        timeFrame: {
            earliestArrival: "2015/07/10",
            latestArrival: "2015/07/10",
            timeFrameType: "on"
        }
      }
    ]
  },
    items: [
      {
        commodity: "CarsLightTrucks",
        year: "2011",
        makeName: "Ford",
        modelName: "Escape",
        unitCount: 1,
        isRunning: true,
        isConvertible: true,
        isModified: true
      }
    ],
  thirdPartyId: ""
};

uShip.rateRequest(shipmentDetails).then(function (result) {
    console.log(result.location);
})

/* Output
Location Header: https://api.uship.com/v2/rateRequests/rateRequestID/rates
*/

Supported Methods

Shipping Price Estimates (API Documentation)

Create Rate Request (API Documentation)

  • uShip::estimate(data)
  • uShip::rateRequest(data)

Todo

  • Other methods
  • Extend documentation

uShip.com's Projects

assets-webpack-plugin icon assets-webpack-plugin

Webpack plugin that emits a json file with assets paths (mpost: see custom-manifest branch)

babel-plugin-dev icon babel-plugin-dev

Use Babel to replace "__DEV__" keyword with "process.env.NODE_ENV !== 'production'"

backstage icon backstage

uShip fork. Backstage is an open platform for building developer portals.

compat_resource icon compat_resource

Cookbook (+ gem) to bring some features from future Chef to earlier versions

effortless icon effortless

Automated best practices for Chef Infra and Chef InSpec

hello_uship icon hello_uship

Example hello world app using .NET Core and Habitat

interstellar icon interstellar

Simple and lightweight Functional Reactive Coding in Swift for the rest of us

nhibernateunitofwork icon nhibernateunitofwork

An automatic session and transaction management tool for short-lived database interactions.

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.