npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-metrc

v0.2.2

Published

Metrc REST API Node Wrapper

Downloads

5

Readme

Metrc Node Wrapper

This module helps you intregrate metrc REST APIs to your node project.

const  metrc = require("metrc"); 

metrc.config({
  sandbox:  true,
}); 
Create Merchant Object
 const merchant = new Merchant({
  licenseNo: "licenseNo",
  vendorkey: "vendor-key",
  userkey:"user-key"
 });
Check Merchant's Incoming Transfers
merchant.getIncomingTransfers(
  {
    lastModifiedEnd: "2020-08-18T06%3A30%3A00Z",
    lastModifiedStart: "2020-08-18T17%3A30%3A00Z",
  },
  function response(data, error) {
      if(error)
        throw error
    console.log(data);
  }
);
Check Merchant's Outgoing Transfers
merchant.getOutgoingTransfers(
  {
    lastModifiedEnd: "2020-08-18T06%3A30%3A00Z",
    lastModifiedStart: "2020-08-18T17%3A30%3A00Z",
  },
  function response(data, error) {
      if(error)
        throw error
    console.log(data);
  }
);
Check Merchant's Rejected Transfers
merchant.getRejectedTransfers(
  function response(data, error) {
      if(error)
        throw error
    console.log(data);
  }
);
Check Deliveries of a particular Transfer by Id
let transfer = merchant.getTransfer(1234);
merchant.getDeliveries(transfer, function (data, error) {
    if (error) {
      console.log(error)
    } else {
      console.log(data);
    }
});
Check Packages in a Delivery of a particular Transfer
//A merchant makes a transfer of Deliveries containing Packages to the customer

let delivery = merchant.getDelivery(34600);
merchant.getPackages(delivery, function (data, error) {
  if (error) {
    console.log(error)
  } else {
    console.log(data);
  }
});
Check Wholesale Packages in a Delivery of a particular Transfer
//A merchant makes a transfer of Deliveries containing wholesale Packages to the customer

const transfer = merchant.getTransfer(transferId);
const deliveries = transfer.getDelivery(deliveryId);
let wholesalePackages = delivery.getWholesalePackages();
Check Packages which requires labtest, in a Delivery of a particular Transfer
//A merchant makes a transfer of Deliveries containing Packages to the customer

let package = merchant.getPackage(98202);
merchant.getRequiredLabTestBatches(package, function (data, error) {
  if (error) {
    console.log(error)
  } else {
    console.log(data);
  }
});
Check Package states in a Delivery of a particular Transfer
//A merchant makes a transfer of Deliveries containing Packages to the customer
Delete External incoming transfer
merchant.deleteIncomingTransfer(12344, function (data, error) {
if (error) {
  console.log(error);
} else {
  console.log(data);
}

});

Check templates for transfers
//A merchant makes a transfer to a customer
merchant.getTemplates({
    lastModifiedEnd: "2020-08-18T06%3A30%3A00Z",
    lastModifiedStart: "2020-08-18T17%3A30%3A00Z",
  }, function (data, error) {
    if (error) {
      console.log(error)
    } else {
      console.log(data);
    }
  });
Check deliveries in a template
//A merchant makes a transfer to a customer
let template = merchant.getTransferTemplate();
merchant.getTransferTemplateDeliveries(template, function (data, error) {
    if (error) {
      console.log(error);
    } else {
      console.log(data);
    }
  });
Check Packages in a delivery in a template
//A merchant makes a transfer to a customer
let delivery = merchant.getDelivery(34600);
merchant.getPackages(delivery, function (data, error) {
  if (error) {
    console.log(error)
  } else {
    console.log(data);
  }
});
Check transfer types
//A merchant makes a transfer to a customer

let transfetTypes = merchant.getTransferTypes();
Get Active and Inactive sales receipts
/* set isActive flag to true for accessing active receipts and false for inactive*/
let isActive = true;
  merchant.getIncomingTransfers(
  {
    lastModifiedEnd: "2020-08-18T06%3A30%3A00Z",
    lastModifiedStart: "2020-08-18T17%3A30%3A00Z",
  },
  isActive,
  function response(data, error) {
      if(error)
        throw error
    console.log(data);
  }
);
Get receipt by Id
receiptId = 12345;
merchant.getSalesRecieptById(receiptId,
  function response(data, error) {
    if (error)
      throw error
    console.log(data);
  }
);
Create sales receipt
const transactionOne = new metrc.PostTransaction({
  PackageLabel: "ABCDEF012345670000010331",
  Quantity: 1.0,
  UnitOfMeasure: "Ounces",
  TotalAmount: 9.99
});

const transactionTwo = new metrc.PostTransaction({
  PackageLabel: "ABBBR012345670000010331",
  Quantity: 2.0,
  UnitOfMeasure: "Ounces",
  TotalAmount: 18.99
});

let transactionArray = [
  transactionOne,
  transactionTwo
]

/*Post sales receipt data*/
merchant.postSalesReceipt({
  SalesDateTime: "2016-10-04T16:44:53.000",
  SalesCustomerType: "Consumer",
  PatientLicenseNumber: null,
  CaregiverLicenseNumber: null,
  IdentificationMetho: null,
}, transactionArray, function (data, error) {
  if (error)
    throw error;
    console.log(data);
});

/*Put sales receipt data*/
merchant.putSalesReceipt({
  SalesDateTime: "2016-10-04T16:44:53.000",
  SalesCustomerType: "Consumer",
  PatientLicenseNumber: null,
  CaregiverLicenseNumber: null,
  IdentificationMetho: null,
}, transactionArray, function (data, error) {
  if (error)
    throw error;
    console.log(data);
});
Get plant by Id
const plantId = 23245;
merchant.getPlant(plantId,
function response(data, error) {
    if(error)
      throw error
  console.log(data);
});
Get plant by Label
const plantLabel = '';
merchant.getPlant(plantLabel,
function response(data, error) {
    if(error)
      throw error
  console.log(data);
});
Get Vegetative | flowering | onhold | inactive | additives plants
/** get vegetative plants => plantKey = 'vegetative'
*  get flowering plants => plantKey = 'flowering'
*  get plants that are on hold => plantKey = 'onhold'
*  get plants that are inactive  => plantKey = 'inactive'
*  get additives plants => plantKey = 'additives'
*/
const plantKey = 'vegetative';
merchant.getPlants(
  {
    lastModifiedEnd: "2020-08-18T06%3A30%3A00Z",
    lastModifiedStart: "2020-08-18T17%3A30%3A00Z",
  },
  plantKey,
  function response(data, error) {
      if(error)
        throw error
    console.log(data);
  }
);
Get plant growth phases
merchant.getPlantGrowthPhases(
    function response(data, error) {
        if(error)
          throw error
      console.log(data);
    }
  );
Get plant Additive types
merchant.getPlantAdditiveTypes(
    function response(data, error) {
        if(error)
          throw error
      console.log(data);
    }
  );
Get plant waste methods
merchant.getPlantWasteMethods(
  function response(data, error) {
      if(error)
        throw error
    console.log(data);
  }
);
Get plant waste reasons
merchant.getPlantWasteReasons(
  function response(data, error) {
      if(error)
        throw error
    console.log(data);
  }
);
Get a package by Id
const packageId = 41234;
merchant.getPackage(packageId,
  function (data, error) {
    if (error)
      throw error;
    console.log(data);
  });
Get a package by label
const packageLabel = "1AWFF011232022000002578";
merchant.getPackage(packageLabel,
  function (data, error) {
    if (error)
      throw error;
    console.log(data);
  });
Get Packages by active | onhold | inactive states
  /** 
  *  get active packages => plantKey = 'active'
  *  get packages that are on hold => plantKey = 'onhold'
  *  get inactive packages  => plantKey = 'inactive'
  */
const packageKey = "";
merchant.getPackages(
  {
    lastModifiedEnd: "2020-08-18T06%3A30%3A00Z",
    lastModifiedStart: "2020-08-18T17%3A30%3A00Z",
  },
  packageKey,
  function (data, error) {
    if (error)
      throw error;
    console.log(data);
  });
Get package adjustment reasons
  merchant.getPackageAdjustmentReasons(
  function (data, error) {
    if (error)
      throw error;
    console.log(data);
  });
  
Check Facilities

merchant.getFacilities(function response(data, error) { if (error) throw error; console.log(data); });