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

phaxio

v1.0.0

Published

Send faxes with the Phaxio API

Downloads

1,516

Readme

node-phaxio

Send faxes with Phaxio. It's completely asynchronous.

If you perfer a promised based api, take a look at our fork phaxio-promise

Installation

npm install phaxio

Usage overview

var Phaxio = require('phaxio'),
  phaxio = new Phaxio('e222........................', '62e5........................'),
  callback = function(err,data){console.log(data);};

phaxio.sendFax({
	to: '13165555555',
  string_data: 'Faxing from Node.js',
  string_data_type: 'text'
},callback);

Response

{ success: true,
  message: 'Retrieved fax successfully',
  data:
   { id: '111111',
     num_pages: '0',
     cost: 0,
     direction: 'sent',
     status: 'queued',
     is_test: 'true',
     requested_at: 1344829113,
     recipients: [ { number: '13165555555', status: 'queued' } ]
   }
}

Constructor

new Phaxio(key, secret);

Returns a phaxio object with your keys set on the object.

Methods

phaxio.sendFax(options, callback);

opt = {
  // always required can be an array of a single string
  to = ['xxxxxxxx', 'xxxxxxxxx'],
  // one of these is required
  filenames = ['path','path','path'],
  string_data = 'String of data for phaxio to parse'
  //optional
  string_data_type: '',
  batch: "and othe phaxio options"
}

phaxio.sendFax({
    to: '13165555555', 
    filenames: ['coverletter.doc', 'resume.pdf']
  }, function(err,res) {
  console.log(res);
});

phaxio.sendFax({
  to: '13165555555',
  string_data: 'http://www.google.com/',
  string_data_type: 'url'
});

var batchID;
phaxio.sendFax({
    to: ['13165555555', '19135555555'], 
    filenames: 'my-cat.jpg', 
    batch: true 
  }, function(err,res) {
  if(res.batchId){
    batchId = res.batchId;
  }
});

phaxio.cancelFax(faxId, callback)

Cancels the fax faxId

phaxio.cancelFax('123456', function(err, res) {
  console.log(res);
});

phaxio.faxStatus(faxId, callback)

Returns the status of faxId

phaxio.faxStatus('123456', function(err, res) {
  console.log(res);
});

phaxio.fireBatch(batchId, callback)

Fires the batch batchId

phaxio.fireBatch(batchId);

phaxio.closeBatch(batchId, callback)

Closes the batch batchId

phaxio.closeBatch('123456');

phaxio.provisionNumber(options, callback);

Provisions a number in area code area_code

phaxio.provisionNumber({
    area_code: '212',
    callback_url: 'http://localhost/'
  }, function(res) {
  console.log(res);
});

phaxio.releaseNumber(number, callback)

Releases the number number

phaxio.releaseNumber('8475551234', function(err, res) {
  console.log(res);
});

phaxio.numberList([options,] callback)

Returns user phone numbers matching optional params area_code or number

phaxio.numberList(function(err, res) {
  console.log(res);
});

phaxio.numberList({ area_code: '847' }, function(err, res) {
  console.log(res);
});

phaxio.accountStatus(callback)

Returns the account status

phaxio.accountStatus(function(err, res) {
  console.log(res);
});

phaxio.testReceive(options, callback)

Simulates receiving a fax containing the PhaxCode in filename with optional params from_number and to_number

phaxio.testReceive({filenames: 'PhaxCode.pdf'}, function(err, res) {
  console.log(res);
});

phaxio.testReceive({
    from_number: '3165555555',
    to_number: '9135555555',
    filenames: 'PhaxCode.pdf'
  }, function(err, res) {
  console.log(res);
});

phaxio.attachPhaxCodeToPdf(options, callback)

Returns a PDF of filenames with a PhaxCode at the x,y location specified with optional params metadata and page_number

phaxio.attachPhaxCodeToPdf({
    filenames: 'resume.doc',
    x:0,
    y:5
  },function(err, buffer) {
    fs.writeFile(path.join(__dirname, 'resume-with-PhaxCode.pdf'), buffer, 'binary');
});

phaxio.attachPhaxCodeToPdf({
    filenames:'kittens.pdf',
    x:5,
    y:25,
    metadata: 'Fax with kittens', 
    page_number: 5
  }, function(err, buffer) {
    fs.writeFile(path.join(__dirname, 'kittens-with-PhaxCode.pdf'), buffer, 'binary');
});

phaxio.createPhaxCode([options,] callback)

Creates a new PhaxCode with optional metadata param and returns the URL or returns a PDF if optional redirect param is true

phaxio.createPhaxCode(function(err, res) {
  console.log(res);
});

phaxio.createPhaxCode({ metadata: 'Awesome', redirect: true }, function(err, buffer) {
  fs.writeFileSync(path.join(__dirname, 'Awesome-PhaxCode.pdf'), buffer, 'binary');
});

phaxio.getHostedDocument(options, callback)

Returns the hosted document name with a basic PhaxCode or custom PhaxCode if metadata is set

	phaxio.getHostedDocument({name:'order-form'}, function(err, buffer) {
	  fs.writeFileSync(path.join(__dirname, 'order-form.pdf'), buffer, 'binary');
	});

	phaxio.getHostedDocument({
      name:'order-form', 
      metadata: 'Referred by Chad Smith'
    }, function(err, buffer) {
	  fs.writeFileSync(path.join(__dirname, 'order-form-with-referral-code.pdf'), buffer, 'binary');
	});

phaxio.faxFile(options, callback)

Returns the thumbnail or PDF of fax requested, optional type specifies _p_df (default), _s_mall or _l_arge thumbnail

phaxio.faxFile({id:'123456'}, function(err, buffer) {
  fs.writeFileSync(path.join(__dirname, 'fax-123456.pdf'), buffer, 'binary');
});

phaxio.faxFile({
    id:'123456',
    type:'l'
  }, function(err, buffer) {
  fs.writeFileSync(path.join(__dirname, '123456.jpg'), buffer, 'binary');
});

TODO

See the issue tracker for more.

Author

Chad Smith ([email protected]). Francis Gulotta (rbrtr.com)

License

This project is UNLICENSED and not endorsed by or affiliated with Phaxio.