mirror of
https://github.com/Hopiu/webapi-eca.git
synced 2026-03-17 06:20:23 +00:00
31 lines
656 B
CoffeeScript
31 lines
656 B
CoffeeScript
###
|
|
Remote Engine
|
|
-------------
|
|
#
|
|
# Requires user params:
|
|
|
|
# - eventname: The event type to be pushed into the system
|
|
# - webhook: The url to the emote webhook that will receive the event
|
|
###
|
|
options =
|
|
method: 'POST'
|
|
json: true
|
|
jar: true
|
|
|
|
###
|
|
Push an event into a WebAPI engine.
|
|
|
|
- {Object} evt The event object that will be transmitted.
|
|
###
|
|
exports.pushEvent = ( evt ) ->
|
|
if not evt
|
|
evt = {}
|
|
evt.event = params.eventname
|
|
|
|
options.url = params.webhook
|
|
options.body = JSON.stringify evt
|
|
request options, ( err, resp, body ) ->
|
|
if err or resp.statusCode isnt 200
|
|
log 'Error in pushing event!'
|
|
else
|
|
log 'Successfully posted an event'
|