bitpay / node-bitpay-client

A Node.js module and command line client for interacting with BitPay's Cryptographically Secure API
102 stars 95 forks source link

FEATURE: Invoice Events #56

Closed tacticalchihuahua closed 9 years ago

tacticalchihuahua commented 9 years ago

This PR includes a new a constructor for EventParser which is a stream.Transform. Since all of the RESTClient "verb" methods (get(), put(), post(), and delete()) return a stream.Readable, this constructor can be used to pipe calls to /events through and use EventEmitter style handling.

var events = client.get('events', buspass).pipe(new bitpay.EventParser());

events.on('payment', function(invoice) {
  console.log('Invoice Status: ' + invoice.status);
});

This should effecctively close #55

See the included example and tests for more details. Also addresses Pieter's requested doc updates.

@pnagurny or @martindale - either of you have time today to review, test, and merge? Package version has been bumped and ready to publish to NPM.

martindale commented 9 years ago

This is awesome, nice work. Thanks for including tests!

tacticalchihuahua commented 9 years ago

@martindale thank you kindly - npm publish at will