mirror of
https://github.com/Hopiu/webapi-eca.git
synced 2026-03-16 22:10:31 +00:00
26 lines
703 B
CoffeeScript
26 lines
703 B
CoffeeScript
|
|
#
|
|
# EmailYak EVENT POLLER
|
|
# ---------------------
|
|
#
|
|
# Requires user params:
|
|
# - apikey: The user's EmailYak API key
|
|
#
|
|
|
|
url = 'https://api.emailyak.com/v1/' + params.apikey + '/json/get/new/email/'
|
|
|
|
exports.newMail = ( pushEvent ) ->
|
|
|
|
# needlereq allows the user to make calls to API's
|
|
# Refer to https://github.com/tomas/needle for more information
|
|
#
|
|
# Syntax: needle.request method, url, data, [options], callback
|
|
#
|
|
needlereq 'get', url, null, null, ( err, resp, body ) ->
|
|
if err
|
|
log 'Error in EmailYak EM newMail: ' + err.message
|
|
else
|
|
if resp.statusCode is 200
|
|
mails = JSON.parse( body ).Emails
|
|
pushEvent mail for mail in mails
|
|
|