hostinger-api-sdk 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/publish-release.yaml +53 -0
- package/.idea/api-typescript-sdk.iml +8 -0
- package/.idea/modules.xml +8 -0
- package/.idea/php.xml +19 -0
- package/.idea/vcs.xml +6 -0
- package/README.md +9 -0
- package/api.ts +6882 -0
- package/base.ts +83 -0
- package/common.ts +111 -0
- package/configuration.ts +72 -0
- package/dist/api.d.ts +4171 -0
- package/dist/api.js +4998 -0
- package/dist/base.d.ts +63 -0
- package/dist/base.js +62 -0
- package/dist/common.d.ts +47 -0
- package/dist/common.js +118 -0
- package/dist/configuration.d.ts +51 -0
- package/dist/configuration.js +37 -0
- package/dist/esm/api.d.ts +4171 -0
- package/dist/esm/api.js +4926 -0
- package/dist/esm/base.d.ts +63 -0
- package/dist/esm/base.js +57 -0
- package/dist/esm/common.d.ts +47 -0
- package/dist/esm/common.js +109 -0
- package/dist/esm/configuration.d.ts +51 -0
- package/dist/esm/configuration.js +33 -0
- package/dist/esm/index.d.ts +10 -0
- package/dist/esm/index.js +12 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +28 -0
- package/index.ts +15 -0
- package/package.json +34 -0
- package/tsconfig.esm.json +7 -0
- package/tsconfig.json +18 -0
package/base.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Hostinger API
|
|
5
|
+
*
|
|
6
|
+
* API Version: 0.0.9
|
|
7
|
+
*
|
|
8
|
+
* NOTE: This file is auto-generated, DO NOT EDIT THIS FILE MANUALLY!
|
|
9
|
+
* If you want to contribute or request a new feature, please create an issue or pull request on https://github.com/hostinger/api
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
import type { Configuration } from './configuration';
|
|
14
|
+
// Some imports not used depending on template conditions
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
|
|
17
|
+
import globalAxios from 'axios';
|
|
18
|
+
|
|
19
|
+
export const BASE_PATH = "https://developers.hostinger.com".replace(/\/+$/, "");
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @export
|
|
24
|
+
*/
|
|
25
|
+
export const COLLECTION_FORMATS = {
|
|
26
|
+
csv: ",",
|
|
27
|
+
ssv: " ",
|
|
28
|
+
tsv: "\t",
|
|
29
|
+
pipes: "|",
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
* @export
|
|
35
|
+
* @interface RequestArgs
|
|
36
|
+
*/
|
|
37
|
+
export interface RequestArgs {
|
|
38
|
+
url: string;
|
|
39
|
+
options: RawAxiosRequestConfig;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
*
|
|
44
|
+
* @export
|
|
45
|
+
* @class BaseAPI
|
|
46
|
+
*/
|
|
47
|
+
export class BaseAPI {
|
|
48
|
+
protected configuration: Configuration | undefined;
|
|
49
|
+
|
|
50
|
+
constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) {
|
|
51
|
+
if (configuration) {
|
|
52
|
+
this.configuration = configuration;
|
|
53
|
+
this.basePath = configuration.basePath ?? basePath;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
*
|
|
60
|
+
* @export
|
|
61
|
+
* @class RequiredError
|
|
62
|
+
* @extends {Error}
|
|
63
|
+
*/
|
|
64
|
+
export class RequiredError extends Error {
|
|
65
|
+
constructor(public field: string, msg?: string) {
|
|
66
|
+
super(msg);
|
|
67
|
+
this.name = "RequiredError"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
interface ServerMap {
|
|
72
|
+
[key: string]: {
|
|
73
|
+
url: string,
|
|
74
|
+
description: string,
|
|
75
|
+
}[];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
*
|
|
80
|
+
* @export
|
|
81
|
+
*/
|
|
82
|
+
export const operationServerMap: ServerMap = {
|
|
83
|
+
}
|
package/common.ts
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Hostinger API
|
|
5
|
+
*
|
|
6
|
+
* API Version: 0.0.9
|
|
7
|
+
*
|
|
8
|
+
* NOTE: This file is auto-generated, DO NOT EDIT THIS FILE MANUALLY!
|
|
9
|
+
* If you want to contribute or request a new feature, please create an issue or pull request on https://github.com/hostinger/api
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
import type { Configuration } from "./configuration";
|
|
14
|
+
import type { RequestArgs } from "./base";
|
|
15
|
+
import type { AxiosInstance, AxiosResponse } from 'axios';
|
|
16
|
+
import { RequiredError } from "./base";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @export
|
|
21
|
+
*/
|
|
22
|
+
export const DUMMY_BASE_URL = 'https://example.com'
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @throws {RequiredError}
|
|
27
|
+
* @export
|
|
28
|
+
*/
|
|
29
|
+
export const assertParamExists = function (functionName: string, paramName: string, paramValue: unknown) {
|
|
30
|
+
if (paramValue === null || paramValue === undefined) {
|
|
31
|
+
throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
* @export
|
|
38
|
+
*/
|
|
39
|
+
export const setBearerAuthToObject = async function (object: any, configuration?: Configuration) {
|
|
40
|
+
if (configuration && configuration.accessToken) {
|
|
41
|
+
const accessToken = typeof configuration.accessToken === 'function'
|
|
42
|
+
? await configuration.accessToken()
|
|
43
|
+
: await configuration.accessToken;
|
|
44
|
+
object["Authorization"] = "Bearer " + accessToken;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ""): void {
|
|
49
|
+
if (parameter == null) return;
|
|
50
|
+
if (typeof parameter === "object") {
|
|
51
|
+
if (Array.isArray(parameter)) {
|
|
52
|
+
(parameter as any[]).forEach(item => setFlattenedQueryParams(urlSearchParams, item, key));
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
Object.keys(parameter).forEach(currentKey =>
|
|
56
|
+
setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== '' ? '.' : ''}${currentKey}`)
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
if (urlSearchParams.has(key)) {
|
|
62
|
+
urlSearchParams.append(key, parameter);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
urlSearchParams.set(key, parameter);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
*
|
|
72
|
+
* @export
|
|
73
|
+
*/
|
|
74
|
+
export const setSearchParams = function (url: URL, ...objects: any[]) {
|
|
75
|
+
const searchParams = new URLSearchParams(url.search);
|
|
76
|
+
setFlattenedQueryParams(searchParams, objects);
|
|
77
|
+
url.search = searchParams.toString();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
*
|
|
82
|
+
* @export
|
|
83
|
+
*/
|
|
84
|
+
export const serializeDataIfNeeded = function (value: any, requestOptions: any, configuration?: Configuration) {
|
|
85
|
+
const nonString = typeof value !== 'string';
|
|
86
|
+
const needsSerialization = nonString && configuration && configuration.isJsonMime
|
|
87
|
+
? configuration.isJsonMime(requestOptions.headers['Content-Type'])
|
|
88
|
+
: nonString;
|
|
89
|
+
return needsSerialization
|
|
90
|
+
? JSON.stringify(value !== undefined ? value : {})
|
|
91
|
+
: (value || "");
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
*
|
|
96
|
+
* @export
|
|
97
|
+
*/
|
|
98
|
+
export const toPathString = function (url: URL) {
|
|
99
|
+
return url.pathname + url.search + url.hash
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
*
|
|
104
|
+
* @export
|
|
105
|
+
*/
|
|
106
|
+
export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) {
|
|
107
|
+
return <T = unknown, R = AxiosResponse<T>>(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
|
|
108
|
+
const axiosRequestArgs = {...axiosArgs.options, url: (axios.defaults.baseURL ? '' : configuration?.basePath ?? basePath) + axiosArgs.url};
|
|
109
|
+
return axios.request<T, R>(axiosRequestArgs);
|
|
110
|
+
};
|
|
111
|
+
}
|
package/configuration.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Hostinger API
|
|
5
|
+
*
|
|
6
|
+
* API Version: 0.0.9
|
|
7
|
+
*
|
|
8
|
+
* NOTE: This file is auto-generated, DO NOT EDIT THIS FILE MANUALLY!
|
|
9
|
+
* If you want to contribute or request a new feature, please create an issue or pull request on https://github.com/hostinger/api
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
export interface ConfigurationParameters {
|
|
14
|
+
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
|
|
15
|
+
basePath?: string;
|
|
16
|
+
baseOptions?: any;
|
|
17
|
+
formDataCtor?: new () => any;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export class Configuration {
|
|
21
|
+
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
|
|
22
|
+
/**
|
|
23
|
+
* override base path
|
|
24
|
+
*
|
|
25
|
+
* @type {string}
|
|
26
|
+
* @memberof Configuration
|
|
27
|
+
*/
|
|
28
|
+
basePath?: string;
|
|
29
|
+
/**
|
|
30
|
+
* override server index
|
|
31
|
+
*
|
|
32
|
+
* @type {number}
|
|
33
|
+
* @memberof Configuration
|
|
34
|
+
*/
|
|
35
|
+
baseOptions?: any;
|
|
36
|
+
/**
|
|
37
|
+
* The FormData constructor that will be used to create multipart form data
|
|
38
|
+
* requests. You can inject this here so that execution environments that
|
|
39
|
+
* do not support the FormData class can still run the generated client.
|
|
40
|
+
*
|
|
41
|
+
* @type {new () => FormData}
|
|
42
|
+
*/
|
|
43
|
+
formDataCtor?: new () => any;
|
|
44
|
+
|
|
45
|
+
constructor(param: ConfigurationParameters = {}) {
|
|
46
|
+
this.accessToken = param.accessToken;
|
|
47
|
+
this.basePath = param.basePath;
|
|
48
|
+
this.baseOptions = {
|
|
49
|
+
...param.baseOptions,
|
|
50
|
+
headers: {
|
|
51
|
+
'User-Agent': "hostinger-api-sdk-typescript/0.0.3",
|
|
52
|
+
...param.baseOptions?.headers,
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
this.formDataCtor = param.formDataCtor;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Check if the given MIME is a JSON MIME.
|
|
60
|
+
* JSON MIME examples:
|
|
61
|
+
* application/json
|
|
62
|
+
* application/json; charset=UTF8
|
|
63
|
+
* APPLICATION/JSON
|
|
64
|
+
* application/vnd.company+json
|
|
65
|
+
* @param mime - MIME (Multipurpose Internet Mail Extensions)
|
|
66
|
+
* @return True if the given MIME is JSON, false otherwise.
|
|
67
|
+
*/
|
|
68
|
+
public isJsonMime(mime: string): boolean {
|
|
69
|
+
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
|
|
70
|
+
return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
|
|
71
|
+
}
|
|
72
|
+
}
|