From 6cc91c0a5ead1631e6a0f58fa087d75a4d776089 Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Wed, 27 Apr 2016 06:01:50 +0200 Subject: [PATCH] improved request method of cflare class --- ts/cflare.classes.ts | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/ts/cflare.classes.ts b/ts/cflare.classes.ts index 93da4ad..f06f809 100644 --- a/ts/cflare.classes.ts +++ b/ts/cflare.classes.ts @@ -23,16 +23,40 @@ class cflare { let done = plugins.q.defer(); return done.promise; }; - listRecords(){ + listRecords(domainName:string){ let done = plugins.q.defer(); + return done.promise; } listDomains(){ let done = plugins.q.defer(); + this.request("GET","/zones") + .then(function(responseArg){ + + }); return done.promise; }; - request(){ + request(methodArg:string,routeArg:string){ let done = plugins.q.defer(); + let options = { + method:methodArg, + url:"https://api.cloudflare.com/client/v4" + routeArg, + headers:{ + "Content-Type":"application/json", + "X-Auth-Email":this.authEmail, + "X-Auth-Key":this.authKey + } + } + plugins.request(options,function(err, res, body){ + if (!err && res.statusCode == 200) { + var responseObj = JSON.parse(body); + done.resolve(responseObj); + } else { + console.log(err); + console.log(res); + done.reject(err); + }; + }); return done.promise; } }; \ No newline at end of file