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