@emilgroup/public-api-sdk-node 1.0.0 → 1.0.2

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 (49) hide show
  1. package/.openapi-generator/FILES +5 -1
  2. package/README.md +22 -5
  3. package/api/documents-api.ts +4 -0
  4. package/api/notifications-api.ts +163 -0
  5. package/api/payment-setup-api.ts +4 -0
  6. package/api/products-api.ts +139 -20
  7. package/api.ts +6 -0
  8. package/base.ts +93 -57
  9. package/common.ts +1 -0
  10. package/configuration.ts +8 -0
  11. package/dist/api/documents-api.js +7 -3
  12. package/dist/api/notifications-api.d.ts +92 -0
  13. package/dist/api/notifications-api.js +224 -0
  14. package/dist/api/payment-setup-api.js +6 -2
  15. package/dist/api/products-api.d.ts +72 -11
  16. package/dist/api/products-api.js +127 -27
  17. package/dist/api.d.ts +1 -0
  18. package/dist/api.js +1 -0
  19. package/dist/base.d.ts +9 -5
  20. package/dist/base.js +136 -37
  21. package/dist/common.d.ts +1 -0
  22. package/dist/common.js +2 -1
  23. package/dist/configuration.d.ts +7 -0
  24. package/dist/models/create-account-request-dto.d.ts +12 -0
  25. package/dist/models/create-custom-application-request-dto.d.ts +1 -0
  26. package/dist/models/create-custom-application-request-dto.js +2 -1
  27. package/dist/models/create-estimated-invoice-request-dto.d.ts +14 -6
  28. package/dist/models/create-estimated-invoice-request-dto.js +2 -1
  29. package/dist/models/create-lead-request-dto.d.ts +7 -0
  30. package/dist/models/index.d.ts +4 -0
  31. package/dist/models/index.js +4 -0
  32. package/dist/models/premium-override-dto.d.ts +53 -0
  33. package/dist/models/premium-override-dto.js +25 -0
  34. package/dist/models/premium-override-request-dto.d.ts +25 -0
  35. package/dist/models/premium-override-request-dto.js +15 -0
  36. package/dist/models/send-notification-request-dto.d.ts +36 -0
  37. package/dist/models/send-notification-request-dto.js +15 -0
  38. package/dist/models/update-lead-request-dto.d.ts +84 -0
  39. package/dist/models/update-lead-request-dto.js +22 -0
  40. package/models/create-account-request-dto.ts +12 -0
  41. package/models/create-custom-application-request-dto.ts +2 -1
  42. package/models/create-estimated-invoice-request-dto.ts +15 -7
  43. package/models/create-lead-request-dto.ts +7 -0
  44. package/models/index.ts +4 -0
  45. package/models/premium-override-dto.ts +63 -0
  46. package/models/premium-override-request-dto.ts +31 -0
  47. package/models/send-notification-request-dto.ts +42 -0
  48. package/models/update-lead-request-dto.ts +93 -0
  49. package/package.json +5 -3
package/base.ts CHANGED
@@ -14,13 +14,20 @@
14
14
 
15
15
 
16
16
  import { Configuration } from "./configuration";
17
- import { defaultStorage } from "./common";
18
17
  // Some imports not used depending on template conditions
19
18
  // @ts-ignore
20
19
  import globalAxios, { AxiosPromise, AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
21
-
20
+ import * as fs from 'fs';
21
+ import * as path from 'path';
22
+ import * as os from 'os';
22
23
 
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;
24
31
  /**
25
32
  *
26
33
  * @export
@@ -59,13 +66,7 @@ export interface RequestArgs {
59
66
  options: AxiosRequestConfig;
60
67
  }
61
68
 
62
- interface TokenData {
63
- accessToken?: string;
64
- username?: string;
65
- }
66
-
67
69
  const NETWORK_ERROR_MESSAGE = "Network Error";
68
- const TOKEN_DATA = 'APP_TOKEN';
69
70
 
70
71
  /**
71
72
  *
@@ -73,31 +74,75 @@ const TOKEN_DATA = 'APP_TOKEN';
73
74
  * @class BaseAPI
74
75
  */
75
76
  export class BaseAPI {
76
- protected configuration: Configuration | undefined;
77
- private tokenData?: TokenData;
78
-
79
- constructor(configuration?: Configuration,
80
- protected basePath: string = BASE_PATH,
81
- protected axios: AxiosInstance = globalAxios) {
82
-
83
- this.loadTokenData();
77
+ protected configuration: Configuration;
78
+ private username?: string;
79
+ private password?: string;
84
80
 
81
+ constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) {
85
82
  if (configuration) {
86
83
  this.configuration = configuration;
87
84
  this.basePath = configuration.basePath || this.basePath;
88
85
  } else {
89
- const { accessToken, username } = this.tokenData;
90
-
91
86
  this.configuration = new Configuration({
92
87
  basePath: this.basePath,
93
- accessToken: accessToken ? `Bearer ${accessToken}` : '',
94
- username,
95
88
  });
96
89
  }
97
90
 
98
91
  this.attachInterceptor(axios);
99
92
  }
100
93
 
94
+ async initialize(env: Environment = Environment.Production) {
95
+ this.configuration.basePath = env;
96
+
97
+ await this.loadCredentials();
98
+
99
+ if (this.username) {
100
+ await this.authorize(this.username, this.password);
101
+ this.password = null; // to avoid keeping password loaded in memory.
102
+ }
103
+ }
104
+
105
+ private async loadCredentials() {
106
+ try {
107
+ await this.readConfigFile();
108
+ } catch (error) {
109
+ console.warn(`No credentials file found. Check that ${filePath} exists.`);
110
+ }
111
+
112
+ this.readEnvVariables();
113
+
114
+ if (!this.username) {
115
+ console.info(`No credentials found in credentials file or environment variables. Either provide some or use
116
+ authorize() function.`);
117
+ }
118
+ }
119
+
120
+ private async readConfigFile() {
121
+ const file = await fs.promises.readFile(filePath, 'utf-8');
122
+
123
+ const lines = file.split(os.EOL)
124
+ .filter(Boolean);
125
+
126
+ lines.forEach((line: string) => {
127
+ if (line.startsWith(KEY_USERNAME)) {
128
+ this.username = line.length > KEY_USERNAME.length + 1 ? line.substring(KEY_USERNAME.length + 1) : '';
129
+ } else if (line.startsWith(KEY_PASSWORD)) {
130
+ this.password = line.length > KEY_PASSWORD.length + 1 ? line.substring(KEY_PASSWORD.length + 1) : '';
131
+ }
132
+ });
133
+ }
134
+
135
+ private readEnvVariables(): boolean {
136
+ if (process.env.EMIL_USERNAME) {
137
+ this.username = process.env.EMIL_USERNAME;
138
+ this.password = process.env.EMIL_PASSWORD || '';
139
+
140
+ return true;
141
+ }
142
+
143
+ return false;
144
+ }
145
+
101
146
  selectEnvironment(env: Environment) {
102
147
  this.configuration.basePath = env;
103
148
  }
@@ -117,21 +162,18 @@ export class BaseAPI {
117
162
  const response = await globalAxios.request<LoginClass>(options);
118
163
 
119
164
  const { data: { accessToken } } = response;
120
-
121
165
  this.configuration.username = username;
122
166
  this.configuration.accessToken = `Bearer ${accessToken}`;
123
- this.tokenData.username = username;
124
- this.tokenData.accessToken = accessToken;
125
167
 
126
- this.storeTokenData({
127
- ...this.tokenData
128
- });
168
+ const refreshToken = this.extractRefreshToken(response)
169
+ this.configuration.refreshToken = refreshToken;
129
170
  }
130
171
 
131
172
  async refreshToken(): Promise<string> {
132
- const { username } = this.configuration;
173
+ const { username, refreshToken } = this.configuration;
174
+
133
175
 
134
- if (!username) {
176
+ if (!username || !refreshToken) {
135
177
  return '';
136
178
  }
137
179
 
@@ -140,6 +182,7 @@ export class BaseAPI {
140
182
  url: `${this.configuration.basePath}/authservice/v1/refresh-token`,
141
183
  headers: {
142
184
  'Content-Type': 'application/json',
185
+ Cookie: refreshToken,
143
186
  },
144
187
  data: { username: username },
145
188
  withCredentials: true,
@@ -150,20 +193,18 @@ export class BaseAPI {
150
193
  return accessToken;
151
194
  }
152
195
 
153
- private storeTokenData(tokenData?: TokenData) {
154
- if (typeof window !== 'undefined') {
155
- defaultStorage().set<TokenData>(TOKEN_DATA, tokenData);
156
- }
157
- }
196
+ private extractRefreshToken(response: AxiosResponse): string {
197
+ if (response.headers && response.headers['set-cookie']
198
+ && response.headers['set-cookie'].length > 0) {
158
199
 
159
- public loadTokenData() {
160
- if (typeof window !== 'undefined') {
161
- this.tokenData = defaultStorage().get<TokenData>(TOKEN_DATA) || {};
200
+ return `${response.headers['set-cookie'][0].split(';')[0]};`;
162
201
  }
202
+
203
+ return '';
163
204
  }
164
205
 
165
- public cleanTokenData() {
166
- this.storeTokenData(null);
206
+ getConfiguration(): Configuration {
207
+ return this.configuration;
167
208
  }
168
209
 
169
210
  private attachInterceptor(axios: AxiosInstance) {
@@ -173,25 +214,19 @@ export class BaseAPI {
173
214
  },
174
215
  async (err) => {
175
216
  let originalConfig = err.config;
176
- if (err.response && !(err.response instanceof XMLHttpRequest)) { // sometimes buggy and is of type request
217
+ if (err.response) {
177
218
  // Access Token was expired
178
- if ((err.response.status === 401 || err.response.status === 403)
179
- && !originalConfig._retry) {
219
+ if (err.response.status === 401 && !originalConfig._retry) {
180
220
  originalConfig._retry = true;
181
221
  try {
182
- let tokenString = await this.refreshToken();
222
+ const tokenString = await this.refreshToken();
183
223
  const accessToken = `Bearer ${tokenString}`;
184
224
 
185
- delete originalConfig.headers['Authorization']
186
-
187
- originalConfig.headers['Authorization'] = accessToken;
225
+ originalConfig.headers['Authorization'] = `Bearer ${accessToken}`
188
226
 
189
227
  this.configuration.accessToken = accessToken;
190
- this.tokenData.accessToken = tokenString;
191
-
192
- this.storeTokenData(this.tokenData);
193
228
 
194
- return axios(originalConfig);
229
+ return axios.request(originalConfig);
195
230
  } catch (_error) {
196
231
  if (_error.response && _error.response.data) {
197
232
  return Promise.reject(_error.response.data);
@@ -199,22 +234,23 @@ export class BaseAPI {
199
234
  return Promise.reject(_error);
200
235
  }
201
236
  }
202
- } else if (err.message === NETWORK_ERROR_MESSAGE
237
+ if (err.response.status === 403 && err.response.data) {
238
+ return Promise.reject(err.response.data);
239
+ }
240
+ } else if(err.message === NETWORK_ERROR_MESSAGE
241
+ && err.isAxiosError
203
242
  && originalConfig.headers.hasOwnProperty('Authorization')
204
243
  && _retry_count < 4
205
- ) {
244
+ ){
206
245
  _retry_count++;
207
246
  try {
208
- let tokenString = await this.refreshToken();
247
+ const tokenString = await this.refreshToken();
209
248
  const accessToken = `Bearer ${tokenString}`;
210
249
 
211
250
  _retry = true;
212
- originalConfig.headers['Authorization'] = accessToken;
251
+ originalConfig.headers['Authorization'] = accessToken;
213
252
 
214
253
  this.configuration.accessToken = accessToken;
215
- this.tokenData.accessToken = tokenString;
216
-
217
- this.storeTokenData(this.tokenData);
218
254
 
219
255
  return axios.request({
220
256
  ...originalConfig,
@@ -224,7 +260,7 @@ export class BaseAPI {
224
260
  return Promise.reject(_error.response.data);
225
261
  }
226
262
  return Promise.reject(_error);
227
- }
263
+ }
228
264
  }
229
265
  return Promise.reject(err);
230
266
  }
package/common.ts CHANGED
@@ -16,6 +16,7 @@
16
16
  import { Configuration } from "./configuration";
17
17
  import { RequiredError, RequestArgs } from "./base";
18
18
  import { AxiosInstance, AxiosResponse } from 'axios';
19
+ import { URL, URLSearchParams } from 'url';
19
20
  /**
20
21
  *
21
22
  * @export
package/configuration.ts CHANGED
@@ -74,6 +74,14 @@ export class Configuration {
74
74
  */
75
75
  formDataCtor?: new () => any;
76
76
 
77
+ /**
78
+ * parameter for automatically refreshing access token for oauth2 security
79
+ *
80
+ * @type {string}
81
+ * @memberof Configuration
82
+ */
83
+ refreshToken?: string;
84
+
77
85
  constructor(param: ConfigurationParameters = {}) {
78
86
  this.apiKey = param.apiKey;
79
87
  this.username = param.username;
@@ -85,6 +85,10 @@ var axios_1 = __importDefault(require("axios"));
85
85
  var common_1 = require("../common");
86
86
  // @ts-ignore
87
87
  var base_1 = require("../base");
88
+ // URLSearchParams not necessarily used
89
+ // @ts-ignore
90
+ var url_1 = require("url");
91
+ var FormData = require('form-data');
88
92
  /**
89
93
  * DocumentsApi - axios parameter creator
90
94
  * @export
@@ -109,7 +113,7 @@ var DocumentsApiAxiosParamCreator = function (configuration) {
109
113
  // verify required parameter 'createDocumentRequestDto' is not null or undefined
110
114
  (0, common_1.assertParamExists)('createTemporaryDocument', 'createDocumentRequestDto', createDocumentRequestDto);
111
115
  localVarPath = "/publicapi/v1/documents";
112
- localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
116
+ localVarUrlObj = new url_1.URL(localVarPath, common_1.DUMMY_BASE_URL);
113
117
  if (configuration) {
114
118
  baseOptions = configuration.baseOptions;
115
119
  baseAccessToken = configuration.accessToken;
@@ -158,7 +162,7 @@ var DocumentsApiAxiosParamCreator = function (configuration) {
158
162
  (0, common_1.assertParamExists)('downloadDocument', 'code', code);
159
163
  localVarPath = "/publicapi/v1/documents/download/{code}"
160
164
  .replace("{".concat("code", "}"), encodeURIComponent(String(code)));
161
- localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
165
+ localVarUrlObj = new url_1.URL(localVarPath, common_1.DUMMY_BASE_URL);
162
166
  if (configuration) {
163
167
  baseOptions = configuration.baseOptions;
164
168
  baseAccessToken = configuration.accessToken;
@@ -207,7 +211,7 @@ var DocumentsApiAxiosParamCreator = function (configuration) {
207
211
  switch (_a.label) {
208
212
  case 0:
209
213
  localVarPath = "/publicapi/v1/documents";
210
- localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
214
+ localVarUrlObj = new url_1.URL(localVarPath, common_1.DUMMY_BASE_URL);
211
215
  if (configuration) {
212
216
  baseOptions = configuration.baseOptions;
213
217
  baseAccessToken = configuration.accessToken;
@@ -0,0 +1,92 @@
1
+ /**
2
+ * EMIL PublicAPI
3
+ * The EMIL Public 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 { SendNotificationRequestDto } from '../models';
16
+ /**
17
+ * NotificationsApi - axios parameter creator
18
+ * @export
19
+ */
20
+ export declare const NotificationsApiAxiosParamCreator: (configuration?: Configuration) => {
21
+ /**
22
+ *
23
+ * @param {SendNotificationRequestDto} sendNotificationRequestDto
24
+ * @param {string} [authorization] Bearer Token
25
+ * @param {*} [options] Override http request option.
26
+ * @throws {RequiredError}
27
+ */
28
+ sendNotification: (sendNotificationRequestDto: SendNotificationRequestDto, authorization?: string, options?: AxiosRequestConfig) => Promise<RequestArgs>;
29
+ };
30
+ /**
31
+ * NotificationsApi - functional programming interface
32
+ * @export
33
+ */
34
+ export declare const NotificationsApiFp: (configuration?: Configuration) => {
35
+ /**
36
+ *
37
+ * @param {SendNotificationRequestDto} sendNotificationRequestDto
38
+ * @param {string} [authorization] Bearer Token
39
+ * @param {*} [options] Override http request option.
40
+ * @throws {RequiredError}
41
+ */
42
+ sendNotification(sendNotificationRequestDto: SendNotificationRequestDto, authorization?: string, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>>;
43
+ };
44
+ /**
45
+ * NotificationsApi - factory interface
46
+ * @export
47
+ */
48
+ export declare const NotificationsApiFactory: (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) => {
49
+ /**
50
+ *
51
+ * @param {SendNotificationRequestDto} sendNotificationRequestDto
52
+ * @param {string} [authorization] Bearer Token
53
+ * @param {*} [options] Override http request option.
54
+ * @throws {RequiredError}
55
+ */
56
+ sendNotification(sendNotificationRequestDto: SendNotificationRequestDto, authorization?: string, options?: any): AxiosPromise<void>;
57
+ };
58
+ /**
59
+ * Request parameters for sendNotification operation in NotificationsApi.
60
+ * @export
61
+ * @interface NotificationsApiSendNotificationRequest
62
+ */
63
+ export interface NotificationsApiSendNotificationRequest {
64
+ /**
65
+ *
66
+ * @type {SendNotificationRequestDto}
67
+ * @memberof NotificationsApiSendNotification
68
+ */
69
+ readonly sendNotificationRequestDto: SendNotificationRequestDto;
70
+ /**
71
+ * Bearer Token
72
+ * @type {string}
73
+ * @memberof NotificationsApiSendNotification
74
+ */
75
+ readonly authorization?: string;
76
+ }
77
+ /**
78
+ * NotificationsApi - object-oriented interface
79
+ * @export
80
+ * @class NotificationsApi
81
+ * @extends {BaseAPI}
82
+ */
83
+ export declare class NotificationsApi extends BaseAPI {
84
+ /**
85
+ *
86
+ * @param {NotificationsApiSendNotificationRequest} requestParameters Request parameters.
87
+ * @param {*} [options] Override http request option.
88
+ * @throws {RequiredError}
89
+ * @memberof NotificationsApi
90
+ */
91
+ sendNotification(requestParameters: NotificationsApiSendNotificationRequest, options?: AxiosRequestConfig): Promise<import("axios").AxiosResponse<void, any>>;
92
+ }
@@ -0,0 +1,224 @@
1
+ "use strict";
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ /**
5
+ * EMIL PublicAPI
6
+ * The EMIL Public API description
7
+ *
8
+ * The version of the OpenAPI document: 1.0
9
+ *
10
+ *
11
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
12
+ * https://openapi-generator.tech
13
+ * Do not edit the class manually.
14
+ */
15
+ var __extends = (this && this.__extends) || (function () {
16
+ var extendStatics = function (d, b) {
17
+ extendStatics = Object.setPrototypeOf ||
18
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
19
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
20
+ return extendStatics(d, b);
21
+ };
22
+ return function (d, b) {
23
+ if (typeof b !== "function" && b !== null)
24
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
25
+ extendStatics(d, b);
26
+ function __() { this.constructor = d; }
27
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
28
+ };
29
+ })();
30
+ var __assign = (this && this.__assign) || function () {
31
+ __assign = Object.assign || function(t) {
32
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
33
+ s = arguments[i];
34
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
35
+ t[p] = s[p];
36
+ }
37
+ return t;
38
+ };
39
+ return __assign.apply(this, arguments);
40
+ };
41
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
42
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
43
+ return new (P || (P = Promise))(function (resolve, reject) {
44
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
45
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
46
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
47
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
48
+ });
49
+ };
50
+ var __generator = (this && this.__generator) || function (thisArg, body) {
51
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
52
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
53
+ function verb(n) { return function (v) { return step([n, v]); }; }
54
+ function step(op) {
55
+ if (f) throw new TypeError("Generator is already executing.");
56
+ while (_) try {
57
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
58
+ if (y = 0, t) op = [op[0] & 2, t.value];
59
+ switch (op[0]) {
60
+ case 0: case 1: t = op; break;
61
+ case 4: _.label++; return { value: op[1], done: false };
62
+ case 5: _.label++; y = op[1]; op = [0]; continue;
63
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
64
+ default:
65
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
66
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
67
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
68
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
69
+ if (t[2]) _.ops.pop();
70
+ _.trys.pop(); continue;
71
+ }
72
+ op = body.call(thisArg, _);
73
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
74
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
75
+ }
76
+ };
77
+ var __importDefault = (this && this.__importDefault) || function (mod) {
78
+ return (mod && mod.__esModule) ? mod : { "default": mod };
79
+ };
80
+ Object.defineProperty(exports, "__esModule", { value: true });
81
+ exports.NotificationsApi = exports.NotificationsApiFactory = exports.NotificationsApiFp = exports.NotificationsApiAxiosParamCreator = void 0;
82
+ var axios_1 = __importDefault(require("axios"));
83
+ // Some imports not used depending on template conditions
84
+ // @ts-ignore
85
+ var common_1 = require("../common");
86
+ // @ts-ignore
87
+ var base_1 = require("../base");
88
+ // URLSearchParams not necessarily used
89
+ // @ts-ignore
90
+ var url_1 = require("url");
91
+ var FormData = require('form-data');
92
+ /**
93
+ * NotificationsApi - axios parameter creator
94
+ * @export
95
+ */
96
+ var NotificationsApiAxiosParamCreator = function (configuration) {
97
+ var _this = this;
98
+ return {
99
+ /**
100
+ *
101
+ * @param {SendNotificationRequestDto} sendNotificationRequestDto
102
+ * @param {string} [authorization] Bearer Token
103
+ * @param {*} [options] Override http request option.
104
+ * @throws {RequiredError}
105
+ */
106
+ sendNotification: function (sendNotificationRequestDto, authorization, options) {
107
+ if (options === void 0) { options = {}; }
108
+ return __awaiter(_this, void 0, void 0, function () {
109
+ var localVarPath, localVarUrlObj, baseOptions, baseAccessToken, localVarRequestOptions, localVarHeaderParameter, localVarQueryParameter, headersFromBaseOptions;
110
+ return __generator(this, function (_a) {
111
+ switch (_a.label) {
112
+ case 0:
113
+ // verify required parameter 'sendNotificationRequestDto' is not null or undefined
114
+ (0, common_1.assertParamExists)('sendNotification', 'sendNotificationRequestDto', sendNotificationRequestDto);
115
+ localVarPath = "/publicapi/v1/emails/send";
116
+ localVarUrlObj = new url_1.URL(localVarPath, common_1.DUMMY_BASE_URL);
117
+ if (configuration) {
118
+ baseOptions = configuration.baseOptions;
119
+ baseAccessToken = configuration.accessToken;
120
+ }
121
+ localVarRequestOptions = __assign(__assign({ method: 'POST' }, baseOptions), options);
122
+ localVarHeaderParameter = {};
123
+ localVarQueryParameter = {};
124
+ // authentication bearer required
125
+ // http bearer authentication required
126
+ return [4 /*yield*/, (0, common_1.setBearerAuthToObject)(localVarHeaderParameter, configuration)];
127
+ case 1:
128
+ // authentication bearer required
129
+ // http bearer authentication required
130
+ _a.sent();
131
+ if (authorization !== undefined && authorization !== null || baseAccessToken !== undefined && baseAccessToken !== null) {
132
+ localVarHeaderParameter['Authorization'] = String(authorization ? authorization : baseAccessToken);
133
+ }
134
+ localVarHeaderParameter['Content-Type'] = 'application/json';
135
+ (0, common_1.setSearchParams)(localVarUrlObj, localVarQueryParameter);
136
+ headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
137
+ localVarRequestOptions.headers = __assign(__assign(__assign({}, localVarHeaderParameter), headersFromBaseOptions), options.headers);
138
+ localVarRequestOptions.data = (0, common_1.serializeDataIfNeeded)(sendNotificationRequestDto, localVarRequestOptions, configuration);
139
+ return [2 /*return*/, {
140
+ url: (0, common_1.toPathString)(localVarUrlObj),
141
+ options: localVarRequestOptions,
142
+ }];
143
+ }
144
+ });
145
+ });
146
+ },
147
+ };
148
+ };
149
+ exports.NotificationsApiAxiosParamCreator = NotificationsApiAxiosParamCreator;
150
+ /**
151
+ * NotificationsApi - functional programming interface
152
+ * @export
153
+ */
154
+ var NotificationsApiFp = function (configuration) {
155
+ var localVarAxiosParamCreator = (0, exports.NotificationsApiAxiosParamCreator)(configuration);
156
+ return {
157
+ /**
158
+ *
159
+ * @param {SendNotificationRequestDto} sendNotificationRequestDto
160
+ * @param {string} [authorization] Bearer Token
161
+ * @param {*} [options] Override http request option.
162
+ * @throws {RequiredError}
163
+ */
164
+ sendNotification: function (sendNotificationRequestDto, authorization, options) {
165
+ return __awaiter(this, void 0, void 0, function () {
166
+ var localVarAxiosArgs;
167
+ return __generator(this, function (_a) {
168
+ switch (_a.label) {
169
+ case 0: return [4 /*yield*/, localVarAxiosParamCreator.sendNotification(sendNotificationRequestDto, authorization, options)];
170
+ case 1:
171
+ localVarAxiosArgs = _a.sent();
172
+ return [2 /*return*/, (0, common_1.createRequestFunction)(localVarAxiosArgs, axios_1.default, base_1.BASE_PATH, configuration)];
173
+ }
174
+ });
175
+ });
176
+ },
177
+ };
178
+ };
179
+ exports.NotificationsApiFp = NotificationsApiFp;
180
+ /**
181
+ * NotificationsApi - factory interface
182
+ * @export
183
+ */
184
+ var NotificationsApiFactory = function (configuration, basePath, axios) {
185
+ var localVarFp = (0, exports.NotificationsApiFp)(configuration);
186
+ return {
187
+ /**
188
+ *
189
+ * @param {SendNotificationRequestDto} sendNotificationRequestDto
190
+ * @param {string} [authorization] Bearer Token
191
+ * @param {*} [options] Override http request option.
192
+ * @throws {RequiredError}
193
+ */
194
+ sendNotification: function (sendNotificationRequestDto, authorization, options) {
195
+ return localVarFp.sendNotification(sendNotificationRequestDto, authorization, options).then(function (request) { return request(axios, basePath); });
196
+ },
197
+ };
198
+ };
199
+ exports.NotificationsApiFactory = NotificationsApiFactory;
200
+ /**
201
+ * NotificationsApi - object-oriented interface
202
+ * @export
203
+ * @class NotificationsApi
204
+ * @extends {BaseAPI}
205
+ */
206
+ var NotificationsApi = /** @class */ (function (_super) {
207
+ __extends(NotificationsApi, _super);
208
+ function NotificationsApi() {
209
+ return _super !== null && _super.apply(this, arguments) || this;
210
+ }
211
+ /**
212
+ *
213
+ * @param {NotificationsApiSendNotificationRequest} requestParameters Request parameters.
214
+ * @param {*} [options] Override http request option.
215
+ * @throws {RequiredError}
216
+ * @memberof NotificationsApi
217
+ */
218
+ NotificationsApi.prototype.sendNotification = function (requestParameters, options) {
219
+ var _this = this;
220
+ return (0, exports.NotificationsApiFp)(this.configuration).sendNotification(requestParameters.sendNotificationRequestDto, requestParameters.authorization, options).then(function (request) { return request(_this.axios, _this.basePath); });
221
+ };
222
+ return NotificationsApi;
223
+ }(base_1.BaseAPI));
224
+ exports.NotificationsApi = NotificationsApi;
@@ -85,6 +85,10 @@ var axios_1 = __importDefault(require("axios"));
85
85
  var common_1 = require("../common");
86
86
  // @ts-ignore
87
87
  var base_1 = require("../base");
88
+ // URLSearchParams not necessarily used
89
+ // @ts-ignore
90
+ var url_1 = require("url");
91
+ var FormData = require('form-data');
88
92
  /**
89
93
  * PaymentSetupApi - axios parameter creator
90
94
  * @export
@@ -109,7 +113,7 @@ var PaymentSetupApiAxiosParamCreator = function (configuration) {
109
113
  // verify required parameter 'completePaymentSetupRequestDto' is not null or undefined
110
114
  (0, common_1.assertParamExists)('completePaymentSetup', 'completePaymentSetupRequestDto', completePaymentSetupRequestDto);
111
115
  localVarPath = "/publicapi/v1/payment-setup/complete";
112
- localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
116
+ localVarUrlObj = new url_1.URL(localVarPath, common_1.DUMMY_BASE_URL);
113
117
  if (configuration) {
114
118
  baseOptions = configuration.baseOptions;
115
119
  baseAccessToken = configuration.accessToken;
@@ -157,7 +161,7 @@ var PaymentSetupApiAxiosParamCreator = function (configuration) {
157
161
  // verify required parameter 'initiatePaymentSetupRequestDto' is not null or undefined
158
162
  (0, common_1.assertParamExists)('initiatePaymentSetup', 'initiatePaymentSetupRequestDto', initiatePaymentSetupRequestDto);
159
163
  localVarPath = "/publicapi/v1/payment-setup/initiate";
160
- localVarUrlObj = new URL(localVarPath, common_1.DUMMY_BASE_URL);
164
+ localVarUrlObj = new url_1.URL(localVarPath, common_1.DUMMY_BASE_URL);
161
165
  if (configuration) {
162
166
  baseOptions = configuration.baseOptions;
163
167
  baseAccessToken = configuration.accessToken;