From 842c73c475d91a5be07a1553b614d6a85461e4d5 Mon Sep 17 00:00:00 2001 From: Dominic Bosch Date: Sun, 27 Apr 2014 20:51:42 +0200 Subject: [PATCH] Updated remote engine example, called webhook now --- examples/.gitignore | 1 + examples/action-invokers/remote-engine.coffee | 31 ++++--------------- 2 files changed, 7 insertions(+), 25 deletions(-) create mode 100644 examples/.gitignore diff --git a/examples/.gitignore b/examples/.gitignore new file mode 100644 index 0000000..880d744 --- /dev/null +++ b/examples/.gitignore @@ -0,0 +1 @@ +params.json \ No newline at end of file diff --git a/examples/action-invokers/remote-engine.coffee b/examples/action-invokers/remote-engine.coffee index a79d329..63c3f97 100644 --- a/examples/action-invokers/remote-engine.coffee +++ b/examples/action-invokers/remote-engine.coffee @@ -3,27 +3,14 @@ Remote Engine ------------- # # Requires user params: -# - username: username to the remote system -# - password: password to the remote system -# - event: The event type to be pushed into the system -# - url: The url to the WebAPI engine that will receive the event +# - eventname: The event type to be pushed into the system +# - webhook: The url to the emote webhook that will receive the event ### -hashedPassword = cryptoJS.SHA3( params.password, outputLength: 512 ).toString() options = method: 'POST' json: true jar: true -fPushEvent = ( evt ) -> - options.url = params.url + '/event' - 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' - - ### Push an event into a WebAPI engine. @@ -32,18 +19,12 @@ Push an event into a WebAPI engine. exports.pushEvent = ( evt ) -> if not evt evt = {} - evt.event = params.event + evt.event = params.eventname - data = - username: params.username - password: hashedPassword - options.url = params.url + '/login' - options.body = JSON.stringify data + 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 - fPushEvent evt - - -# http://localhost:8125 \ No newline at end of file + log 'Successfully posted an event'