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

Shippo is a shipping API that connects you with [multiple shipping carriers](https://goshippo.com/carriers) (such as USPS, UPS, DHL, Canada Post, Australia Post, and many others) through one interface.

MIT
Latest version published 3 days ago

Package Health Score

78 / 100
Full package analysis

Popular shippo functions