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

printnode-client

v1.0.3

Published

Cloud printing using PrintNode API

Downloads

378

Readme

PrintNode-NodeJS

npm

Cloud Printing wrapper for the PrintNode API.

Installation

Install nodejs + npm.

Clone repo and install dependencies:

  // clone repo
  git clone https://github.com/miketownsend/PrintNode-NodeJS.git 

  // install dependencies
  cd PrintNode-NodeJS && npm install

Usage

Require and instantiate a client:

  var PrintNodeClient = require('~/path/to/printnode-client/index.js');
  var client = new PrintNodeClient({ api_key: "DUMMY_API_KEY", default_printer_id: 123456 });

Account Information

  // fetch metadata about account
  client.whoami().then(console.log);

  // fetch account credits
  client.credits().then(console.log);

Computers

  // fetch computers
  client.fetchComputers().then(...);

Printers

  // Fetch printers
  client.fetchPrinters().then(...);

  // Fetch printers for a specific computer
  client.fetchPrinters(computer_id).then(...);

  // Fetch a specific printer (returns array of one)
  client.fetchPrinters(printer_id).then(...);

  // Fetch a specific printer from a computer
  client.fetchPrinters(computer_id, printer_id).then(...);

PrintJobs

Fetching:

  // Fetch all print jobs
  client.fetchPrintJob().then(...);

  // Fetch a specific print jobs (returns array of one)
  client.fetchPrintJob(printjob_id).then(...);

  // Fetch all print jobs for a specific printer
  client.fetchPrintJobsForPrinter(printer_id).then(...);

  // Fetch a specific printer from a printer (returns array of one)
  client.fetchPrintJobForPrinter(printer_id, printjob_id).then(...);

Creating Full options for creation of PrintJobs are available in the API documentation.

  // Create a print job
  var options = {
    title: "Printing example 1",
    source: "PrintNode-NodeJS", // defaults to this
    content: "https://app.printnode.com/testpdfs/4x6_combo_vertical_ol829.pdf",
    contentType: "pdf_uri"
  };
  client.createPrintJob(options).then(console.log); // returns printjob id only

  // Create a print job from a local PDF file
  var options = {
    title: "Printing example 2",
    filename: "./test/examples/label.pdf"
  };
  client.createPrintJobFromPdf().then(...);


  // Create a print job from a local raw print file
  var options = {
    title: "Printing example 2",
    filename: "./test/examples/label.pdf"
  };
  client.createPrintJobFromRaw().then(...);

Scales

  // Retrieves a single scale by computer_id, device_name and device_number.
  client.fetchScale(computer_id, device_name, device_number).then(...);

  // Retrieves an array of scales for a specific computer 
  client.fetchScalesForComputer(computer_id).then(...);

  // Retrieves an array of scales for a specific computer with a specific device name
  client.fetchScalesForComputerByDeviceName(computer_id, device_name).then(...);

Testing

The tests in place at the moment are simply testing for positive responses, they are not looking at the detail of the response.

Requirements:

  • a live account. This should be setup on printnode.com
  • the printnode client to be installed and logged in on that computer
  • at least one active printer to be available on that computer, you can use a pdf printer to avoid printing during testing CutePDF

Running the tests

  1. Change the API_KEY and ACTIVE_PRINTER_ID in test/live_test.js
  2. Run npm test