@kanmon/sdk 2.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 (137) hide show
  1. package/README.md +2 -0
  2. package/package.json +45 -0
  3. package/src/index.ts +65 -0
  4. package/src/openapi/.openapi-generator/FILES +130 -0
  5. package/src/openapi/.openapi-generator/VERSION +1 -0
  6. package/src/openapi/.openapi-generator-ignore +30 -0
  7. package/src/openapi/apis/BankAccountsApi.ts +503 -0
  8. package/src/openapi/apis/BusinessesApi.ts +614 -0
  9. package/src/openapi/apis/ConnectTokensApi.ts +133 -0
  10. package/src/openapi/apis/DocumentsApi.ts +150 -0
  11. package/src/openapi/apis/DrawRequestsApi.ts +258 -0
  12. package/src/openapi/apis/EmbeddedSessionsApi.ts +141 -0
  13. package/src/openapi/apis/InvoicesApi.ts +272 -0
  14. package/src/openapi/apis/IssuedProductsApi.ts +251 -0
  15. package/src/openapi/apis/OffersApi.ts +251 -0
  16. package/src/openapi/apis/PaymentsApi.ts +268 -0
  17. package/src/openapi/apis/PrequalificationsApi.ts +141 -0
  18. package/src/openapi/apis/UsersApi.ts +622 -0
  19. package/src/openapi/apis/baseapi.ts +37 -0
  20. package/src/openapi/apis/exception.ts +15 -0
  21. package/src/openapi/auth/auth.ts +79 -0
  22. package/src/openapi/configuration.ts +82 -0
  23. package/src/openapi/http/http.ts +247 -0
  24. package/src/openapi/http/isomorphic-fetch.ts +32 -0
  25. package/src/openapi/index.ts +12 -0
  26. package/src/openapi/middleware.ts +66 -0
  27. package/src/openapi/models/ActivityLog.ts +98 -0
  28. package/src/openapi/models/Address.ts +140 -0
  29. package/src/openapi/models/BadRequestException.ts +63 -0
  30. package/src/openapi/models/BankAccountAlreadyExistException.ts +63 -0
  31. package/src/openapi/models/BankAccountNotFoundException.ts +63 -0
  32. package/src/openapi/models/BankStatementsInvalidException.ts +63 -0
  33. package/src/openapi/models/Business.ts +126 -0
  34. package/src/openapi/models/BusinessAddress.ts +143 -0
  35. package/src/openapi/models/BusinessAlreadyExistsException.ts +63 -0
  36. package/src/openapi/models/BusinessBankAccount.ts +126 -0
  37. package/src/openapi/models/BusinessDocument.ts +98 -0
  38. package/src/openapi/models/BusinessDocumentType.ts +17 -0
  39. package/src/openapi/models/BusinessHasNoInvoiceFinancingProductException.ts +63 -0
  40. package/src/openapi/models/BusinessHasNoPrimaryOwnerException.ts +63 -0
  41. package/src/openapi/models/BusinessNotFoundException.ts +63 -0
  42. package/src/openapi/models/BusinessPlaidBankAccountNotFoundException.ts +63 -0
  43. package/src/openapi/models/BusinessPrequalification.ts +116 -0
  44. package/src/openapi/models/CheckingAccountRequiredException.ts +63 -0
  45. package/src/openapi/models/ConnectToken.ts +38 -0
  46. package/src/openapi/models/CreateBusinessBankAccountRequestBody.ts +116 -0
  47. package/src/openapi/models/CreateBusinessDocumentsResponse.ts +39 -0
  48. package/src/openapi/models/CreateBusinessRequestBody.ts +99 -0
  49. package/src/openapi/models/CreateConnectTokenRequestBody.ts +48 -0
  50. package/src/openapi/models/CreateEmbeddedSession409Response.ts +65 -0
  51. package/src/openapi/models/CreateSessionTokenRequestBody.ts +56 -0
  52. package/src/openapi/models/CreateSessionTokenRequestBodyData.ts +56 -0
  53. package/src/openapi/models/CreateUser409Response.ts +66 -0
  54. package/src/openapi/models/CreateUserRequestBody.ts +125 -0
  55. package/src/openapi/models/DrawRequest.ts +138 -0
  56. package/src/openapi/models/DrawRequestNotFoundException.ts +63 -0
  57. package/src/openapi/models/DrawRequestState.ts +21 -0
  58. package/src/openapi/models/EmbeddedSession.ts +38 -0
  59. package/src/openapi/models/FixedDateInvoiceRepaymentWindow.ts +50 -0
  60. package/src/openapi/models/FixedDurationInvoiceRepaymentWindow.ts +50 -0
  61. package/src/openapi/models/ForbiddenException.ts +63 -0
  62. package/src/openapi/models/GetActivityLogsResponse.ts +50 -0
  63. package/src/openapi/models/GetBusinessBankAccountsResponse.ts +50 -0
  64. package/src/openapi/models/GetBusinessesResponse.ts +50 -0
  65. package/src/openapi/models/GetDrawRequestsResponse.ts +50 -0
  66. package/src/openapi/models/GetInvoice404Response.ts +65 -0
  67. package/src/openapi/models/GetInvoicesResponse.ts +50 -0
  68. package/src/openapi/models/GetIssuedProductsResponse.ts +50 -0
  69. package/src/openapi/models/GetOffersResponse.ts +50 -0
  70. package/src/openapi/models/GetPaymentScheduleResponse.ts +50 -0
  71. package/src/openapi/models/GetPrequalificationsResponse.ts +50 -0
  72. package/src/openapi/models/GetUsersResponse.ts +50 -0
  73. package/src/openapi/models/InternalServerErrorException.ts +63 -0
  74. package/src/openapi/models/InvalidInvoiceDueDateException.ts +63 -0
  75. package/src/openapi/models/Invoice.ts +281 -0
  76. package/src/openapi/models/InvoiceFinancingOfferTerms.ts +61 -0
  77. package/src/openapi/models/InvoiceFinancingServicingData.ts +71 -0
  78. package/src/openapi/models/InvoiceFlowSessionTokenData.ts +51 -0
  79. package/src/openapi/models/InvoiceFlowWithInvoiceFileSessionTokenData.ts +51 -0
  80. package/src/openapi/models/InvoiceNotFoundException.ts +63 -0
  81. package/src/openapi/models/InvoicePaymentPlan.ts +58 -0
  82. package/src/openapi/models/InvoicePayorAddress.ts +143 -0
  83. package/src/openapi/models/InvoiceRepaymentSchedule.ts +39 -0
  84. package/src/openapi/models/InvoiceRepaymentScheduleItem.ts +68 -0
  85. package/src/openapi/models/InvoiceStatus.ts +22 -0
  86. package/src/openapi/models/IssuedProduct.ts +115 -0
  87. package/src/openapi/models/IssuedProductNotFoundException.ts +63 -0
  88. package/src/openapi/models/IssuedProductServicingData.ts +234 -0
  89. package/src/openapi/models/LineOfCreditOfferTerms.ts +80 -0
  90. package/src/openapi/models/LineOfCreditServicingData.ts +90 -0
  91. package/src/openapi/models/McaOfferTerms.ts +96 -0
  92. package/src/openapi/models/McaServicingData.ts +116 -0
  93. package/src/openapi/models/MergeUsersRequestBody.ts +68 -0
  94. package/src/openapi/models/MergeUsersResponseBody.ts +39 -0
  95. package/src/openapi/models/MultipleDurationInvoiceRepaymentWindow.ts +48 -0
  96. package/src/openapi/models/ObjectSerializer.ts +643 -0
  97. package/src/openapi/models/Offer.ts +106 -0
  98. package/src/openapi/models/OfferAlreadySelectedException.ts +63 -0
  99. package/src/openapi/models/OfferNotFoundException.ts +63 -0
  100. package/src/openapi/models/OfferNotLockedException.ts +63 -0
  101. package/src/openapi/models/OfferTerms.ts +184 -0
  102. package/src/openapi/models/PaginationResult.ts +58 -0
  103. package/src/openapi/models/PaymentOrder.ts +198 -0
  104. package/src/openapi/models/PaymentOrderNotFoundException.ts +63 -0
  105. package/src/openapi/models/PaymentOrderStatus.ts +19 -0
  106. package/src/openapi/models/PaymentPlanRepaymentSchedule.ts +39 -0
  107. package/src/openapi/models/PaymentPlanRepaymentScheduleItem.ts +48 -0
  108. package/src/openapi/models/PaymentScheduleItem.ts +56 -0
  109. package/src/openapi/models/PaymentScheduleItemPaymentOrder.ts +201 -0
  110. package/src/openapi/models/PlaidAssetReportsInvalidException.ts +63 -0
  111. package/src/openapi/models/PlatformInvoiceIdAlreadyExistsForAnotherIssuedProductException.ts +63 -0
  112. package/src/openapi/models/PrimaryBusinessOwnerAlreadyExistsForBusinessException.ts +63 -0
  113. package/src/openapi/models/PrimaryBusinessOwnerAlreadyExistsWithEmailException.ts +63 -0
  114. package/src/openapi/models/PrimaryBusinessOwnerNotFoundException.ts +63 -0
  115. package/src/openapi/models/SessionInvoice.ts +165 -0
  116. package/src/openapi/models/SessionInvoiceWithInvoiceFile.ts +175 -0
  117. package/src/openapi/models/SomeOffersHaveExpiredException.ts +63 -0
  118. package/src/openapi/models/TermLoanOfferTerms.ts +90 -0
  119. package/src/openapi/models/TermLoanServicingData.ts +100 -0
  120. package/src/openapi/models/UnmergeableBusinessException.ts +63 -0
  121. package/src/openapi/models/UpdateBusinessAccountRequestBody.ts +68 -0
  122. package/src/openapi/models/UpdateBusinessRequestBody.ts +99 -0
  123. package/src/openapi/models/UpdateUser409Response.ts +65 -0
  124. package/src/openapi/models/UpdateUserRequestBody.ts +95 -0
  125. package/src/openapi/models/User.ts +152 -0
  126. package/src/openapi/models/UserAddress.ts +143 -0
  127. package/src/openapi/models/UserAlreadyExistsWithEmailException.ts +63 -0
  128. package/src/openapi/models/UserAlreadyExistsWithPlatformUserIdException.ts +63 -0
  129. package/src/openapi/models/UserNotFoundException.ts +63 -0
  130. package/src/openapi/models/all.ts +102 -0
  131. package/src/openapi/rxjsStub.ts +27 -0
  132. package/src/openapi/servers.ts +58 -0
  133. package/src/openapi/types/ObjectParamAPI.ts +1403 -0
  134. package/src/openapi/types/ObservableAPI.ts +1348 -0
  135. package/src/openapi/types/PromiseAPI.ts +995 -0
  136. package/src/openapi/util.ts +37 -0
  137. package/tsconfig.json +32 -0
@@ -0,0 +1,622 @@
1
+ // TODO: better import syntax?
2
+ import {BaseAPIRequestFactory, RequiredError, COLLECTION_FORMATS} from './baseapi';
3
+ import {Configuration} from '../configuration';
4
+ import {RequestContext, HttpMethod, ResponseContext, HttpFile, HttpInfo} from '../http/http';
5
+ import FormData from "form-data";
6
+ import { URLSearchParams } from 'url';
7
+ import {ObjectSerializer} from '../models/ObjectSerializer';
8
+ import {ApiException} from './exception';
9
+ import {canConsumeForm, isCodeInRange} from '../util';
10
+ import {SecurityAuthentication} from '../auth/auth';
11
+
12
+
13
+ import { BadRequestException } from '../models/BadRequestException';
14
+ import { BusinessNotFoundException } from '../models/BusinessNotFoundException';
15
+ import { CreateUser409Response } from '../models/CreateUser409Response';
16
+ import { CreateUserRequestBody } from '../models/CreateUserRequestBody';
17
+ import { ForbiddenException } from '../models/ForbiddenException';
18
+ import { GetUsersResponse } from '../models/GetUsersResponse';
19
+ import { InternalServerErrorException } from '../models/InternalServerErrorException';
20
+ import { MergeUsersRequestBody } from '../models/MergeUsersRequestBody';
21
+ import { MergeUsersResponseBody } from '../models/MergeUsersResponseBody';
22
+ import { PrimaryBusinessOwnerAlreadyExistsForBusinessException } from '../models/PrimaryBusinessOwnerAlreadyExistsForBusinessException';
23
+ import { UpdateUser409Response } from '../models/UpdateUser409Response';
24
+ import { UpdateUserRequestBody } from '../models/UpdateUserRequestBody';
25
+ import { User } from '../models/User';
26
+ import { UserNotFoundException } from '../models/UserNotFoundException';
27
+
28
+ /**
29
+ * no description
30
+ */
31
+ export class UsersApiRequestFactory extends BaseAPIRequestFactory {
32
+
33
+ /**
34
+ * Create a user
35
+ * @param createUserRequestBody
36
+ */
37
+ public async createUser(createUserRequestBody: CreateUserRequestBody, _options?: Configuration): Promise<RequestContext> {
38
+ let _config = _options || this.configuration;
39
+
40
+ // verify required parameter 'createUserRequestBody' is not null or undefined
41
+ if (createUserRequestBody === null || createUserRequestBody === undefined) {
42
+ throw new RequiredError("UsersApi", "createUser", "createUserRequestBody");
43
+ }
44
+
45
+
46
+ // Path Params
47
+ const localVarPath = '/api/platform/v2/users';
48
+
49
+ // Make Request Context
50
+ const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
51
+ requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
52
+
53
+
54
+ // Body Params
55
+ const contentType = ObjectSerializer.getPreferredMediaType([
56
+ "application/json"
57
+ ]);
58
+ requestContext.setHeaderParam("Content-Type", contentType);
59
+ const serializedBody = ObjectSerializer.stringify(
60
+ ObjectSerializer.serialize(createUserRequestBody, "CreateUserRequestBody", ""),
61
+ contentType
62
+ );
63
+ requestContext.setBody(serializedBody);
64
+
65
+ let authMethod: SecurityAuthentication | undefined;
66
+ // Apply auth methods
67
+ authMethod = _config.authMethods["Authorization"]
68
+ if (authMethod?.applySecurityAuthentication) {
69
+ await authMethod?.applySecurityAuthentication(requestContext);
70
+ }
71
+
72
+ const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
73
+ if (defaultAuth?.applySecurityAuthentication) {
74
+ await defaultAuth?.applySecurityAuthentication(requestContext);
75
+ }
76
+
77
+ return requestContext;
78
+ }
79
+
80
+ /**
81
+ * Fetch a user
82
+ * @param id Either the Kanmon user UUID or your platform’s user ID, depending on &#x60;idType&#x60;.
83
+ * @param idType Which ID type to query the user by. Defaults to &#x60;KANMON&#x60;. Use &#x60;PLATFORM&#x60; if you want to query by your platform’s ID.
84
+ */
85
+ public async getUser(id: string, idType?: 'KANMON' | 'PLATFORM', _options?: Configuration): Promise<RequestContext> {
86
+ let _config = _options || this.configuration;
87
+
88
+ // verify required parameter 'id' is not null or undefined
89
+ if (id === null || id === undefined) {
90
+ throw new RequiredError("UsersApi", "getUser", "id");
91
+ }
92
+
93
+
94
+
95
+ // Path Params
96
+ const localVarPath = '/api/platform/v2/users/{id}'
97
+ .replace('{' + 'id' + '}', encodeURIComponent(String(id)));
98
+
99
+ // Make Request Context
100
+ const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
101
+ requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
102
+
103
+ // Query Params
104
+ if (idType !== undefined) {
105
+ requestContext.setQueryParam("idType", ObjectSerializer.serialize(idType, "'KANMON' | 'PLATFORM'", ""));
106
+ }
107
+
108
+
109
+ let authMethod: SecurityAuthentication | undefined;
110
+ // Apply auth methods
111
+ authMethod = _config.authMethods["Authorization"]
112
+ if (authMethod?.applySecurityAuthentication) {
113
+ await authMethod?.applySecurityAuthentication(requestContext);
114
+ }
115
+
116
+ const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
117
+ if (defaultAuth?.applySecurityAuthentication) {
118
+ await defaultAuth?.applySecurityAuthentication(requestContext);
119
+ }
120
+
121
+ return requestContext;
122
+ }
123
+
124
+ /**
125
+ * Fetch users
126
+ * @param ids A comma delimited list of Kanmon’s unique IDs for users.
127
+ * @param platformUserIds A comma delimited list of your platform’s unique IDs for users.
128
+ * @param platformBusinessIds A comma delimited list of your platform’s unique business IDs for users.
129
+ * @param businessIds A comma delimited list of your Kanmon’s unique business IDs for users.
130
+ * @param offset The number of records to skip when performing pagination. Defaults to &#x60;0&#x60;.
131
+ * @param limit The number of records to limit when performing pagination. Defaults to &#x60;100&#x60;, which is the max.
132
+ * @param createdAtStart Filter for records where &#x60;createdAt&#x60; is greater than or equal to this value. ISO 8601 format.
133
+ * @param createdAtEnd Filter for records where &#x60;createdAt&#x60; is less than or equal to this value. ISO 8601 format.
134
+ */
135
+ public async getUsers(ids?: string, platformUserIds?: string, platformBusinessIds?: string, businessIds?: string, offset?: number, limit?: number, createdAtStart?: string, createdAtEnd?: string, _options?: Configuration): Promise<RequestContext> {
136
+ let _config = _options || this.configuration;
137
+
138
+
139
+
140
+
141
+
142
+
143
+
144
+
145
+
146
+ // Path Params
147
+ const localVarPath = '/api/platform/v2/users';
148
+
149
+ // Make Request Context
150
+ const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
151
+ requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
152
+
153
+ // Query Params
154
+ if (ids !== undefined) {
155
+ requestContext.setQueryParam("ids", ObjectSerializer.serialize(ids, "string", ""));
156
+ }
157
+
158
+ // Query Params
159
+ if (platformUserIds !== undefined) {
160
+ requestContext.setQueryParam("platformUserIds", ObjectSerializer.serialize(platformUserIds, "string", ""));
161
+ }
162
+
163
+ // Query Params
164
+ if (platformBusinessIds !== undefined) {
165
+ requestContext.setQueryParam("platformBusinessIds", ObjectSerializer.serialize(platformBusinessIds, "string", ""));
166
+ }
167
+
168
+ // Query Params
169
+ if (businessIds !== undefined) {
170
+ requestContext.setQueryParam("businessIds", ObjectSerializer.serialize(businessIds, "string", ""));
171
+ }
172
+
173
+ // Query Params
174
+ if (offset !== undefined) {
175
+ requestContext.setQueryParam("offset", ObjectSerializer.serialize(offset, "number", ""));
176
+ }
177
+
178
+ // Query Params
179
+ if (limit !== undefined) {
180
+ requestContext.setQueryParam("limit", ObjectSerializer.serialize(limit, "number", ""));
181
+ }
182
+
183
+ // Query Params
184
+ if (createdAtStart !== undefined) {
185
+ requestContext.setQueryParam("createdAtStart", ObjectSerializer.serialize(createdAtStart, "string", ""));
186
+ }
187
+
188
+ // Query Params
189
+ if (createdAtEnd !== undefined) {
190
+ requestContext.setQueryParam("createdAtEnd", ObjectSerializer.serialize(createdAtEnd, "string", ""));
191
+ }
192
+
193
+
194
+ let authMethod: SecurityAuthentication | undefined;
195
+ // Apply auth methods
196
+ authMethod = _config.authMethods["Authorization"]
197
+ if (authMethod?.applySecurityAuthentication) {
198
+ await authMethod?.applySecurityAuthentication(requestContext);
199
+ }
200
+
201
+ const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
202
+ if (defaultAuth?.applySecurityAuthentication) {
203
+ await defaultAuth?.applySecurityAuthentication(requestContext);
204
+ }
205
+
206
+ return requestContext;
207
+ }
208
+
209
+ /**
210
+ * Users from the source business will be moved into the target business. This will only work if the source business has not started onboarding yet. After the merge, the source business will be deleted.
211
+ * Merge users from a source business into a target business
212
+ * @param mergeUsersRequestBody
213
+ */
214
+ public async mergeUserIntoBusines(mergeUsersRequestBody: MergeUsersRequestBody, _options?: Configuration): Promise<RequestContext> {
215
+ let _config = _options || this.configuration;
216
+
217
+ // verify required parameter 'mergeUsersRequestBody' is not null or undefined
218
+ if (mergeUsersRequestBody === null || mergeUsersRequestBody === undefined) {
219
+ throw new RequiredError("UsersApi", "mergeUserIntoBusines", "mergeUsersRequestBody");
220
+ }
221
+
222
+
223
+ // Path Params
224
+ const localVarPath = '/api/platform/v2/users/merge';
225
+
226
+ // Make Request Context
227
+ const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
228
+ requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
229
+
230
+
231
+ // Body Params
232
+ const contentType = ObjectSerializer.getPreferredMediaType([
233
+ "application/json"
234
+ ]);
235
+ requestContext.setHeaderParam("Content-Type", contentType);
236
+ const serializedBody = ObjectSerializer.stringify(
237
+ ObjectSerializer.serialize(mergeUsersRequestBody, "MergeUsersRequestBody", ""),
238
+ contentType
239
+ );
240
+ requestContext.setBody(serializedBody);
241
+
242
+ let authMethod: SecurityAuthentication | undefined;
243
+ // Apply auth methods
244
+ authMethod = _config.authMethods["Authorization"]
245
+ if (authMethod?.applySecurityAuthentication) {
246
+ await authMethod?.applySecurityAuthentication(requestContext);
247
+ }
248
+
249
+ const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
250
+ if (defaultAuth?.applySecurityAuthentication) {
251
+ await defaultAuth?.applySecurityAuthentication(requestContext);
252
+ }
253
+
254
+ return requestContext;
255
+ }
256
+
257
+ /**
258
+ * Update a user
259
+ * @param id Either the Kanmon user UUID or your platform’s user ID, depending on &#x60;idType&#x60;.
260
+ * @param updateUserRequestBody
261
+ * @param idType Which ID type to query the user by. Defaults to &#x60;KANMON&#x60;. Use &#x60;PLATFORM&#x60; if you want to query by your platform’s ID.
262
+ */
263
+ public async updateUser(id: string, updateUserRequestBody: UpdateUserRequestBody, idType?: 'KANMON' | 'PLATFORM', _options?: Configuration): Promise<RequestContext> {
264
+ let _config = _options || this.configuration;
265
+
266
+ // verify required parameter 'id' is not null or undefined
267
+ if (id === null || id === undefined) {
268
+ throw new RequiredError("UsersApi", "updateUser", "id");
269
+ }
270
+
271
+
272
+ // verify required parameter 'updateUserRequestBody' is not null or undefined
273
+ if (updateUserRequestBody === null || updateUserRequestBody === undefined) {
274
+ throw new RequiredError("UsersApi", "updateUser", "updateUserRequestBody");
275
+ }
276
+
277
+
278
+
279
+ // Path Params
280
+ const localVarPath = '/api/platform/v2/users/{id}'
281
+ .replace('{' + 'id' + '}', encodeURIComponent(String(id)));
282
+
283
+ // Make Request Context
284
+ const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.PATCH);
285
+ requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
286
+
287
+ // Query Params
288
+ if (idType !== undefined) {
289
+ requestContext.setQueryParam("idType", ObjectSerializer.serialize(idType, "'KANMON' | 'PLATFORM'", ""));
290
+ }
291
+
292
+
293
+ // Body Params
294
+ const contentType = ObjectSerializer.getPreferredMediaType([
295
+ "application/json"
296
+ ]);
297
+ requestContext.setHeaderParam("Content-Type", contentType);
298
+ const serializedBody = ObjectSerializer.stringify(
299
+ ObjectSerializer.serialize(updateUserRequestBody, "UpdateUserRequestBody", ""),
300
+ contentType
301
+ );
302
+ requestContext.setBody(serializedBody);
303
+
304
+ let authMethod: SecurityAuthentication | undefined;
305
+ // Apply auth methods
306
+ authMethod = _config.authMethods["Authorization"]
307
+ if (authMethod?.applySecurityAuthentication) {
308
+ await authMethod?.applySecurityAuthentication(requestContext);
309
+ }
310
+
311
+ const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
312
+ if (defaultAuth?.applySecurityAuthentication) {
313
+ await defaultAuth?.applySecurityAuthentication(requestContext);
314
+ }
315
+
316
+ return requestContext;
317
+ }
318
+
319
+ }
320
+
321
+ export class UsersApiResponseProcessor {
322
+
323
+ /**
324
+ * Unwraps the actual response sent by the server from the response context and deserializes the response content
325
+ * to the expected objects
326
+ *
327
+ * @params response Response returned by the server for a request to createUser
328
+ * @throws ApiException if the response code was not in [200, 299]
329
+ */
330
+ public async createUserWithHttpInfo(response: ResponseContext): Promise<HttpInfo<User >> {
331
+ const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
332
+ if (isCodeInRange("201", response.httpStatusCode)) {
333
+ const body: User = ObjectSerializer.deserialize(
334
+ ObjectSerializer.parse(await response.body.text(), contentType),
335
+ "User", ""
336
+ ) as User;
337
+ return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
338
+ }
339
+ if (isCodeInRange("400", response.httpStatusCode)) {
340
+ const body: BadRequestException = ObjectSerializer.deserialize(
341
+ ObjectSerializer.parse(await response.body.text(), contentType),
342
+ "BadRequestException", ""
343
+ ) as BadRequestException;
344
+ throw new ApiException<BadRequestException>(response.httpStatusCode, "BadRequestException", body, response.headers);
345
+ }
346
+ if (isCodeInRange("403", response.httpStatusCode)) {
347
+ const body: ForbiddenException = ObjectSerializer.deserialize(
348
+ ObjectSerializer.parse(await response.body.text(), contentType),
349
+ "ForbiddenException", ""
350
+ ) as ForbiddenException;
351
+ throw new ApiException<ForbiddenException>(response.httpStatusCode, "ForbiddenException", body, response.headers);
352
+ }
353
+ if (isCodeInRange("404", response.httpStatusCode)) {
354
+ const body: BusinessNotFoundException = ObjectSerializer.deserialize(
355
+ ObjectSerializer.parse(await response.body.text(), contentType),
356
+ "BusinessNotFoundException", ""
357
+ ) as BusinessNotFoundException;
358
+ throw new ApiException<BusinessNotFoundException>(response.httpStatusCode, "BusinessNotFoundException", body, response.headers);
359
+ }
360
+ if (isCodeInRange("409", response.httpStatusCode)) {
361
+ const body: CreateUser409Response = ObjectSerializer.deserialize(
362
+ ObjectSerializer.parse(await response.body.text(), contentType),
363
+ "CreateUser409Response", ""
364
+ ) as CreateUser409Response;
365
+ throw new ApiException<CreateUser409Response>(response.httpStatusCode, "PrimaryBusinessOwnerAlreadyExistsForBusinessException, UserAlreadyExistsWithPlatformUserIdException, UserAlreadyExistsWithEmailException", body, response.headers);
366
+ }
367
+ if (isCodeInRange("500", response.httpStatusCode)) {
368
+ const body: InternalServerErrorException = ObjectSerializer.deserialize(
369
+ ObjectSerializer.parse(await response.body.text(), contentType),
370
+ "InternalServerErrorException", ""
371
+ ) as InternalServerErrorException;
372
+ throw new ApiException<InternalServerErrorException>(response.httpStatusCode, "InternalServerErrorException", body, response.headers);
373
+ }
374
+
375
+ // Work around for missing responses in specification, e.g. for petstore.yaml
376
+ if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
377
+ const body: User = ObjectSerializer.deserialize(
378
+ ObjectSerializer.parse(await response.body.text(), contentType),
379
+ "User", ""
380
+ ) as User;
381
+ return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
382
+ }
383
+
384
+ throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
385
+ }
386
+
387
+ /**
388
+ * Unwraps the actual response sent by the server from the response context and deserializes the response content
389
+ * to the expected objects
390
+ *
391
+ * @params response Response returned by the server for a request to getUser
392
+ * @throws ApiException if the response code was not in [200, 299]
393
+ */
394
+ public async getUserWithHttpInfo(response: ResponseContext): Promise<HttpInfo<User >> {
395
+ const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
396
+ if (isCodeInRange("200", response.httpStatusCode)) {
397
+ const body: User = ObjectSerializer.deserialize(
398
+ ObjectSerializer.parse(await response.body.text(), contentType),
399
+ "User", ""
400
+ ) as User;
401
+ return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
402
+ }
403
+ if (isCodeInRange("400", response.httpStatusCode)) {
404
+ const body: BadRequestException = ObjectSerializer.deserialize(
405
+ ObjectSerializer.parse(await response.body.text(), contentType),
406
+ "BadRequestException", ""
407
+ ) as BadRequestException;
408
+ throw new ApiException<BadRequestException>(response.httpStatusCode, "BadRequestException", body, response.headers);
409
+ }
410
+ if (isCodeInRange("403", response.httpStatusCode)) {
411
+ const body: ForbiddenException = ObjectSerializer.deserialize(
412
+ ObjectSerializer.parse(await response.body.text(), contentType),
413
+ "ForbiddenException", ""
414
+ ) as ForbiddenException;
415
+ throw new ApiException<ForbiddenException>(response.httpStatusCode, "ForbiddenException", body, response.headers);
416
+ }
417
+ if (isCodeInRange("404", response.httpStatusCode)) {
418
+ const body: UserNotFoundException = ObjectSerializer.deserialize(
419
+ ObjectSerializer.parse(await response.body.text(), contentType),
420
+ "UserNotFoundException", ""
421
+ ) as UserNotFoundException;
422
+ throw new ApiException<UserNotFoundException>(response.httpStatusCode, "UserNotFoundException", body, response.headers);
423
+ }
424
+ if (isCodeInRange("500", response.httpStatusCode)) {
425
+ const body: InternalServerErrorException = ObjectSerializer.deserialize(
426
+ ObjectSerializer.parse(await response.body.text(), contentType),
427
+ "InternalServerErrorException", ""
428
+ ) as InternalServerErrorException;
429
+ throw new ApiException<InternalServerErrorException>(response.httpStatusCode, "InternalServerErrorException", body, response.headers);
430
+ }
431
+
432
+ // Work around for missing responses in specification, e.g. for petstore.yaml
433
+ if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
434
+ const body: User = ObjectSerializer.deserialize(
435
+ ObjectSerializer.parse(await response.body.text(), contentType),
436
+ "User", ""
437
+ ) as User;
438
+ return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
439
+ }
440
+
441
+ throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
442
+ }
443
+
444
+ /**
445
+ * Unwraps the actual response sent by the server from the response context and deserializes the response content
446
+ * to the expected objects
447
+ *
448
+ * @params response Response returned by the server for a request to getUsers
449
+ * @throws ApiException if the response code was not in [200, 299]
450
+ */
451
+ public async getUsersWithHttpInfo(response: ResponseContext): Promise<HttpInfo<GetUsersResponse >> {
452
+ const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
453
+ if (isCodeInRange("200", response.httpStatusCode)) {
454
+ const body: GetUsersResponse = ObjectSerializer.deserialize(
455
+ ObjectSerializer.parse(await response.body.text(), contentType),
456
+ "GetUsersResponse", ""
457
+ ) as GetUsersResponse;
458
+ return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
459
+ }
460
+ if (isCodeInRange("400", response.httpStatusCode)) {
461
+ const body: BadRequestException = ObjectSerializer.deserialize(
462
+ ObjectSerializer.parse(await response.body.text(), contentType),
463
+ "BadRequestException", ""
464
+ ) as BadRequestException;
465
+ throw new ApiException<BadRequestException>(response.httpStatusCode, "BadRequestException", body, response.headers);
466
+ }
467
+ if (isCodeInRange("403", response.httpStatusCode)) {
468
+ const body: ForbiddenException = ObjectSerializer.deserialize(
469
+ ObjectSerializer.parse(await response.body.text(), contentType),
470
+ "ForbiddenException", ""
471
+ ) as ForbiddenException;
472
+ throw new ApiException<ForbiddenException>(response.httpStatusCode, "ForbiddenException", body, response.headers);
473
+ }
474
+ if (isCodeInRange("500", response.httpStatusCode)) {
475
+ const body: InternalServerErrorException = ObjectSerializer.deserialize(
476
+ ObjectSerializer.parse(await response.body.text(), contentType),
477
+ "InternalServerErrorException", ""
478
+ ) as InternalServerErrorException;
479
+ throw new ApiException<InternalServerErrorException>(response.httpStatusCode, "InternalServerErrorException", body, response.headers);
480
+ }
481
+
482
+ // Work around for missing responses in specification, e.g. for petstore.yaml
483
+ if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
484
+ const body: GetUsersResponse = ObjectSerializer.deserialize(
485
+ ObjectSerializer.parse(await response.body.text(), contentType),
486
+ "GetUsersResponse", ""
487
+ ) as GetUsersResponse;
488
+ return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
489
+ }
490
+
491
+ throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
492
+ }
493
+
494
+ /**
495
+ * Unwraps the actual response sent by the server from the response context and deserializes the response content
496
+ * to the expected objects
497
+ *
498
+ * @params response Response returned by the server for a request to mergeUserIntoBusines
499
+ * @throws ApiException if the response code was not in [200, 299]
500
+ */
501
+ public async mergeUserIntoBusinesWithHttpInfo(response: ResponseContext): Promise<HttpInfo<MergeUsersResponseBody >> {
502
+ const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
503
+ if (isCodeInRange("200", response.httpStatusCode)) {
504
+ const body: MergeUsersResponseBody = ObjectSerializer.deserialize(
505
+ ObjectSerializer.parse(await response.body.text(), contentType),
506
+ "MergeUsersResponseBody", ""
507
+ ) as MergeUsersResponseBody;
508
+ return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
509
+ }
510
+ if (isCodeInRange("400", response.httpStatusCode)) {
511
+ const body: BadRequestException = ObjectSerializer.deserialize(
512
+ ObjectSerializer.parse(await response.body.text(), contentType),
513
+ "BadRequestException", ""
514
+ ) as BadRequestException;
515
+ throw new ApiException<BadRequestException>(response.httpStatusCode, "BadRequestException", body, response.headers);
516
+ }
517
+ if (isCodeInRange("403", response.httpStatusCode)) {
518
+ const body: ForbiddenException = ObjectSerializer.deserialize(
519
+ ObjectSerializer.parse(await response.body.text(), contentType),
520
+ "ForbiddenException", ""
521
+ ) as ForbiddenException;
522
+ throw new ApiException<ForbiddenException>(response.httpStatusCode, "ForbiddenException", body, response.headers);
523
+ }
524
+ if (isCodeInRange("404", response.httpStatusCode)) {
525
+ const body: BusinessNotFoundException = ObjectSerializer.deserialize(
526
+ ObjectSerializer.parse(await response.body.text(), contentType),
527
+ "BusinessNotFoundException", ""
528
+ ) as BusinessNotFoundException;
529
+ throw new ApiException<BusinessNotFoundException>(response.httpStatusCode, "BusinessNotFoundException", body, response.headers);
530
+ }
531
+ if (isCodeInRange("409", response.httpStatusCode)) {
532
+ const body: PrimaryBusinessOwnerAlreadyExistsForBusinessException = ObjectSerializer.deserialize(
533
+ ObjectSerializer.parse(await response.body.text(), contentType),
534
+ "PrimaryBusinessOwnerAlreadyExistsForBusinessException", ""
535
+ ) as PrimaryBusinessOwnerAlreadyExistsForBusinessException;
536
+ throw new ApiException<PrimaryBusinessOwnerAlreadyExistsForBusinessException>(response.httpStatusCode, "PrimaryBusinessOwnerAlreadyExistsForBusinessException", body, response.headers);
537
+ }
538
+ if (isCodeInRange("500", response.httpStatusCode)) {
539
+ const body: InternalServerErrorException = ObjectSerializer.deserialize(
540
+ ObjectSerializer.parse(await response.body.text(), contentType),
541
+ "InternalServerErrorException", ""
542
+ ) as InternalServerErrorException;
543
+ throw new ApiException<InternalServerErrorException>(response.httpStatusCode, "InternalServerErrorException", body, response.headers);
544
+ }
545
+
546
+ // Work around for missing responses in specification, e.g. for petstore.yaml
547
+ if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
548
+ const body: MergeUsersResponseBody = ObjectSerializer.deserialize(
549
+ ObjectSerializer.parse(await response.body.text(), contentType),
550
+ "MergeUsersResponseBody", ""
551
+ ) as MergeUsersResponseBody;
552
+ return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
553
+ }
554
+
555
+ throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
556
+ }
557
+
558
+ /**
559
+ * Unwraps the actual response sent by the server from the response context and deserializes the response content
560
+ * to the expected objects
561
+ *
562
+ * @params response Response returned by the server for a request to updateUser
563
+ * @throws ApiException if the response code was not in [200, 299]
564
+ */
565
+ public async updateUserWithHttpInfo(response: ResponseContext): Promise<HttpInfo<User >> {
566
+ const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
567
+ if (isCodeInRange("200", response.httpStatusCode)) {
568
+ const body: User = ObjectSerializer.deserialize(
569
+ ObjectSerializer.parse(await response.body.text(), contentType),
570
+ "User", ""
571
+ ) as User;
572
+ return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
573
+ }
574
+ if (isCodeInRange("400", response.httpStatusCode)) {
575
+ const body: BadRequestException = ObjectSerializer.deserialize(
576
+ ObjectSerializer.parse(await response.body.text(), contentType),
577
+ "BadRequestException", ""
578
+ ) as BadRequestException;
579
+ throw new ApiException<BadRequestException>(response.httpStatusCode, "BadRequestException", body, response.headers);
580
+ }
581
+ if (isCodeInRange("403", response.httpStatusCode)) {
582
+ const body: ForbiddenException = ObjectSerializer.deserialize(
583
+ ObjectSerializer.parse(await response.body.text(), contentType),
584
+ "ForbiddenException", ""
585
+ ) as ForbiddenException;
586
+ throw new ApiException<ForbiddenException>(response.httpStatusCode, "ForbiddenException", body, response.headers);
587
+ }
588
+ if (isCodeInRange("404", response.httpStatusCode)) {
589
+ const body: UserNotFoundException = ObjectSerializer.deserialize(
590
+ ObjectSerializer.parse(await response.body.text(), contentType),
591
+ "UserNotFoundException", ""
592
+ ) as UserNotFoundException;
593
+ throw new ApiException<UserNotFoundException>(response.httpStatusCode, "UserNotFoundException", body, response.headers);
594
+ }
595
+ if (isCodeInRange("409", response.httpStatusCode)) {
596
+ const body: UpdateUser409Response = ObjectSerializer.deserialize(
597
+ ObjectSerializer.parse(await response.body.text(), contentType),
598
+ "UpdateUser409Response", ""
599
+ ) as UpdateUser409Response;
600
+ throw new ApiException<UpdateUser409Response>(response.httpStatusCode, "UserAlreadyExistsWithEmailException, PrimaryBusinessOwnerAlreadyExistsForBusinessException", body, response.headers);
601
+ }
602
+ if (isCodeInRange("500", response.httpStatusCode)) {
603
+ const body: InternalServerErrorException = ObjectSerializer.deserialize(
604
+ ObjectSerializer.parse(await response.body.text(), contentType),
605
+ "InternalServerErrorException", ""
606
+ ) as InternalServerErrorException;
607
+ throw new ApiException<InternalServerErrorException>(response.httpStatusCode, "InternalServerErrorException", body, response.headers);
608
+ }
609
+
610
+ // Work around for missing responses in specification, e.g. for petstore.yaml
611
+ if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
612
+ const body: User = ObjectSerializer.deserialize(
613
+ ObjectSerializer.parse(await response.body.text(), contentType),
614
+ "User", ""
615
+ ) as User;
616
+ return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
617
+ }
618
+
619
+ throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
620
+ }
621
+
622
+ }
@@ -0,0 +1,37 @@
1
+ import { Configuration } from '../configuration'
2
+
3
+ /**
4
+ *
5
+ * @export
6
+ */
7
+ export const COLLECTION_FORMATS = {
8
+ csv: ",",
9
+ ssv: " ",
10
+ tsv: "\t",
11
+ pipes: "|",
12
+ };
13
+
14
+
15
+ /**
16
+ *
17
+ * @export
18
+ * @class BaseAPI
19
+ */
20
+ export class BaseAPIRequestFactory {
21
+
22
+ constructor(protected configuration: Configuration) {
23
+ }
24
+ };
25
+
26
+ /**
27
+ *
28
+ * @export
29
+ * @class RequiredError
30
+ * @extends {Error}
31
+ */
32
+ export class RequiredError extends Error {
33
+ name: "RequiredError" = "RequiredError";
34
+ constructor(public api: string, public method: string, public field: string) {
35
+ super("Required parameter " + field + " was null or undefined when calling " + api + "." + method + ".");
36
+ }
37
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Represents an error caused by an api call i.e. it has attributes for a HTTP status code
3
+ * and the returned body object.
4
+ *
5
+ * Example
6
+ * API returns a ErrorMessageObject whenever HTTP status code is not in [200, 299]
7
+ * => ApiException(404, someErrorMessageObject)
8
+ *
9
+ */
10
+ export class ApiException<T> extends Error {
11
+ public constructor(public code: number, message: string, public body: T, public headers: { [key: string]: string; }) {
12
+ super("HTTP-Code: " + code + "\nMessage: " + message + "\nBody: " + JSON.stringify(body) + "\nHeaders: " +
13
+ JSON.stringify(headers))
14
+ }
15
+ }