improve domain string handling

This commit is contained in:
Philipp Kunz 2016-05-25 07:06:06 +02:00
parent e99d597c12
commit ff71de8f6c
3 changed files with 11 additions and 10 deletions

File diff suppressed because one or more lines are too long

View File

@ -24,11 +24,11 @@
"beautylog": "^5.0.6", "beautylog": "^5.0.6",
"q": "^1.4.1", "q": "^1.4.1",
"request": "^2.72.0", "request": "^2.72.0",
"smartstring": "^2.0.0", "smartstring": "^2.0.1",
"typings-global": "^1.0.3" "typings-global": "^1.0.3"
}, },
"devDependencies": { "devDependencies": {
"npmts": "^5.1.13", "npmts": "^5.1.14",
"should": "^8.4.0", "should": "^8.4.0",
"typings-test": "^1.0.1" "typings-test": "^1.0.1"
} }

View File

@ -34,7 +34,7 @@ export class CflareAccount {
getRecord(domainNameArg:string,typeArg:string){ getRecord(domainNameArg:string,typeArg:string){
let done = plugins.q.defer(); let done = plugins.q.defer();
let domain = new plugins.smartstring.Domain(domainNameArg); let domain = new plugins.smartstring.Domain(domainNameArg);
this.listRecords(domainNameArg) this.listRecords(domain.zoneName)
.then((responseArg) => { .then((responseArg) => {
let filteredResponse = responseArg.result.filter((recordArg) => { let filteredResponse = responseArg.result.filter((recordArg) => {
return (recordArg.type == typeArg && recordArg.name == domainNameArg); return (recordArg.type == typeArg && recordArg.name == domainNameArg);
@ -45,8 +45,7 @@ export class CflareAccount {
createRecord(domainNameArg:string,typeArg:string,contentArg:string){ createRecord(domainNameArg:string,typeArg:string,contentArg:string){
let done = plugins.q.defer(); let done = plugins.q.defer();
let domain = new plugins.smartstring.Domain(domainNameArg); let domain = new plugins.smartstring.Domain(domainNameArg);
let zoneName:string = domain.level2 + "." + domain.level1; this.getZoneId(domain.zoneName)
this.getZoneId(zoneName)
.then((domainIdArg)=>{ .then((domainIdArg)=>{
let dataObject = { let dataObject = {
name: domain.fullName, name: domain.fullName,
@ -63,20 +62,21 @@ export class CflareAccount {
removeRecord(domainNameArg:string,typeArg:string){ removeRecord(domainNameArg:string,typeArg:string){
let done = plugins.q.defer(); let done = plugins.q.defer();
let domain = new plugins.smartstring.Domain(domainNameArg); let domain = new plugins.smartstring.Domain(domainNameArg);
let zoneName = domain.level2 + "." + domain.level1; this.getRecord(domain.zoneName,typeArg)
this.listRecords(zoneName)
.then((responseArg) => { .then((responseArg) => {
let filteredResponse = responseArg;
}); });
return done.promise; return done.promise;
}; };
updateRecord(domainNameArg:string,typeArg:string,valueArg){ updateRecord(domainNameArg:string,typeArg:string,valueArg){
let done = plugins.q.defer(); let done = plugins.q.defer();
let domain = new plugins.smartstring.Domain(domainNameArg);
return done.promise; return done.promise;
}; };
listRecords(domainNameArg:string){ listRecords(domainNameArg:string){
let done = plugins.q.defer(); let done = plugins.q.defer();
this.getZoneId(domainNameArg) let domain = new plugins.smartstring.Domain(domainNameArg);
this.getZoneId(domain.zoneName)
.then((domainIdArg)=>{ .then((domainIdArg)=>{
this.request("GET","/zones/" + domainIdArg + "/dns_records?per_page=100") this.request("GET","/zones/" + domainIdArg + "/dns_records?per_page=100")
.then(function(responseArg){ .then(function(responseArg){