@morabr/mora-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.
@@ -0,0 +1,485 @@
1
+ /* eslint-disable */
2
+ /* tslint:disable */
3
+ // @ts-nocheck
4
+ /*
5
+ * ---------------------------------------------------------------
6
+ * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
7
+ * ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
8
+ * ---------------------------------------------------------------
9
+ */
10
+ var __extends = (this && this.__extends) || (function () {
11
+ var extendStatics = function (d, b) {
12
+ extendStatics = Object.setPrototypeOf ||
13
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
14
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
15
+ return extendStatics(d, b);
16
+ };
17
+ return function (d, b) {
18
+ if (typeof b !== "function" && b !== null)
19
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
20
+ extendStatics(d, b);
21
+ function __() { this.constructor = d; }
22
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
23
+ };
24
+ })();
25
+ var __assign = (this && this.__assign) || function () {
26
+ __assign = Object.assign || function(t) {
27
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
28
+ s = arguments[i];
29
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
30
+ t[p] = s[p];
31
+ }
32
+ return t;
33
+ };
34
+ return __assign.apply(this, arguments);
35
+ };
36
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
37
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
38
+ return new (P || (P = Promise))(function (resolve, reject) {
39
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
40
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
41
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
42
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
43
+ });
44
+ };
45
+ var __generator = (this && this.__generator) || function (thisArg, body) {
46
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
47
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
48
+ function verb(n) { return function (v) { return step([n, v]); }; }
49
+ function step(op) {
50
+ if (f) throw new TypeError("Generator is already executing.");
51
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
52
+ 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;
53
+ if (y = 0, t) op = [op[0] & 2, t.value];
54
+ switch (op[0]) {
55
+ case 0: case 1: t = op; break;
56
+ case 4: _.label++; return { value: op[1], done: false };
57
+ case 5: _.label++; y = op[1]; op = [0]; continue;
58
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
59
+ default:
60
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
61
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
62
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
63
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
64
+ if (t[2]) _.ops.pop();
65
+ _.trys.pop(); continue;
66
+ }
67
+ op = body.call(thisArg, _);
68
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
69
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
70
+ }
71
+ };
72
+ var __rest = (this && this.__rest) || function (s, e) {
73
+ var t = {};
74
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
75
+ t[p] = s[p];
76
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
77
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
78
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
79
+ t[p[i]] = s[p[i]];
80
+ }
81
+ return t;
82
+ };
83
+ export var ChargeStatusEnum;
84
+ (function (ChargeStatusEnum) {
85
+ ChargeStatusEnum["Pending"] = "pending";
86
+ ChargeStatusEnum["Processing"] = "processing";
87
+ ChargeStatusEnum["Paid"] = "paid";
88
+ })(ChargeStatusEnum || (ChargeStatusEnum = {}));
89
+ export var OrderByEnum;
90
+ (function (OrderByEnum) {
91
+ OrderByEnum["ASC"] = "ASC";
92
+ OrderByEnum["DESC"] = "DESC";
93
+ })(OrderByEnum || (OrderByEnum = {}));
94
+ export var PaymentMethodEnum;
95
+ (function (PaymentMethodEnum) {
96
+ PaymentMethodEnum["Pix"] = "pix";
97
+ PaymentMethodEnum["CreditCard"] = "credit_card";
98
+ })(PaymentMethodEnum || (PaymentMethodEnum = {}));
99
+ export var TenantRoleEnum;
100
+ (function (TenantRoleEnum) {
101
+ TenantRoleEnum["Operator"] = "operator";
102
+ TenantRoleEnum["Admin"] = "admin";
103
+ TenantRoleEnum["Owner"] = "owner";
104
+ TenantRoleEnum["Receiver"] = "receiver";
105
+ })(TenantRoleEnum || (TenantRoleEnum = {}));
106
+ export var TenantUserStatusEnum;
107
+ (function (TenantUserStatusEnum) {
108
+ TenantUserStatusEnum["Enabled"] = "enabled";
109
+ TenantUserStatusEnum["Blocked"] = "blocked";
110
+ })(TenantUserStatusEnum || (TenantUserStatusEnum = {}));
111
+ export var WithdrawalAccountTypeEnum;
112
+ (function (WithdrawalAccountTypeEnum) {
113
+ WithdrawalAccountTypeEnum["Pix"] = "pix";
114
+ })(WithdrawalAccountTypeEnum || (WithdrawalAccountTypeEnum = {}));
115
+ import axios from "axios";
116
+ export var ContentType;
117
+ (function (ContentType) {
118
+ ContentType["Json"] = "application/json";
119
+ ContentType["JsonApi"] = "application/vnd.api+json";
120
+ ContentType["FormData"] = "multipart/form-data";
121
+ ContentType["UrlEncoded"] = "application/x-www-form-urlencoded";
122
+ ContentType["Text"] = "text/plain";
123
+ })(ContentType || (ContentType = {}));
124
+ var HttpClient = /** @class */ (function () {
125
+ function HttpClient(_a) {
126
+ if (_a === void 0) { _a = {}; }
127
+ var _this = this;
128
+ var securityWorker = _a.securityWorker, secure = _a.secure, format = _a.format, axiosConfig = __rest(_a, ["securityWorker", "secure", "format"]);
129
+ this.securityData = null;
130
+ this.setSecurityData = function (data) {
131
+ _this.securityData = data;
132
+ };
133
+ this.request = function (_a) { return __awaiter(_this, void 0, void 0, function () {
134
+ var secureParams, _b, requestParams, responseFormat;
135
+ var secure = _a.secure, path = _a.path, type = _a.type, query = _a.query, format = _a.format, body = _a.body, params = __rest(_a, ["secure", "path", "type", "query", "format", "body"]);
136
+ return __generator(this, function (_c) {
137
+ switch (_c.label) {
138
+ case 0:
139
+ _b = (typeof secure === "boolean" ? secure : this.secure) &&
140
+ this.securityWorker;
141
+ if (!_b) return [3 /*break*/, 2];
142
+ return [4 /*yield*/, this.securityWorker(this.securityData)];
143
+ case 1:
144
+ _b = (_c.sent());
145
+ _c.label = 2;
146
+ case 2:
147
+ secureParams = (_b) ||
148
+ {};
149
+ requestParams = this.mergeRequestParams(params, secureParams);
150
+ responseFormat = format || this.format || undefined;
151
+ if (type === ContentType.FormData &&
152
+ body &&
153
+ body !== null &&
154
+ typeof body === "object") {
155
+ body = this.createFormData(body);
156
+ }
157
+ if (type === ContentType.Text &&
158
+ body &&
159
+ body !== null &&
160
+ typeof body !== "string") {
161
+ body = JSON.stringify(body);
162
+ }
163
+ return [2 /*return*/, this.instance
164
+ .request(__assign(__assign({}, requestParams), { headers: __assign(__assign({}, (requestParams.headers || {})), (type ? { "Content-Type": type } : {})), params: query, responseType: responseFormat, data: body, url: path }))
165
+ .then(function (response) { return response.data; })];
166
+ }
167
+ });
168
+ }); };
169
+ this.instance = axios.create(__assign(__assign({}, axiosConfig), { baseURL: axiosConfig.baseURL || "http://localhost:3000" }));
170
+ this.secure = secure;
171
+ this.format = format;
172
+ this.securityWorker = securityWorker;
173
+ }
174
+ HttpClient.prototype.mergeRequestParams = function (params1, params2) {
175
+ var method = params1.method || (params2 && params2.method);
176
+ return __assign(__assign(__assign(__assign({}, this.instance.defaults), params1), (params2 || {})), { headers: __assign(__assign(__assign({}, ((method &&
177
+ this.instance.defaults.headers[method.toLowerCase()]) ||
178
+ {})), (params1.headers || {})), ((params2 && params2.headers) || {})) });
179
+ };
180
+ HttpClient.prototype.stringifyFormItem = function (formItem) {
181
+ if (typeof formItem === "object" && formItem !== null) {
182
+ return JSON.stringify(formItem);
183
+ }
184
+ else {
185
+ return "".concat(formItem);
186
+ }
187
+ };
188
+ HttpClient.prototype.createFormData = function (input) {
189
+ var _this = this;
190
+ if (input instanceof FormData) {
191
+ return input;
192
+ }
193
+ return Object.keys(input || {}).reduce(function (formData, key) {
194
+ var property = input[key];
195
+ var propertyContent = property instanceof Array ? property : [property];
196
+ for (var _i = 0, propertyContent_1 = propertyContent; _i < propertyContent_1.length; _i++) {
197
+ var formItem = propertyContent_1[_i];
198
+ var isFileType = formItem instanceof Blob || formItem instanceof File;
199
+ formData.append(key, isFileType ? formItem : _this.stringifyFormItem(formItem));
200
+ }
201
+ return formData;
202
+ }, new FormData());
203
+ };
204
+ return HttpClient;
205
+ }());
206
+ export { HttpClient };
207
+ /**
208
+ * @title mora-backend
209
+ * @version 0.0.1
210
+ * @baseUrl http://localhost:3000
211
+ * @contact
212
+ */
213
+ var Api = /** @class */ (function (_super) {
214
+ __extends(Api, _super);
215
+ function Api() {
216
+ var _this = _super !== null && _super.apply(this, arguments) || this;
217
+ /**
218
+ * No description
219
+ *
220
+ * @tags App
221
+ * @name Index
222
+ * @request GET:/
223
+ * @response `200` `void`
224
+ */
225
+ _this.index = function (params) {
226
+ if (params === void 0) { params = {}; }
227
+ return _this.request(__assign({ path: "/", method: "GET" }, params));
228
+ };
229
+ _this.webhooks = {
230
+ /**
231
+ * @description Receives ASAAS events webhooks to validate and sync states
232
+ *
233
+ * @tags Integration Webhooks
234
+ * @name ReceiveAsaasEventWebhook
235
+ * @request POST:/webhooks/asaas/events
236
+ * @secure
237
+ * @response `200` `void`
238
+ * @response `403` `void` Invalid ASAAS access token
239
+ */
240
+ receiveAsaasEventWebhook: function (data, params) {
241
+ if (params === void 0) { params = {}; }
242
+ return _this.request(__assign({ path: "/webhooks/asaas/events", method: "POST", body: data, secure: true, type: ContentType.Json }, params));
243
+ },
244
+ /**
245
+ * @description Receives ASAAS webhooks to validate withdraws on receiver account
246
+ *
247
+ * @tags Integration Webhooks
248
+ * @name ReceiveAsaasWithdrawValidationWebhook
249
+ * @request POST:/webhooks/asaas/withdraw-validation
250
+ * @secure
251
+ * @response `200` `void`
252
+ * @response `403` `void` Invalid ASAAS access token
253
+ */
254
+ receiveAsaasWithdrawValidationWebhook: function (data, params) {
255
+ if (params === void 0) { params = {}; }
256
+ return _this.request(__assign({ path: "/webhooks/asaas/withdraw-validation", method: "POST", body: data, secure: true, type: ContentType.Json }, params));
257
+ },
258
+ };
259
+ _this.tenants = {
260
+ /**
261
+ * No description
262
+ *
263
+ * @tags Users Withdrawal Accounts
264
+ * @name AddUserWithdrawalAccount
265
+ * @request POST:/tenants/{tenantId}/users/{userId}/withdrawal-accounts
266
+ * @secure
267
+ * @response `201` `WithdrawalAccountEntityDto`
268
+ * @response `403` `HttpExceptionDto` You're not enabled to make this operation.
269
+ */
270
+ addUserWithdrawalAccount: function (tenantId, userId, data, params) {
271
+ if (params === void 0) { params = {}; }
272
+ return _this.request(__assign({ path: "/tenants/".concat(tenantId, "/users/").concat(userId, "/withdrawal-accounts"), method: "POST", body: data, secure: true, type: ContentType.Json, format: "json" }, params));
273
+ },
274
+ /**
275
+ * No description
276
+ *
277
+ * @tags Users Withdrawal Accounts
278
+ * @name DeleteUserWithdrawalAccount
279
+ * @request DELETE:/tenants/{tenantId}/users/{userId}/withdrawal-accounts/{accountId}
280
+ * @secure
281
+ * @response `204` `void`
282
+ * @response `403` `HttpExceptionDto` You're not enabled to make this operation.
283
+ */
284
+ deleteUserWithdrawalAccount: function (tenantId, userId, accountId, params) {
285
+ if (params === void 0) { params = {}; }
286
+ return _this.request(__assign({ path: "/tenants/".concat(tenantId, "/users/").concat(userId, "/withdrawal-accounts/").concat(accountId), method: "DELETE", secure: true }, params));
287
+ },
288
+ /**
289
+ * No description
290
+ *
291
+ * @tags Tenant Users
292
+ * @name DisableTenantUser
293
+ * @request PATCH:/tenants/{tenantId}/users/{userId}/disable
294
+ * @secure
295
+ * @response `204` `void`
296
+ * @response `403` `HttpExceptionDto` Need user with one of these roles: owner
297
+ */
298
+ disableTenantUser: function (tenantId, userId, params) {
299
+ if (params === void 0) { params = {}; }
300
+ return _this.request(__assign({ path: "/tenants/".concat(tenantId, "/users/").concat(userId, "/disable"), method: "PATCH", secure: true }, params));
301
+ },
302
+ /**
303
+ * No description
304
+ *
305
+ * @tags Tenant Users
306
+ * @name EnableTenantUser
307
+ * @request PATCH:/tenants/{tenantId}/users/{userId}/enable
308
+ * @secure
309
+ * @response `204` `void`
310
+ * @response `403` `HttpExceptionDto` Need user with one of these roles: owner
311
+ */
312
+ enableTenantUser: function (tenantId, userId, params) {
313
+ if (params === void 0) { params = {}; }
314
+ return _this.request(__assign({ path: "/tenants/".concat(tenantId, "/users/").concat(userId, "/enable"), method: "PATCH", secure: true }, params));
315
+ },
316
+ /**
317
+ * No description
318
+ *
319
+ * @tags Tenant Users
320
+ * @name GetTenantUser
321
+ * @request GET:/tenants/{tenantId}/users/{userId}
322
+ * @secure
323
+ * @response `200` `UserEntityDto`
324
+ * @response `403` `HttpExceptionDto` You're not enabled to make this operation.
325
+ */
326
+ getTenantUser: function (tenantId, userId, params) {
327
+ if (params === void 0) { params = {}; }
328
+ return _this.request(__assign({ path: "/tenants/".concat(tenantId, "/users/").concat(userId), method: "GET", secure: true, format: "json" }, params));
329
+ },
330
+ /**
331
+ * No description
332
+ *
333
+ * @tags Users Withdrawal Accounts
334
+ * @name GetUserWithdrawalAccountById
335
+ * @request GET:/tenants/{tenantId}/users/{userId}/withdrawal-accounts/{accountId}
336
+ * @secure
337
+ * @response `200` `WithdrawalAccountEntityDto`
338
+ * @response `403` `HttpExceptionDto` You're not enabled to make this operation.
339
+ */
340
+ getUserWithdrawalAccountById: function (tenantId, userId, accountId, params) {
341
+ if (params === void 0) { params = {}; }
342
+ return _this.request(__assign({ path: "/tenants/".concat(tenantId, "/users/").concat(userId, "/withdrawal-accounts/").concat(accountId), method: "GET", secure: true, format: "json" }, params));
343
+ },
344
+ /**
345
+ * No description
346
+ *
347
+ * @tags Tenant Users
348
+ * @name ListTenantUsers
349
+ * @request GET:/tenants/{tenantId}/users
350
+ * @secure
351
+ * @response `200` `UserEntityPaginatedDto`
352
+ * @response `403` `HttpExceptionDto` Need user with one of these roles: owner, admin, operator
353
+ */
354
+ listTenantUsers: function (tenantId, query, params) {
355
+ if (params === void 0) { params = {}; }
356
+ return _this.request(__assign({ path: "/tenants/".concat(tenantId, "/users"), method: "GET", query: query, secure: true, format: "json" }, params));
357
+ },
358
+ /**
359
+ * No description
360
+ *
361
+ * @tags Users Withdrawal Accounts
362
+ * @name ListUserWithdrawalAccounts
363
+ * @request GET:/tenants/{tenantId}/users/{userId}/withdrawal-accounts
364
+ * @secure
365
+ * @response `200` `WithdrawalAccountEntityPaginatedDto`
366
+ * @response `403` `HttpExceptionDto` You're not enabled to make this operation.
367
+ */
368
+ listUserWithdrawalAccounts: function (tenantId, userId, query, params) {
369
+ if (params === void 0) { params = {}; }
370
+ return _this.request(__assign({ path: "/tenants/".concat(tenantId, "/users/").concat(userId, "/withdrawal-accounts"), method: "GET", query: query, secure: true, format: "json" }, params));
371
+ },
372
+ /**
373
+ * No description
374
+ *
375
+ * @tags Integration Webhooks
376
+ * @name ReceiveStatusCallback
377
+ * @request POST:/tenants/{tenantId}/webhooks/twilio/message-status
378
+ * @secure
379
+ * @response `200` `void`
380
+ */
381
+ receiveStatusCallback: function (tenantId, data, params) {
382
+ if (params === void 0) { params = {}; }
383
+ return _this.request(__assign({ path: "/tenants/".concat(tenantId, "/webhooks/twilio/message-status"), method: "POST", body: data, secure: true, type: ContentType.Json }, params));
384
+ },
385
+ };
386
+ _this.public = {
387
+ /**
388
+ * No description
389
+ *
390
+ * @tags [Public] Tenant Charges
391
+ * @name GetPublicChargeById
392
+ * @request GET:/public/tenants/{tenantId}/charges/{document}/{chargeId}
393
+ * @secure
394
+ * @response `200` `PublicFullChargeEntityDto`
395
+ */
396
+ getPublicChargeById: function (tenantId, document, chargeId, params) {
397
+ if (params === void 0) { params = {}; }
398
+ return _this.request(__assign({ path: "/public/tenants/".concat(tenantId, "/charges/").concat(document, "/").concat(chargeId), method: "GET", secure: true, format: "json" }, params));
399
+ },
400
+ /**
401
+ * No description
402
+ *
403
+ * @tags [Public] Tenant Charges
404
+ * @name ListPublicChargesByDocument
405
+ * @request GET:/public/tenants/{tenantId}/charges/{document}
406
+ * @secure
407
+ * @response `200` `PublicChargeEntityPaginatedDto`
408
+ */
409
+ listPublicChargesByDocument: function (tenantId, document, query, params) {
410
+ if (params === void 0) { params = {}; }
411
+ return _this.request(__assign({ path: "/public/tenants/".concat(tenantId, "/charges/").concat(document), method: "GET", query: query, secure: true, format: "json" }, params));
412
+ },
413
+ /**
414
+ * No description
415
+ *
416
+ * @tags [Public] Tenant Charges
417
+ * @name PayCharge
418
+ * @request POST:/public/tenants/{tenantId}/charges/{document}/{chargeId}/pay
419
+ * @secure
420
+ * @response `200` `PublicFullChargeEntityDto`
421
+ */
422
+ payCharge: function (tenantId, document, chargeId, data, params) {
423
+ if (params === void 0) { params = {}; }
424
+ return _this.request(__assign({ path: "/public/tenants/".concat(tenantId, "/charges/").concat(document, "/").concat(chargeId, "/pay"), method: "POST", body: data, secure: true, type: ContentType.Json, format: "json" }, params));
425
+ },
426
+ };
427
+ _this.auth = {
428
+ /**
429
+ * No description
430
+ *
431
+ * @tags Authentication
432
+ * @name Logout
433
+ * @request POST:/auth/logout
434
+ * @secure
435
+ * @response `204` `void`
436
+ */
437
+ logout: function (params) {
438
+ if (params === void 0) { params = {}; }
439
+ return _this.request(__assign({ path: "/auth/logout", method: "POST", secure: true }, params));
440
+ },
441
+ /**
442
+ * No description
443
+ *
444
+ * @tags Authentication
445
+ * @name RequestPasswordReset
446
+ * @request POST:/auth/request-password-reset
447
+ * @secure
448
+ * @response `204` `void`
449
+ */
450
+ requestPasswordReset: function (data, params) {
451
+ if (params === void 0) { params = {}; }
452
+ return _this.request(__assign({ path: "/auth/request-password-reset", method: "POST", body: data, secure: true, type: ContentType.Json }, params));
453
+ },
454
+ /**
455
+ * No description
456
+ *
457
+ * @tags Authentication
458
+ * @name ResetPassword
459
+ * @request PATCH:/auth/reset-password
460
+ * @secure
461
+ * @response `200` `SigninResponseDto`
462
+ */
463
+ resetPassword: function (data, params) {
464
+ if (params === void 0) { params = {}; }
465
+ return _this.request(__assign({ path: "/auth/reset-password", method: "PATCH", body: data, secure: true, type: ContentType.Json, format: "json" }, params));
466
+ },
467
+ /**
468
+ * No description
469
+ *
470
+ * @tags Authentication
471
+ * @name SignIn
472
+ * @request POST:/auth/signin
473
+ * @secure
474
+ * @response `200` `SigninResponseDto`
475
+ */
476
+ signIn: function (data, params) {
477
+ if (params === void 0) { params = {}; }
478
+ return _this.request(__assign({ path: "/auth/signin", method: "POST", body: data, secure: true, type: ContentType.Json, format: "json" }, params));
479
+ },
480
+ };
481
+ return _this;
482
+ }
483
+ return Api;
484
+ }(HttpClient));
485
+ export { Api };
@@ -0,0 +1,3 @@
1
+ export { MoraSDK } from './sdk';
2
+ export * from './api/api';
3
+ export * from './interfaces';
@@ -0,0 +1 @@
1
+ export {};