From 71dcdd0d66d1b94c2db01be0ff7aa0a5e83e51c3 Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Wed, 27 Apr 2016 03:08:14 +0200 Subject: [PATCH] now returning promises --- README.md | 10 +++++----- package.json | 1 + ts/cflare.classes.ts | 28 +++++++++++++++++++++++++++- ts/cflare.plugins.ts | 1 + 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 1c78fb0..dc03e00 100644 --- a/README.md +++ b/README.md @@ -18,11 +18,11 @@ cflareInstance.auth({ key:"" }); -cflareInstance.createRecord(); -cflareInstance.removeRecord(); -cflareInstance.copyRecord(); -cflareInstance.listRecords(); -cflareInstance.listDomains(); +cflareInstance.createRecord(); // returns promise with resolve function getting the response; +cflareInstance.removeRecord(); // returns promise with resolve function getting the response; +cflareInstance.copyRecord(); // returns promise with resolve function getting the response; +cflareInstance.listRecords(); // returns promise with resolve function getting the response; +cflareInstance.listDomains(); // returns promise with resolve function getting the response; ``` ### About the authors: diff --git a/package.json b/package.json index 0aeb7bc..9fedcb7 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "homepage": "https://github.com/pushrocks/cflare#readme", "dependencies": { "beautylog": "^4.1.2", + "q": "^1.4.1", "request": "^2.72.0" }, "devDependencies": { diff --git a/ts/cflare.classes.ts b/ts/cflare.classes.ts index 26b99ff..93da4ad 100644 --- a/ts/cflare.classes.ts +++ b/ts/cflare.classes.ts @@ -5,8 +5,34 @@ import helpers = require("./cflare.classes.helpers"); class cflare { private authEmail:string; private authKey:string; + private authCheck(){ + return (this.authEmail && this.authKey); //check if auth is available + } constructor(){ }; - + auth(optionsArg:{email:string,key:string}){ + this.authEmail = optionsArg.email; + this.authKey = optionsArg.key; + } + createRecord(){ + let done = plugins.q.defer(); + return done.promise; + }; + removeRecord(){ + let done = plugins.q.defer(); + return done.promise; + }; + listRecords(){ + let done = plugins.q.defer(); + return done.promise; + } + listDomains(){ + let done = plugins.q.defer(); + return done.promise; + }; + request(){ + let done = plugins.q.defer(); + return done.promise; + } }; \ No newline at end of file diff --git a/ts/cflare.plugins.ts b/ts/cflare.plugins.ts index 289c8f7..0480258 100644 --- a/ts/cflare.plugins.ts +++ b/ts/cflare.plugins.ts @@ -1,3 +1,4 @@ /// export let beautylog = require("beautylog"); +export let q = require("q"); export let request = require("request"); \ No newline at end of file