Skip to content

Commit a08cb86

Browse files
authored
Add files via upload
1 parent 1c0ffec commit a08cb86

File tree

25 files changed

+2824
-0
lines changed

25 files changed

+2824
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 PlanetHoster
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "ph-node-api",
3+
"version": "1.0.6",
4+
"description": "NodeJS PlanetHoster api integration",
5+
"repository": "git@github.com:PlanetHoster/api-node.git",
6+
"author": "Marc-Andre G. <marc-andre.godin@planethoster.info>",
7+
"license": "MIT",
8+
"private": false,
9+
"main": "./build/main.js",
10+
"typings": "./build/main.d.ts",
11+
"files": [
12+
"build/**/**/*"
13+
],
14+
"scripts": {
15+
"build": "rm -rf ./build && tsc",
16+
"lint": "npx eslint src/**/**/*",
17+
"prebuild-package": "yarn build",
18+
"build-package": "cp ./package.json ./build && cp ./README.md ./build/README.md"
19+
},
20+
"devDependencies": {
21+
"@tsconfig/node16": "1.0.4",
22+
"@types/node": "18.16.16",
23+
"@typescript-eslint/eslint-plugin": "5.59.8",
24+
"@typescript-eslint/parser": "5.59.8",
25+
"eslint": "8.42.0",
26+
"eslint-config-standard": "17.1.0",
27+
"eslint-plugin-import": "2.27.5",
28+
"eslint-plugin-n": "16.0.0",
29+
"eslint-plugin-node": "11.1.0",
30+
"eslint-plugin-promise": "6.1.1",
31+
"typescript": "5.0.4"
32+
}
33+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3+
"extends": [
4+
"config:base",
5+
"schedule:daily",
6+
":disableRateLimiting",
7+
"group:linters",
8+
"group:testNonMajor",
9+
":automergeLinters",
10+
":automergeTesters",
11+
":automergeTypes"
12+
],
13+
"timezone": "America/Montreal",
14+
"labels": [
15+
"dependency"
16+
],
17+
"lockFileMaintenance": {
18+
"enabled": true,
19+
"automerge": true,
20+
"schedule": [
21+
"before 5am on monday"
22+
]
23+
}
24+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { Client } from '../http/client';
2+
import { RequestParams } from '../interfaces/client.interface';
3+
4+
export class Base {
5+
protected client: Client;
6+
7+
constructor (client: Client) {
8+
this.client = client;
9+
}
10+
11+
public testConnection () {
12+
return this.client.sendRequest({
13+
method: 'GET',
14+
path: '/reseller-api/test-connection'
15+
});
16+
}
17+
18+
// Maybe we should use this to keep the same syntax with all parameters
19+
// protected toSnakeCase(params: any) {
20+
// const newObj: {[key: string]: string} = {};
21+
// Object.keys(params).forEach(k => {
22+
// newObj[k.split(/(?=[A-Z])/).join('_').toLowerCase()] = params[k];
23+
// });
24+
// return newObj;
25+
// }
26+
}
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
import { Base } from './base';
2+
import {
3+
ContactDetails,
4+
RegisterDomain,
5+
RegistrarLock,
6+
RenewDomain,
7+
SaveDnsRecords,
8+
SaveNameservers,
9+
SldTld,
10+
TransferDomain
11+
} from '../interfaces/domain.interface';
12+
13+
const BASE_PATH = '/reseller-api';
14+
15+
export class Domain extends Base {
16+
accountInfo () {
17+
return this.client.sendRequest({
18+
method: 'GET',
19+
path: '/account-info'
20+
});
21+
}
22+
23+
tldPrices () {
24+
return this.client.sendRequest({
25+
method: 'GET',
26+
path: `${BASE_PATH}/tld-prices`
27+
});
28+
}
29+
30+
checkDomainAvailability (params: SldTld) {
31+
return this.client.sendRequest({
32+
method: 'GET',
33+
path: `${BASE_PATH}/check-availability?sld=${params.sld}&tld=${params.tld}`
34+
});
35+
}
36+
37+
domainInformation (params: SldTld) {
38+
return this.client.sendRequest({
39+
method: 'GET',
40+
path: `${BASE_PATH}/domain-info?sld=${params.sld}&tld=${params.tld}`
41+
});
42+
}
43+
44+
contactDetails (params: SldTld) {
45+
return this.client.sendRequest({
46+
method: 'GET',
47+
path: `${BASE_PATH}/get-contact-details?sld=${params.sld}&tld=${params.tld}`
48+
});
49+
}
50+
51+
saveContactDetails (params: ContactDetails) {
52+
return this.client.sendRequest({
53+
method: 'POST',
54+
path: `${BASE_PATH}/save-contact-details`,
55+
params
56+
});
57+
}
58+
59+
getRegistrarLock (params: SldTld) {
60+
return this.client.sendRequest({
61+
method: 'GET',
62+
path: `${BASE_PATH}/get-registrar-lock?sld=${params.sld}&tld=${params.tld}`
63+
});
64+
}
65+
66+
saveRegistrarLock (params: RegistrarLock) {
67+
return this.client.sendRequest({
68+
method: 'GET',
69+
path: `${BASE_PATH}/save-registrar-lock`,
70+
params
71+
});
72+
}
73+
74+
getNameservers (params: SldTld) {
75+
return this.client.sendRequest({
76+
method: 'GET',
77+
path: `${BASE_PATH}/get-nameservers?sld=${params.sld}&tld=${params.tld}`
78+
});
79+
}
80+
81+
saveNameservers (params: SaveNameservers) {
82+
return this.client.sendRequest({
83+
method: 'POST',
84+
path: `${BASE_PATH}/save-nameservers`,
85+
params
86+
});
87+
}
88+
89+
getDnsRecords (params: SldTld) {
90+
return this.client.sendRequest({
91+
method: 'GET',
92+
path: `${BASE_PATH}/get-ph-dns-records?sld=${params.sld}&tld=${params.tld}`
93+
});
94+
}
95+
96+
saveDnsRecords (params: SaveDnsRecords) {
97+
return this.client.sendRequest({
98+
method: 'POST',
99+
path: `${BASE_PATH}/save-ph-dns-records`,
100+
params
101+
});
102+
}
103+
104+
deleteZone (params: SldTld) {
105+
return this.client.sendRequest({
106+
method: 'POST',
107+
path: `${BASE_PATH}/delete-ph-dns-zone`,
108+
params
109+
});
110+
}
111+
112+
emailEppCode (params: SldTld) {
113+
return this.client.sendRequest({
114+
method: 'POST',
115+
path: `${BASE_PATH}/email-epp-code`,
116+
params
117+
});
118+
}
119+
120+
registerDomain (params: RegisterDomain) {
121+
return this.client.sendRequest({
122+
method: 'POST',
123+
path: `${BASE_PATH}/register-domain`,
124+
params
125+
});
126+
}
127+
128+
renewDomain (params: RenewDomain) {
129+
return this.client.sendRequest({
130+
method: 'POST',
131+
path: `${BASE_PATH}/renew-domain`,
132+
params
133+
});
134+
}
135+
136+
transferDomain (params: TransferDomain) {
137+
return this.client.sendRequest({
138+
method: 'POST',
139+
path: `${BASE_PATH}/transfert-domain`,
140+
params
141+
});
142+
}
143+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export * from './world';
2+
export * from './domain';
3+
export * from './n0c';
4+
export * from './base';
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import { RequestParams } from "../interfaces/client.interface";
2+
import { Base } from "./base";
3+
import {
4+
N0cUser,
5+
N0cDomain,
6+
N0cDns,
7+
N0cEmail,
8+
N0cDatabase,
9+
N0cCron,
10+
N0cWordpress,
11+
} from "./n0c/";
12+
import { N0cFtp } from "./n0c/ftp";
13+
14+
export class N0c extends Base {
15+
16+
/**
17+
*
18+
* @returns N0C User object
19+
* @docs https://apidoc.planethoster.com/en/#tag/User
20+
*
21+
*/
22+
user () {
23+
return new N0cUser(this.client);
24+
}
25+
26+
/**
27+
*
28+
* @returns N0C Domain object
29+
* @docs https://apidoc.planethoster.com/en/#tag/Domain
30+
*
31+
*/
32+
domain () {
33+
return new N0cDomain(this.client);
34+
}
35+
36+
/**
37+
*
38+
* @returns N0C Dns object
39+
* @docs https://apidoc.planethoster.com/en/#tag/DNS
40+
*
41+
*/
42+
dns () {
43+
return new N0cDns(this.client);
44+
}
45+
46+
/**
47+
*
48+
* @returns N0C Email object
49+
* @docs https://apidoc.planethoster.com/en/#tag/Email
50+
*
51+
*/
52+
email () {
53+
return new N0cEmail(this.client);
54+
}
55+
56+
/**
57+
*
58+
* @returns N0C Database object
59+
* @docs https://apidoc.planethoster.com/en/#tag/Database
60+
*
61+
*/
62+
database () {
63+
return new N0cDatabase(this.client);
64+
}
65+
66+
/**
67+
*
68+
* @returns N0C Cron object
69+
* @docs https://apidoc.planethoster.com/en/#tag/Cron
70+
*
71+
*/
72+
cron () {
73+
return new N0cCron(this.client);
74+
}
75+
76+
/**
77+
*
78+
* @returns N0C Ftp object
79+
* @docs https://apidoc.planethoster.com/en/#tag/FTP
80+
*
81+
*/
82+
ftp () {
83+
return new N0cFtp(this.client);
84+
}
85+
86+
/**
87+
*
88+
* @returns N0C Ftp object
89+
* @docs https://apidoc.planethoster.com/en/#tag/Wordpress
90+
*
91+
*/
92+
wordpress () {
93+
return new N0cWordpress(this.client);
94+
}
95+
}

0 commit comments

Comments
 (0)