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.
@@ -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 {};
@@ -0,0 +1,57 @@
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
+ import globalAxios from 'axios';
12
+ export const BASE_PATH = "https://developers.hostinger.com".replace(/\/+$/, "");
13
+ /**
14
+ *
15
+ * @export
16
+ */
17
+ export const COLLECTION_FORMATS = {
18
+ csv: ",",
19
+ ssv: " ",
20
+ tsv: "\t",
21
+ pipes: "|",
22
+ };
23
+ /**
24
+ *
25
+ * @export
26
+ * @class BaseAPI
27
+ */
28
+ export class BaseAPI {
29
+ constructor(configuration, basePath = BASE_PATH, axios = globalAxios) {
30
+ var _a;
31
+ this.basePath = basePath;
32
+ this.axios = axios;
33
+ if (configuration) {
34
+ this.configuration = configuration;
35
+ this.basePath = (_a = configuration.basePath) !== null && _a !== void 0 ? _a : basePath;
36
+ }
37
+ }
38
+ }
39
+ ;
40
+ /**
41
+ *
42
+ * @export
43
+ * @class RequiredError
44
+ * @extends {Error}
45
+ */
46
+ export class RequiredError extends Error {
47
+ constructor(field, msg) {
48
+ super(msg);
49
+ this.field = field;
50
+ this.name = "RequiredError";
51
+ }
52
+ }
53
+ /**
54
+ *
55
+ * @export
56
+ */
57
+ export const 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>;
@@ -0,0 +1,109 @@
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
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
12
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
13
+ return new (P || (P = Promise))(function (resolve, reject) {
14
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
15
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
16
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
17
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
18
+ });
19
+ };
20
+ import { RequiredError } from "./base";
21
+ /**
22
+ *
23
+ * @export
24
+ */
25
+ export const DUMMY_BASE_URL = 'https://example.com';
26
+ /**
27
+ *
28
+ * @throws {RequiredError}
29
+ * @export
30
+ */
31
+ export const assertParamExists = function (functionName, paramName, paramValue) {
32
+ if (paramValue === null || paramValue === undefined) {
33
+ throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`);
34
+ }
35
+ };
36
+ /**
37
+ *
38
+ * @export
39
+ */
40
+ export const setBearerAuthToObject = function (object, configuration) {
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ if (configuration && configuration.accessToken) {
43
+ const accessToken = typeof configuration.accessToken === 'function'
44
+ ? yield configuration.accessToken()
45
+ : yield configuration.accessToken;
46
+ object["Authorization"] = "Bearer " + accessToken;
47
+ }
48
+ });
49
+ };
50
+ function setFlattenedQueryParams(urlSearchParams, parameter, key = "") {
51
+ if (parameter == null)
52
+ return;
53
+ if (typeof parameter === "object") {
54
+ if (Array.isArray(parameter)) {
55
+ parameter.forEach(item => setFlattenedQueryParams(urlSearchParams, item, key));
56
+ }
57
+ else {
58
+ Object.keys(parameter).forEach(currentKey => setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== '' ? '.' : ''}${currentKey}`));
59
+ }
60
+ }
61
+ else {
62
+ if (urlSearchParams.has(key)) {
63
+ urlSearchParams.append(key, parameter);
64
+ }
65
+ else {
66
+ urlSearchParams.set(key, parameter);
67
+ }
68
+ }
69
+ }
70
+ /**
71
+ *
72
+ * @export
73
+ */
74
+ export const setSearchParams = function (url, ...objects) {
75
+ const searchParams = new URLSearchParams(url.search);
76
+ setFlattenedQueryParams(searchParams, objects);
77
+ url.search = searchParams.toString();
78
+ };
79
+ /**
80
+ *
81
+ * @export
82
+ */
83
+ export const serializeDataIfNeeded = function (value, requestOptions, configuration) {
84
+ const nonString = typeof value !== 'string';
85
+ const needsSerialization = nonString && configuration && configuration.isJsonMime
86
+ ? configuration.isJsonMime(requestOptions.headers['Content-Type'])
87
+ : nonString;
88
+ return needsSerialization
89
+ ? JSON.stringify(value !== undefined ? value : {})
90
+ : (value || "");
91
+ };
92
+ /**
93
+ *
94
+ * @export
95
+ */
96
+ export const toPathString = function (url) {
97
+ return url.pathname + url.search + url.hash;
98
+ };
99
+ /**
100
+ *
101
+ * @export
102
+ */
103
+ export const createRequestFunction = function (axiosArgs, globalAxios, BASE_PATH, configuration) {
104
+ return (axios = globalAxios, basePath = BASE_PATH) => {
105
+ var _a;
106
+ 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 });
107
+ return axios.request(axiosRequestArgs);
108
+ };
109
+ };
@@ -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,33 @@
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
+ export class Configuration {
12
+ constructor(param = {}) {
13
+ var _a;
14
+ this.accessToken = param.accessToken;
15
+ this.basePath = param.basePath;
16
+ 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) });
17
+ this.formDataCtor = param.formDataCtor;
18
+ }
19
+ /**
20
+ * Check if the given MIME is a JSON MIME.
21
+ * JSON MIME examples:
22
+ * application/json
23
+ * application/json; charset=UTF8
24
+ * APPLICATION/JSON
25
+ * application/vnd.company+json
26
+ * @param mime - MIME (Multipurpose Internet Mail Extensions)
27
+ * @return True if the given MIME is JSON, false otherwise.
28
+ */
29
+ isJsonMime(mime) {
30
+ const jsonMime = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
31
+ return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
32
+ }
33
+ }
@@ -0,0 +1,10 @@
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 * from "./api";
10
+ export * from "./configuration";
@@ -0,0 +1,12 @@
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
+ export * from "./api";
12
+ export * from "./configuration";
@@ -0,0 +1,10 @@
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 * from "./api";
10
+ export * from "./configuration";
package/dist/index.js ADDED
@@ -0,0 +1,28 @@
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ var desc = Object.getOwnPropertyDescriptor(m, k);
15
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
16
+ desc = { enumerable: true, get: function() { return m[k]; } };
17
+ }
18
+ Object.defineProperty(o, k2, desc);
19
+ }) : (function(o, m, k, k2) {
20
+ if (k2 === undefined) k2 = k;
21
+ o[k2] = m[k];
22
+ }));
23
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
24
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
25
+ };
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ __exportStar(require("./api"), exports);
28
+ __exportStar(require("./configuration"), exports);
package/index.ts ADDED
@@ -0,0 +1,15 @@
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 * from "./api";
14
+ export * from "./configuration";
15
+
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "hostinger-api-sdk",
3
+ "version": "0.0.1",
4
+ "description": "Hostinger API TypeScript SDK",
5
+ "author": "Hostinger",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/hostinger/api-typescript-sdk.git"
9
+ },
10
+ "keywords": [
11
+ "hostinger",
12
+ "openapi",
13
+ "typescript",
14
+ "sdk",
15
+ "rest",
16
+ "api"
17
+ ],
18
+ "license": "MIT",
19
+ "main": "./dist/index.js",
20
+ "typings": "./dist/index.d.ts",
21
+ "module": "./dist/esm/index.js",
22
+ "sideEffects": false,
23
+ "scripts": {
24
+ "build": "tsc && tsc -p tsconfig.esm.json",
25
+ "prepare": "npm run build"
26
+ },
27
+ "dependencies": {
28
+ "axios": "^1.8.0"
29
+ },
30
+ "devDependencies": {
31
+ "@types/node": "12.11.5 - 12.20.42",
32
+ "typescript": "^4.0 || ^5.0"
33
+ }
34
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "module": "esnext",
5
+ "outDir": "dist/esm"
6
+ }
7
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "compilerOptions": {
3
+ "declaration": true,
4
+ "target": "ES6",
5
+ "module": "commonjs",
6
+ "noImplicitAny": true,
7
+ "outDir": "dist",
8
+ "rootDir": ".",
9
+ "moduleResolution": "node",
10
+ "typeRoots": [
11
+ "node_modules/@types"
12
+ ]
13
+ },
14
+ "exclude": [
15
+ "dist",
16
+ "node_modules"
17
+ ]
18
+ }