@emilgroup/payment-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 (160) hide show
  1. package/.openapi-generator/FILES +58 -0
  2. package/.openapi-generator/VERSION +1 -0
  3. package/.openapi-generator-ignore +23 -0
  4. package/README.md +51 -0
  5. package/api/bank-accounts-api.ts +337 -0
  6. package/api/default-api.ts +120 -0
  7. package/api/payment-methods-api.ts +577 -0
  8. package/api/payment-reminders-api.ts +556 -0
  9. package/api/payment-service-providers-api.ts +161 -0
  10. package/api/payment-setup-api.ts +264 -0
  11. package/api/payments-api.ts +489 -0
  12. package/api/webhooks-api.ts +150 -0
  13. package/api.ts +41 -0
  14. package/base.ts +251 -0
  15. package/common.ts +198 -0
  16. package/configuration.ts +101 -0
  17. package/dist/api/bank-accounts-api.d.ts +197 -0
  18. package/dist/api/bank-accounts-api.js +347 -0
  19. package/dist/api/default-api.d.ts +66 -0
  20. package/dist/api/default-api.js +196 -0
  21. package/dist/api/payment-methods-api.d.ts +327 -0
  22. package/dist/api/payment-methods-api.js +547 -0
  23. package/dist/api/payment-reminders-api.d.ts +317 -0
  24. package/dist/api/payment-reminders-api.js +538 -0
  25. package/dist/api/payment-service-providers-api.d.ts +93 -0
  26. package/dist/api/payment-service-providers-api.js +220 -0
  27. package/dist/api/payment-setup-api.d.ts +146 -0
  28. package/dist/api/payment-setup-api.js +309 -0
  29. package/dist/api/payments-api.d.ts +281 -0
  30. package/dist/api/payments-api.js +461 -0
  31. package/dist/api/webhooks-api.d.ts +91 -0
  32. package/dist/api/webhooks-api.js +209 -0
  33. package/dist/api.d.ts +19 -0
  34. package/dist/api.js +37 -0
  35. package/dist/base.d.ts +74 -0
  36. package/dist/base.js +298 -0
  37. package/dist/common.d.ts +91 -0
  38. package/dist/common.js +276 -0
  39. package/dist/configuration.d.ts +83 -0
  40. package/dist/configuration.js +44 -0
  41. package/dist/index.d.ts +15 -0
  42. package/dist/index.js +36 -0
  43. package/dist/models/bank-account-class.d.ts +54 -0
  44. package/dist/models/bank-account-class.js +15 -0
  45. package/dist/models/billing-profile-dto.d.ts +38 -0
  46. package/dist/models/billing-profile-dto.js +15 -0
  47. package/dist/models/billing-profile-limited-response-dto.d.ts +54 -0
  48. package/dist/models/billing-profile-limited-response-dto.js +15 -0
  49. package/dist/models/complete-braintree-payment-setup-request-dto.d.ts +48 -0
  50. package/dist/models/complete-braintree-payment-setup-request-dto.js +15 -0
  51. package/dist/models/complete-payment-setup-request-dto.d.ts +32 -0
  52. package/dist/models/complete-payment-setup-request-dto.js +15 -0
  53. package/dist/models/complete-payment-setup-response-class.d.ts +25 -0
  54. package/dist/models/complete-payment-setup-response-class.js +15 -0
  55. package/dist/models/complete-stripe-payment-setup-request-dto.d.ts +60 -0
  56. package/dist/models/complete-stripe-payment-setup-request-dto.js +15 -0
  57. package/dist/models/create-bank-account-request-dto.d.ts +30 -0
  58. package/dist/models/create-bank-account-request-dto.js +15 -0
  59. package/dist/models/create-payment-method-response-class.d.ts +25 -0
  60. package/dist/models/create-payment-method-response-class.js +15 -0
  61. package/dist/models/create-payment-reminder-request-dto.d.ts +65 -0
  62. package/dist/models/create-payment-reminder-request-dto.js +26 -0
  63. package/dist/models/create-payment-request-dto.d.ts +72 -0
  64. package/dist/models/create-payment-request-dto.js +15 -0
  65. package/dist/models/create-payment-response-class.d.ts +25 -0
  66. package/dist/models/create-payment-response-class.js +15 -0
  67. package/dist/models/create-psp-payment-method-request-dto.d.ts +61 -0
  68. package/dist/models/create-psp-payment-method-request-dto.js +32 -0
  69. package/dist/models/deactivate-payment-reminder-request-dto.d.ts +30 -0
  70. package/dist/models/deactivate-payment-reminder-request-dto.js +21 -0
  71. package/dist/models/get-payment-method-response-class.d.ts +25 -0
  72. package/dist/models/get-payment-method-response-class.js +15 -0
  73. package/dist/models/get-payment-response-class.d.ts +25 -0
  74. package/dist/models/get-payment-response-class.js +15 -0
  75. package/dist/models/get-request-dto.d.ts +30 -0
  76. package/dist/models/get-request-dto.js +15 -0
  77. package/dist/models/index.d.ts +37 -0
  78. package/dist/models/index.js +53 -0
  79. package/dist/models/initiate-braintree-payment-setup-request-dto.d.ts +30 -0
  80. package/dist/models/initiate-braintree-payment-setup-request-dto.js +15 -0
  81. package/dist/models/initiate-braintree-payment-setup-response-class.d.ts +24 -0
  82. package/dist/models/initiate-braintree-payment-setup-response-class.js +15 -0
  83. package/dist/models/initiate-payment-setup-request-dto.d.ts +44 -0
  84. package/dist/models/initiate-payment-setup-request-dto.js +15 -0
  85. package/dist/models/initiate-payment-setup-response-class.d.ts +32 -0
  86. package/dist/models/initiate-payment-setup-response-class.js +15 -0
  87. package/dist/models/initiate-stripe-payment-setup-request-dto.d.ts +30 -0
  88. package/dist/models/initiate-stripe-payment-setup-request-dto.js +15 -0
  89. package/dist/models/initiate-stripe-payment-setup-response-class.d.ts +30 -0
  90. package/dist/models/initiate-stripe-payment-setup-response-class.js +15 -0
  91. package/dist/models/inline-response200.d.ts +54 -0
  92. package/dist/models/inline-response200.js +15 -0
  93. package/dist/models/inline-response503.d.ts +54 -0
  94. package/dist/models/inline-response503.js +15 -0
  95. package/dist/models/list-bank-accounts-response-class.d.ts +31 -0
  96. package/dist/models/list-bank-accounts-response-class.js +15 -0
  97. package/dist/models/list-payment-methods-response-class.d.ts +31 -0
  98. package/dist/models/list-payment-methods-response-class.js +15 -0
  99. package/dist/models/list-payment-reminders-response-class.d.ts +31 -0
  100. package/dist/models/list-payment-reminders-response-class.js +15 -0
  101. package/dist/models/list-payments-response-class.d.ts +31 -0
  102. package/dist/models/list-payments-response-class.js +15 -0
  103. package/dist/models/payment-class.d.ts +103 -0
  104. package/dist/models/payment-class.js +15 -0
  105. package/dist/models/payment-method-class.d.ts +60 -0
  106. package/dist/models/payment-method-class.js +15 -0
  107. package/dist/models/payment-reminder-class.d.ts +112 -0
  108. package/dist/models/payment-reminder-class.js +36 -0
  109. package/dist/models/sepa-direct-dto.d.ts +24 -0
  110. package/dist/models/sepa-direct-dto.js +15 -0
  111. package/dist/models/symphony-profile-limited-response-dto.d.ts +42 -0
  112. package/dist/models/symphony-profile-limited-response-dto.js +15 -0
  113. package/dist/models/transaction-class.d.ts +54 -0
  114. package/dist/models/transaction-class.js +15 -0
  115. package/dist/models/validate-pspconfig-request-dto.d.ts +43 -0
  116. package/dist/models/validate-pspconfig-request-dto.js +22 -0
  117. package/dist/models/validate-pspconfig-response-class.d.ts +24 -0
  118. package/dist/models/validate-pspconfig-response-class.js +15 -0
  119. package/git_push.sh +57 -0
  120. package/index.ts +19 -0
  121. package/models/bank-account-class.ts +60 -0
  122. package/models/billing-profile-dto.ts +44 -0
  123. package/models/billing-profile-limited-response-dto.ts +60 -0
  124. package/models/complete-braintree-payment-setup-request-dto.ts +54 -0
  125. package/models/complete-payment-setup-request-dto.ts +38 -0
  126. package/models/complete-payment-setup-response-class.ts +31 -0
  127. package/models/complete-stripe-payment-setup-request-dto.ts +66 -0
  128. package/models/create-bank-account-request-dto.ts +36 -0
  129. package/models/create-payment-method-response-class.ts +31 -0
  130. package/models/create-payment-reminder-request-dto.ts +74 -0
  131. package/models/create-payment-request-dto.ts +78 -0
  132. package/models/create-payment-response-class.ts +31 -0
  133. package/models/create-psp-payment-method-request-dto.ts +70 -0
  134. package/models/deactivate-payment-reminder-request-dto.ts +39 -0
  135. package/models/get-payment-method-response-class.ts +31 -0
  136. package/models/get-payment-response-class.ts +31 -0
  137. package/models/get-request-dto.ts +36 -0
  138. package/models/index.ts +37 -0
  139. package/models/initiate-braintree-payment-setup-request-dto.ts +36 -0
  140. package/models/initiate-braintree-payment-setup-response-class.ts +30 -0
  141. package/models/initiate-payment-setup-request-dto.ts +50 -0
  142. package/models/initiate-payment-setup-response-class.ts +38 -0
  143. package/models/initiate-stripe-payment-setup-request-dto.ts +36 -0
  144. package/models/initiate-stripe-payment-setup-response-class.ts +36 -0
  145. package/models/inline-response200.ts +48 -0
  146. package/models/inline-response503.ts +48 -0
  147. package/models/list-bank-accounts-response-class.ts +37 -0
  148. package/models/list-payment-methods-response-class.ts +37 -0
  149. package/models/list-payment-reminders-response-class.ts +37 -0
  150. package/models/list-payments-response-class.ts +37 -0
  151. package/models/payment-class.ts +109 -0
  152. package/models/payment-method-class.ts +66 -0
  153. package/models/payment-reminder-class.ts +122 -0
  154. package/models/sepa-direct-dto.ts +30 -0
  155. package/models/symphony-profile-limited-response-dto.ts +48 -0
  156. package/models/transaction-class.ts +60 -0
  157. package/models/validate-pspconfig-request-dto.ts +52 -0
  158. package/models/validate-pspconfig-response-class.ts +30 -0
  159. package/package.json +27 -0
  160. package/tsconfig.json +22 -0
package/api.ts ADDED
@@ -0,0 +1,41 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * Emil Payment Service
5
+ * This service directly communicates with the various Payment Service Providers (PSPs) in order to charge or refund customers. This service will automatically connect to the PSP linked in your admin configuration; meaning if you configured Stripe, it will automatically create a payment on Stripe when you create it in Emil.
6
+ *
7
+ * The version of the OpenAPI document: 1.0
8
+ * Contact: kontakt@emil.de
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 { BankAccountsApi } from './api';
24
+ import { DefaultApi } from './api';
25
+ import { PaymentMethodsApi } from './api';
26
+ import { PaymentRemindersApi } from './api';
27
+ import { PaymentServiceProvidersApi } from './api';
28
+ import { PaymentSetupApi } from './api';
29
+ import { PaymentsApi } from './api';
30
+ import { WebhooksApi } from './api';
31
+
32
+
33
+ export * from './api/bank-accounts-api';
34
+ export * from './api/default-api';
35
+ export * from './api/payment-methods-api';
36
+ export * from './api/payment-reminders-api';
37
+ export * from './api/payment-service-providers-api';
38
+ export * from './api/payment-setup-api';
39
+ export * from './api/payments-api';
40
+ export * from './api/webhooks-api';
41
+
package/base.ts ADDED
@@ -0,0 +1,251 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * Emil Payment Service
5
+ * This service directly communicates with the various Payment Service Providers (PSPs) in order to charge or refund customers. This service will automatically connect to the PSP linked in your admin configuration; meaning if you configured Stripe, it will automatically create a payment on Stripe when you create it in Emil.
6
+ *
7
+ * The version of the OpenAPI document: 1.0
8
+ * Contact: kontakt@emil.de
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 { defaultStorage } from "./common";
18
+ // Some imports not used depending on template conditions
19
+ // @ts-ignore
20
+ import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
21
+
22
+
23
+ export const BASE_PATH = "https://apiv2.emil.de".replace(/\/+$/, "");
24
+ /**
25
+ *
26
+ * @export
27
+ */
28
+ export const COLLECTION_FORMATS = {
29
+ csv: ",",
30
+ ssv: " ",
31
+ tsv: "\t",
32
+ pipes: "|",
33
+ };
34
+
35
+ export interface LoginClass {
36
+ accessToken: string;
37
+ permissions: Array<string>;
38
+ }
39
+
40
+ export enum Environment {
41
+ Production = 'https://apiv2.emil.de',
42
+ Test = 'https://apiv2-test.emil.de',
43
+ Development = 'https://apiv2-dev.emil.de',
44
+ ProductionZurich = 'https://eu-central-2.apiv2.emil.de',
45
+ }
46
+
47
+ let _retry_count = 0
48
+ let _retry = null
49
+
50
+ export function resetRetry() {
51
+ _retry_count = 0
52
+ }
53
+
54
+ /**
55
+ *
56
+ * @export
57
+ * @interface RequestArgs
58
+ */
59
+ export interface RequestArgs {
60
+ url: string;
61
+ options: AxiosRequestConfig;
62
+ }
63
+
64
+ interface TokenData {
65
+ accessToken?: string;
66
+ username?: string;
67
+ }
68
+
69
+ const NETWORK_ERROR_MESSAGE = "Network Error";
70
+ const TOKEN_DATA = 'APP_TOKEN';
71
+
72
+ /**
73
+ *
74
+ * @export
75
+ * @class BaseAPI
76
+ */
77
+ export class BaseAPI {
78
+ protected configuration: Configuration | undefined;
79
+ private tokenData?: TokenData;
80
+
81
+ constructor(configuration?: Configuration,
82
+ protected basePath: string = BASE_PATH,
83
+ protected axios: AxiosInstance = globalAxios) {
84
+
85
+ this.loadTokenData();
86
+
87
+ if (configuration) {
88
+ this.configuration = configuration;
89
+ this.basePath = configuration.basePath || this.basePath;
90
+ } else {
91
+ const { accessToken, username } = this.tokenData;
92
+
93
+ this.configuration = new Configuration({
94
+ basePath: this.basePath,
95
+ accessToken: accessToken ? `Bearer ${accessToken}` : '',
96
+ username,
97
+ });
98
+ }
99
+
100
+ this.attachInterceptor(axios);
101
+ }
102
+
103
+ selectEnvironment(env: Environment) {
104
+ this.configuration.basePath = env;
105
+ }
106
+
107
+ async authorize(username: string, password: string): Promise<void> {
108
+ const options: AxiosRequestConfig = {
109
+ method: 'POST',
110
+ url: `${this.configuration.basePath}/authservice/v1/login`,
111
+ headers: { 'Content-Type': 'application/json' },
112
+ data: {
113
+ username,
114
+ password,
115
+ },
116
+ withCredentials: true,
117
+ };
118
+
119
+ const response = await globalAxios.request<LoginClass>(options);
120
+
121
+ const { data: { accessToken } } = response;
122
+
123
+ this.configuration.username = username;
124
+ this.configuration.accessToken = `Bearer ${accessToken}`;
125
+ this.tokenData.username = username;
126
+ this.tokenData.accessToken = accessToken;
127
+
128
+ this.storeTokenData({
129
+ ...this.tokenData
130
+ });
131
+ }
132
+
133
+ async refreshTokenInternal(): Promise<string> {
134
+ const { username } = this.configuration;
135
+
136
+ if (!username) {
137
+ return '';
138
+ }
139
+
140
+ const options: AxiosRequestConfig = {
141
+ method: 'POST',
142
+ url: `${this.configuration.basePath}/authservice/v1/refresh-token`,
143
+ headers: {
144
+ 'Content-Type': 'application/json',
145
+ },
146
+ data: { username: username },
147
+ withCredentials: true,
148
+ };
149
+
150
+ const { data: { accessToken } } = await globalAxios.request<LoginClass>(options);
151
+
152
+ return accessToken;
153
+ }
154
+
155
+ private storeTokenData(tokenData?: TokenData) {
156
+ if (typeof window !== 'undefined') {
157
+ defaultStorage().set<TokenData>(TOKEN_DATA, tokenData);
158
+ }
159
+ }
160
+
161
+ public loadTokenData() {
162
+ if (typeof window !== 'undefined') {
163
+ this.tokenData = defaultStorage().get<TokenData>(TOKEN_DATA) || {};
164
+ } else {
165
+ this.tokenData = {};
166
+ }
167
+ }
168
+
169
+ public cleanTokenData() {
170
+ this.storeTokenData(null);
171
+ }
172
+
173
+ private attachInterceptor(axios: AxiosInstance) {
174
+ axios.interceptors.response.use(
175
+ (res) => {
176
+ return res;
177
+ },
178
+ async (err) => {
179
+ let originalConfig = err.config;
180
+ if (err.response && !(err.response instanceof XMLHttpRequest)) { // sometimes buggy and is of type request
181
+ // Access Token was expired
182
+ if ((err.response.status === 401 || err.response.status === 403)
183
+ && !originalConfig._retry) {
184
+ originalConfig._retry = true;
185
+ try {
186
+ let tokenString = await this.refreshTokenInternal();
187
+ const accessToken = `Bearer ${tokenString}`;
188
+
189
+ delete originalConfig.headers['Authorization']
190
+
191
+ originalConfig.headers['Authorization'] = accessToken;
192
+
193
+ this.configuration.accessToken = accessToken;
194
+ this.tokenData.accessToken = tokenString;
195
+
196
+ this.storeTokenData(this.tokenData);
197
+
198
+ return axios(originalConfig);
199
+ } catch (_error) {
200
+ if (_error.response && _error.response.data) {
201
+ return Promise.reject(_error.response.data);
202
+ }
203
+ return Promise.reject(_error);
204
+ }
205
+ }
206
+ } else if (err.message === NETWORK_ERROR_MESSAGE
207
+ && originalConfig.headers.hasOwnProperty('Authorization')
208
+ && _retry_count < 4
209
+ ) {
210
+ _retry_count++;
211
+ try {
212
+ let tokenString = await this.refreshTokenInternal();
213
+ const accessToken = `Bearer ${tokenString}`;
214
+
215
+ _retry = true;
216
+ originalConfig.headers['Authorization'] = accessToken;
217
+
218
+ this.configuration.accessToken = accessToken;
219
+ this.tokenData.accessToken = tokenString;
220
+
221
+ this.storeTokenData(this.tokenData);
222
+
223
+ return axios.request({
224
+ ...originalConfig,
225
+ });
226
+ } catch (_error) {
227
+ if (_error.response && _error.response.data) {
228
+ return Promise.reject(_error.response.data);
229
+ }
230
+ return Promise.reject(_error);
231
+ }
232
+ }
233
+ return Promise.reject(err);
234
+ }
235
+ );
236
+ }
237
+ };
238
+
239
+ /**
240
+ *
241
+ * @export
242
+ * @class RequiredError
243
+ * @extends {Error}
244
+ */
245
+ export class RequiredError extends Error {
246
+ name: "RequiredError" = "RequiredError";
247
+ constructor(public field: string, msg?: string) {
248
+ super(msg);
249
+ }
250
+ }
251
+
package/common.ts ADDED
@@ -0,0 +1,198 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * Emil Payment Service
5
+ * This service directly communicates with the various Payment Service Providers (PSPs) in order to charge or refund customers. This service will automatically connect to the PSP linked in your admin configuration; meaning if you configured Stripe, it will automatically create a payment on Stripe when you create it in Emil.
6
+ *
7
+ * The version of the OpenAPI document: 1.0
8
+ * Contact: kontakt@emil.de
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
+ * @export
22
+ */
23
+ export const DUMMY_BASE_URL = 'https://example.com'
24
+
25
+ /**
26
+ *
27
+ * @throws {RequiredError}
28
+ * @export
29
+ */
30
+ export const assertParamExists = function (functionName: string, paramName: string, paramValue: unknown) {
31
+ if (paramValue === null || paramValue === undefined) {
32
+ throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`);
33
+ }
34
+ }
35
+
36
+ /**
37
+ *
38
+ * @export
39
+ */
40
+ export const setApiKeyToObject = async function (object: any, keyParamName: string, configuration?: Configuration) {
41
+ if (configuration && configuration.apiKey) {
42
+ const localVarApiKeyValue = typeof configuration.apiKey === 'function'
43
+ ? await configuration.apiKey(keyParamName)
44
+ : await configuration.apiKey;
45
+ object[keyParamName] = localVarApiKeyValue;
46
+ }
47
+ }
48
+
49
+ /**
50
+ *
51
+ * @export
52
+ */
53
+ export const setBasicAuthToObject = function (object: any, configuration?: Configuration) {
54
+ if (configuration && (configuration.username || configuration.password)) {
55
+ object["auth"] = { username: configuration.username, password: configuration.password };
56
+ }
57
+ }
58
+
59
+ /**
60
+ *
61
+ * @export
62
+ */
63
+ export const setBearerAuthToObject = async function (object: any, configuration?: Configuration) {
64
+ if (configuration && configuration.accessToken) {
65
+ const accessToken = typeof configuration.accessToken === 'function'
66
+ ? await configuration.accessToken()
67
+ : await configuration.accessToken;
68
+ object["Authorization"] = "Bearer " + accessToken;
69
+ }
70
+ }
71
+
72
+ /**
73
+ *
74
+ * @export
75
+ */
76
+ export const setOAuthToObject = async function (object: any, name: string, scopes: string[], configuration?: Configuration) {
77
+ if (configuration && configuration.accessToken) {
78
+ const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
79
+ ? await configuration.accessToken(name, scopes)
80
+ : await configuration.accessToken;
81
+ object["Authorization"] = "Bearer " + localVarAccessTokenValue;
82
+ }
83
+ }
84
+
85
+ /**
86
+ *
87
+ * @export
88
+ */
89
+ export const setSearchParams = function (url: URL, ...objects: any[]) {
90
+ const searchParams = new URLSearchParams(url.search);
91
+ for (const object of objects) {
92
+ for (const key in object) {
93
+ if (Array.isArray(object[key])) {
94
+ searchParams.delete(key);
95
+ for (const item of object[key]) {
96
+ searchParams.append(key, item);
97
+ }
98
+ } else {
99
+ searchParams.set(key, object[key]);
100
+ }
101
+ }
102
+ }
103
+ url.search = searchParams.toString();
104
+ }
105
+
106
+ /**
107
+ *
108
+ * @export
109
+ */
110
+ export const serializeDataIfNeeded = function (value: any, requestOptions: any, configuration?: Configuration) {
111
+ const nonString = typeof value !== 'string';
112
+ const needsSerialization = nonString && configuration && configuration.isJsonMime
113
+ ? configuration.isJsonMime(requestOptions.headers['Content-Type'])
114
+ : nonString;
115
+ return needsSerialization
116
+ ? JSON.stringify(value !== undefined ? value : {})
117
+ : (value || "");
118
+ }
119
+
120
+ /**
121
+ *
122
+ * @export
123
+ */
124
+ export const toPathString = function (url: URL) {
125
+ return url.pathname + url.search + url.hash
126
+ }
127
+
128
+ /**
129
+ *
130
+ * @export
131
+ */
132
+ export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) {
133
+ return <T = unknown, R = AxiosResponse<T>>(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
134
+ const axiosRequestArgs = {...axiosArgs.options, url: (configuration?.basePath || basePath) + axiosArgs.url};
135
+ return axios.request<T, R>(axiosRequestArgs);
136
+ };
137
+ }
138
+
139
+ /* tslint:disable */
140
+ /* eslint-disable */
141
+ /**
142
+ * Emil Payment Service
143
+ * This service directly communicates with the various Payment Service Providers (PSPs) in order to charge or refund customers. This service will automatically connect to the PSP linked in your admin configuration; meaning if you configured Stripe, it will automatically create a payment on Stripe when you create it in Emil.
144
+ *
145
+ * The version of the OpenAPI document: 1.0
146
+ * Contact: kontakt@emil.de
147
+ *
148
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
149
+ * https://openapi-generator.tech
150
+ * Do not edit the class manually.
151
+ */
152
+
153
+
154
+ export interface IStorageConverter<D, SD> {
155
+ toStorageData( data: D ): SD;
156
+ fromStorageData( storageData: SD ): D;
157
+ }
158
+
159
+ export interface IStorage {
160
+ get<T>( key: string, converter?: IStorageConverter<T, any> ): T | null;
161
+ set<T>( key: string, value: T, converter?: IStorageConverter<T, any> ): void;
162
+ }
163
+
164
+ export class LocalStorage implements IStorage {
165
+ readonly storage: Storage;
166
+
167
+ constructor() {
168
+ this.storage = localStorage;
169
+ }
170
+
171
+ get<T>( key: string, converter?: IStorageConverter<T, any> ): T | null {
172
+ const jsonValue = this.storage.getItem( key );
173
+ if ( jsonValue === null ) {
174
+ return null;
175
+ }
176
+ const value = JSON.parse( jsonValue );
177
+ if ( converter !== undefined ) {
178
+ return converter.fromStorageData( value );
179
+ } else {
180
+ return value as T;
181
+ }
182
+ }
183
+
184
+ set<T>( key: string, value: T, converter?: IStorageConverter<T, any> ): void {
185
+ let valueToStore: any = value;
186
+ if ( converter !== undefined ) {
187
+ valueToStore = converter.toStorageData( value );
188
+ }
189
+ const jsonValue = JSON.stringify( valueToStore );
190
+ this.storage.setItem( key, jsonValue );
191
+ }
192
+ }
193
+
194
+ let _defaultStorage: IStorage = null;
195
+
196
+ export const defaultStorage = (): IStorage => {
197
+ return _defaultStorage || (_defaultStorage = new LocalStorage());
198
+ };
@@ -0,0 +1,101 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * Emil Payment Service
5
+ * This service directly communicates with the various Payment Service Providers (PSPs) in order to charge or refund customers. This service will automatically connect to the PSP linked in your admin configuration; meaning if you configured Stripe, it will automatically create a payment on Stripe when you create it in Emil.
6
+ *
7
+ * The version of the OpenAPI document: 1.0
8
+ * Contact: kontakt@emil.de
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
+ constructor(param: ConfigurationParameters = {}) {
78
+ this.apiKey = param.apiKey;
79
+ this.username = param.username;
80
+ this.password = param.password;
81
+ this.accessToken = param.accessToken;
82
+ this.basePath = param.basePath;
83
+ this.baseOptions = param.baseOptions;
84
+ this.formDataCtor = param.formDataCtor;
85
+ }
86
+
87
+ /**
88
+ * Check if the given MIME is a JSON MIME.
89
+ * JSON MIME examples:
90
+ * application/json
91
+ * application/json; charset=UTF8
92
+ * APPLICATION/JSON
93
+ * application/vnd.company+json
94
+ * @param mime - MIME (Multipurpose Internet Mail Extensions)
95
+ * @return True if the given MIME is JSON, false otherwise.
96
+ */
97
+ public isJsonMime(mime: string): boolean {
98
+ const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
99
+ return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
100
+ }
101
+ }