Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

printnode-client

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

printnode-client

Cloud printing using PrintNode API

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
489
increased by3.38%
Maintainers
1
Weekly downloads
 
Created
Source

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

FAQs

Package last updated on 09 Dec 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc