@emilgroup/customer-sdk-node 1.0.0

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.
Files changed (91) hide show
  1. package/.openapi-generator/FILES +35 -0
  2. package/.openapi-generator/VERSION +1 -0
  3. package/.openapi-generator-ignore +23 -0
  4. package/README.md +51 -0
  5. package/api/customers-api.ts +1284 -0
  6. package/api.ts +36 -0
  7. package/base.ts +187 -0
  8. package/common.ts +139 -0
  9. package/configuration.ts +118 -0
  10. package/dist/api/customers-api.d.ts +730 -0
  11. package/dist/api/customers-api.js +1095 -0
  12. package/dist/api.d.ts +16 -0
  13. package/dist/api.js +36 -0
  14. package/dist/base.d.ts +68 -0
  15. package/dist/base.js +251 -0
  16. package/dist/common.d.ts +66 -0
  17. package/dist/common.js +244 -0
  18. package/dist/configuration.d.ts +98 -0
  19. package/dist/configuration.js +45 -0
  20. package/dist/index.d.ts +15 -0
  21. package/dist/index.js +35 -0
  22. package/dist/models/create-account-request-dto.d.ts +102 -0
  23. package/dist/models/create-account-request-dto.js +21 -0
  24. package/dist/models/create-customer-request-dto.d.ts +43 -0
  25. package/dist/models/create-customer-request-dto.js +15 -0
  26. package/dist/models/create-customer-response-class.d.ts +24 -0
  27. package/dist/models/create-customer-response-class.js +15 -0
  28. package/dist/models/forgot-password-request-dto.d.ts +30 -0
  29. package/dist/models/forgot-password-request-dto.js +15 -0
  30. package/dist/models/get-policy-response-class.d.ts +25 -0
  31. package/dist/models/get-policy-response-class.js +15 -0
  32. package/dist/models/index.d.ts +21 -0
  33. package/dist/models/index.js +37 -0
  34. package/dist/models/invite-class.d.ts +54 -0
  35. package/dist/models/invite-class.js +15 -0
  36. package/dist/models/invite-customer-request-dto.d.ts +30 -0
  37. package/dist/models/invite-customer-request-dto.js +15 -0
  38. package/dist/models/invite-customer-response-class.d.ts +25 -0
  39. package/dist/models/invite-customer-response-class.js +15 -0
  40. package/dist/models/list-invoices-response-class.d.ts +30 -0
  41. package/dist/models/list-invoices-response-class.js +15 -0
  42. package/dist/models/list-policies-response-class.d.ts +31 -0
  43. package/dist/models/list-policies-response-class.js +15 -0
  44. package/dist/models/login-request-dto.d.ts +36 -0
  45. package/dist/models/login-request-dto.js +15 -0
  46. package/dist/models/login-response-class.d.ts +30 -0
  47. package/dist/models/login-response-class.js +15 -0
  48. package/dist/models/policy-class.d.ts +55 -0
  49. package/dist/models/policy-class.js +15 -0
  50. package/dist/models/policy-object-class.d.ts +30 -0
  51. package/dist/models/policy-object-class.js +15 -0
  52. package/dist/models/policy-premium-class.d.ts +43 -0
  53. package/dist/models/policy-premium-class.js +15 -0
  54. package/dist/models/policy-premium-item-class.d.ts +36 -0
  55. package/dist/models/policy-premium-item-class.js +15 -0
  56. package/dist/models/policy-version-class.d.ts +49 -0
  57. package/dist/models/policy-version-class.js +15 -0
  58. package/dist/models/refresh-token-dto.d.ts +30 -0
  59. package/dist/models/refresh-token-dto.js +15 -0
  60. package/dist/models/reset-password-by-customer-request-dto.d.ts +36 -0
  61. package/dist/models/reset-password-by-customer-request-dto.js +15 -0
  62. package/dist/models/timeslice-class.d.ts +56 -0
  63. package/dist/models/timeslice-class.js +15 -0
  64. package/dist/models/verify-customer-invite-response-class.d.ts +36 -0
  65. package/dist/models/verify-customer-invite-response-class.js +15 -0
  66. package/git_push.sh +57 -0
  67. package/index.ts +19 -0
  68. package/models/create-account-request-dto.ts +111 -0
  69. package/models/create-customer-request-dto.ts +49 -0
  70. package/models/create-customer-response-class.ts +30 -0
  71. package/models/forgot-password-request-dto.ts +36 -0
  72. package/models/get-policy-response-class.ts +31 -0
  73. package/models/index.ts +21 -0
  74. package/models/invite-class.ts +60 -0
  75. package/models/invite-customer-request-dto.ts +36 -0
  76. package/models/invite-customer-response-class.ts +31 -0
  77. package/models/list-invoices-response-class.ts +36 -0
  78. package/models/list-policies-response-class.ts +37 -0
  79. package/models/login-request-dto.ts +42 -0
  80. package/models/login-response-class.ts +36 -0
  81. package/models/policy-class.ts +61 -0
  82. package/models/policy-object-class.ts +36 -0
  83. package/models/policy-premium-class.ts +49 -0
  84. package/models/policy-premium-item-class.ts +42 -0
  85. package/models/policy-version-class.ts +55 -0
  86. package/models/refresh-token-dto.ts +36 -0
  87. package/models/reset-password-by-customer-request-dto.ts +42 -0
  88. package/models/timeslice-class.ts +62 -0
  89. package/models/verify-customer-invite-response-class.ts +42 -0
  90. package/package.json +29 -0
  91. package/tsconfig.json +22 -0
package/api.ts ADDED
@@ -0,0 +1,36 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * EMIL CustomerService
5
+ * The EMIL CustomerService API description
6
+ *
7
+ * The version of the OpenAPI document: 1.0
8
+ *
9
+ *
10
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
+ * https://openapi-generator.tech
12
+ * Do not edit the class manually.
13
+ */
14
+
15
+
16
+ import { Configuration } from './configuration';
17
+ import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
18
+ // URLSearchParams not necessarily used
19
+ // @ts-ignore
20
+ import { URL, URLSearchParams } from 'url';
21
+ import FormData from 'form-data'
22
+ // Some imports not used depending on template conditions
23
+ // @ts-ignore
24
+ import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from './common';
25
+ // @ts-ignore
26
+ import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from './base';
27
+ import { CustomersApi } from './api';
28
+
29
+
30
+ export * from './api/customers-api';
31
+
32
+
33
+ export enum Environment {
34
+ Production = 'https://apiv2.emil.de',
35
+ Test = 'https://apiv2-test.emil.de',
36
+ }
package/base.ts ADDED
@@ -0,0 +1,187 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * EMIL CustomerService
5
+ * The EMIL CustomerService API description
6
+ *
7
+ * The version of the OpenAPI document: 1.0
8
+ *
9
+ *
10
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
+ * https://openapi-generator.tech
12
+ * Do not edit the class manually.
13
+ */
14
+
15
+
16
+ import { Configuration } from "./configuration";
17
+ // Some imports not used depending on template conditions
18
+ // @ts-ignore
19
+ import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
20
+
21
+ export const BASE_PATH = "http://localhost".replace(/\/+$/, "");
22
+
23
+ /**
24
+ *
25
+ * @export
26
+ */
27
+ export const COLLECTION_FORMATS = {
28
+ csv: ",",
29
+ ssv: " ",
30
+ tsv: "\t",
31
+ pipes: "|",
32
+ };
33
+
34
+ export interface LoginClass {
35
+ accessToken: string;
36
+ permissions: Array<string>;
37
+ newPasswordRequired: boolean;
38
+ }
39
+
40
+ export enum Environment {
41
+ Production = 'https://apiv2.emil.de',
42
+ Test = 'https://apiv2-test.emil.de',
43
+ }
44
+
45
+ /**
46
+ *
47
+ * @export
48
+ * @interface RequestArgs
49
+ */
50
+ export interface RequestArgs {
51
+ url: string;
52
+ options: AxiosRequestConfig;
53
+ }
54
+
55
+ /**
56
+ *
57
+ * @export
58
+ * @class BaseAPI
59
+ */
60
+ export class BaseAPI {
61
+ protected configuration: Configuration | undefined;
62
+
63
+ constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) {
64
+ if (configuration) {
65
+ this.configuration = configuration;
66
+ this.basePath = configuration.basePath || this.basePath;
67
+ } else {
68
+ this.configuration = new Configuration({
69
+ basePath: this.basePath,
70
+ });
71
+ }
72
+
73
+ axios.interceptors.response.use(
74
+ (res) => {
75
+ return res;
76
+ },
77
+ async (err) => {
78
+ const originalConfig = err.config;
79
+ if (err.response) {
80
+ // Access Token was expired
81
+ if (err.response.status === 401 && !originalConfig._retry) {
82
+ originalConfig._retry = true;
83
+ try {
84
+ const tokenString = await this.refreshTokenInternal();
85
+ const accessToken = `Bearer ${tokenString}`;
86
+
87
+ const localVarHeaderParameter = {} as any;
88
+ localVarHeaderParameter['Authorization'] = accessToken;
89
+
90
+ originalConfig.headers = {
91
+ ...originalConfig.headers,
92
+ ...localVarHeaderParameter,
93
+ };
94
+
95
+ this.configuration.accessToken = accessToken;
96
+
97
+ return axios(originalConfig);
98
+ } catch (_error) {
99
+ if (_error.response && _error.response.data) {
100
+ return Promise.reject(_error.response.data);
101
+ }
102
+ return Promise.reject(_error);
103
+ }
104
+ }
105
+ if (err.response.status === 403 && err.response.data) {
106
+ return Promise.reject(err.response.data);
107
+ }
108
+ }
109
+ return Promise.reject(err);
110
+ }
111
+ );
112
+ }
113
+
114
+ selectEnvironment(env: Environment) {
115
+ this.configuration.basePath = env;
116
+ }
117
+
118
+ async authorize(username: string, password: string, tenantSlug: string): Promise<void> {
119
+ const options: AxiosRequestConfig = {
120
+ method: 'POST',
121
+ url: `${Environment.Test}/v1/customers/login`,
122
+ headers: {'Content-Type': 'application/json'},
123
+ data: {
124
+ username,
125
+ password,
126
+ tenantSlug,
127
+ },
128
+ withCredentials: true,
129
+ };
130
+
131
+ const response = await globalAxios.request<LoginClass>(options);
132
+
133
+ const { data: { accessToken } } = response;
134
+ const refreshToken = this.extractRefreshToken(response)
135
+
136
+ this.configuration.username = username;
137
+ this.configuration.tenantSlug = tenantSlug;
138
+ this.configuration.accessToken = `Bearer ${accessToken}`;
139
+ this.configuration.refreshToken = refreshToken;
140
+ }
141
+
142
+ async refreshTokenInternal(): Promise<string> {
143
+ const { username, refreshToken, tenantSlug } = this.configuration;
144
+
145
+ if (!username || !refreshToken) {
146
+ return '';
147
+ }
148
+
149
+ const options: AxiosRequestConfig = {
150
+ method: 'POST',
151
+ url: `${Environment.Test}/v1/customers/refresh-token`,
152
+ headers: {
153
+ 'Content-Type': 'application/json',
154
+ Cookie: refreshToken,
155
+ },
156
+ data: {username, tenantSlug},
157
+ withCredentials: true,
158
+ };
159
+
160
+ const { data: { accessToken } } = await globalAxios.request<LoginClass>(options);
161
+
162
+ return accessToken;
163
+ }
164
+
165
+ private extractRefreshToken(response: AxiosResponse): string {
166
+ if (response.headers && response.headers['set-cookie']
167
+ && response.headers['set-cookie'].length > 0) {
168
+
169
+ return `${response.headers['set-cookie'][0].split(';')[0]};`;
170
+ }
171
+
172
+ return '';
173
+ }
174
+ };
175
+
176
+ /**
177
+ *
178
+ * @export
179
+ * @class RequiredError
180
+ * @extends {Error}
181
+ */
182
+ export class RequiredError extends Error {
183
+ name: "RequiredError" = "RequiredError";
184
+ constructor(public field: string, msg?: string) {
185
+ super(msg);
186
+ }
187
+ }
package/common.ts ADDED
@@ -0,0 +1,139 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * EMIL CustomerService
5
+ * The EMIL CustomerService API description
6
+ *
7
+ * The version of the OpenAPI document: 1.0
8
+ *
9
+ *
10
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
+ * https://openapi-generator.tech
12
+ * Do not edit the class manually.
13
+ */
14
+
15
+
16
+ import { Configuration } from "./configuration";
17
+ import { RequiredError, RequestArgs } from "./base";
18
+ import { AxiosInstance, AxiosResponse } from 'axios';
19
+ import { URL, URLSearchParams } from 'url';
20
+
21
+ /**
22
+ *
23
+ * @export
24
+ */
25
+ export const DUMMY_BASE_URL = 'https://example.com'
26
+
27
+ /**
28
+ *
29
+ * @throws {RequiredError}
30
+ * @export
31
+ */
32
+ export const assertParamExists = function (functionName: string, paramName: string, paramValue: unknown) {
33
+ if (paramValue === null || paramValue === undefined) {
34
+ throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`);
35
+ }
36
+ }
37
+
38
+ /**
39
+ *
40
+ * @export
41
+ */
42
+ export const setApiKeyToObject = async function (object: any, keyParamName: string, configuration?: Configuration) {
43
+ if (configuration && configuration.apiKey) {
44
+ const localVarApiKeyValue = typeof configuration.apiKey === 'function'
45
+ ? await configuration.apiKey(keyParamName)
46
+ : await configuration.apiKey;
47
+ object[keyParamName] = localVarApiKeyValue;
48
+ }
49
+ }
50
+
51
+ /**
52
+ *
53
+ * @export
54
+ */
55
+ export const setBasicAuthToObject = function (object: any, configuration?: Configuration) {
56
+ if (configuration && (configuration.username || configuration.password)) {
57
+ object["auth"] = { username: configuration.username, password: configuration.password };
58
+ }
59
+ }
60
+
61
+ /**
62
+ *
63
+ * @export
64
+ */
65
+ export const setBearerAuthToObject = async function (object: any, configuration?: Configuration) {
66
+ if (configuration && configuration.accessToken) {
67
+ const accessToken = typeof configuration.accessToken === 'function'
68
+ ? await configuration.accessToken()
69
+ : await configuration.accessToken;
70
+ object["Authorization"] = "Bearer " + accessToken;
71
+ }
72
+ }
73
+
74
+ /**
75
+ *
76
+ * @export
77
+ */
78
+ export const setOAuthToObject = async function (object: any, name: string, scopes: string[], configuration?: Configuration) {
79
+ if (configuration && configuration.accessToken) {
80
+ const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
81
+ ? await configuration.accessToken(name, scopes)
82
+ : await configuration.accessToken;
83
+ object["Authorization"] = "Bearer " + localVarAccessTokenValue;
84
+ }
85
+ }
86
+
87
+ /**
88
+ *
89
+ * @export
90
+ */
91
+ export const setSearchParams = function (url: URL, ...objects: any[]) {
92
+ const searchParams = new URLSearchParams(url.search);
93
+ for (const object of objects) {
94
+ for (const key in object) {
95
+ if (Array.isArray(object[key])) {
96
+ searchParams.delete(key);
97
+ for (const item of object[key]) {
98
+ searchParams.append(key, item);
99
+ }
100
+ } else {
101
+ searchParams.set(key, object[key]);
102
+ }
103
+ }
104
+ }
105
+ url.search = searchParams.toString();
106
+ }
107
+
108
+ /**
109
+ *
110
+ * @export
111
+ */
112
+ export const serializeDataIfNeeded = function (value: any, requestOptions: any, configuration?: Configuration) {
113
+ const nonString = typeof value !== 'string';
114
+ const needsSerialization = nonString && configuration && configuration.isJsonMime
115
+ ? configuration.isJsonMime(requestOptions.headers['Content-Type'])
116
+ : nonString;
117
+ return needsSerialization
118
+ ? JSON.stringify(value !== undefined ? value : {})
119
+ : (value || "");
120
+ }
121
+
122
+ /**
123
+ *
124
+ * @export
125
+ */
126
+ export const toPathString = function (url: URL) {
127
+ return url.pathname + url.search + url.hash
128
+ }
129
+
130
+ /**
131
+ *
132
+ * @export
133
+ */
134
+ export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) {
135
+ return <T = unknown, R = AxiosResponse<T>>(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
136
+ const axiosRequestArgs = {...axiosArgs.options, url: (configuration?.basePath || basePath) + axiosArgs.url};
137
+ return axios.request<T, R>(axiosRequestArgs);
138
+ };
139
+ }
@@ -0,0 +1,118 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * EMIL CustomerService
5
+ * The EMIL CustomerService API description
6
+ *
7
+ * The version of the OpenAPI document: 1.0
8
+ *
9
+ *
10
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11
+ * https://openapi-generator.tech
12
+ * Do not edit the class manually.
13
+ */
14
+
15
+
16
+ export interface ConfigurationParameters {
17
+ apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
18
+ username?: string;
19
+ password?: string;
20
+ tenantSlug?: string;
21
+ accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
22
+ basePath?: string;
23
+ baseOptions?: any;
24
+ formDataCtor?: new () => any;
25
+ }
26
+
27
+ export class Configuration {
28
+ /**
29
+ * parameter for apiKey security
30
+ * @param name security name
31
+ * @memberof Configuration
32
+ */
33
+ apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
34
+ /**
35
+ * parameter for basic security
36
+ *
37
+ * @type {string}
38
+ * @memberof Configuration
39
+ */
40
+ username?: string;
41
+ /**
42
+ * parameter for basic security
43
+ *
44
+ * @type {string}
45
+ * @memberof Configuration
46
+ */
47
+ password?: string;
48
+ /**
49
+ * parameter necessary for auto refresh token
50
+ *
51
+ * @type {string}
52
+ * @memberof Configuration
53
+ */
54
+ tenantSlug?: string;
55
+ /**
56
+ * parameter for oauth2 security
57
+ * @param name security name
58
+ * @param scopes oauth2 scope
59
+ * @memberof Configuration
60
+ */
61
+ accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
62
+ /**
63
+ * override base path
64
+ *
65
+ * @type {string}
66
+ * @memberof Configuration
67
+ */
68
+ basePath?: string;
69
+ /**
70
+ * base options for axios calls
71
+ *
72
+ * @type {any}
73
+ * @memberof Configuration
74
+ */
75
+ baseOptions?: any;
76
+ /**
77
+ * The FormData constructor that will be used to create multipart form data
78
+ * requests. You can inject this here so that execution environments that
79
+ * do not support the FormData class can still run the generated client.
80
+ *
81
+ * @type {new () => FormData}
82
+ */
83
+ formDataCtor?: new () => any;
84
+
85
+ /**
86
+ * parameter for automatically refreshing access token for oauth2 security
87
+ *
88
+ * @type {string}
89
+ * @memberof Configuration
90
+ */
91
+ refreshToken?: string;
92
+
93
+ constructor(param: ConfigurationParameters = {}) {
94
+ this.apiKey = param.apiKey;
95
+ this.username = param.username;
96
+ this.password = param.password;
97
+ this.tenantSlug = param.tenantSlug;
98
+ this.accessToken = param.accessToken;
99
+ this.basePath = param.basePath;
100
+ this.baseOptions = param.baseOptions;
101
+ this.formDataCtor = param.formDataCtor;
102
+ }
103
+
104
+ /**
105
+ * Check if the given MIME is a JSON MIME.
106
+ * JSON MIME examples:
107
+ * application/json
108
+ * application/json; charset=UTF8
109
+ * APPLICATION/JSON
110
+ * application/vnd.company+json
111
+ * @param mime - MIME (Multipurpose Internet Mail Extensions)
112
+ * @return True if the given MIME is JSON, false otherwise.
113
+ */
114
+ public isJsonMime(mime: string): boolean {
115
+ const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
116
+ return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
117
+ }
118
+ }