@astrada.co/ts-astrada-sdk 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -2
- package/README.md +0 -2
- package/dist/apis/CardApi.js +218 -0
- package/dist/apis/CardSubscriptionApi.js +268 -0
- package/dist/apis/CardholderApi.js +138 -0
- package/dist/apis/EnrollmentMethodsApi.js +139 -0
- package/dist/apis/NetworkBulkFeedsApi.js +264 -0
- package/dist/apis/SubaccountsApi.js +319 -0
- package/dist/apis/TransactionMessagesApi.js +138 -0
- package/dist/apis/TransactionsApi.js +215 -0
- package/dist/apis/WebhooksApi.js +380 -0
- package/{lib → dist}/models/Card.js +5 -4
- package/{lib → dist}/models/CardLinks.js +3 -2
- package/{lib → dist}/models/CardSubscription.js +7 -6
- package/{lib → dist}/models/CardSubscriptionLinks.js +3 -2
- package/{lib → dist}/models/Cardholder.js +6 -5
- package/{lib → dist}/models/CardholderCorporate.js +2 -1
- package/{lib → dist}/models/CardholderLinks.js +3 -2
- package/{lib → dist}/models/Conflict.js +2 -1
- package/{lib → dist}/models/CreateNetworkBulkFeedRequest.js +2 -1
- package/{lib → dist}/models/CreateSubaccountRequest.js +3 -2
- package/{lib → dist}/models/CreateWebhook201Response.d.ts +2 -0
- package/{lib → dist}/models/CreateWebhook201Response.js +8 -5
- package/{lib → dist}/models/CreateWebhookRequest.d.ts +2 -0
- package/{lib → dist}/models/CreateWebhookRequest.js +5 -2
- package/{lib → dist}/models/EnrollmentMethods200Response.js +2 -1
- package/dist/models/EnrollmentMethods413Response.d.ts +45 -0
- package/dist/models/EnrollmentMethods413Response.js +62 -0
- package/{lib → dist}/models/EnrollmentMethodsRequest.js +2 -1
- package/dist/models/GetCardSubscription404Response.d.ts +57 -0
- package/dist/models/GetCardSubscription404Response.js +66 -0
- package/{lib → dist}/models/GetSubaccounts200Response.js +4 -3
- package/{lib → dist}/models/GetSubaccounts200ResponseEmbedded.js +3 -2
- package/{lib → dist}/models/GetSubaccounts200ResponseLinks.js +3 -2
- package/{lib → dist}/models/GetTransactions200Response.js +4 -3
- package/{lib → dist}/models/GetTransactions200ResponseEmbedded.js +3 -2
- package/{lib → dist}/models/InlineObject.js +3 -2
- package/{lib → dist}/models/InlineObject1.js +2 -1
- package/{lib → dist}/models/InlineObject2.js +2 -1
- package/{lib → dist}/models/InlineObject3.js +2 -1
- package/{lib → dist}/models/InlineObject4.js +2 -1
- package/{lib → dist}/models/InlineObject5.js +2 -1
- package/{lib → dist}/models/InlineObjectErrorsInner.js +2 -1
- package/{lib → dist}/models/Link.js +2 -1
- package/{lib → dist}/models/ListCardSubscriptions200Response.js +4 -3
- package/{lib → dist}/models/ListCardSubscriptions200ResponseEmbedded.js +3 -2
- package/{lib → dist}/models/ListCardSubscriptions200ResponseLinks.js +3 -2
- package/dist/models/ListCardSubscriptions400Response.d.ts +52 -0
- package/dist/models/ListCardSubscriptions400Response.js +65 -0
- package/dist/models/ListCardSubscriptions400ResponseErrorsInner.d.ts +38 -0
- package/dist/models/ListCardSubscriptions400ResponseErrorsInner.js +55 -0
- package/dist/models/ListCardSubscriptions401Response.d.ts +45 -0
- package/dist/models/ListCardSubscriptions401Response.js +62 -0
- package/dist/models/ListCardSubscriptions403Response.d.ts +45 -0
- package/dist/models/ListCardSubscriptions403Response.js +62 -0
- package/dist/models/ListCardSubscriptions500Response.d.ts +45 -0
- package/dist/models/ListCardSubscriptions500Response.js +62 -0
- package/{lib → dist}/models/ListCards200Response.js +4 -3
- package/{lib → dist}/models/ListCards200ResponseEmbedded.js +3 -2
- package/{lib → dist}/models/ListNetworkBulkFeeds200Response.js +4 -3
- package/{lib → dist}/models/ListNetworkBulkFeeds200ResponseEmbedded.js +3 -2
- package/{lib → dist}/models/ListWebhooks200Response.js +4 -3
- package/{lib → dist}/models/ListWebhooks200ResponseEmbedded.js +3 -2
- package/{lib → dist}/models/ListWebhooks200ResponseLinks.js +3 -2
- package/{lib → dist}/models/NetworkBulkFeeds.d.ts +16 -1
- package/{lib → dist}/models/NetworkBulkFeeds.js +18 -5
- package/{lib → dist}/models/Subaccount.js +6 -5
- package/{lib → dist}/models/SubaccountConfiguration.js +3 -2
- package/{lib → dist}/models/SubaccountConfigurationVISA.js +2 -1
- package/{lib → dist}/models/Transaction.js +7 -6
- package/{lib → dist}/models/TransactionAcceptor.js +2 -1
- package/{lib → dist}/models/TransactionLinks.js +3 -2
- package/{lib → dist}/models/TransactionMessage.js +7 -6
- package/{lib → dist}/models/TransactionMessageAcceptor.js +2 -1
- package/{lib → dist}/models/UnprocessableEntity.js +2 -1
- package/{lib → dist}/models/UpdateCardSubscriptionRequest.js +2 -1
- package/{lib → dist}/models/UpdateSubaccountRequest.js +3 -2
- package/{lib → dist}/models/UpdateWebhookRequest.d.ts +2 -0
- package/{lib → dist}/models/UpdateWebhookRequest.js +5 -2
- package/{lib → dist}/models/Webhook.d.ts +2 -0
- package/{lib → dist}/models/Webhook.js +8 -5
- package/{lib → dist}/models/index.d.ts +7 -7
- package/{lib → dist}/models/index.js +7 -7
- package/dist/runtime.js +638 -0
- package/docs/Card.md +54 -0
- package/docs/CardApi.md +176 -0
- package/docs/CardLinks.md +36 -0
- package/docs/CardSubscription.md +56 -0
- package/docs/CardSubscriptionApi.md +252 -0
- package/docs/CardSubscriptionLinks.md +38 -0
- package/docs/Cardholder.md +44 -0
- package/docs/CardholderApi.md +85 -0
- package/docs/CardholderCorporate.md +37 -0
- package/docs/CardholderLinks.md +34 -0
- package/docs/Conflict.md +40 -0
- package/docs/CreateNetworkBulkFeedRequest.md +38 -0
- package/docs/CreateSubaccountRequest.md +36 -0
- package/docs/CreateWebhook201Response.md +52 -0
- package/docs/CreateWebhookRequest.md +42 -0
- package/docs/EnrollmentMethods200Response.md +34 -0
- package/docs/EnrollmentMethods413Response.md +36 -0
- package/docs/EnrollmentMethodsApi.md +85 -0
- package/docs/EnrollmentMethodsRequest.md +34 -0
- package/docs/GetCardSubscription404Response.md +40 -0
- package/docs/GetSubaccounts200Response.md +36 -0
- package/docs/GetSubaccounts200ResponseEmbedded.md +34 -0
- package/docs/GetSubaccounts200ResponseLinks.md +36 -0
- package/docs/GetTransactions200Response.md +36 -0
- package/docs/GetTransactions200ResponseEmbedded.md +34 -0
- package/docs/Link.md +48 -0
- package/docs/ListCardSubscriptions200Response.md +38 -0
- package/docs/ListCardSubscriptions200ResponseEmbedded.md +34 -0
- package/docs/ListCardSubscriptions200ResponseLinks.md +42 -0
- package/docs/ListCardSubscriptions400Response.md +38 -0
- package/docs/ListCardSubscriptions400ResponseErrorsInner.md +36 -0
- package/docs/ListCardSubscriptions401Response.md +36 -0
- package/docs/ListCardSubscriptions403Response.md +36 -0
- package/docs/ListCardSubscriptions500Response.md +36 -0
- package/docs/ListCards200Response.md +38 -0
- package/docs/ListCards200ResponseEmbedded.md +34 -0
- package/docs/ListNetworkBulkFeeds200Response.md +38 -0
- package/docs/ListNetworkBulkFeeds200ResponseEmbedded.md +34 -0
- package/docs/ListWebhooks200Response.md +37 -0
- package/docs/ListWebhooks200ResponseEmbedded.md +34 -0
- package/docs/ListWebhooks200ResponseLinks.md +36 -0
- package/docs/NetworkBulkFeeds.md +48 -0
- package/docs/NetworkBulkFeedsApi.md +247 -0
- package/docs/Subaccount.md +46 -0
- package/docs/SubaccountConfiguration.md +37 -0
- package/docs/SubaccountConfigurationVISA.md +34 -0
- package/docs/SubaccountsApi.md +321 -0
- package/docs/Transaction.md +66 -0
- package/docs/TransactionAcceptor.md +41 -0
- package/docs/TransactionLinks.md +40 -0
- package/docs/TransactionMessage.md +70 -0
- package/docs/TransactionMessageAcceptor.md +47 -0
- package/docs/TransactionMessagesApi.md +85 -0
- package/docs/TransactionsApi.md +174 -0
- package/docs/UnprocessableEntity.md +36 -0
- package/docs/UpdateCardSubscriptionRequest.md +34 -0
- package/docs/UpdateSubaccountRequest.md +36 -0
- package/docs/UpdateWebhookRequest.md +40 -0
- package/docs/Webhook.md +51 -0
- package/docs/WebhooksApi.md +401 -0
- package/openapitools.json +7 -0
- package/package.json +10 -10
- package/src/apis/CardApi.ts +15 -15
- package/src/apis/CardSubscriptionApi.ts +15 -15
- package/src/apis/CardholderApi.ts +15 -15
- package/src/apis/EnrollmentMethodsApi.ts +15 -15
- package/src/apis/NetworkBulkFeedsApi.ts +15 -15
- package/src/apis/SubaccountsApi.ts +15 -15
- package/src/apis/TransactionMessagesApi.ts +15 -15
- package/src/apis/TransactionsApi.ts +15 -15
- package/src/apis/WebhooksApi.ts +15 -15
- package/src/models/Card.ts +2 -2
- package/src/models/CardSubscription.ts +4 -4
- package/src/models/Cardholder.ts +2 -2
- package/src/models/CreateWebhook201Response.ts +5 -3
- package/src/models/CreateWebhookRequest.ts +3 -1
- package/src/models/EnrollmentMethods413Response.ts +85 -0
- package/src/models/GetCardSubscription404Response.ts +101 -0
- package/src/models/ListCardSubscriptions400Response.ts +101 -0
- package/src/models/ListCardSubscriptions400ResponseErrorsInner.ts +75 -0
- package/src/models/ListCardSubscriptions401Response.ts +85 -0
- package/src/models/ListCardSubscriptions403Response.ts +85 -0
- package/src/models/ListCardSubscriptions500Response.ts +85 -0
- package/src/models/NetworkBulkFeeds.ts +22 -3
- package/src/models/Subaccount.ts +2 -2
- package/src/models/Transaction.ts +3 -3
- package/src/models/TransactionMessage.ts +3 -3
- package/src/models/UpdateWebhookRequest.ts +3 -1
- package/src/models/Webhook.ts +5 -3
- package/src/models/index.ts +7 -7
- package/src/runtime.ts +0 -1
- package/tsconfig.json +14 -7
- package/dist/astrada.co-ts-astrada-sdk-1.2.0.tgz +0 -0
- package/lib/apis/CardApi.js +0 -109
- package/lib/apis/CardSubscriptionApi.js +0 -133
- package/lib/apis/CardholderApi.js +0 -56
- package/lib/apis/EnrollmentMethodsApi.js +0 -57
- package/lib/apis/NetworkBulkFeedsApi.js +0 -129
- package/lib/apis/SubaccountsApi.js +0 -157
- package/lib/apis/TransactionMessagesApi.js +0 -56
- package/lib/apis/TransactionsApi.js +0 -106
- package/lib/apis/WebhooksApi.js +0 -194
- package/lib/runtime.js +0 -394
- package/openapi-generator/templates/README.mustache +0 -274
- package/openapi-generator/templates/npmignore.mustache +0 -2
- package/openapi-generator/templates/package.mustache +0 -44
- package/openapi-generator/templates/runtime.mustache +0 -515
- /package/{lib → dist}/apis/CardApi.d.ts +0 -0
- /package/{lib → dist}/apis/CardSubscriptionApi.d.ts +0 -0
- /package/{lib → dist}/apis/CardholderApi.d.ts +0 -0
- /package/{lib → dist}/apis/EnrollmentMethodsApi.d.ts +0 -0
- /package/{lib → dist}/apis/NetworkBulkFeedsApi.d.ts +0 -0
- /package/{lib → dist}/apis/SubaccountsApi.d.ts +0 -0
- /package/{lib → dist}/apis/TransactionMessagesApi.d.ts +0 -0
- /package/{lib → dist}/apis/TransactionsApi.d.ts +0 -0
- /package/{lib → dist}/apis/WebhooksApi.d.ts +0 -0
- /package/{lib → dist}/apis/index.d.ts +0 -0
- /package/{lib → dist}/apis/index.js +0 -0
- /package/{lib → dist}/index.d.ts +0 -0
- /package/{lib → dist}/index.js +0 -0
- /package/{lib → dist}/models/Card.d.ts +0 -0
- /package/{lib → dist}/models/CardLinks.d.ts +0 -0
- /package/{lib → dist}/models/CardSubscription.d.ts +0 -0
- /package/{lib → dist}/models/CardSubscriptionLinks.d.ts +0 -0
- /package/{lib → dist}/models/Cardholder.d.ts +0 -0
- /package/{lib → dist}/models/CardholderCorporate.d.ts +0 -0
- /package/{lib → dist}/models/CardholderLinks.d.ts +0 -0
- /package/{lib → dist}/models/Conflict.d.ts +0 -0
- /package/{lib → dist}/models/CreateNetworkBulkFeedRequest.d.ts +0 -0
- /package/{lib → dist}/models/CreateSubaccountRequest.d.ts +0 -0
- /package/{lib → dist}/models/EnrollmentMethods200Response.d.ts +0 -0
- /package/{lib → dist}/models/EnrollmentMethodsRequest.d.ts +0 -0
- /package/{lib → dist}/models/GetSubaccounts200Response.d.ts +0 -0
- /package/{lib → dist}/models/GetSubaccounts200ResponseEmbedded.d.ts +0 -0
- /package/{lib → dist}/models/GetSubaccounts200ResponseLinks.d.ts +0 -0
- /package/{lib → dist}/models/GetTransactions200Response.d.ts +0 -0
- /package/{lib → dist}/models/GetTransactions200ResponseEmbedded.d.ts +0 -0
- /package/{lib → dist}/models/InlineObject.d.ts +0 -0
- /package/{lib → dist}/models/InlineObject1.d.ts +0 -0
- /package/{lib → dist}/models/InlineObject2.d.ts +0 -0
- /package/{lib → dist}/models/InlineObject3.d.ts +0 -0
- /package/{lib → dist}/models/InlineObject4.d.ts +0 -0
- /package/{lib → dist}/models/InlineObject5.d.ts +0 -0
- /package/{lib → dist}/models/InlineObjectErrorsInner.d.ts +0 -0
- /package/{lib → dist}/models/Link.d.ts +0 -0
- /package/{lib → dist}/models/ListCardSubscriptions200Response.d.ts +0 -0
- /package/{lib → dist}/models/ListCardSubscriptions200ResponseEmbedded.d.ts +0 -0
- /package/{lib → dist}/models/ListCardSubscriptions200ResponseLinks.d.ts +0 -0
- /package/{lib → dist}/models/ListCards200Response.d.ts +0 -0
- /package/{lib → dist}/models/ListCards200ResponseEmbedded.d.ts +0 -0
- /package/{lib → dist}/models/ListNetworkBulkFeeds200Response.d.ts +0 -0
- /package/{lib → dist}/models/ListNetworkBulkFeeds200ResponseEmbedded.d.ts +0 -0
- /package/{lib → dist}/models/ListWebhooks200Response.d.ts +0 -0
- /package/{lib → dist}/models/ListWebhooks200ResponseEmbedded.d.ts +0 -0
- /package/{lib → dist}/models/ListWebhooks200ResponseLinks.d.ts +0 -0
- /package/{lib → dist}/models/Subaccount.d.ts +0 -0
- /package/{lib → dist}/models/SubaccountConfiguration.d.ts +0 -0
- /package/{lib → dist}/models/SubaccountConfigurationVISA.d.ts +0 -0
- /package/{lib → dist}/models/Transaction.d.ts +0 -0
- /package/{lib → dist}/models/TransactionAcceptor.d.ts +0 -0
- /package/{lib → dist}/models/TransactionLinks.d.ts +0 -0
- /package/{lib → dist}/models/TransactionMessage.d.ts +0 -0
- /package/{lib → dist}/models/TransactionMessageAcceptor.d.ts +0 -0
- /package/{lib → dist}/models/UnprocessableEntity.d.ts +0 -0
- /package/{lib → dist}/models/UpdateCardSubscriptionRequest.d.ts +0 -0
- /package/{lib → dist}/models/UpdateSubaccountRequest.d.ts +0 -0
- /package/{lib → dist}/runtime.d.ts +0 -0
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/* tslint:disable */
|
|
3
|
-
/* eslint-disable */
|
|
4
|
-
/**
|
|
5
|
-
* Astrada API
|
|
6
|
-
* Welcome to our API Reference. 👋
|
|
7
|
-
*
|
|
8
|
-
* The version of the OpenAPI document: 2024-02-28
|
|
9
|
-
* Contact: developer@astrada.co
|
|
10
|
-
*
|
|
11
|
-
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
12
|
-
* https://openapi-generator.tech
|
|
13
|
-
* Do not edit the class manually.
|
|
14
|
-
*/
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.GetTransactionsOrderEnum = exports.TransactionsApi = void 0;
|
|
17
|
-
const runtime = require("../runtime");
|
|
18
|
-
const index_1 = require("../models/index");
|
|
19
|
-
/**
|
|
20
|
-
*
|
|
21
|
-
*/
|
|
22
|
-
class TransactionsApi extends runtime.BaseAPI {
|
|
23
|
-
/**
|
|
24
|
-
* Returns a transaction by its unique identifier, including details about the transaction\'s state and relevant transactional data.
|
|
25
|
-
* Retrieve transaction
|
|
26
|
-
*/
|
|
27
|
-
async getTransactionByIdRaw(requestParameters, initOverrides) {
|
|
28
|
-
if (requestParameters['transactionId'] == null) {
|
|
29
|
-
throw new runtime.RequiredError('transactionId', 'Required parameter "transactionId" was null or undefined when calling getTransactionById().');
|
|
30
|
-
}
|
|
31
|
-
const queryParameters = {};
|
|
32
|
-
const headerParameters = {};
|
|
33
|
-
if (this.configuration && this.configuration.accessToken) {
|
|
34
|
-
// oauth required
|
|
35
|
-
headerParameters["Authorization"] = await this.configuration.accessToken("main-auth", ["transactions:read"]);
|
|
36
|
-
}
|
|
37
|
-
let urlPath = `/transactions/{transactionId}`;
|
|
38
|
-
urlPath = urlPath.replace(`{${"transactionId"}}`, encodeURIComponent(String(requestParameters['transactionId'])));
|
|
39
|
-
const response = await this.request({
|
|
40
|
-
path: urlPath,
|
|
41
|
-
method: 'GET',
|
|
42
|
-
headers: headerParameters,
|
|
43
|
-
query: queryParameters,
|
|
44
|
-
}, initOverrides);
|
|
45
|
-
return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.TransactionFromJSON)(jsonValue));
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Returns a transaction by its unique identifier, including details about the transaction\'s state and relevant transactional data.
|
|
49
|
-
* Retrieve transaction
|
|
50
|
-
*/
|
|
51
|
-
async getTransactionById(requestParameters, initOverrides) {
|
|
52
|
-
const response = await this.getTransactionByIdRaw(requestParameters, initOverrides);
|
|
53
|
-
return await response.value();
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Returns a list of all transactions under the account. By default, `GET /transactions` returns transactions ordered by the latest `createdAt`. You can combine the different filters as documented. This endpoint supports [cursor-based pagination](https://docs.astrada.co/reference/pagination).
|
|
57
|
-
* List transactions
|
|
58
|
-
*/
|
|
59
|
-
async getTransactionsRaw(requestParameters, initOverrides) {
|
|
60
|
-
const queryParameters = {};
|
|
61
|
-
if (requestParameters['transactionMessageId'] != null) {
|
|
62
|
-
queryParameters['transactionMessageId'] = requestParameters['transactionMessageId'];
|
|
63
|
-
}
|
|
64
|
-
if (requestParameters['cursor'] != null) {
|
|
65
|
-
queryParameters['cursor'] = requestParameters['cursor'];
|
|
66
|
-
}
|
|
67
|
-
if (requestParameters['cardId'] != null) {
|
|
68
|
-
queryParameters['cardId'] = requestParameters['cardId'];
|
|
69
|
-
}
|
|
70
|
-
if (requestParameters['limit'] != null) {
|
|
71
|
-
queryParameters['limit'] = requestParameters['limit'];
|
|
72
|
-
}
|
|
73
|
-
if (requestParameters['order'] != null) {
|
|
74
|
-
queryParameters['order'] = requestParameters['order'];
|
|
75
|
-
}
|
|
76
|
-
const headerParameters = {};
|
|
77
|
-
if (this.configuration && this.configuration.accessToken) {
|
|
78
|
-
// oauth required
|
|
79
|
-
headerParameters["Authorization"] = await this.configuration.accessToken("main-auth", ["transactions:read"]);
|
|
80
|
-
}
|
|
81
|
-
let urlPath = `/transactions`;
|
|
82
|
-
const response = await this.request({
|
|
83
|
-
path: urlPath,
|
|
84
|
-
method: 'GET',
|
|
85
|
-
headers: headerParameters,
|
|
86
|
-
query: queryParameters,
|
|
87
|
-
}, initOverrides);
|
|
88
|
-
return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.GetTransactions200ResponseFromJSON)(jsonValue));
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Returns a list of all transactions under the account. By default, `GET /transactions` returns transactions ordered by the latest `createdAt`. You can combine the different filters as documented. This endpoint supports [cursor-based pagination](https://docs.astrada.co/reference/pagination).
|
|
92
|
-
* List transactions
|
|
93
|
-
*/
|
|
94
|
-
async getTransactions(requestParameters = {}, initOverrides) {
|
|
95
|
-
const response = await this.getTransactionsRaw(requestParameters, initOverrides);
|
|
96
|
-
return await response.value();
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
exports.TransactionsApi = TransactionsApi;
|
|
100
|
-
/**
|
|
101
|
-
* @export
|
|
102
|
-
*/
|
|
103
|
-
exports.GetTransactionsOrderEnum = {
|
|
104
|
-
Asc: 'asc',
|
|
105
|
-
Desc: 'desc'
|
|
106
|
-
};
|
package/lib/apis/WebhooksApi.js
DELETED
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/* tslint:disable */
|
|
3
|
-
/* eslint-disable */
|
|
4
|
-
/**
|
|
5
|
-
* Astrada API
|
|
6
|
-
* Welcome to our API Reference. 👋
|
|
7
|
-
*
|
|
8
|
-
* The version of the OpenAPI document: 2024-02-28
|
|
9
|
-
* Contact: developer@astrada.co
|
|
10
|
-
*
|
|
11
|
-
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
12
|
-
* https://openapi-generator.tech
|
|
13
|
-
* Do not edit the class manually.
|
|
14
|
-
*/
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.WebhooksApi = void 0;
|
|
17
|
-
const runtime = require("../runtime");
|
|
18
|
-
const index_1 = require("../models/index");
|
|
19
|
-
/**
|
|
20
|
-
*
|
|
21
|
-
*/
|
|
22
|
-
class WebhooksApi extends runtime.BaseAPI {
|
|
23
|
-
/**
|
|
24
|
-
* Registers a new webhook for capturing event notifications.
|
|
25
|
-
* Create webhook
|
|
26
|
-
*/
|
|
27
|
-
async createWebhookRaw(requestParameters, initOverrides) {
|
|
28
|
-
if (requestParameters['createWebhookRequest'] == null) {
|
|
29
|
-
throw new runtime.RequiredError('createWebhookRequest', 'Required parameter "createWebhookRequest" was null or undefined when calling createWebhook().');
|
|
30
|
-
}
|
|
31
|
-
const queryParameters = {};
|
|
32
|
-
const headerParameters = {};
|
|
33
|
-
headerParameters['Content-Type'] = 'application/json';
|
|
34
|
-
if (this.configuration && this.configuration.accessToken) {
|
|
35
|
-
// oauth required
|
|
36
|
-
headerParameters["Authorization"] = await this.configuration.accessToken("main-auth", ["webhooks:write"]);
|
|
37
|
-
}
|
|
38
|
-
let urlPath = `/webhooks`;
|
|
39
|
-
const response = await this.request({
|
|
40
|
-
path: urlPath,
|
|
41
|
-
method: 'POST',
|
|
42
|
-
headers: headerParameters,
|
|
43
|
-
query: queryParameters,
|
|
44
|
-
body: (0, index_1.CreateWebhookRequestToJSON)(requestParameters['createWebhookRequest']),
|
|
45
|
-
}, initOverrides);
|
|
46
|
-
return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.CreateWebhook201ResponseFromJSON)(jsonValue));
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Registers a new webhook for capturing event notifications.
|
|
50
|
-
* Create webhook
|
|
51
|
-
*/
|
|
52
|
-
async createWebhook(requestParameters, initOverrides) {
|
|
53
|
-
const response = await this.createWebhookRaw(requestParameters, initOverrides);
|
|
54
|
-
return await response.value();
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Remove a configured webhook by its identifier. Results in the resource being deleted and no longer available.
|
|
58
|
-
* Delete webhook
|
|
59
|
-
*/
|
|
60
|
-
async deleteWebhookRaw(requestParameters, initOverrides) {
|
|
61
|
-
if (requestParameters['webhookId'] == null) {
|
|
62
|
-
throw new runtime.RequiredError('webhookId', 'Required parameter "webhookId" was null or undefined when calling deleteWebhook().');
|
|
63
|
-
}
|
|
64
|
-
const queryParameters = {};
|
|
65
|
-
const headerParameters = {};
|
|
66
|
-
if (this.configuration && this.configuration.accessToken) {
|
|
67
|
-
// oauth required
|
|
68
|
-
headerParameters["Authorization"] = await this.configuration.accessToken("main-auth", ["webhooks:write"]);
|
|
69
|
-
}
|
|
70
|
-
let urlPath = `/webhooks/{webhookId}`;
|
|
71
|
-
urlPath = urlPath.replace(`{${"webhookId"}}`, encodeURIComponent(String(requestParameters['webhookId'])));
|
|
72
|
-
const response = await this.request({
|
|
73
|
-
path: urlPath,
|
|
74
|
-
method: 'DELETE',
|
|
75
|
-
headers: headerParameters,
|
|
76
|
-
query: queryParameters,
|
|
77
|
-
}, initOverrides);
|
|
78
|
-
return new runtime.VoidApiResponse(response);
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Remove a configured webhook by its identifier. Results in the resource being deleted and no longer available.
|
|
82
|
-
* Delete webhook
|
|
83
|
-
*/
|
|
84
|
-
async deleteWebhook(requestParameters, initOverrides) {
|
|
85
|
-
await this.deleteWebhookRaw(requestParameters, initOverrides);
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Returns detailed information about a specific webhook by its identifier, including its configuration and event subscription details.
|
|
89
|
-
* Retrieve webhook
|
|
90
|
-
*/
|
|
91
|
-
async getWebhookRaw(requestParameters, initOverrides) {
|
|
92
|
-
if (requestParameters['webhookId'] == null) {
|
|
93
|
-
throw new runtime.RequiredError('webhookId', 'Required parameter "webhookId" was null or undefined when calling getWebhook().');
|
|
94
|
-
}
|
|
95
|
-
const queryParameters = {};
|
|
96
|
-
const headerParameters = {};
|
|
97
|
-
if (this.configuration && this.configuration.accessToken) {
|
|
98
|
-
// oauth required
|
|
99
|
-
headerParameters["Authorization"] = await this.configuration.accessToken("main-auth", ["webhooks:read"]);
|
|
100
|
-
}
|
|
101
|
-
let urlPath = `/webhooks/{webhookId}`;
|
|
102
|
-
urlPath = urlPath.replace(`{${"webhookId"}}`, encodeURIComponent(String(requestParameters['webhookId'])));
|
|
103
|
-
const response = await this.request({
|
|
104
|
-
path: urlPath,
|
|
105
|
-
method: 'GET',
|
|
106
|
-
headers: headerParameters,
|
|
107
|
-
query: queryParameters,
|
|
108
|
-
}, initOverrides);
|
|
109
|
-
return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.WebhookFromJSON)(jsonValue));
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Returns detailed information about a specific webhook by its identifier, including its configuration and event subscription details.
|
|
113
|
-
* Retrieve webhook
|
|
114
|
-
*/
|
|
115
|
-
async getWebhook(requestParameters, initOverrides) {
|
|
116
|
-
const response = await this.getWebhookRaw(requestParameters, initOverrides);
|
|
117
|
-
return await response.value();
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Returns all webhooks configured under the account, optionally filtered by subaccount, including details on the events each webhook is subscribed to. This endpoint supports [cursor-based pagination](https://docs.astrada.co/reference/pagination).
|
|
121
|
-
* List webhooks
|
|
122
|
-
*/
|
|
123
|
-
async listWebhooksRaw(requestParameters, initOverrides) {
|
|
124
|
-
const queryParameters = {};
|
|
125
|
-
if (requestParameters['subaccountId'] != null) {
|
|
126
|
-
queryParameters['subaccountId'] = requestParameters['subaccountId'];
|
|
127
|
-
}
|
|
128
|
-
if (requestParameters['limit'] != null) {
|
|
129
|
-
queryParameters['limit'] = requestParameters['limit'];
|
|
130
|
-
}
|
|
131
|
-
if (requestParameters['cursor'] != null) {
|
|
132
|
-
queryParameters['cursor'] = requestParameters['cursor'];
|
|
133
|
-
}
|
|
134
|
-
const headerParameters = {};
|
|
135
|
-
if (this.configuration && this.configuration.accessToken) {
|
|
136
|
-
// oauth required
|
|
137
|
-
headerParameters["Authorization"] = await this.configuration.accessToken("main-auth", ["webhooks:read"]);
|
|
138
|
-
}
|
|
139
|
-
let urlPath = `/webhooks`;
|
|
140
|
-
const response = await this.request({
|
|
141
|
-
path: urlPath,
|
|
142
|
-
method: 'GET',
|
|
143
|
-
headers: headerParameters,
|
|
144
|
-
query: queryParameters,
|
|
145
|
-
}, initOverrides);
|
|
146
|
-
return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.ListWebhooks200ResponseFromJSON)(jsonValue));
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Returns all webhooks configured under the account, optionally filtered by subaccount, including details on the events each webhook is subscribed to. This endpoint supports [cursor-based pagination](https://docs.astrada.co/reference/pagination).
|
|
150
|
-
* List webhooks
|
|
151
|
-
*/
|
|
152
|
-
async listWebhooks(requestParameters = {}, initOverrides) {
|
|
153
|
-
const response = await this.listWebhooksRaw(requestParameters, initOverrides);
|
|
154
|
-
return await response.value();
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Updates the configuration of an existing webhook, allowing changes to the event subscriptions or notification URL.
|
|
158
|
-
* Update webhook
|
|
159
|
-
*/
|
|
160
|
-
async updateWebhookRaw(requestParameters, initOverrides) {
|
|
161
|
-
if (requestParameters['webhookId'] == null) {
|
|
162
|
-
throw new runtime.RequiredError('webhookId', 'Required parameter "webhookId" was null or undefined when calling updateWebhook().');
|
|
163
|
-
}
|
|
164
|
-
if (requestParameters['updateWebhookRequest'] == null) {
|
|
165
|
-
throw new runtime.RequiredError('updateWebhookRequest', 'Required parameter "updateWebhookRequest" was null or undefined when calling updateWebhook().');
|
|
166
|
-
}
|
|
167
|
-
const queryParameters = {};
|
|
168
|
-
const headerParameters = {};
|
|
169
|
-
headerParameters['Content-Type'] = 'application/json';
|
|
170
|
-
if (this.configuration && this.configuration.accessToken) {
|
|
171
|
-
// oauth required
|
|
172
|
-
headerParameters["Authorization"] = await this.configuration.accessToken("main-auth", ["webhooks:write"]);
|
|
173
|
-
}
|
|
174
|
-
let urlPath = `/webhooks/{webhookId}`;
|
|
175
|
-
urlPath = urlPath.replace(`{${"webhookId"}}`, encodeURIComponent(String(requestParameters['webhookId'])));
|
|
176
|
-
const response = await this.request({
|
|
177
|
-
path: urlPath,
|
|
178
|
-
method: 'PATCH',
|
|
179
|
-
headers: headerParameters,
|
|
180
|
-
query: queryParameters,
|
|
181
|
-
body: (0, index_1.UpdateWebhookRequestToJSON)(requestParameters['updateWebhookRequest']),
|
|
182
|
-
}, initOverrides);
|
|
183
|
-
return new runtime.JSONApiResponse(response, (jsonValue) => (0, index_1.WebhookFromJSON)(jsonValue));
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* Updates the configuration of an existing webhook, allowing changes to the event subscriptions or notification URL.
|
|
187
|
-
* Update webhook
|
|
188
|
-
*/
|
|
189
|
-
async updateWebhook(requestParameters, initOverrides) {
|
|
190
|
-
const response = await this.updateWebhookRaw(requestParameters, initOverrides);
|
|
191
|
-
return await response.value();
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
exports.WebhooksApi = WebhooksApi;
|
package/lib/runtime.js
DELETED
|
@@ -1,394 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/* tslint:disable */
|
|
3
|
-
/* eslint-disable */
|
|
4
|
-
/**
|
|
5
|
-
* Astrada API
|
|
6
|
-
* Welcome to our API Reference. 👋
|
|
7
|
-
*
|
|
8
|
-
* The version of the OpenAPI document: 2024-02-28
|
|
9
|
-
* Contact: developer@astrada.co
|
|
10
|
-
*
|
|
11
|
-
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
12
|
-
* https://openapi-generator.tech
|
|
13
|
-
* Do not edit the class manually.
|
|
14
|
-
*/
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.TextApiResponse = exports.BlobApiResponse = exports.VoidApiResponse = exports.JSONApiResponse = exports.COLLECTION_FORMATS = exports.RequiredError = exports.FetchError = exports.ResponseError = exports.BaseAPI = exports.AuthenticationClient = exports.Configuration = exports.BASE_PATH = void 0;
|
|
17
|
-
exports.querystring = querystring;
|
|
18
|
-
exports.exists = exists;
|
|
19
|
-
exports.mapValues = mapValues;
|
|
20
|
-
exports.canConsumeForm = canConsumeForm;
|
|
21
|
-
exports.BASE_PATH = "https://api.astrada.co".replace(/\/+$/, "");
|
|
22
|
-
class Configuration {
|
|
23
|
-
constructor(configuration) {
|
|
24
|
-
this.configuration = configuration;
|
|
25
|
-
this.authClient = new AuthenticationClient({
|
|
26
|
-
basePath: this.basePath,
|
|
27
|
-
clientId: this.clientId,
|
|
28
|
-
clientSecret: this.clientSecret,
|
|
29
|
-
accountId: this.accountId,
|
|
30
|
-
fetchApi: this.fetchApi
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
set config(configuration) {
|
|
34
|
-
this.configuration = configuration;
|
|
35
|
-
}
|
|
36
|
-
get accessToken() {
|
|
37
|
-
return this.authClient.getAccessToken.bind(this.authClient);
|
|
38
|
-
}
|
|
39
|
-
get accountId() {
|
|
40
|
-
return this.configuration.accountId;
|
|
41
|
-
}
|
|
42
|
-
get clientId() {
|
|
43
|
-
return this.configuration.clientId;
|
|
44
|
-
}
|
|
45
|
-
get clientSecret() {
|
|
46
|
-
return this.configuration.clientSecret;
|
|
47
|
-
}
|
|
48
|
-
get basePath() {
|
|
49
|
-
return this.configuration.basePath != null ? this.configuration.basePath : exports.BASE_PATH;
|
|
50
|
-
}
|
|
51
|
-
get fetchApi() {
|
|
52
|
-
return this.configuration.fetchApi;
|
|
53
|
-
}
|
|
54
|
-
get middleware() {
|
|
55
|
-
return this.configuration.middleware || [];
|
|
56
|
-
}
|
|
57
|
-
get queryParamsStringify() {
|
|
58
|
-
return this.configuration.queryParamsStringify || querystring;
|
|
59
|
-
}
|
|
60
|
-
get headers() {
|
|
61
|
-
return this.configuration.headers;
|
|
62
|
-
}
|
|
63
|
-
get credentials() {
|
|
64
|
-
return this.configuration.credentials;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
exports.Configuration = Configuration;
|
|
68
|
-
class AuthenticationClient {
|
|
69
|
-
constructor(authConfig) {
|
|
70
|
-
this.authConfig = authConfig;
|
|
71
|
-
this.cachedToken = null;
|
|
72
|
-
this.tokenExpiry = 0;
|
|
73
|
-
}
|
|
74
|
-
async getAccessToken(name, scopes) {
|
|
75
|
-
if (this.isTokenValid()) {
|
|
76
|
-
return 'Bearer ' + this.cachedToken.access_token;
|
|
77
|
-
}
|
|
78
|
-
const tokenResponse = await this.requestNewToken();
|
|
79
|
-
this.cacheToken(tokenResponse);
|
|
80
|
-
return 'Bearer ' + tokenResponse.access_token;
|
|
81
|
-
}
|
|
82
|
-
async requestNewToken() {
|
|
83
|
-
const params = new URLSearchParams({
|
|
84
|
-
client_id: this.authConfig.clientId,
|
|
85
|
-
client_secret: this.authConfig.clientSecret,
|
|
86
|
-
grant_type: "client_credentials",
|
|
87
|
-
});
|
|
88
|
-
const url = `${this.authConfig.basePath}/auth/realms/${this.authConfig.accountId}/protocol/openid-connect/token`;
|
|
89
|
-
const response = await (this.authConfig.fetchApi || fetch)(url, {
|
|
90
|
-
method: 'POST',
|
|
91
|
-
headers: {
|
|
92
|
-
'Content-Type': 'application/x-www-form-urlencoded',
|
|
93
|
-
},
|
|
94
|
-
body: params
|
|
95
|
-
});
|
|
96
|
-
const data = await response.json();
|
|
97
|
-
if (response && (response.status >= 200 && response.status < 300)) {
|
|
98
|
-
return data;
|
|
99
|
-
}
|
|
100
|
-
if (data) {
|
|
101
|
-
const astradaError = {
|
|
102
|
-
error: data.error || "authentication_failed",
|
|
103
|
-
error_description: data.error_description ||
|
|
104
|
-
"Failed to authenticate with Astrada API",
|
|
105
|
-
status: response.status,
|
|
106
|
-
};
|
|
107
|
-
throw new ResponseError(response, `Authentication failed: ${astradaError.error_description}`);
|
|
108
|
-
}
|
|
109
|
-
throw new ResponseError(response, 'Response returned an error code');
|
|
110
|
-
}
|
|
111
|
-
cacheToken(token) {
|
|
112
|
-
this.cachedToken = token;
|
|
113
|
-
this.tokenExpiry = Date.now() + token.expires_in * 1000 - 30000; // 30s buffer
|
|
114
|
-
}
|
|
115
|
-
isTokenValid() {
|
|
116
|
-
return this.cachedToken !== null && Date.now() < this.tokenExpiry;
|
|
117
|
-
}
|
|
118
|
-
clearCache() {
|
|
119
|
-
this.cachedToken = null;
|
|
120
|
-
this.tokenExpiry = 0;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
exports.AuthenticationClient = AuthenticationClient;
|
|
124
|
-
/**
|
|
125
|
-
* This is the base class for all generated API classes.
|
|
126
|
-
*/
|
|
127
|
-
class BaseAPI {
|
|
128
|
-
constructor(configuration) {
|
|
129
|
-
this.configuration = configuration;
|
|
130
|
-
this.cachedToken = null;
|
|
131
|
-
this.tokenExpiry = 0;
|
|
132
|
-
this.fetchApi = async (url, init) => {
|
|
133
|
-
let fetchParams = { url, init };
|
|
134
|
-
for (const middleware of this.middleware) {
|
|
135
|
-
if (middleware.pre) {
|
|
136
|
-
fetchParams = await middleware.pre({
|
|
137
|
-
fetch: this.fetchApi,
|
|
138
|
-
...fetchParams,
|
|
139
|
-
}) || fetchParams;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
let response = undefined;
|
|
143
|
-
try {
|
|
144
|
-
response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
|
|
145
|
-
}
|
|
146
|
-
catch (e) {
|
|
147
|
-
for (const middleware of this.middleware) {
|
|
148
|
-
if (middleware.onError) {
|
|
149
|
-
response = await middleware.onError({
|
|
150
|
-
fetch: this.fetchApi,
|
|
151
|
-
url: fetchParams.url,
|
|
152
|
-
init: fetchParams.init,
|
|
153
|
-
error: e,
|
|
154
|
-
response: response ? response.clone() : undefined,
|
|
155
|
-
}) || response;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
if (response === undefined) {
|
|
159
|
-
if (e instanceof Error) {
|
|
160
|
-
throw new FetchError(e, 'The request failed and the interceptors did not return an alternative response');
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
throw e;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
for (const middleware of this.middleware) {
|
|
168
|
-
if (middleware.post) {
|
|
169
|
-
response = await middleware.post({
|
|
170
|
-
fetch: this.fetchApi,
|
|
171
|
-
url: fetchParams.url,
|
|
172
|
-
init: fetchParams.init,
|
|
173
|
-
response: response.clone(),
|
|
174
|
-
}) || response;
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
return response;
|
|
178
|
-
};
|
|
179
|
-
this.middleware = configuration.middleware;
|
|
180
|
-
}
|
|
181
|
-
withMiddleware(...middlewares) {
|
|
182
|
-
const next = this.clone();
|
|
183
|
-
next.middleware = next.middleware.concat(...middlewares);
|
|
184
|
-
return next;
|
|
185
|
-
}
|
|
186
|
-
withPreMiddleware(...preMiddlewares) {
|
|
187
|
-
const middlewares = preMiddlewares.map((pre) => ({ pre }));
|
|
188
|
-
return this.withMiddleware(...middlewares);
|
|
189
|
-
}
|
|
190
|
-
withPostMiddleware(...postMiddlewares) {
|
|
191
|
-
const middlewares = postMiddlewares.map((post) => ({ post }));
|
|
192
|
-
return this.withMiddleware(...middlewares);
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* Check if the given MIME is a JSON MIME.
|
|
196
|
-
* JSON MIME examples:
|
|
197
|
-
* application/json
|
|
198
|
-
* application/json; charset=UTF8
|
|
199
|
-
* APPLICATION/JSON
|
|
200
|
-
* application/vnd.company+json
|
|
201
|
-
* @param mime - MIME (Multipurpose Internet Mail Extensions)
|
|
202
|
-
* @return True if the given MIME is JSON, false otherwise.
|
|
203
|
-
*/
|
|
204
|
-
isJsonMime(mime) {
|
|
205
|
-
if (!mime) {
|
|
206
|
-
return false;
|
|
207
|
-
}
|
|
208
|
-
return BaseAPI.jsonRegex.test(mime);
|
|
209
|
-
}
|
|
210
|
-
async request(context, initOverrides) {
|
|
211
|
-
const { url, init } = await this.createFetchParams(context, initOverrides);
|
|
212
|
-
const response = await this.fetchApi(url, init);
|
|
213
|
-
if (response && (response.status >= 200 && response.status < 300)) {
|
|
214
|
-
return response;
|
|
215
|
-
}
|
|
216
|
-
throw new ResponseError(response, 'Response returned an error code');
|
|
217
|
-
}
|
|
218
|
-
async createFetchParams(context, initOverrides) {
|
|
219
|
-
let url = this.configuration.basePath + context.path;
|
|
220
|
-
if (context.query !== undefined && Object.keys(context.query).length !== 0) {
|
|
221
|
-
// only add the querystring to the URL if there are query parameters.
|
|
222
|
-
// this is done to avoid urls ending with a "?" character which buggy webservers
|
|
223
|
-
// do not handle correctly sometimes.
|
|
224
|
-
url += '?' + this.configuration.queryParamsStringify(context.query);
|
|
225
|
-
}
|
|
226
|
-
const headers = Object.assign({}, this.configuration.headers, context.headers);
|
|
227
|
-
Object.keys(headers).forEach(key => headers[key] === undefined ? delete headers[key] : {});
|
|
228
|
-
const initOverrideFn = typeof initOverrides === "function"
|
|
229
|
-
? initOverrides
|
|
230
|
-
: async () => initOverrides;
|
|
231
|
-
const initParams = {
|
|
232
|
-
method: context.method,
|
|
233
|
-
headers,
|
|
234
|
-
body: context.body,
|
|
235
|
-
credentials: this.configuration.credentials,
|
|
236
|
-
};
|
|
237
|
-
const overriddenInit = {
|
|
238
|
-
...initParams,
|
|
239
|
-
...(await initOverrideFn({
|
|
240
|
-
init: initParams,
|
|
241
|
-
context,
|
|
242
|
-
}))
|
|
243
|
-
};
|
|
244
|
-
let body;
|
|
245
|
-
if (isFormData(overriddenInit.body)
|
|
246
|
-
|| (overriddenInit.body instanceof URLSearchParams)
|
|
247
|
-
|| isBlob(overriddenInit.body)) {
|
|
248
|
-
body = overriddenInit.body;
|
|
249
|
-
}
|
|
250
|
-
else if (this.isJsonMime(headers['Content-Type'])) {
|
|
251
|
-
body = JSON.stringify(overriddenInit.body);
|
|
252
|
-
}
|
|
253
|
-
else {
|
|
254
|
-
body = overriddenInit.body;
|
|
255
|
-
}
|
|
256
|
-
const init = {
|
|
257
|
-
...overriddenInit,
|
|
258
|
-
body
|
|
259
|
-
};
|
|
260
|
-
return { url, init };
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* Create a shallow clone of `this` by constructing a new instance
|
|
264
|
-
* and then shallow cloning data members.
|
|
265
|
-
*/
|
|
266
|
-
clone() {
|
|
267
|
-
const constructor = this.constructor;
|
|
268
|
-
const next = new constructor(this.configuration);
|
|
269
|
-
next.middleware = this.middleware.slice();
|
|
270
|
-
return next;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
exports.BaseAPI = BaseAPI;
|
|
274
|
-
BaseAPI.jsonRegex = new RegExp('^(:?application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$', 'i');
|
|
275
|
-
;
|
|
276
|
-
function isBlob(value) {
|
|
277
|
-
return typeof Blob !== 'undefined' && value instanceof Blob;
|
|
278
|
-
}
|
|
279
|
-
function isFormData(value) {
|
|
280
|
-
return typeof FormData !== "undefined" && value instanceof FormData;
|
|
281
|
-
}
|
|
282
|
-
class ResponseError extends Error {
|
|
283
|
-
constructor(response, msg) {
|
|
284
|
-
super(msg);
|
|
285
|
-
this.response = response;
|
|
286
|
-
this.name = "ResponseError";
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
exports.ResponseError = ResponseError;
|
|
290
|
-
class FetchError extends Error {
|
|
291
|
-
constructor(cause, msg) {
|
|
292
|
-
super(msg);
|
|
293
|
-
this.cause = cause;
|
|
294
|
-
this.name = "FetchError";
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
exports.FetchError = FetchError;
|
|
298
|
-
class RequiredError extends Error {
|
|
299
|
-
constructor(field, msg) {
|
|
300
|
-
super(msg);
|
|
301
|
-
this.field = field;
|
|
302
|
-
this.name = "RequiredError";
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
exports.RequiredError = RequiredError;
|
|
306
|
-
exports.COLLECTION_FORMATS = {
|
|
307
|
-
csv: ",",
|
|
308
|
-
ssv: " ",
|
|
309
|
-
tsv: "\t",
|
|
310
|
-
pipes: "|",
|
|
311
|
-
};
|
|
312
|
-
function querystring(params, prefix = '') {
|
|
313
|
-
return Object.keys(params)
|
|
314
|
-
.map(key => querystringSingleKey(key, params[key], prefix))
|
|
315
|
-
.filter(part => part.length > 0)
|
|
316
|
-
.join('&');
|
|
317
|
-
}
|
|
318
|
-
function querystringSingleKey(key, value, keyPrefix = '') {
|
|
319
|
-
const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key);
|
|
320
|
-
if (value instanceof Array) {
|
|
321
|
-
const multiValue = value.map(singleValue => encodeURIComponent(String(singleValue)))
|
|
322
|
-
.join(`&${encodeURIComponent(fullKey)}=`);
|
|
323
|
-
return `${encodeURIComponent(fullKey)}=${multiValue}`;
|
|
324
|
-
}
|
|
325
|
-
if (value instanceof Set) {
|
|
326
|
-
const valueAsArray = Array.from(value);
|
|
327
|
-
return querystringSingleKey(key, valueAsArray, keyPrefix);
|
|
328
|
-
}
|
|
329
|
-
if (value instanceof Date) {
|
|
330
|
-
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`;
|
|
331
|
-
}
|
|
332
|
-
if (value instanceof Object) {
|
|
333
|
-
return querystring(value, fullKey);
|
|
334
|
-
}
|
|
335
|
-
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
|
|
336
|
-
}
|
|
337
|
-
function exists(json, key) {
|
|
338
|
-
const value = json[key];
|
|
339
|
-
return value !== null && value !== undefined;
|
|
340
|
-
}
|
|
341
|
-
function mapValues(data, fn) {
|
|
342
|
-
const result = {};
|
|
343
|
-
for (const key of Object.keys(data)) {
|
|
344
|
-
result[key] = fn(data[key]);
|
|
345
|
-
}
|
|
346
|
-
return result;
|
|
347
|
-
}
|
|
348
|
-
function canConsumeForm(consumes) {
|
|
349
|
-
for (const consume of consumes) {
|
|
350
|
-
if ('multipart/form-data' === consume.contentType) {
|
|
351
|
-
return true;
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
return false;
|
|
355
|
-
}
|
|
356
|
-
class JSONApiResponse {
|
|
357
|
-
constructor(raw, transformer = (jsonValue) => jsonValue) {
|
|
358
|
-
this.raw = raw;
|
|
359
|
-
this.transformer = transformer;
|
|
360
|
-
}
|
|
361
|
-
async value() {
|
|
362
|
-
return this.transformer(await this.raw.json());
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
exports.JSONApiResponse = JSONApiResponse;
|
|
366
|
-
class VoidApiResponse {
|
|
367
|
-
constructor(raw) {
|
|
368
|
-
this.raw = raw;
|
|
369
|
-
}
|
|
370
|
-
async value() {
|
|
371
|
-
return undefined;
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
exports.VoidApiResponse = VoidApiResponse;
|
|
375
|
-
class BlobApiResponse {
|
|
376
|
-
constructor(raw) {
|
|
377
|
-
this.raw = raw;
|
|
378
|
-
}
|
|
379
|
-
async value() {
|
|
380
|
-
return await this.raw.blob();
|
|
381
|
-
}
|
|
382
|
-
;
|
|
383
|
-
}
|
|
384
|
-
exports.BlobApiResponse = BlobApiResponse;
|
|
385
|
-
class TextApiResponse {
|
|
386
|
-
constructor(raw) {
|
|
387
|
-
this.raw = raw;
|
|
388
|
-
}
|
|
389
|
-
async value() {
|
|
390
|
-
return await this.raw.text();
|
|
391
|
-
}
|
|
392
|
-
;
|
|
393
|
-
}
|
|
394
|
-
exports.TextApiResponse = TextApiResponse;
|