How to use shippo - 4 common examples

To help you get started, we’ve selected a few shippo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github reactioncommerce / reaction / imports / plugins / included / shipping-shippo / server / methods / shippoapi.js View on Github external
run({ apiKey }) {
    const shippoObj = new Shippo(apiKey);
    shippoObj.set("version", "2016-10-25");
    let allCarriers = [];

    // recursively fetch carriers because shippo returns paginated results
    function fetchCarriers() {
      try {
        const response = Meteor.wrapAsync(shippoObj.carrieraccount.list, shippoObj.carrieraccount)();
        allCarriers = allCarriers.concat(response.results);

        if (!response.next) {
          response.results = allCarriers;
          return response;
        }
        // the Shippo module uses "createFullPath" to form the url for the request
        // https://github.com/goshippo/shippo-node-client/blob/master/lib/Resource.js#L40-L48
        // hence we're passing the next url in this way
github reactioncommerce / reaction / imports / plugins / included / shipping-shippo / server / methods / shippoapi.js View on Github external
run({ apiKey }) {
    const shippoObj = new Shippo(apiKey);
    shippoObj.set("version", "2016-10-25");
    const getAddressListFiber = Meteor.wrapAsync(shippoObj.address.list, shippoObj.address);
    try {
      const addressList = getAddressListFiber();

      return addressList;
    } catch (error) {
      Logger.error(error.message);
      throw new Meteor.Error("server-error", error.message);
    }
  }
});
github reactioncommerce / reaction / imports / plugins / included / shipping-shippo / server / methods / shippoapi.js View on Github external
run({ rateId, apiKey }) {
    const shippoObj = new Shippo(apiKey);
    shippoObj.set("version", "2016-10-25");

    const createTransactionFiber = Meteor.wrapAsync(shippoObj.transaction.create, shippoObj.transaction);
    try {
      const transaction = createTransactionFiber({
        rate: rateId,
        label_file_type: "PDF",
        async: false
      });

      if (transaction.object_status !== "SUCCESS") {
        const error = transaction.messages[0].text;
        Logger.error(error);
        throw new Meteor.Error("server-error", error);
      }
github reactioncommerce / reaction / imports / plugins / included / shipping-shippo / server / methods / shippoapi.js View on Github external
run({ shippoAddressFrom, shippoAddressTo, shippoParcel, purpose, apiKey, carrierAccounts }) {
    const shippoObj = new Shippo(apiKey);
    shippoObj.set("version", "2016-10-25");

    const createShipmentFiber = Meteor.wrapAsync(shippoObj.shipment.create, shippoObj.shipment);
    try {
      const shipment = createShipmentFiber({
        object_purpose: purpose,
        address_from: shippoAddressFrom,
        address_to: shippoAddressTo,
        parcel: shippoParcel,
        carrier_accounts: carrierAccounts,
        async: false
      });

      return shipment;
    } catch (error) {
      Logger.error(error.message);

shippo

A node client for connecting with over 20 shipping carriers and consolidators via a single integration using Shippo API. Support for shipping rates, buying and printing labels, tracking as well as some carrier specific functionality such as signature requ

MIT
Latest version published 2 years ago

Package Health Score

61 / 100
Full package analysis

Popular shippo functions