 
   request options
   .promise()
-  .then ({ statusCode }) -> notificationsApi.success message.JobId, statusCode
+  .tap ({ statusCode }) -> emitter.emit "success", { message, statusCode }
   .catch ({ statusCode, error }) ->
     throw { statusCode, error } unless dequeueCount >= MAX_DEQUEUE_COUNT
-    notificationsApi.fail message.JobId, statusCode, error
+    emitter.emit "failed", { message, statusCode, error }

    headers: _getHeaders HeadersForRequest
  }, _.isUndefined

module.exports = (generateOptions) -> ({ message, meta: { dequeueCount }}) ->
  messageOptions = _cleanOptions message
  notificationsApi = new NotificationsApi messageOptions.headers["Authorization"]

request = require("request-promise")
Promise = require("bluebird")
_ = require("lodash")
EventEmitter = require("events").EventEmitter
notificationsApi = null

_getHeaders = (headers) ->
  _(headers)
