@emilgroup/billing-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.
- package/.openapi-generator/FILES +35 -0
- package/.openapi-generator/VERSION +1 -0
- package/.openapi-generator-ignore +23 -0
- package/README.md +68 -0
- package/api/correction-invoices-api.ts +165 -0
- package/api/estimated-invoices-api.ts +268 -0
- package/api/initial-invoices-api.ts +165 -0
- package/api/invoices-api.ts +232 -0
- package/api/recurring-invoices-api.ts +165 -0
- package/api.ts +44 -0
- package/base.ts +293 -0
- package/common.ts +138 -0
- package/configuration.ts +109 -0
- package/dist/api/correction-invoices-api.d.ts +93 -0
- package/dist/api/correction-invoices-api.js +224 -0
- package/dist/api/estimated-invoices-api.d.ts +146 -0
- package/dist/api/estimated-invoices-api.js +313 -0
- package/dist/api/initial-invoices-api.d.ts +93 -0
- package/dist/api/initial-invoices-api.js +224 -0
- package/dist/api/invoices-api.d.ts +137 -0
- package/dist/api/invoices-api.js +254 -0
- package/dist/api/recurring-invoices-api.d.ts +93 -0
- package/dist/api/recurring-invoices-api.js +224 -0
- package/dist/api.d.ts +20 -0
- package/dist/api.js +40 -0
- package/dist/base.d.ts +77 -0
- package/dist/base.js +394 -0
- package/dist/common.d.ts +66 -0
- package/dist/common.js +244 -0
- package/dist/configuration.d.ts +90 -0
- package/dist/configuration.js +44 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +35 -0
- package/dist/models/create-correction-invoices-response-class.d.ts +24 -0
- package/dist/models/create-correction-invoices-response-class.js +15 -0
- package/dist/models/create-custom-estimated-invoice-request-dto.d.ts +35 -0
- package/dist/models/create-custom-estimated-invoice-request-dto.js +20 -0
- package/dist/models/create-custom-estimated-invoice-response-class.d.ts +24 -0
- package/dist/models/create-custom-estimated-invoice-response-class.js +15 -0
- package/dist/models/create-estimated-invoice-request-dto.d.ts +31 -0
- package/dist/models/create-estimated-invoice-request-dto.js +15 -0
- package/dist/models/create-estimated-invoice-response-class.d.ts +31 -0
- package/dist/models/create-estimated-invoice-response-class.js +15 -0
- package/dist/models/create-invoice-request-dto.d.ts +75 -0
- package/dist/models/create-invoice-request-dto.js +24 -0
- package/dist/models/create-invoice-response-class.d.ts +25 -0
- package/dist/models/create-invoice-response-class.js +15 -0
- package/dist/models/index.d.ts +17 -0
- package/dist/models/index.js +33 -0
- package/dist/models/invoice-class.d.ts +120 -0
- package/dist/models/invoice-class.js +15 -0
- package/dist/models/list-invoices-response-class.d.ts +30 -0
- package/dist/models/list-invoices-response-class.js +15 -0
- package/dist/models/list-request-dto.d.ts +54 -0
- package/dist/models/list-request-dto.js +15 -0
- package/dist/models/policy-dto.d.ts +85 -0
- package/dist/models/policy-dto.js +15 -0
- package/dist/models/policy-object-dto.d.ts +42 -0
- package/dist/models/policy-object-dto.js +15 -0
- package/dist/models/policy-premium-dto.d.ts +43 -0
- package/dist/models/policy-premium-dto.js +15 -0
- package/dist/models/policy-premium-item-dto.d.ts +49 -0
- package/dist/models/policy-premium-item-dto.js +15 -0
- package/dist/models/policy-version-dto.d.ts +55 -0
- package/dist/models/policy-version-dto.js +15 -0
- package/dist/models/premium-formula-dto.d.ts +72 -0
- package/dist/models/premium-formula-dto.js +15 -0
- package/dist/models/timeslice-dto.d.ts +62 -0
- package/dist/models/timeslice-dto.js +15 -0
- package/git_push.sh +57 -0
- package/index.ts +19 -0
- package/models/create-correction-invoices-response-class.ts +30 -0
- package/models/create-custom-estimated-invoice-request-dto.ts +44 -0
- package/models/create-custom-estimated-invoice-response-class.ts +30 -0
- package/models/create-estimated-invoice-request-dto.ts +37 -0
- package/models/create-estimated-invoice-response-class.ts +37 -0
- package/models/create-invoice-request-dto.ts +84 -0
- package/models/create-invoice-response-class.ts +31 -0
- package/models/index.ts +17 -0
- package/models/invoice-class.ts +126 -0
- package/models/list-invoices-response-class.ts +36 -0
- package/models/list-request-dto.ts +60 -0
- package/models/policy-dto.ts +91 -0
- package/models/policy-object-dto.ts +48 -0
- package/models/policy-premium-dto.ts +49 -0
- package/models/policy-premium-item-dto.ts +55 -0
- package/models/policy-version-dto.ts +61 -0
- package/models/premium-formula-dto.ts +78 -0
- package/models/timeslice-dto.ts +68 -0
- package/package.json +30 -0
- package/tsconfig.json +22 -0
package/base.ts
ADDED
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* EMIL BillingService
|
|
5
|
+
* The EMIL BillingService 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
|
+
import * as fs from 'fs';
|
|
21
|
+
import * as path from 'path';
|
|
22
|
+
import * as os from 'os';
|
|
23
|
+
|
|
24
|
+
export const BASE_PATH = "https://apiv2.emil.de".replace(/\/+$/, "");
|
|
25
|
+
const CONFIG_DIRECTORY = '.emil';
|
|
26
|
+
const CONFIG_FILENAME = 'credentials';
|
|
27
|
+
const KEY_USERNAME = 'emil_username';
|
|
28
|
+
const KEY_PASSWORD = 'emil_password';
|
|
29
|
+
|
|
30
|
+
const filePath = os.homedir() + path.sep + CONFIG_DIRECTORY + path.sep + CONFIG_FILENAME;
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* @export
|
|
34
|
+
*/
|
|
35
|
+
export const COLLECTION_FORMATS = {
|
|
36
|
+
csv: ",",
|
|
37
|
+
ssv: " ",
|
|
38
|
+
tsv: "\t",
|
|
39
|
+
pipes: "|",
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export interface LoginClass {
|
|
43
|
+
accessToken: string;
|
|
44
|
+
permissions: Array<string>;
|
|
45
|
+
newPasswordRequired: boolean;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export enum Environment {
|
|
49
|
+
Production = 'https://apiv2.emil.de',
|
|
50
|
+
Test = 'https://apiv2-test.emil.de',
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
*
|
|
55
|
+
* @export
|
|
56
|
+
* @interface RequestArgs
|
|
57
|
+
*/
|
|
58
|
+
export interface RequestArgs {
|
|
59
|
+
url: string;
|
|
60
|
+
options: AxiosRequestConfig;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const NETWORK_ERROR_MESSAGE = "Network Error";
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
*
|
|
67
|
+
* @export
|
|
68
|
+
* @class BaseAPI
|
|
69
|
+
*/
|
|
70
|
+
export class BaseAPI {
|
|
71
|
+
protected configuration: Configuration;
|
|
72
|
+
private lastRequestConfig?: AxiosRequestConfig;
|
|
73
|
+
private username?: string;
|
|
74
|
+
private password?: string;
|
|
75
|
+
|
|
76
|
+
constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) {
|
|
77
|
+
if (configuration) {
|
|
78
|
+
this.configuration = configuration;
|
|
79
|
+
this.basePath = configuration.basePath || this.basePath;
|
|
80
|
+
} else {
|
|
81
|
+
this.configuration = new Configuration({
|
|
82
|
+
basePath: this.basePath,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
this.attachInterceptor(axios);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async initialize(env: Environment = Environment.Production) {
|
|
90
|
+
this.configuration.basePath = env;
|
|
91
|
+
|
|
92
|
+
await this.loadCredentials();
|
|
93
|
+
|
|
94
|
+
if (this.username) {
|
|
95
|
+
await this.authorize(this.username, this.password);
|
|
96
|
+
this.password = null; // to avoid keeping password loaded in memory.
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
private async loadCredentials() {
|
|
101
|
+
try {
|
|
102
|
+
await this.readConfigFile();
|
|
103
|
+
} catch (error) {
|
|
104
|
+
console.warn(`No credentials file found. Check that ${filePath} exists.`);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
this.readEnvVariables();
|
|
108
|
+
|
|
109
|
+
if (!this.username) {
|
|
110
|
+
console.info(`No credentials found in credentials file or environment variables. Either provide some or use
|
|
111
|
+
authorize() function.`);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
private async readConfigFile() {
|
|
116
|
+
const file = await fs.promises.readFile(filePath, 'utf-8');
|
|
117
|
+
|
|
118
|
+
const lines = file.split(os.EOL)
|
|
119
|
+
.filter(Boolean);
|
|
120
|
+
|
|
121
|
+
lines.forEach((line: string) => {
|
|
122
|
+
if (line.startsWith(KEY_USERNAME)) {
|
|
123
|
+
this.username = line.length > KEY_USERNAME.length + 1 ? line.substring(KEY_USERNAME.length + 1) : '';
|
|
124
|
+
} else if (line.startsWith(KEY_PASSWORD)) {
|
|
125
|
+
this.password = line.length > KEY_PASSWORD.length + 1 ? line.substring(KEY_PASSWORD.length + 1) : '';
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
private readEnvVariables(): boolean {
|
|
131
|
+
if (process.env.EMIL_USERNAME) {
|
|
132
|
+
this.username = process.env.EMIL_USERNAME;
|
|
133
|
+
this.password = process.env.EMIL_PASSWORD || '';
|
|
134
|
+
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
selectEnvironment(env: Environment) {
|
|
142
|
+
this.configuration.basePath = env;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
async authorize(username: string, password: string): Promise<void> {
|
|
146
|
+
const options: AxiosRequestConfig = {
|
|
147
|
+
method: 'POST',
|
|
148
|
+
url: `${this.configuration.basePath}/authservice/v1/login`,
|
|
149
|
+
headers: { 'Content-Type': 'application/json' },
|
|
150
|
+
data: {
|
|
151
|
+
username,
|
|
152
|
+
password,
|
|
153
|
+
},
|
|
154
|
+
withCredentials: true,
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const response = await globalAxios.request<LoginClass>(options);
|
|
158
|
+
|
|
159
|
+
const { data: { accessToken } } = response;
|
|
160
|
+
this.configuration.username = username;
|
|
161
|
+
this.configuration.accessToken = `Bearer ${accessToken}`;
|
|
162
|
+
|
|
163
|
+
const refreshToken = this.extractRefreshToken(response)
|
|
164
|
+
this.configuration.refreshToken = refreshToken;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
async refreshToken(): Promise<string> {
|
|
168
|
+
const { username, refreshToken } = this.configuration;
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
if (!username || !refreshToken) {
|
|
172
|
+
return '';
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const options: AxiosRequestConfig = {
|
|
176
|
+
method: 'POST',
|
|
177
|
+
url: `${this.configuration.basePath}/authservice/v1/refresh-token`,
|
|
178
|
+
headers: {
|
|
179
|
+
'Content-Type': 'application/json',
|
|
180
|
+
Cookie: refreshToken,
|
|
181
|
+
},
|
|
182
|
+
data: { username: username },
|
|
183
|
+
withCredentials: true,
|
|
184
|
+
};
|
|
185
|
+
const { data: { accessToken } } = await globalAxios.request<LoginClass>(options);
|
|
186
|
+
|
|
187
|
+
return accessToken;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
private extractRefreshToken(response: AxiosResponse): string {
|
|
191
|
+
if (response.headers && response.headers['set-cookie']
|
|
192
|
+
&& response.headers['set-cookie'].length > 0) {
|
|
193
|
+
|
|
194
|
+
return `${response.headers['set-cookie'][0].split(';')[0]};`;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return '';
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
getConfiguration(): Configuration {
|
|
201
|
+
return this.configuration;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
private attachInterceptor(axios: AxiosInstance) {
|
|
205
|
+
axios.interceptors.request.use((config) => {
|
|
206
|
+
if (config.url?.indexOf('refresh-token') === -1) {
|
|
207
|
+
this.lastRequestConfig = config;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return config;
|
|
211
|
+
});
|
|
212
|
+
axios.interceptors.response.use(
|
|
213
|
+
(res) => {
|
|
214
|
+
return res;
|
|
215
|
+
},
|
|
216
|
+
async (err) => {
|
|
217
|
+
let originalConfig = err.config;
|
|
218
|
+
if (err.response) {
|
|
219
|
+
// Access Token was expired
|
|
220
|
+
if (err.response.status === 401 && !originalConfig._retry) {
|
|
221
|
+
originalConfig._retry = true;
|
|
222
|
+
try {
|
|
223
|
+
const tokenString = await this.refreshToken();
|
|
224
|
+
const accessToken = `Bearer ${tokenString}`;
|
|
225
|
+
|
|
226
|
+
const localVarHeaderParameter = {} as any;
|
|
227
|
+
localVarHeaderParameter['Authorization'] = accessToken;
|
|
228
|
+
|
|
229
|
+
originalConfig.headers = {
|
|
230
|
+
...originalConfig.headers,
|
|
231
|
+
...localVarHeaderParameter,
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
this.configuration.accessToken = accessToken;
|
|
235
|
+
|
|
236
|
+
return axios(originalConfig);
|
|
237
|
+
} catch (_error) {
|
|
238
|
+
if (_error.response && _error.response.data) {
|
|
239
|
+
return Promise.reject(_error.response.data);
|
|
240
|
+
}
|
|
241
|
+
return Promise.reject(_error);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
if (err.response.status === 403 && err.response.data) {
|
|
245
|
+
return Promise.reject(err.response.data);
|
|
246
|
+
}
|
|
247
|
+
} else if (err.message === NETWORK_ERROR_MESSAGE && !originalConfig._retry) {
|
|
248
|
+
try {
|
|
249
|
+
const tokenString = await this.refreshToken();
|
|
250
|
+
const accessToken = `Bearer ${tokenString}`;
|
|
251
|
+
|
|
252
|
+
const localVarHeaderParameter = {} as any;
|
|
253
|
+
localVarHeaderParameter['Authorization'] = accessToken;
|
|
254
|
+
|
|
255
|
+
this.lastRequestConfig.headers = {
|
|
256
|
+
...originalConfig.headers,
|
|
257
|
+
...localVarHeaderParameter,
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
originalConfig = {
|
|
261
|
+
...this.lastRequestConfig,
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
originalConfig._retry = true;
|
|
265
|
+
|
|
266
|
+
this.configuration.accessToken = accessToken;
|
|
267
|
+
|
|
268
|
+
return axios(originalConfig);
|
|
269
|
+
} catch (_error) {
|
|
270
|
+
if (_error.response && _error.response.data) {
|
|
271
|
+
return Promise.reject(_error.response.data);
|
|
272
|
+
}
|
|
273
|
+
return Promise.reject(_error);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
return Promise.reject(err);
|
|
277
|
+
}
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
*
|
|
284
|
+
* @export
|
|
285
|
+
* @class RequiredError
|
|
286
|
+
* @extends {Error}
|
|
287
|
+
*/
|
|
288
|
+
export class RequiredError extends Error {
|
|
289
|
+
name: "RequiredError" = "RequiredError";
|
|
290
|
+
constructor(public field: string, msg?: string) {
|
|
291
|
+
super(msg);
|
|
292
|
+
}
|
|
293
|
+
}
|
package/common.ts
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* EMIL BillingService
|
|
5
|
+
* The EMIL BillingService 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
|
+
* @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
|
+
}
|
package/configuration.ts
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* EMIL BillingService
|
|
5
|
+
* The EMIL BillingService 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
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EMIL BillingService
|
|
3
|
+
* The EMIL BillingService API description
|
|
4
|
+
*
|
|
5
|
+
* The version of the OpenAPI document: 1.0
|
|
6
|
+
*
|
|
7
|
+
*
|
|
8
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
9
|
+
* https://openapi-generator.tech
|
|
10
|
+
* Do not edit the class manually.
|
|
11
|
+
*/
|
|
12
|
+
import { AxiosPromise, AxiosInstance, AxiosRequestConfig } from 'axios';
|
|
13
|
+
import { Configuration } from '../configuration';
|
|
14
|
+
import { RequestArgs, BaseAPI } from '../base';
|
|
15
|
+
import { CreateCorrectionInvoicesResponseClass } from '../models';
|
|
16
|
+
import { CreateInvoiceRequestDto } from '../models';
|
|
17
|
+
/**
|
|
18
|
+
* CorrectionInvoicesApi - axios parameter creator
|
|
19
|
+
* @export
|
|
20
|
+
*/
|
|
21
|
+
export declare const CorrectionInvoicesApiAxiosParamCreator: (configuration?: Configuration) => {
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
* @param {CreateInvoiceRequestDto} createInvoiceRequestDto
|
|
25
|
+
* @param {string} [authorization] Bearer Token
|
|
26
|
+
* @param {*} [options] Override http request option.
|
|
27
|
+
* @throws {RequiredError}
|
|
28
|
+
*/
|
|
29
|
+
createCorrectionInvoice: (createInvoiceRequestDto: CreateInvoiceRequestDto, authorization?: string, options?: AxiosRequestConfig) => Promise<RequestArgs>;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* CorrectionInvoicesApi - functional programming interface
|
|
33
|
+
* @export
|
|
34
|
+
*/
|
|
35
|
+
export declare const CorrectionInvoicesApiFp: (configuration?: Configuration) => {
|
|
36
|
+
/**
|
|
37
|
+
*
|
|
38
|
+
* @param {CreateInvoiceRequestDto} createInvoiceRequestDto
|
|
39
|
+
* @param {string} [authorization] Bearer Token
|
|
40
|
+
* @param {*} [options] Override http request option.
|
|
41
|
+
* @throws {RequiredError}
|
|
42
|
+
*/
|
|
43
|
+
createCorrectionInvoice(createInvoiceRequestDto: CreateInvoiceRequestDto, authorization?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<CreateCorrectionInvoicesResponseClass>>;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* CorrectionInvoicesApi - factory interface
|
|
47
|
+
* @export
|
|
48
|
+
*/
|
|
49
|
+
export declare const CorrectionInvoicesApiFactory: (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) => {
|
|
50
|
+
/**
|
|
51
|
+
*
|
|
52
|
+
* @param {CreateInvoiceRequestDto} createInvoiceRequestDto
|
|
53
|
+
* @param {string} [authorization] Bearer Token
|
|
54
|
+
* @param {*} [options] Override http request option.
|
|
55
|
+
* @throws {RequiredError}
|
|
56
|
+
*/
|
|
57
|
+
createCorrectionInvoice(createInvoiceRequestDto: CreateInvoiceRequestDto, authorization?: string, options?: any): AxiosPromise<CreateCorrectionInvoicesResponseClass>;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Request parameters for createCorrectionInvoice operation in CorrectionInvoicesApi.
|
|
61
|
+
* @export
|
|
62
|
+
* @interface CorrectionInvoicesApiCreateCorrectionInvoiceRequest
|
|
63
|
+
*/
|
|
64
|
+
export interface CorrectionInvoicesApiCreateCorrectionInvoiceRequest {
|
|
65
|
+
/**
|
|
66
|
+
*
|
|
67
|
+
* @type {CreateInvoiceRequestDto}
|
|
68
|
+
* @memberof CorrectionInvoicesApiCreateCorrectionInvoice
|
|
69
|
+
*/
|
|
70
|
+
readonly createInvoiceRequestDto: CreateInvoiceRequestDto;
|
|
71
|
+
/**
|
|
72
|
+
* Bearer Token
|
|
73
|
+
* @type {string}
|
|
74
|
+
* @memberof CorrectionInvoicesApiCreateCorrectionInvoice
|
|
75
|
+
*/
|
|
76
|
+
readonly authorization?: string;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* CorrectionInvoicesApi - object-oriented interface
|
|
80
|
+
* @export
|
|
81
|
+
* @class CorrectionInvoicesApi
|
|
82
|
+
* @extends {BaseAPI}
|
|
83
|
+
*/
|
|
84
|
+
export declare class CorrectionInvoicesApi extends BaseAPI {
|
|
85
|
+
/**
|
|
86
|
+
*
|
|
87
|
+
* @param {CorrectionInvoicesApiCreateCorrectionInvoiceRequest} requestParameters Request parameters.
|
|
88
|
+
* @param {*} [options] Override http request option.
|
|
89
|
+
* @throws {RequiredError}
|
|
90
|
+
* @memberof CorrectionInvoicesApi
|
|
91
|
+
*/
|
|
92
|
+
createCorrectionInvoice(requestParameters: CorrectionInvoicesApiCreateCorrectionInvoiceRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<CreateCorrectionInvoicesResponseClass, any>>;
|
|
93
|
+
}
|