improve .createRecord

This commit is contained in:
Philipp Kunz 2016-05-25 06:26:48 +02:00
parent 0ed9c7f4f4
commit f44698078e
9 changed files with 60 additions and 18 deletions

View File

@ -11,7 +11,7 @@ export declare class CflareAccount {
getZoneId(domainName: string): any;
getRecord(domainNameArg: string, typeArg: string): any;
createRecord(domainNameArg: string, typeArg: string, contentArg: string): any;
removeRecord(): any;
removeRecord(domainNameArg: string, typeArg: string): any;
updateRecord(domainNameArg: string, typeArg: string, valueArg: any): any;
listRecords(domainNameArg: string): any;
listZones(domainName?: string): any;

File diff suppressed because one or more lines are too long

View File

@ -2,3 +2,4 @@ import "typings-global";
export declare let beautylog: any;
export declare let q: any;
export declare let request: any;
export import smartstring = require("smartstring");

View File

@ -3,5 +3,6 @@ require("typings-global");
exports.beautylog = require("beautylog");
exports.q = require("q");
exports.request = require("request");
exports.smartstring = require("smartstring");
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImNmbGFyZS5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFDYixpQkFBUyxHQUFHLE9BQU8sQ0FBQyxXQUFXLENBQUMsQ0FBQztBQUNqQyxTQUFDLEdBQUcsT0FBTyxDQUFDLEdBQUcsQ0FBQyxDQUFDO0FBQ2pCLGVBQU8sR0FBRyxPQUFPLENBQUMsU0FBUyxDQUFDLENBQUMiLCJmaWxlIjoiY2ZsYXJlLnBsdWdpbnMuanMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgXCJ0eXBpbmdzLWdsb2JhbFwiO1xyXG5leHBvcnQgbGV0IGJlYXV0eWxvZyA9IHJlcXVpcmUoXCJiZWF1dHlsb2dcIik7XHJcbmV4cG9ydCBsZXQgcSA9IHJlcXVpcmUoXCJxXCIpO1xyXG5leHBvcnQgbGV0IHJlcXVlc3QgPSByZXF1aXJlKFwicmVxdWVzdFwiKTsiXX0=
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImNmbGFyZS5wbHVnaW5zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFDYixpQkFBUyxHQUFHLE9BQU8sQ0FBQyxXQUFXLENBQUMsQ0FBQztBQUNqQyxTQUFDLEdBQUcsT0FBTyxDQUFDLEdBQUcsQ0FBQyxDQUFDO0FBQ2pCLGVBQU8sR0FBRyxPQUFPLENBQUMsU0FBUyxDQUFDLENBQUM7QUFDMUIsbUJBQVcsV0FBVyxhQUFhLENBQUMsQ0FBQyIsImZpbGUiOiJjZmxhcmUucGx1Z2lucy5qcyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBcInR5cGluZ3MtZ2xvYmFsXCI7XHJcbmV4cG9ydCBsZXQgYmVhdXR5bG9nID0gcmVxdWlyZShcImJlYXV0eWxvZ1wiKTtcclxuZXhwb3J0IGxldCBxID0gcmVxdWlyZShcInFcIik7XHJcbmV4cG9ydCBsZXQgcmVxdWVzdCA9IHJlcXVpcmUoXCJyZXF1ZXN0XCIpO1xyXG5leHBvcnQgaW1wb3J0IHNtYXJ0c3RyaW5nID0gcmVxdWlyZShcInNtYXJ0c3RyaW5nXCIpOyJdfQ==

View File

@ -24,6 +24,7 @@
"beautylog": "^5.0.6",
"q": "^1.4.1",
"request": "^2.72.0",
"smartstring": "^2.0.0",
"typings-global": "^1.0.3"
},
"devDependencies": {

File diff suppressed because one or more lines are too long

View File

@ -43,22 +43,29 @@ describe("cflare",function(){
})
describe(".createRecord",function(){
this.timeout(10000);
it("should create a valid record for a domain",function(done){
it("should create a valid record for a level 2 domain",function(done){
testCflareAccount.createRecord("bleu.de","A","127.0.0.1")
.then(function(responseArg){
console.log(responseArg);
done();
});
});
it("should create a valid record for a subdomain",function(done){
testCflareAccount.createRecord("subdomain.bleu.de","A","127.0.0.1")
.then(function(responseArg){
console.log(responseArg);
done();
});
});
});
describe(".removeRecord",function(){
it("should remove a record from Cloudflare",function(done){
/*it("should remove a record from Cloudflare",function(done){
testCflareAccount.removeRecord()
.then(function(responseArg){
console.log(responseArg);
done();
})
});
});
});*/
});
})
});

View File

@ -43,10 +43,12 @@ export class CflareAccount {
};
createRecord(domainNameArg:string,typeArg:string,contentArg:string){
let done = plugins.q.defer();
this.getZoneId(domainNameArg)
let domain = new plugins.smartstring.Domain(domainNameArg);
let zoneName:string = domain.level2 + "." + domain.level1;
this.getZoneId(zoneName)
.then((domainIdArg)=>{
let dataObject = {
name: domainNameArg,
name: domain.fullName,
type: typeArg,
content: contentArg
};
@ -59,7 +61,12 @@ export class CflareAccount {
};
removeRecord(domainNameArg:string,typeArg:string){
let done = plugins.q.defer();
let domain = new plugins.smartstring.Domain(domainNameArg);
let zoneName = domain.level2 + "." + domain.level1;
this.listRecords(zoneName)
.then((responseArg) => {
let filteredResponse = responseArg;
});
return done.promise;
};
updateRecord(domainNameArg:string,typeArg:string,valueArg){

View File

@ -1,4 +1,5 @@
import "typings-global";
export let beautylog = require("beautylog");
export let q = require("q");
export let request = require("request");
export let request = require("request");
export import smartstring = require("smartstring");