@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,133 @@
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 { ConnectToken } from '../models/ConnectToken';
15
+ import { CreateConnectTokenRequestBody } from '../models/CreateConnectTokenRequestBody';
16
+ import { ForbiddenException } from '../models/ForbiddenException';
17
+ import { InternalServerErrorException } from '../models/InternalServerErrorException';
18
+ import { UserNotFoundException } from '../models/UserNotFoundException';
19
+
20
+ /**
21
+ * no description
22
+ */
23
+ export class ConnectTokensApiRequestFactory extends BaseAPIRequestFactory {
24
+
25
+ /**
26
+ * Create a connect token
27
+ * @param createConnectTokenRequestBody
28
+ */
29
+ public async connectToken(createConnectTokenRequestBody: CreateConnectTokenRequestBody, _options?: Configuration): Promise<RequestContext> {
30
+ let _config = _options || this.configuration;
31
+
32
+ // verify required parameter 'createConnectTokenRequestBody' is not null or undefined
33
+ if (createConnectTokenRequestBody === null || createConnectTokenRequestBody === undefined) {
34
+ throw new RequiredError("ConnectTokensApi", "connectToken", "createConnectTokenRequestBody");
35
+ }
36
+
37
+
38
+ // Path Params
39
+ const localVarPath = '/api/platform/v2/connect-tokens';
40
+
41
+ // Make Request Context
42
+ const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
43
+ requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
44
+
45
+
46
+ // Body Params
47
+ const contentType = ObjectSerializer.getPreferredMediaType([
48
+ "application/json"
49
+ ]);
50
+ requestContext.setHeaderParam("Content-Type", contentType);
51
+ const serializedBody = ObjectSerializer.stringify(
52
+ ObjectSerializer.serialize(createConnectTokenRequestBody, "CreateConnectTokenRequestBody", ""),
53
+ contentType
54
+ );
55
+ requestContext.setBody(serializedBody);
56
+
57
+ let authMethod: SecurityAuthentication | undefined;
58
+ // Apply auth methods
59
+ authMethod = _config.authMethods["Authorization"]
60
+ if (authMethod?.applySecurityAuthentication) {
61
+ await authMethod?.applySecurityAuthentication(requestContext);
62
+ }
63
+
64
+ const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
65
+ if (defaultAuth?.applySecurityAuthentication) {
66
+ await defaultAuth?.applySecurityAuthentication(requestContext);
67
+ }
68
+
69
+ return requestContext;
70
+ }
71
+
72
+ }
73
+
74
+ export class ConnectTokensApiResponseProcessor {
75
+
76
+ /**
77
+ * Unwraps the actual response sent by the server from the response context and deserializes the response content
78
+ * to the expected objects
79
+ *
80
+ * @params response Response returned by the server for a request to connectToken
81
+ * @throws ApiException if the response code was not in [200, 299]
82
+ */
83
+ public async connectTokenWithHttpInfo(response: ResponseContext): Promise<HttpInfo<ConnectToken >> {
84
+ const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
85
+ if (isCodeInRange("201", response.httpStatusCode)) {
86
+ const body: ConnectToken = ObjectSerializer.deserialize(
87
+ ObjectSerializer.parse(await response.body.text(), contentType),
88
+ "ConnectToken", ""
89
+ ) as ConnectToken;
90
+ return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
91
+ }
92
+ if (isCodeInRange("400", response.httpStatusCode)) {
93
+ const body: BadRequestException = ObjectSerializer.deserialize(
94
+ ObjectSerializer.parse(await response.body.text(), contentType),
95
+ "BadRequestException", ""
96
+ ) as BadRequestException;
97
+ throw new ApiException<BadRequestException>(response.httpStatusCode, "BadRequestException", body, response.headers);
98
+ }
99
+ if (isCodeInRange("403", response.httpStatusCode)) {
100
+ const body: ForbiddenException = ObjectSerializer.deserialize(
101
+ ObjectSerializer.parse(await response.body.text(), contentType),
102
+ "ForbiddenException", ""
103
+ ) as ForbiddenException;
104
+ throw new ApiException<ForbiddenException>(response.httpStatusCode, "ForbiddenException", body, response.headers);
105
+ }
106
+ if (isCodeInRange("404", response.httpStatusCode)) {
107
+ const body: UserNotFoundException = ObjectSerializer.deserialize(
108
+ ObjectSerializer.parse(await response.body.text(), contentType),
109
+ "UserNotFoundException", ""
110
+ ) as UserNotFoundException;
111
+ throw new ApiException<UserNotFoundException>(response.httpStatusCode, "UserNotFoundException", body, response.headers);
112
+ }
113
+ if (isCodeInRange("500", response.httpStatusCode)) {
114
+ const body: InternalServerErrorException = ObjectSerializer.deserialize(
115
+ ObjectSerializer.parse(await response.body.text(), contentType),
116
+ "InternalServerErrorException", ""
117
+ ) as InternalServerErrorException;
118
+ throw new ApiException<InternalServerErrorException>(response.httpStatusCode, "InternalServerErrorException", body, response.headers);
119
+ }
120
+
121
+ // Work around for missing responses in specification, e.g. for petstore.yaml
122
+ if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
123
+ const body: ConnectToken = ObjectSerializer.deserialize(
124
+ ObjectSerializer.parse(await response.body.text(), contentType),
125
+ "ConnectToken", ""
126
+ ) as ConnectToken;
127
+ return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
128
+ }
129
+
130
+ throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
131
+ }
132
+
133
+ }
@@ -0,0 +1,150 @@
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 { CreateBusinessDocumentsResponse } from '../models/CreateBusinessDocumentsResponse';
15
+ import { ForbiddenException } from '../models/ForbiddenException';
16
+ import { InternalServerErrorException } from '../models/InternalServerErrorException';
17
+
18
+ /**
19
+ * no description
20
+ */
21
+ export class DocumentsApiRequestFactory extends BaseAPIRequestFactory {
22
+
23
+ /**
24
+ * Upload documents for a business
25
+ * @param invoices Invoices to be uploaded. The file format must be PDF. The limit is 10 files, 10 MB per file.
26
+ * @param businessId The unique identifier for business in our system. Either of &#x60;businessId&#x60; or &#x60;platformBusinessId&#x60; is required.
27
+ * @param platformBusinessId The unique identifier for business in your platform. Either of &#x60;businessId&#x60; or &#x60;platformBusinessId&#x60; is required.
28
+ */
29
+ public async createBusinessDocument(invoices: Array<HttpFile>, businessId?: string, platformBusinessId?: string, _options?: Configuration): Promise<RequestContext> {
30
+ let _config = _options || this.configuration;
31
+
32
+ // verify required parameter 'invoices' is not null or undefined
33
+ if (invoices === null || invoices === undefined) {
34
+ throw new RequiredError("DocumentsApi", "createBusinessDocument", "invoices");
35
+ }
36
+
37
+
38
+
39
+
40
+ // Path Params
41
+ const localVarPath = '/api/platform/v2/documents';
42
+
43
+ // Make Request Context
44
+ const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.POST);
45
+ requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
46
+
47
+ // Form Params
48
+ const useForm = canConsumeForm([
49
+ 'multipart/form-data',
50
+ ]);
51
+
52
+ let localVarFormParams
53
+ if (useForm) {
54
+ localVarFormParams = new FormData();
55
+ } else {
56
+ localVarFormParams = new URLSearchParams();
57
+ }
58
+
59
+ if (invoices) {
60
+ // TODO: replace .append with .set
61
+ localVarFormParams.append('invoices', invoices.join(COLLECTION_FORMATS["csv"]));
62
+ }
63
+ if (businessId !== undefined) {
64
+ // TODO: replace .append with .set
65
+ localVarFormParams.append('businessId', businessId as any);
66
+ }
67
+ if (platformBusinessId !== undefined) {
68
+ // TODO: replace .append with .set
69
+ localVarFormParams.append('platformBusinessId', platformBusinessId as any);
70
+ }
71
+
72
+ requestContext.setBody(localVarFormParams);
73
+
74
+ if(!useForm) {
75
+ const contentType = ObjectSerializer.getPreferredMediaType([
76
+ "multipart/form-data"
77
+ ]);
78
+ requestContext.setHeaderParam("Content-Type", contentType);
79
+ }
80
+
81
+ let authMethod: SecurityAuthentication | undefined;
82
+ // Apply auth methods
83
+ authMethod = _config.authMethods["Authorization"]
84
+ if (authMethod?.applySecurityAuthentication) {
85
+ await authMethod?.applySecurityAuthentication(requestContext);
86
+ }
87
+
88
+ const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
89
+ if (defaultAuth?.applySecurityAuthentication) {
90
+ await defaultAuth?.applySecurityAuthentication(requestContext);
91
+ }
92
+
93
+ return requestContext;
94
+ }
95
+
96
+ }
97
+
98
+ export class DocumentsApiResponseProcessor {
99
+
100
+ /**
101
+ * Unwraps the actual response sent by the server from the response context and deserializes the response content
102
+ * to the expected objects
103
+ *
104
+ * @params response Response returned by the server for a request to createBusinessDocument
105
+ * @throws ApiException if the response code was not in [200, 299]
106
+ */
107
+ public async createBusinessDocumentWithHttpInfo(response: ResponseContext): Promise<HttpInfo<CreateBusinessDocumentsResponse >> {
108
+ const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
109
+ if (isCodeInRange("201", response.httpStatusCode)) {
110
+ const body: CreateBusinessDocumentsResponse = ObjectSerializer.deserialize(
111
+ ObjectSerializer.parse(await response.body.text(), contentType),
112
+ "CreateBusinessDocumentsResponse", ""
113
+ ) as CreateBusinessDocumentsResponse;
114
+ return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
115
+ }
116
+ if (isCodeInRange("400", response.httpStatusCode)) {
117
+ const body: BadRequestException = ObjectSerializer.deserialize(
118
+ ObjectSerializer.parse(await response.body.text(), contentType),
119
+ "BadRequestException", ""
120
+ ) as BadRequestException;
121
+ throw new ApiException<BadRequestException>(response.httpStatusCode, "BadRequestException", body, response.headers);
122
+ }
123
+ if (isCodeInRange("403", response.httpStatusCode)) {
124
+ const body: ForbiddenException = ObjectSerializer.deserialize(
125
+ ObjectSerializer.parse(await response.body.text(), contentType),
126
+ "ForbiddenException", ""
127
+ ) as ForbiddenException;
128
+ throw new ApiException<ForbiddenException>(response.httpStatusCode, "ForbiddenException", body, response.headers);
129
+ }
130
+ if (isCodeInRange("500", response.httpStatusCode)) {
131
+ const body: InternalServerErrorException = ObjectSerializer.deserialize(
132
+ ObjectSerializer.parse(await response.body.text(), contentType),
133
+ "InternalServerErrorException", ""
134
+ ) as InternalServerErrorException;
135
+ throw new ApiException<InternalServerErrorException>(response.httpStatusCode, "InternalServerErrorException", body, response.headers);
136
+ }
137
+
138
+ // Work around for missing responses in specification, e.g. for petstore.yaml
139
+ if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
140
+ const body: CreateBusinessDocumentsResponse = ObjectSerializer.deserialize(
141
+ ObjectSerializer.parse(await response.body.text(), contentType),
142
+ "CreateBusinessDocumentsResponse", ""
143
+ ) as CreateBusinessDocumentsResponse;
144
+ return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
145
+ }
146
+
147
+ throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
148
+ }
149
+
150
+ }
@@ -0,0 +1,258 @@
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 { DrawRequest } from '../models/DrawRequest';
15
+ import { DrawRequestNotFoundException } from '../models/DrawRequestNotFoundException';
16
+ import { ForbiddenException } from '../models/ForbiddenException';
17
+ import { GetDrawRequestsResponse } from '../models/GetDrawRequestsResponse';
18
+ import { InternalServerErrorException } from '../models/InternalServerErrorException';
19
+
20
+ /**
21
+ * no description
22
+ */
23
+ export class DrawRequestsApiRequestFactory extends BaseAPIRequestFactory {
24
+
25
+ /**
26
+ * Fetch a draw request
27
+ * @param id The Kanmon draw request UUID.
28
+ */
29
+ public async getDrawRequest(id: string, _options?: Configuration): Promise<RequestContext> {
30
+ let _config = _options || this.configuration;
31
+
32
+ // verify required parameter 'id' is not null or undefined
33
+ if (id === null || id === undefined) {
34
+ throw new RequiredError("DrawRequestsApi", "getDrawRequest", "id");
35
+ }
36
+
37
+
38
+ // Path Params
39
+ const localVarPath = '/api/platform/v2/draw-requests/{id}'
40
+ .replace('{' + 'id' + '}', encodeURIComponent(String(id)));
41
+
42
+ // Make Request Context
43
+ const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
44
+ requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
45
+
46
+
47
+ let authMethod: SecurityAuthentication | undefined;
48
+ // Apply auth methods
49
+ authMethod = _config.authMethods["Authorization"]
50
+ if (authMethod?.applySecurityAuthentication) {
51
+ await authMethod?.applySecurityAuthentication(requestContext);
52
+ }
53
+
54
+ const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
55
+ if (defaultAuth?.applySecurityAuthentication) {
56
+ await defaultAuth?.applySecurityAuthentication(requestContext);
57
+ }
58
+
59
+ return requestContext;
60
+ }
61
+
62
+ /**
63
+ * Fetch draw requests
64
+ * @param statuses A comma delimited list of draw request statuses.
65
+ * @param ids A comma delimited list of Kanmon’s unique IDs for invoices.
66
+ * @param platformBusinessIds A comma delimited list of your platform’s unique IDs for businesses.
67
+ * @param businessIds A comma delimited list of Kanmon’s unique IDs for businesses.
68
+ * @param offset The number of records to skip when performing pagination. Defaults to &#x60;0&#x60;.
69
+ * @param limit The number of records to limit when performing pagination. Defaults to &#x60;100&#x60;, which is the max.
70
+ * @param createdAtStart Filter for records where &#x60;createdAt&#x60; is greater than or equal to this value. ISO 8601 format.
71
+ * @param createdAtEnd Filter for records where &#x60;createdAt&#x60; is less than or equal to this value. ISO 8601 format.
72
+ */
73
+ public async getDrawRequests(statuses?: string, ids?: string, platformBusinessIds?: string, businessIds?: string, offset?: number, limit?: number, createdAtStart?: string, createdAtEnd?: string, _options?: Configuration): Promise<RequestContext> {
74
+ let _config = _options || this.configuration;
75
+
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
84
+ // Path Params
85
+ const localVarPath = '/api/platform/v2/draw-requests';
86
+
87
+ // Make Request Context
88
+ const requestContext = _config.baseServer.makeRequestContext(localVarPath, HttpMethod.GET);
89
+ requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8")
90
+
91
+ // Query Params
92
+ if (statuses !== undefined) {
93
+ requestContext.setQueryParam("statuses", ObjectSerializer.serialize(statuses, "string", ""));
94
+ }
95
+
96
+ // Query Params
97
+ if (ids !== undefined) {
98
+ requestContext.setQueryParam("ids", ObjectSerializer.serialize(ids, "string", ""));
99
+ }
100
+
101
+ // Query Params
102
+ if (platformBusinessIds !== undefined) {
103
+ requestContext.setQueryParam("platformBusinessIds", ObjectSerializer.serialize(platformBusinessIds, "string", ""));
104
+ }
105
+
106
+ // Query Params
107
+ if (businessIds !== undefined) {
108
+ requestContext.setQueryParam("businessIds", ObjectSerializer.serialize(businessIds, "string", ""));
109
+ }
110
+
111
+ // Query Params
112
+ if (offset !== undefined) {
113
+ requestContext.setQueryParam("offset", ObjectSerializer.serialize(offset, "number", ""));
114
+ }
115
+
116
+ // Query Params
117
+ if (limit !== undefined) {
118
+ requestContext.setQueryParam("limit", ObjectSerializer.serialize(limit, "number", ""));
119
+ }
120
+
121
+ // Query Params
122
+ if (createdAtStart !== undefined) {
123
+ requestContext.setQueryParam("createdAtStart", ObjectSerializer.serialize(createdAtStart, "string", ""));
124
+ }
125
+
126
+ // Query Params
127
+ if (createdAtEnd !== undefined) {
128
+ requestContext.setQueryParam("createdAtEnd", ObjectSerializer.serialize(createdAtEnd, "string", ""));
129
+ }
130
+
131
+
132
+ let authMethod: SecurityAuthentication | undefined;
133
+ // Apply auth methods
134
+ authMethod = _config.authMethods["Authorization"]
135
+ if (authMethod?.applySecurityAuthentication) {
136
+ await authMethod?.applySecurityAuthentication(requestContext);
137
+ }
138
+
139
+ const defaultAuth: SecurityAuthentication | undefined = _options?.authMethods?.default || this.configuration?.authMethods?.default
140
+ if (defaultAuth?.applySecurityAuthentication) {
141
+ await defaultAuth?.applySecurityAuthentication(requestContext);
142
+ }
143
+
144
+ return requestContext;
145
+ }
146
+
147
+ }
148
+
149
+ export class DrawRequestsApiResponseProcessor {
150
+
151
+ /**
152
+ * Unwraps the actual response sent by the server from the response context and deserializes the response content
153
+ * to the expected objects
154
+ *
155
+ * @params response Response returned by the server for a request to getDrawRequest
156
+ * @throws ApiException if the response code was not in [200, 299]
157
+ */
158
+ public async getDrawRequestWithHttpInfo(response: ResponseContext): Promise<HttpInfo<DrawRequest >> {
159
+ const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
160
+ if (isCodeInRange("200", response.httpStatusCode)) {
161
+ const body: DrawRequest = ObjectSerializer.deserialize(
162
+ ObjectSerializer.parse(await response.body.text(), contentType),
163
+ "DrawRequest", ""
164
+ ) as DrawRequest;
165
+ return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
166
+ }
167
+ if (isCodeInRange("400", response.httpStatusCode)) {
168
+ const body: BadRequestException = ObjectSerializer.deserialize(
169
+ ObjectSerializer.parse(await response.body.text(), contentType),
170
+ "BadRequestException", ""
171
+ ) as BadRequestException;
172
+ throw new ApiException<BadRequestException>(response.httpStatusCode, "BadRequestException", body, response.headers);
173
+ }
174
+ if (isCodeInRange("403", response.httpStatusCode)) {
175
+ const body: ForbiddenException = ObjectSerializer.deserialize(
176
+ ObjectSerializer.parse(await response.body.text(), contentType),
177
+ "ForbiddenException", ""
178
+ ) as ForbiddenException;
179
+ throw new ApiException<ForbiddenException>(response.httpStatusCode, "ForbiddenException", body, response.headers);
180
+ }
181
+ if (isCodeInRange("404", response.httpStatusCode)) {
182
+ const body: DrawRequestNotFoundException = ObjectSerializer.deserialize(
183
+ ObjectSerializer.parse(await response.body.text(), contentType),
184
+ "DrawRequestNotFoundException", ""
185
+ ) as DrawRequestNotFoundException;
186
+ throw new ApiException<DrawRequestNotFoundException>(response.httpStatusCode, "", body, response.headers);
187
+ }
188
+ if (isCodeInRange("500", response.httpStatusCode)) {
189
+ const body: InternalServerErrorException = ObjectSerializer.deserialize(
190
+ ObjectSerializer.parse(await response.body.text(), contentType),
191
+ "InternalServerErrorException", ""
192
+ ) as InternalServerErrorException;
193
+ throw new ApiException<InternalServerErrorException>(response.httpStatusCode, "InternalServerErrorException", body, response.headers);
194
+ }
195
+
196
+ // Work around for missing responses in specification, e.g. for petstore.yaml
197
+ if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
198
+ const body: DrawRequest = ObjectSerializer.deserialize(
199
+ ObjectSerializer.parse(await response.body.text(), contentType),
200
+ "DrawRequest", ""
201
+ ) as DrawRequest;
202
+ return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
203
+ }
204
+
205
+ throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
206
+ }
207
+
208
+ /**
209
+ * Unwraps the actual response sent by the server from the response context and deserializes the response content
210
+ * to the expected objects
211
+ *
212
+ * @params response Response returned by the server for a request to getDrawRequests
213
+ * @throws ApiException if the response code was not in [200, 299]
214
+ */
215
+ public async getDrawRequestsWithHttpInfo(response: ResponseContext): Promise<HttpInfo<GetDrawRequestsResponse >> {
216
+ const contentType = ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
217
+ if (isCodeInRange("200", response.httpStatusCode)) {
218
+ const body: GetDrawRequestsResponse = ObjectSerializer.deserialize(
219
+ ObjectSerializer.parse(await response.body.text(), contentType),
220
+ "GetDrawRequestsResponse", ""
221
+ ) as GetDrawRequestsResponse;
222
+ return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
223
+ }
224
+ if (isCodeInRange("400", response.httpStatusCode)) {
225
+ const body: BadRequestException = ObjectSerializer.deserialize(
226
+ ObjectSerializer.parse(await response.body.text(), contentType),
227
+ "BadRequestException", ""
228
+ ) as BadRequestException;
229
+ throw new ApiException<BadRequestException>(response.httpStatusCode, "BadRequestException", body, response.headers);
230
+ }
231
+ if (isCodeInRange("403", response.httpStatusCode)) {
232
+ const body: ForbiddenException = ObjectSerializer.deserialize(
233
+ ObjectSerializer.parse(await response.body.text(), contentType),
234
+ "ForbiddenException", ""
235
+ ) as ForbiddenException;
236
+ throw new ApiException<ForbiddenException>(response.httpStatusCode, "ForbiddenException", body, response.headers);
237
+ }
238
+ if (isCodeInRange("500", response.httpStatusCode)) {
239
+ const body: InternalServerErrorException = ObjectSerializer.deserialize(
240
+ ObjectSerializer.parse(await response.body.text(), contentType),
241
+ "InternalServerErrorException", ""
242
+ ) as InternalServerErrorException;
243
+ throw new ApiException<InternalServerErrorException>(response.httpStatusCode, "InternalServerErrorException", body, response.headers);
244
+ }
245
+
246
+ // Work around for missing responses in specification, e.g. for petstore.yaml
247
+ if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
248
+ const body: GetDrawRequestsResponse = ObjectSerializer.deserialize(
249
+ ObjectSerializer.parse(await response.body.text(), contentType),
250
+ "GetDrawRequestsResponse", ""
251
+ ) as GetDrawRequestsResponse;
252
+ return new HttpInfo(response.httpStatusCode, response.headers, response.body, body);
253
+ }
254
+
255
+ throw new ApiException<string | Buffer | undefined>(response.httpStatusCode, "Unknown API Status Code!", await response.getBodyAsAny(), response.headers);
256
+ }
257
+
258
+ }