Skip to content

Commit 36f0a8f

Browse files
committed
feat: updateDnsRecords
1 parent 5bf8cec commit 36f0a8f

5 files changed

Lines changed: 56 additions & 2 deletions

File tree

src/@types/Actions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ export enum Actions {
22
login = 'login',
33
infoDnsZone = 'infoDnsZone',
44
infoDnsRecords = 'infoDnsRecords',
5+
updateDnsRecords = 'updateDnsRecords',
56
}

src/@types/Requests.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { DnsRecord } from './Responses';
2+
13
export interface AuthParam {
24
customernumber: string;
35
apikey: string;
@@ -30,3 +32,13 @@ export interface LoginParam {
3032
apipassword: string;
3133
customernumber: string;
3234
}
35+
36+
export interface UpdateDNSRecordsRequest {
37+
action: string;
38+
param: UpdateDNSRecordsParam;
39+
}
40+
41+
export interface UpdateDNSRecordsParam extends AuthParam {
42+
domainname: string;
43+
dnsrecordset: { dnsrecords: DnsRecord[] };
44+
}

src/@types/Responses.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export interface LoginResponsedata {
2323
export interface InfoDNSZoneResponse {
2424
serverrequestid: string;
2525
clientrequestid: string;
26-
action: string;
26+
action: Actions.infoDnsZone;
2727
status: string;
2828
statuscode: number;
2929
shortmessage: string;
@@ -59,3 +59,12 @@ export interface DnsRecord {
5959
deleterecord: boolean;
6060
state: string;
6161
}
62+
63+
export interface UpdateDNSRecordsResponse extends ApiResponse {
64+
action: Actions.updateDnsRecords;
65+
responsedata: UpdateDNSRecordsResponseData;
66+
}
67+
68+
interface UpdateDNSRecordsResponseData {
69+
dnsrecords: DnsRecord[];
70+
}

src/api.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@ import {
88
InfoDNSZoneRequest,
99
LoginParam,
1010
LoginRequest,
11+
UpdateDNSRecordsParam,
12+
UpdateDNSRecordsRequest,
1113
} from './@types/Requests';
1214
import {
1315
InfoDNSRecordsResponse,
1416
InfoDNSZoneResponse,
1517
LoginResponse,
18+
UpdateDNSRecordsResponse,
1619
} from './@types/Responses';
1720
import { getFormattedUrl } from './utils';
1821

@@ -82,4 +85,16 @@ export default class NetcupRestApi {
8285
},
8386
);
8487
}
88+
89+
public updateDnsRecords(params: UpdateDNSRecordsParam) {
90+
return this.postJson<UpdateDNSRecordsRequest, UpdateDNSRecordsResponse>(
91+
getFormattedUrl(this.format),
92+
{
93+
action: Actions.updateDnsRecords,
94+
param: {
95+
...params,
96+
},
97+
},
98+
);
99+
}
85100
}

src/index.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
import { Formats } from './@types/Formats';
22
import { InitParams } from './@types/InitParams';
33
import { NetcupAuth } from './@types/NetcupAuth';
4-
import { InfoDNSRecordsParam, InfoDNSZoneParam } from './@types/Requests';
4+
import {
5+
InfoDNSRecordsParam,
6+
InfoDNSZoneParam,
7+
UpdateDNSRecordsParam,
8+
} from './@types/Requests';
59
import {
610
InfoDNSRecordsResponse,
711
InfoDNSZoneResponse,
812
LoginResponse,
13+
UpdateDNSRecordsResponse,
914
} from './@types/Responses';
1015
import NetcupRestApi from './api';
1116
import { INVALID_FORMAT_ERROR, NOT_INITIALIZED_ERROR } from './constants';
@@ -70,6 +75,18 @@ class NetcupApi {
7075
});
7176
}
7277

78+
public async updateDnsRecords(
79+
params: Pick<UpdateDNSRecordsParam, 'dnsrecordset' | 'domainname'>,
80+
): Promise<UpdateDNSRecordsResponse> {
81+
await this.checkAndRefreshAuth();
82+
return this.restApi.updateDnsRecords({
83+
apisessionid: this.authData.apiSessionId,
84+
customernumber: this.authData.customerNumber,
85+
apikey: this.authData.apiKey,
86+
...params,
87+
});
88+
}
89+
7390
public getAuthData(): NetcupAuth {
7491
return this.authData;
7592
}

0 commit comments

Comments
 (0)