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/dist/base.d.ts ADDED
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Hostinger API
3
+ *
4
+ * API Version: 0.0.9
5
+ *
6
+ * NOTE: This file is auto-generated, DO NOT EDIT THIS FILE MANUALLY!
7
+ * If you want to contribute or request a new feature, please create an issue or pull request on https://github.com/hostinger/api
8
+ */
9
+ import type { Configuration } from './configuration';
10
+ import type { AxiosInstance, RawAxiosRequestConfig } from 'axios';
11
+ export declare const BASE_PATH: string;
12
+ /**
13
+ *
14
+ * @export
15
+ */
16
+ export declare const COLLECTION_FORMATS: {
17
+ csv: string;
18
+ ssv: string;
19
+ tsv: string;
20
+ pipes: string;
21
+ };
22
+ /**
23
+ *
24
+ * @export
25
+ * @interface RequestArgs
26
+ */
27
+ export interface RequestArgs {
28
+ url: string;
29
+ options: RawAxiosRequestConfig;
30
+ }
31
+ /**
32
+ *
33
+ * @export
34
+ * @class BaseAPI
35
+ */
36
+ export declare class BaseAPI {
37
+ protected basePath: string;
38
+ protected axios: AxiosInstance;
39
+ protected configuration: Configuration | undefined;
40
+ constructor(configuration?: Configuration, basePath?: string, axios?: AxiosInstance);
41
+ }
42
+ /**
43
+ *
44
+ * @export
45
+ * @class RequiredError
46
+ * @extends {Error}
47
+ */
48
+ export declare class RequiredError extends Error {
49
+ field: string;
50
+ constructor(field: string, msg?: string);
51
+ }
52
+ interface ServerMap {
53
+ [key: string]: {
54
+ url: string;
55
+ description: string;
56
+ }[];
57
+ }
58
+ /**
59
+ *
60
+ * @export
61
+ */
62
+ export declare const operationServerMap: ServerMap;
63
+ export {};
package/dist/base.js ADDED
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ /**
5
+ * Hostinger API
6
+ *
7
+ * API Version: 0.0.9
8
+ *
9
+ * NOTE: This file is auto-generated, DO NOT EDIT THIS FILE MANUALLY!
10
+ * If you want to contribute or request a new feature, please create an issue or pull request on https://github.com/hostinger/api
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.operationServerMap = exports.RequiredError = exports.BaseAPI = exports.COLLECTION_FORMATS = exports.BASE_PATH = void 0;
14
+ const axios_1 = require("axios");
15
+ exports.BASE_PATH = "https://developers.hostinger.com".replace(/\/+$/, "");
16
+ /**
17
+ *
18
+ * @export
19
+ */
20
+ exports.COLLECTION_FORMATS = {
21
+ csv: ",",
22
+ ssv: " ",
23
+ tsv: "\t",
24
+ pipes: "|",
25
+ };
26
+ /**
27
+ *
28
+ * @export
29
+ * @class BaseAPI
30
+ */
31
+ class BaseAPI {
32
+ constructor(configuration, basePath = exports.BASE_PATH, axios = axios_1.default) {
33
+ var _a;
34
+ this.basePath = basePath;
35
+ this.axios = axios;
36
+ if (configuration) {
37
+ this.configuration = configuration;
38
+ this.basePath = (_a = configuration.basePath) !== null && _a !== void 0 ? _a : basePath;
39
+ }
40
+ }
41
+ }
42
+ exports.BaseAPI = BaseAPI;
43
+ ;
44
+ /**
45
+ *
46
+ * @export
47
+ * @class RequiredError
48
+ * @extends {Error}
49
+ */
50
+ class RequiredError extends Error {
51
+ constructor(field, msg) {
52
+ super(msg);
53
+ this.field = field;
54
+ this.name = "RequiredError";
55
+ }
56
+ }
57
+ exports.RequiredError = RequiredError;
58
+ /**
59
+ *
60
+ * @export
61
+ */
62
+ exports.operationServerMap = {};
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Hostinger API
3
+ *
4
+ * API Version: 0.0.9
5
+ *
6
+ * NOTE: This file is auto-generated, DO NOT EDIT THIS FILE MANUALLY!
7
+ * If you want to contribute or request a new feature, please create an issue or pull request on https://github.com/hostinger/api
8
+ */
9
+ import type { Configuration } from "./configuration";
10
+ import type { RequestArgs } from "./base";
11
+ import type { AxiosInstance, AxiosResponse } from 'axios';
12
+ /**
13
+ *
14
+ * @export
15
+ */
16
+ export declare const DUMMY_BASE_URL = "https://example.com";
17
+ /**
18
+ *
19
+ * @throws {RequiredError}
20
+ * @export
21
+ */
22
+ export declare const assertParamExists: (functionName: string, paramName: string, paramValue: unknown) => void;
23
+ /**
24
+ *
25
+ * @export
26
+ */
27
+ export declare const setBearerAuthToObject: (object: any, configuration?: Configuration) => Promise<void>;
28
+ /**
29
+ *
30
+ * @export
31
+ */
32
+ export declare const setSearchParams: (url: URL, ...objects: any[]) => void;
33
+ /**
34
+ *
35
+ * @export
36
+ */
37
+ export declare const serializeDataIfNeeded: (value: any, requestOptions: any, configuration?: Configuration) => any;
38
+ /**
39
+ *
40
+ * @export
41
+ */
42
+ export declare const toPathString: (url: URL) => string;
43
+ /**
44
+ *
45
+ * @export
46
+ */
47
+ export declare const createRequestFunction: (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) => <T = unknown, R = AxiosResponse<T>>(axios?: AxiosInstance, basePath?: string) => Promise<R>;
package/dist/common.js ADDED
@@ -0,0 +1,118 @@
1
+ "use strict";
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ /**
5
+ * Hostinger API
6
+ *
7
+ * API Version: 0.0.9
8
+ *
9
+ * NOTE: This file is auto-generated, DO NOT EDIT THIS FILE MANUALLY!
10
+ * If you want to contribute or request a new feature, please create an issue or pull request on https://github.com/hostinger/api
11
+ */
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.createRequestFunction = exports.toPathString = exports.serializeDataIfNeeded = exports.setSearchParams = exports.setBearerAuthToObject = exports.assertParamExists = exports.DUMMY_BASE_URL = void 0;
23
+ const base_1 = require("./base");
24
+ /**
25
+ *
26
+ * @export
27
+ */
28
+ exports.DUMMY_BASE_URL = 'https://example.com';
29
+ /**
30
+ *
31
+ * @throws {RequiredError}
32
+ * @export
33
+ */
34
+ const assertParamExists = function (functionName, paramName, paramValue) {
35
+ if (paramValue === null || paramValue === undefined) {
36
+ throw new base_1.RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`);
37
+ }
38
+ };
39
+ exports.assertParamExists = assertParamExists;
40
+ /**
41
+ *
42
+ * @export
43
+ */
44
+ const setBearerAuthToObject = function (object, configuration) {
45
+ return __awaiter(this, void 0, void 0, function* () {
46
+ if (configuration && configuration.accessToken) {
47
+ const accessToken = typeof configuration.accessToken === 'function'
48
+ ? yield configuration.accessToken()
49
+ : yield configuration.accessToken;
50
+ object["Authorization"] = "Bearer " + accessToken;
51
+ }
52
+ });
53
+ };
54
+ exports.setBearerAuthToObject = setBearerAuthToObject;
55
+ function setFlattenedQueryParams(urlSearchParams, parameter, key = "") {
56
+ if (parameter == null)
57
+ return;
58
+ if (typeof parameter === "object") {
59
+ if (Array.isArray(parameter)) {
60
+ parameter.forEach(item => setFlattenedQueryParams(urlSearchParams, item, key));
61
+ }
62
+ else {
63
+ Object.keys(parameter).forEach(currentKey => setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== '' ? '.' : ''}${currentKey}`));
64
+ }
65
+ }
66
+ else {
67
+ if (urlSearchParams.has(key)) {
68
+ urlSearchParams.append(key, parameter);
69
+ }
70
+ else {
71
+ urlSearchParams.set(key, parameter);
72
+ }
73
+ }
74
+ }
75
+ /**
76
+ *
77
+ * @export
78
+ */
79
+ const setSearchParams = function (url, ...objects) {
80
+ const searchParams = new URLSearchParams(url.search);
81
+ setFlattenedQueryParams(searchParams, objects);
82
+ url.search = searchParams.toString();
83
+ };
84
+ exports.setSearchParams = setSearchParams;
85
+ /**
86
+ *
87
+ * @export
88
+ */
89
+ const serializeDataIfNeeded = function (value, requestOptions, configuration) {
90
+ const nonString = typeof value !== 'string';
91
+ const needsSerialization = nonString && configuration && configuration.isJsonMime
92
+ ? configuration.isJsonMime(requestOptions.headers['Content-Type'])
93
+ : nonString;
94
+ return needsSerialization
95
+ ? JSON.stringify(value !== undefined ? value : {})
96
+ : (value || "");
97
+ };
98
+ exports.serializeDataIfNeeded = serializeDataIfNeeded;
99
+ /**
100
+ *
101
+ * @export
102
+ */
103
+ const toPathString = function (url) {
104
+ return url.pathname + url.search + url.hash;
105
+ };
106
+ exports.toPathString = toPathString;
107
+ /**
108
+ *
109
+ * @export
110
+ */
111
+ const createRequestFunction = function (axiosArgs, globalAxios, BASE_PATH, configuration) {
112
+ return (axios = globalAxios, basePath = BASE_PATH) => {
113
+ var _a;
114
+ const axiosRequestArgs = Object.assign(Object.assign({}, axiosArgs.options), { url: (axios.defaults.baseURL ? '' : (_a = configuration === null || configuration === void 0 ? void 0 : configuration.basePath) !== null && _a !== void 0 ? _a : basePath) + axiosArgs.url });
115
+ return axios.request(axiosRequestArgs);
116
+ };
117
+ };
118
+ exports.createRequestFunction = createRequestFunction;
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Hostinger API
3
+ *
4
+ * API Version: 0.0.9
5
+ *
6
+ * NOTE: This file is auto-generated, DO NOT EDIT THIS FILE MANUALLY!
7
+ * If you want to contribute or request a new feature, please create an issue or pull request on https://github.com/hostinger/api
8
+ */
9
+ export interface ConfigurationParameters {
10
+ accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
11
+ basePath?: string;
12
+ baseOptions?: any;
13
+ formDataCtor?: new () => any;
14
+ }
15
+ export declare class Configuration {
16
+ accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
17
+ /**
18
+ * override base path
19
+ *
20
+ * @type {string}
21
+ * @memberof Configuration
22
+ */
23
+ basePath?: string;
24
+ /**
25
+ * override server index
26
+ *
27
+ * @type {number}
28
+ * @memberof Configuration
29
+ */
30
+ baseOptions?: any;
31
+ /**
32
+ * The FormData constructor that will be used to create multipart form data
33
+ * requests. You can inject this here so that execution environments that
34
+ * do not support the FormData class can still run the generated client.
35
+ *
36
+ * @type {new () => FormData}
37
+ */
38
+ formDataCtor?: new () => any;
39
+ constructor(param?: ConfigurationParameters);
40
+ /**
41
+ * Check if the given MIME is a JSON MIME.
42
+ * JSON MIME examples:
43
+ * application/json
44
+ * application/json; charset=UTF8
45
+ * APPLICATION/JSON
46
+ * application/vnd.company+json
47
+ * @param mime - MIME (Multipurpose Internet Mail Extensions)
48
+ * @return True if the given MIME is JSON, false otherwise.
49
+ */
50
+ isJsonMime(mime: string): boolean;
51
+ }
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ /**
5
+ * Hostinger API
6
+ *
7
+ * API Version: 0.0.9
8
+ *
9
+ * NOTE: This file is auto-generated, DO NOT EDIT THIS FILE MANUALLY!
10
+ * If you want to contribute or request a new feature, please create an issue or pull request on https://github.com/hostinger/api
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.Configuration = void 0;
14
+ class Configuration {
15
+ constructor(param = {}) {
16
+ var _a;
17
+ this.accessToken = param.accessToken;
18
+ this.basePath = param.basePath;
19
+ this.baseOptions = Object.assign(Object.assign({}, param.baseOptions), { headers: Object.assign({ 'User-Agent': "hostinger-api-sdk-typescript/0.0.3" }, (_a = param.baseOptions) === null || _a === void 0 ? void 0 : _a.headers) });
20
+ this.formDataCtor = param.formDataCtor;
21
+ }
22
+ /**
23
+ * Check if the given MIME is a JSON MIME.
24
+ * JSON MIME examples:
25
+ * application/json
26
+ * application/json; charset=UTF8
27
+ * APPLICATION/JSON
28
+ * application/vnd.company+json
29
+ * @param mime - MIME (Multipurpose Internet Mail Extensions)
30
+ * @return True if the given MIME is JSON, false otherwise.
31
+ */
32
+ isJsonMime(mime) {
33
+ const jsonMime = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
34
+ return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
35
+ }
36
+ }
37
+ exports.Configuration = Configuration;