summaryrefslogtreecommitdiffstats
path: root/examples/alerts
diff options
context:
space:
mode:
authorElmer Thomas <elmer@thinkingserious.com>2016-07-05 14:51:47 -0700
committerElmer Thomas <elmer@thinkingserious.com>2016-07-05 14:51:47 -0700
commita0aee2f880a8e736b638d5188ef56f07d6ce3f82 (patch)
tree11ac0be09ab27d5a82ea7d5bf9cfca62f60c6896 /examples/alerts
parenta369c84cf9f747252dc90a0fd108909b60b3f30d (diff)
downloadsendgrid-nodejs-3.0.7.zip
sendgrid-nodejs-3.0.7.tar.gz
sendgrid-nodejs-3.0.7.tar.bz2
Version Bump v3.0.7: swagger/oai updates + accept header fixv3.0.7
Diffstat (limited to 'examples/alerts')
-rw-r--r--examples/alerts/alerts.js80
1 files changed, 80 insertions, 0 deletions
diff --git a/examples/alerts/alerts.js b/examples/alerts/alerts.js
new file mode 100644
index 0000000..01a4fc9
--- /dev/null
+++ b/examples/alerts/alerts.js
@@ -0,0 +1,80 @@
+var sg = require('sendgrid').SendGrid(process.env.SENDGRID_API_KEY)
+
+///////////////////////////////////////////////////
+// Create a new Alert
+// POST /alerts
+
+
+var request = sg.emptyRequest()
+request.body = {
+ "email_to": "example@example.com",
+ "frequency": "daily",
+ "type": "stats_notification"
+};
+request.method = 'POST'
+request.path = '/v3/alerts'
+sg.API(request, function (response) {
+ console.log(response.statusCode)
+ console.log(response.body)
+ console.log(response.headers)
+})
+
+///////////////////////////////////////////////////
+// Retrieve all alerts
+// GET /alerts
+
+
+var request = sg.emptyRequest()
+request.method = 'GET'
+request.path = '/v3/alerts'
+sg.API(request, function (response) {
+ console.log(response.statusCode)
+ console.log(response.body)
+ console.log(response.headers)
+})
+
+///////////////////////////////////////////////////
+// Update an alert
+// PATCH /alerts/{alert_id}
+
+
+var request = sg.emptyRequest()
+request.body = {
+ "email_to": "example@example.com"
+};
+request.method = 'PATCH'
+request.path = '/v3/alerts/{alert_id}'
+sg.API(request, function (response) {
+ console.log(response.statusCode)
+ console.log(response.body)
+ console.log(response.headers)
+})
+
+///////////////////////////////////////////////////
+// Retrieve a specific alert
+// GET /alerts/{alert_id}
+
+
+var request = sg.emptyRequest()
+request.method = 'GET'
+request.path = '/v3/alerts/{alert_id}'
+sg.API(request, function (response) {
+ console.log(response.statusCode)
+ console.log(response.body)
+ console.log(response.headers)
+})
+
+///////////////////////////////////////////////////
+// Delete an alert
+// DELETE /alerts/{alert_id}
+
+
+var request = sg.emptyRequest()
+request.method = 'DELETE'
+request.path = '/v3/alerts/{alert_id}'
+sg.API(request, function (response) {
+ console.log(response.statusCode)
+ console.log(response.body)
+ console.log(response.headers)
+})
+