lib/card.js
function (options, callback) {
    if (!options) {
      throw new Error('You must provide an options object to .');
    }
    
    if (!options.packName) {
      throw new Error('You must provide a pack name the card belongs to.');
    }
    
    if (!options.cardName) {
      throw new Error('You must provide a card name of the card to render.');
    }
    
    var packPath = Path.join(options.directory, 'hashdo-' + options.packName.replace('hashdo-', '')),
      cardFile = Path.join(packPath, options.cardName) + '.js';
    
    // check for card pack
    FS.stat(packPath, function (err) {
      if (!err) {

        // check for card
        FS.stat(cardFile, function (err) {
          if (!err) {

            // Remove card from cache to ease development by reloading from disk each time.
            if (process.env.NODE_ENV !== 'production') {
              delete require.cache[require.resolve(Path.join(packPath, options.cardName))];
            }

            var Card = require(Path.join(packPath, options.cardName));

            // If this card has a web hook function then let's call it.
            if (Card.webHook) {
              var DB = require('../index').db;

              Card.webHook(options.payload, function (err, urlParams, state) {
                if (!err) {
                  if (state) {
                    var cardKey = Utils.getCardKey('/' + options.packName + '/' + options.cardName + objectToQueryString(urlParams), process.env.CARD_SECRET),
                      firebaseUrl = 'card/' + cardKey;

                    if (Card.clientStateSupport && process.env.FIREBASE_URL) {
                      Firebase.set(firebaseUrl, state);
                    }

                    DB.getCardState(cardKey, null, function (err, currentCardState) {
                      DB.saveCardState(cardKey, Utils.deepMerge(true, true, currentCardState || {}, state));
                    });
                  }
                }

                callback && callback(null);
              });
            }
            else {
              // No web hook function.
              callback && callback('Web hook not available.');
            }
          }
          else {
            callback && callback('No card found.');
          }
        });
      }
      else {
        // No card pack.
        callback && callback('Pack not found.');
      }
    });
  }
function (options, callback) {
    if (!options) {
      throw new Error('You must provide an options object to .');
    }
    
    if (!options.packName) {
      throw new Error('You must provide a pack name the card belongs to.');
    }
    
    if (!options.cardName) {
      throw new Error('You must provide a card name of the card to render.');
    }
    
    var packPath = Path.join(options.directory, 'hashdo-' + options.packName.replace('hashdo-', '')),
      cardFile = Path.join(packPath, options.cardName) + '.js';
    
    // check for card pack
    FS.stat(packPath, function (err) {
      if (!err) {

        // check for card
        FS.stat(cardFile, function (err) {
          if (!err) {

            // Remove card from cache to ease development by reloading from disk each time.
            if (process.env.NODE_ENV !== 'production') {
              delete require.cache[require.resolve(Path.join(packPath, options.cardName))];
            }

            var Card = require(Path.join(packPath, options.cardName));

            // If this card has a web hook function then let's call it.
            if (Card.webHook) {
              var DB = require('../index').db;

              Card.webHook(options.payload, function (err, urlParams, state) {
                if (!err) {
                  if (state) {
                    var cardKey = Utils.getCardKey('/' + options.packName + '/' + options.cardName + objectToQueryString(urlParams), process.env.CARD_SECRET),
                      firebaseUrl = 'card/' + cardKey;

                    if (Card.clientStateSupport && process.env.FIREBASE_URL) {
                      Firebase.set(firebaseUrl, state);
                    }

                    DB.getCardState(cardKey, null, function (err, currentCardState) {
                      DB.saveCardState(cardKey, Utils.deepMerge(true, true, currentCardState || {}, state));
                    });
                  }
                }

                callback && callback(null);
              });
            }
            else {
              // No web hook function.
              callback && callback('Web hook not available.');
            }
          }
          else {
            callback && callback('No card found.');
          }
        });
      }
      else {
        // No card pack.
        callback && callback('Pack not found.');
      }
    });
  }
function ( options , callback ) { if ( ! options ) { throw new Error ( 'You must provide an options object to .' ) ; } if ( ! options . packName ) { throw new Error ( 'You must provide a pack name the card belongs to.' ) ; } if ( ! options . cardName ) { throw new Error ( 'You must provide a card name of the card to render.' ) ; } var packPath = Path . join ( options . directory , 'hashdo-' + options . packName . replace ( 'hashdo-' , '' ) ) , cardFile = Path . join ( packPath , options . cardName ) + '.js' ; // check for card pack FS . stat ( packPath , function ( err ) { if ( ! err ) { // check for card FS . stat ( cardFile , function ( err ) { if ( ! err ) { // Remove card from cache to ease development by reloading from disk each time. if ( process . env . NODE_ENV !== 'production' ) { delete require . cache [ require . resolve ( Path . join ( packPath , options . cardName ) ) ] ; } var Card = require ( Path . join ( packPath , options . cardName ) ) ; // If this card has a web hook function then let's call it. if ( Card . webHook ) { var DB = require ( '../index' ) . db ; Card . webHook ( options . payload , function ( err , urlParams , state ) { if ( ! err ) { if ( state ) { var cardKey = Utils . getCardKey ( '/' + options . packName + '/' + options . cardName + objectToQueryString ( urlParams ) , process . env . CARD_SECRET ) , firebaseUrl = 'card/' + cardKey ; if ( Card . clientStateSupport && process . env . FIREBASE_URL ) { Firebase . set ( firebaseUrl , state ) ; } DB . getCardState ( cardKey , null , function ( err , currentCardState ) { DB . saveCardState ( cardKey , Utils . deepMerge ( true , true , currentCardState || { } , state ) ) ; } ) ; } } callback && callback ( null ) ; } ) ; } else { // No web hook function. callback && callback ( 'Web hook not available.' ) ; } } else { callback && callback ( 'No card found.' ) ; } } ) ; } else { // No card pack. callback && callback ( 'Pack not found.' ) ; } } ) ; }
Provides the functionality to call a card's web hook functionality and save the state.

@method webHook
@async
@param {Object}   options     Hooking options object.

directory: The directory where the pack and card code can be found.
packName: The pack name.
cardName: The card name.
payload: The values necessary to create new card state.

@param {Function} [callback]  Optional callback function to retrieve the card HTML.
Provides the functionality to call a card s web hook functionality and save the state .