@kard-financial/sdk 12.3.0 → 12.4.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/README.md +106 -15
- package/dist/cjs/BaseClient.d.ts +7 -8
- package/dist/cjs/BaseClient.js +3 -3
- package/dist/cjs/Client.d.ts +13 -2
- package/dist/cjs/Client.js +67 -0
- package/dist/cjs/api/resources/auth/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/auth/client/Client.js +3 -23
- package/dist/cjs/api/resources/auth/exports.d.ts +2 -0
- package/dist/cjs/api/resources/auth/exports.js +21 -0
- package/dist/cjs/api/resources/commons/errors/ConflictError.js +5 -1
- package/dist/cjs/api/resources/commons/errors/DoesNotExistError.js +5 -1
- package/dist/cjs/api/resources/commons/errors/ForbiddenError.js +5 -1
- package/dist/cjs/api/resources/commons/errors/InternalServerError.js +5 -1
- package/dist/cjs/api/resources/commons/errors/InvalidRequest.js +5 -1
- package/dist/cjs/api/resources/commons/errors/UnauthorizedError.js +5 -1
- package/dist/cjs/api/resources/commons/exports.d.ts +1 -0
- package/dist/cjs/api/resources/commons/exports.js +18 -0
- package/dist/cjs/api/resources/commons/types/ErrorObject.d.ts +2 -2
- package/dist/cjs/api/resources/commons/types/ErrorSource.d.ts +3 -3
- package/dist/cjs/api/resources/commons/types/Links.d.ts +2 -2
- package/dist/cjs/api/resources/files/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/files/client/Client.js +11 -47
- package/dist/cjs/api/resources/files/exports.d.ts +2 -0
- package/dist/cjs/api/resources/files/exports.js +21 -0
- package/dist/cjs/api/resources/notifications/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/notifications/exports.d.ts +3 -0
- package/dist/cjs/api/resources/notifications/exports.js +22 -0
- package/dist/cjs/api/resources/notifications/resources/subscriptions/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/notifications/resources/subscriptions/client/Client.js +7 -64
- package/dist/cjs/api/resources/notifications/resources/subscriptions/exports.d.ts +2 -0
- package/dist/cjs/api/resources/notifications/resources/subscriptions/exports.js +21 -0
- package/dist/cjs/api/resources/notifications/resources/subscriptions/types/UpdateSubscriptionRequestAttributes.d.ts +3 -3
- package/dist/cjs/api/resources/notifications/types/AuditUpdateAttributes.d.ts +3 -3
- package/dist/cjs/api/resources/notifications/types/FailedTransactionAttributes.d.ts +1 -1
- package/dist/cjs/api/resources/notifications/types/NotificationPayload.d.ts +2 -2
- package/dist/cjs/api/resources/notifications/types/RewardNotificationAttributes.d.ts +2 -2
- package/dist/cjs/api/resources/ping/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/ping/client/Client.js +2 -20
- package/dist/cjs/api/resources/ping/errors/NetworkBlockedError.js +5 -1
- package/dist/cjs/api/resources/ping/exports.d.ts +2 -0
- package/dist/cjs/api/resources/ping/exports.js +21 -0
- package/dist/cjs/api/resources/transactions/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/transactions/client/Client.js +12 -113
- package/dist/cjs/api/resources/transactions/errors/CreateAuditMultiStatus.js +5 -1
- package/dist/cjs/api/resources/transactions/errors/CreateIncomingTransactionsMultiStatus.js +5 -1
- package/dist/cjs/api/resources/transactions/errors/FraudMultiStatus.js +5 -1
- package/dist/cjs/api/resources/transactions/exports.d.ts +2 -0
- package/dist/cjs/api/resources/transactions/exports.js +21 -0
- package/dist/cjs/api/resources/transactions/types/CoreTransactionAttributes.d.ts +3 -3
- package/dist/cjs/api/resources/transactions/types/CreateAuditMultiStatusResponse.d.ts +1 -1
- package/dist/cjs/api/resources/transactions/types/GetEarnedRewardsResponse.d.ts +1 -1
- package/dist/cjs/api/resources/transactions/types/MatchedTransactionsAttributes.d.ts +14 -14
- package/dist/cjs/api/resources/transactions/types/Merchant.d.ts +9 -9
- package/dist/cjs/api/resources/transactions/types/RewardedTransactionAttributes.d.ts +3 -3
- package/dist/cjs/api/resources/transactions/types/TransactionsAttributes.d.ts +18 -18
- package/dist/cjs/api/resources/users/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/users/client/Client.js +5 -80
- package/dist/cjs/api/resources/users/errors/MultiStatus.js +5 -1
- package/dist/cjs/api/resources/users/exports.d.ts +3 -0
- package/dist/cjs/api/resources/users/exports.js +22 -0
- package/dist/cjs/api/resources/users/resources/attributions/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/users/resources/attributions/client/Client.js +20 -94
- package/dist/cjs/api/resources/users/resources/attributions/exports.d.ts +2 -0
- package/dist/cjs/api/resources/users/resources/attributions/exports.js +21 -0
- package/dist/cjs/api/resources/users/resources/attributions/types/ActivateOfferResponse.d.ts +1 -1
- package/dist/cjs/api/resources/users/resources/attributions/types/AttributionState.d.ts +2 -2
- package/dist/cjs/api/resources/users/resources/attributions/types/BoostOfferResponse.d.ts +1 -1
- package/dist/cjs/api/resources/users/resources/attributions/types/NotificationAttributionAttributes.d.ts +1 -1
- package/dist/cjs/api/resources/users/resources/attributions/types/OfferAttributionAttributes.d.ts +1 -1
- package/dist/cjs/api/resources/users/resources/auth/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/users/resources/auth/client/Client.js +2 -20
- package/dist/cjs/api/resources/users/resources/auth/exports.d.ts +2 -0
- package/dist/cjs/api/resources/users/resources/auth/exports.js +21 -0
- package/dist/cjs/api/resources/users/resources/rewards/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/users/resources/rewards/client/Client.js +39 -144
- package/dist/cjs/api/resources/users/resources/rewards/exports.d.ts +2 -0
- package/dist/cjs/api/resources/users/resources/rewards/exports.js +21 -0
- package/dist/cjs/api/resources/users/resources/rewards/types/CtaComponent.d.ts +2 -2
- package/dist/cjs/api/resources/users/resources/rewards/types/LocationData.d.ts +1 -1
- package/dist/cjs/api/resources/users/resources/rewards/types/LocationsResponseObject.d.ts +1 -1
- package/dist/cjs/api/resources/users/resources/rewards/types/LogoFlare.d.ts +1 -1
- package/dist/cjs/api/resources/users/resources/rewards/types/OfferCommonFields.d.ts +8 -8
- package/dist/cjs/api/resources/users/resources/rewards/types/OfferComponents.d.ts +9 -9
- package/dist/cjs/api/resources/users/resources/rewards/types/OffersMeta.d.ts +1 -1
- package/dist/cjs/api/resources/users/resources/rewards/types/OffersResponseObject.d.ts +2 -2
- package/dist/cjs/api/resources/users/resources/rewards/types/ProgressBar.d.ts +1 -1
- package/dist/cjs/api/resources/users/resources/rewards/types/ProgressBarLabelPair.d.ts +2 -2
- package/dist/cjs/api/resources/users/resources/rewards/types/ProgressBarLabels.d.ts +1 -1
- package/dist/cjs/api/resources/users/resources/rewards/types/ProgressBarSegment.d.ts +1 -1
- package/dist/cjs/api/resources/users/resources/rewards/types/ProgressBarSegments.d.ts +1 -1
- package/dist/cjs/api/resources/users/resources/rewards/types/StandardOffer.d.ts +1 -1
- package/dist/cjs/api/resources/users/resources/uploads/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/users/resources/uploads/client/Client.js +4 -60
- package/dist/cjs/api/resources/users/resources/uploads/errors/UploadPartMultiStatus.js +5 -1
- package/dist/cjs/api/resources/users/resources/uploads/exports.d.ts +2 -0
- package/dist/cjs/api/resources/users/resources/uploads/exports.js +21 -0
- package/dist/cjs/api/resources/users/resources/uploads/types/CreateUploadPartMultiStatusResponse.d.ts +1 -1
- package/dist/cjs/api/resources/users/types/CreateUsersMultiStatusResponse.d.ts +1 -1
- package/dist/cjs/api/resources/users/types/UpdateUserRequestAttributes.d.ts +5 -5
- package/dist/cjs/api/resources/users/types/UserRequestAttributes.d.ts +6 -6
- package/dist/cjs/auth/OAuthAuthProvider.d.ts +36 -14
- package/dist/cjs/auth/OAuthAuthProvider.js +108 -40
- package/dist/cjs/core/auth/BasicAuth.d.ts +2 -2
- package/dist/cjs/core/auth/BasicAuth.js +7 -1
- package/dist/cjs/core/fetcher/BinaryResponse.d.ts +1 -1
- package/dist/cjs/core/fetcher/EndpointSupplier.d.ts +2 -2
- package/dist/cjs/core/fetcher/Fetcher.d.ts +3 -2
- package/dist/cjs/core/fetcher/Fetcher.js +12 -2
- package/dist/cjs/core/fetcher/index.d.ts +2 -0
- package/dist/cjs/core/fetcher/index.js +3 -1
- package/dist/cjs/core/fetcher/makePassthroughRequest.d.ts +49 -0
- package/dist/cjs/core/fetcher/makePassthroughRequest.js +135 -0
- package/dist/cjs/core/fetcher/makeRequest.d.ts +6 -1
- package/dist/cjs/core/fetcher/makeRequest.js +30 -9
- package/dist/cjs/core/headers.d.ts +2 -2
- package/dist/cjs/core/runtime/runtime.js +8 -7
- package/dist/cjs/errors/KardApiError.d.ts +3 -1
- package/dist/cjs/errors/KardApiError.js +9 -2
- package/dist/cjs/errors/KardApiTimeoutError.d.ts +4 -1
- package/dist/cjs/errors/KardApiTimeoutError.js +9 -2
- package/dist/cjs/errors/handleNonStatusCodeError.d.ts +2 -0
- package/dist/cjs/errors/handleNonStatusCodeError.js +68 -0
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/BaseClient.d.mts +7 -8
- package/dist/esm/BaseClient.mjs +3 -3
- package/dist/esm/Client.d.mts +13 -2
- package/dist/esm/Client.mjs +34 -0
- package/dist/esm/api/resources/auth/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/auth/client/Client.mjs +3 -23
- package/dist/esm/api/resources/auth/exports.d.mts +2 -0
- package/dist/esm/api/resources/auth/exports.mjs +3 -0
- package/dist/esm/api/resources/commons/errors/ConflictError.mjs +5 -1
- package/dist/esm/api/resources/commons/errors/DoesNotExistError.mjs +5 -1
- package/dist/esm/api/resources/commons/errors/ForbiddenError.mjs +5 -1
- package/dist/esm/api/resources/commons/errors/InternalServerError.mjs +5 -1
- package/dist/esm/api/resources/commons/errors/InvalidRequest.mjs +5 -1
- package/dist/esm/api/resources/commons/errors/UnauthorizedError.mjs +5 -1
- package/dist/esm/api/resources/commons/exports.d.mts +1 -0
- package/dist/esm/api/resources/commons/exports.mjs +2 -0
- package/dist/esm/api/resources/commons/types/ErrorObject.d.mts +2 -2
- package/dist/esm/api/resources/commons/types/ErrorSource.d.mts +3 -3
- package/dist/esm/api/resources/commons/types/Links.d.mts +2 -2
- package/dist/esm/api/resources/files/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/files/client/Client.mjs +11 -47
- package/dist/esm/api/resources/files/exports.d.mts +2 -0
- package/dist/esm/api/resources/files/exports.mjs +3 -0
- package/dist/esm/api/resources/notifications/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/notifications/exports.d.mts +3 -0
- package/dist/esm/api/resources/notifications/exports.mjs +4 -0
- package/dist/esm/api/resources/notifications/resources/subscriptions/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/notifications/resources/subscriptions/client/Client.mjs +7 -64
- package/dist/esm/api/resources/notifications/resources/subscriptions/exports.d.mts +2 -0
- package/dist/esm/api/resources/notifications/resources/subscriptions/exports.mjs +3 -0
- package/dist/esm/api/resources/notifications/resources/subscriptions/types/UpdateSubscriptionRequestAttributes.d.mts +3 -3
- package/dist/esm/api/resources/notifications/types/AuditUpdateAttributes.d.mts +3 -3
- package/dist/esm/api/resources/notifications/types/FailedTransactionAttributes.d.mts +1 -1
- package/dist/esm/api/resources/notifications/types/NotificationPayload.d.mts +2 -2
- package/dist/esm/api/resources/notifications/types/RewardNotificationAttributes.d.mts +2 -2
- package/dist/esm/api/resources/ping/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/ping/client/Client.mjs +2 -20
- package/dist/esm/api/resources/ping/errors/NetworkBlockedError.mjs +5 -1
- package/dist/esm/api/resources/ping/exports.d.mts +2 -0
- package/dist/esm/api/resources/ping/exports.mjs +3 -0
- package/dist/esm/api/resources/transactions/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/transactions/client/Client.mjs +12 -113
- package/dist/esm/api/resources/transactions/errors/CreateAuditMultiStatus.mjs +5 -1
- package/dist/esm/api/resources/transactions/errors/CreateIncomingTransactionsMultiStatus.mjs +5 -1
- package/dist/esm/api/resources/transactions/errors/FraudMultiStatus.mjs +5 -1
- package/dist/esm/api/resources/transactions/exports.d.mts +2 -0
- package/dist/esm/api/resources/transactions/exports.mjs +3 -0
- package/dist/esm/api/resources/transactions/types/CoreTransactionAttributes.d.mts +3 -3
- package/dist/esm/api/resources/transactions/types/CreateAuditMultiStatusResponse.d.mts +1 -1
- package/dist/esm/api/resources/transactions/types/GetEarnedRewardsResponse.d.mts +1 -1
- package/dist/esm/api/resources/transactions/types/MatchedTransactionsAttributes.d.mts +14 -14
- package/dist/esm/api/resources/transactions/types/Merchant.d.mts +9 -9
- package/dist/esm/api/resources/transactions/types/RewardedTransactionAttributes.d.mts +3 -3
- package/dist/esm/api/resources/transactions/types/TransactionsAttributes.d.mts +18 -18
- package/dist/esm/api/resources/users/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/users/client/Client.mjs +5 -80
- package/dist/esm/api/resources/users/errors/MultiStatus.mjs +5 -1
- package/dist/esm/api/resources/users/exports.d.mts +3 -0
- package/dist/esm/api/resources/users/exports.mjs +4 -0
- package/dist/esm/api/resources/users/resources/attributions/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/users/resources/attributions/client/Client.mjs +20 -94
- package/dist/esm/api/resources/users/resources/attributions/exports.d.mts +2 -0
- package/dist/esm/api/resources/users/resources/attributions/exports.mjs +3 -0
- package/dist/esm/api/resources/users/resources/attributions/types/ActivateOfferResponse.d.mts +1 -1
- package/dist/esm/api/resources/users/resources/attributions/types/AttributionState.d.mts +2 -2
- package/dist/esm/api/resources/users/resources/attributions/types/BoostOfferResponse.d.mts +1 -1
- package/dist/esm/api/resources/users/resources/attributions/types/NotificationAttributionAttributes.d.mts +1 -1
- package/dist/esm/api/resources/users/resources/attributions/types/OfferAttributionAttributes.d.mts +1 -1
- package/dist/esm/api/resources/users/resources/auth/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/users/resources/auth/client/Client.mjs +2 -20
- package/dist/esm/api/resources/users/resources/auth/exports.d.mts +2 -0
- package/dist/esm/api/resources/users/resources/auth/exports.mjs +3 -0
- package/dist/esm/api/resources/users/resources/rewards/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/users/resources/rewards/client/Client.mjs +39 -144
- package/dist/esm/api/resources/users/resources/rewards/exports.d.mts +2 -0
- package/dist/esm/api/resources/users/resources/rewards/exports.mjs +3 -0
- package/dist/esm/api/resources/users/resources/rewards/types/CtaComponent.d.mts +2 -2
- package/dist/esm/api/resources/users/resources/rewards/types/LocationData.d.mts +1 -1
- package/dist/esm/api/resources/users/resources/rewards/types/LocationsResponseObject.d.mts +1 -1
- package/dist/esm/api/resources/users/resources/rewards/types/LogoFlare.d.mts +1 -1
- package/dist/esm/api/resources/users/resources/rewards/types/OfferCommonFields.d.mts +8 -8
- package/dist/esm/api/resources/users/resources/rewards/types/OfferComponents.d.mts +9 -9
- package/dist/esm/api/resources/users/resources/rewards/types/OffersMeta.d.mts +1 -1
- package/dist/esm/api/resources/users/resources/rewards/types/OffersResponseObject.d.mts +2 -2
- package/dist/esm/api/resources/users/resources/rewards/types/ProgressBar.d.mts +1 -1
- package/dist/esm/api/resources/users/resources/rewards/types/ProgressBarLabelPair.d.mts +2 -2
- package/dist/esm/api/resources/users/resources/rewards/types/ProgressBarLabels.d.mts +1 -1
- package/dist/esm/api/resources/users/resources/rewards/types/ProgressBarSegment.d.mts +1 -1
- package/dist/esm/api/resources/users/resources/rewards/types/ProgressBarSegments.d.mts +1 -1
- package/dist/esm/api/resources/users/resources/rewards/types/StandardOffer.d.mts +1 -1
- package/dist/esm/api/resources/users/resources/uploads/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/users/resources/uploads/client/Client.mjs +4 -60
- package/dist/esm/api/resources/users/resources/uploads/errors/UploadPartMultiStatus.mjs +5 -1
- package/dist/esm/api/resources/users/resources/uploads/exports.d.mts +2 -0
- package/dist/esm/api/resources/users/resources/uploads/exports.mjs +3 -0
- package/dist/esm/api/resources/users/resources/uploads/types/CreateUploadPartMultiStatusResponse.d.mts +1 -1
- package/dist/esm/api/resources/users/types/CreateUsersMultiStatusResponse.d.mts +1 -1
- package/dist/esm/api/resources/users/types/UpdateUserRequestAttributes.d.mts +5 -5
- package/dist/esm/api/resources/users/types/UserRequestAttributes.d.mts +6 -6
- package/dist/esm/auth/OAuthAuthProvider.d.mts +36 -14
- package/dist/esm/auth/OAuthAuthProvider.mjs +106 -39
- package/dist/esm/core/auth/BasicAuth.d.mts +2 -2
- package/dist/esm/core/auth/BasicAuth.mjs +7 -1
- package/dist/esm/core/fetcher/BinaryResponse.d.mts +1 -1
- package/dist/esm/core/fetcher/EndpointSupplier.d.mts +2 -2
- package/dist/esm/core/fetcher/Fetcher.d.mts +3 -2
- package/dist/esm/core/fetcher/Fetcher.mjs +12 -2
- package/dist/esm/core/fetcher/index.d.mts +2 -0
- package/dist/esm/core/fetcher/index.mjs +1 -0
- package/dist/esm/core/fetcher/makePassthroughRequest.d.mts +49 -0
- package/dist/esm/core/fetcher/makePassthroughRequest.mjs +132 -0
- package/dist/esm/core/fetcher/makeRequest.d.mts +6 -1
- package/dist/esm/core/fetcher/makeRequest.mjs +28 -9
- package/dist/esm/core/headers.d.mts +2 -2
- package/dist/esm/core/runtime/runtime.mjs +8 -7
- package/dist/esm/errors/KardApiError.d.mts +3 -1
- package/dist/esm/errors/KardApiError.mjs +9 -2
- package/dist/esm/errors/KardApiTimeoutError.d.mts +4 -1
- package/dist/esm/errors/KardApiTimeoutError.mjs +9 -2
- package/dist/esm/errors/handleNonStatusCodeError.d.mts +2 -0
- package/dist/esm/errors/handleNonStatusCodeError.mjs +32 -0
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +134 -10
- package/reference.md +1 -0
package/README.md
CHANGED
|
@@ -5,6 +5,28 @@
|
|
|
5
5
|
|
|
6
6
|
The Kard TypeScript library provides convenient access to the Kard APIs from TypeScript.
|
|
7
7
|
|
|
8
|
+
## Table of Contents
|
|
9
|
+
|
|
10
|
+
- [Installation](#installation)
|
|
11
|
+
- [Reference](#reference)
|
|
12
|
+
- [Usage](#usage)
|
|
13
|
+
- [Environments](#environments)
|
|
14
|
+
- [Authentication](#authentication)
|
|
15
|
+
- [Request and Response Types](#request-and-response-types)
|
|
16
|
+
- [Exception Handling](#exception-handling)
|
|
17
|
+
- [Advanced](#advanced)
|
|
18
|
+
- [Subpackage Exports](#subpackage-exports)
|
|
19
|
+
- [Additional Headers](#additional-headers)
|
|
20
|
+
- [Additional Query String Parameters](#additional-query-string-parameters)
|
|
21
|
+
- [Retries](#retries)
|
|
22
|
+
- [Timeouts](#timeouts)
|
|
23
|
+
- [Aborting Requests](#aborting-requests)
|
|
24
|
+
- [Access Raw Response Data](#access-raw-response-data)
|
|
25
|
+
- [Logging](#logging)
|
|
26
|
+
- [Custom Fetch](#custom-fetch)
|
|
27
|
+
- [Runtime Compatibility](#runtime-compatibility)
|
|
28
|
+
- [Contributing](#contributing)
|
|
29
|
+
|
|
8
30
|
## Installation
|
|
9
31
|
|
|
10
32
|
```sh
|
|
@@ -40,7 +62,50 @@ await client.users.create("organization-123", {
|
|
|
40
62
|
});
|
|
41
63
|
```
|
|
42
64
|
|
|
43
|
-
##
|
|
65
|
+
## Environments
|
|
66
|
+
|
|
67
|
+
This SDK allows you to configure different environments for API requests.
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
import { KardApiClient, KardApiEnvironment } from "@kard-financial/sdk";
|
|
71
|
+
|
|
72
|
+
const client = new KardApiClient({
|
|
73
|
+
environment: KardApiEnvironment.Production,
|
|
74
|
+
});
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Authentication
|
|
78
|
+
|
|
79
|
+
The SDK supports OAuth authentication with two options:
|
|
80
|
+
|
|
81
|
+
**Option 1: OAuth Client Credentials Flow**
|
|
82
|
+
|
|
83
|
+
Use this when you want the SDK to automatically handle OAuth token retrieval and refreshing:
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
import { KardApiClient } from "@kard-financial/sdk";
|
|
87
|
+
|
|
88
|
+
const client = new KardApiClient({
|
|
89
|
+
clientId: "YOUR_CLIENT_ID",
|
|
90
|
+
clientSecret: "YOUR_CLIENT_SECRET",
|
|
91
|
+
...
|
|
92
|
+
});
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
**Option 2: Token Override**
|
|
96
|
+
|
|
97
|
+
Use this when you already have a valid bearer token and want to skip the OAuth flow:
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
import { KardApiClient } from "@kard-financial/sdk";
|
|
101
|
+
|
|
102
|
+
const client = new KardApiClient({
|
|
103
|
+
token: "my-pre-generated-bearer-token",
|
|
104
|
+
...
|
|
105
|
+
});
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Request and Response Types
|
|
44
109
|
|
|
45
110
|
The SDK exports all request and response types as TypeScript interfaces. Simply import them with the
|
|
46
111
|
following namespace:
|
|
@@ -75,11 +140,30 @@ try {
|
|
|
75
140
|
|
|
76
141
|
## Advanced
|
|
77
142
|
|
|
143
|
+
### Subpackage Exports
|
|
144
|
+
|
|
145
|
+
This SDK supports direct imports of subpackage clients, which allows JavaScript bundlers to tree-shake and include only the imported subpackage code. This results in much smaller bundle sizes.
|
|
146
|
+
|
|
147
|
+
```typescript
|
|
148
|
+
import { AuthClient } from '@kard-financial/sdk/auth';
|
|
149
|
+
|
|
150
|
+
const client = new AuthClient({...});
|
|
151
|
+
```
|
|
152
|
+
|
|
78
153
|
### Additional Headers
|
|
79
154
|
|
|
80
155
|
If you would like to send additional headers as part of the request, use the `headers` request option.
|
|
81
156
|
|
|
82
157
|
```typescript
|
|
158
|
+
import { KardApiClient } from "@kard-financial/sdk";
|
|
159
|
+
|
|
160
|
+
const client = new KardApiClient({
|
|
161
|
+
...
|
|
162
|
+
headers: {
|
|
163
|
+
'X-Custom-Header': 'custom value'
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
|
|
83
167
|
const response = await client.users.create(..., {
|
|
84
168
|
headers: {
|
|
85
169
|
'X-Custom-Header': 'custom value'
|
|
@@ -216,6 +300,26 @@ const logger: logging.ILogger = {
|
|
|
216
300
|
</details>
|
|
217
301
|
|
|
218
302
|
|
|
303
|
+
### Custom Fetch
|
|
304
|
+
|
|
305
|
+
The SDK provides a low-level `fetch` method for making custom HTTP requests while still
|
|
306
|
+
benefiting from SDK-level configuration like authentication, retries, timeouts, and logging.
|
|
307
|
+
This is useful for calling API endpoints not yet supported in the SDK.
|
|
308
|
+
|
|
309
|
+
```typescript
|
|
310
|
+
const response = await client.fetch("/v1/custom/endpoint", {
|
|
311
|
+
method: "GET",
|
|
312
|
+
}, {
|
|
313
|
+
timeoutInSeconds: 30,
|
|
314
|
+
maxRetries: 3,
|
|
315
|
+
headers: {
|
|
316
|
+
"X-Custom-Header": "custom-value",
|
|
317
|
+
},
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
const data = await response.json();
|
|
321
|
+
```
|
|
322
|
+
|
|
219
323
|
### Runtime Compatibility
|
|
220
324
|
|
|
221
325
|
|
|
@@ -230,19 +334,6 @@ The SDK works in the following runtimes:
|
|
|
230
334
|
- Bun 1.0+
|
|
231
335
|
- React Native
|
|
232
336
|
|
|
233
|
-
### Customizing Fetch Client
|
|
234
|
-
|
|
235
|
-
The SDK provides a way for you to customize the underlying HTTP client / Fetch function. If you're running in an
|
|
236
|
-
unsupported environment, this provides a way for you to break glass and ensure the SDK works.
|
|
237
|
-
|
|
238
|
-
```typescript
|
|
239
|
-
import { KardApiClient } from "@kard-financial/sdk";
|
|
240
|
-
|
|
241
|
-
const client = new KardApiClient({
|
|
242
|
-
...
|
|
243
|
-
fetcher: // provide your implementation here
|
|
244
|
-
});
|
|
245
|
-
```
|
|
246
337
|
|
|
247
338
|
## Contributing
|
|
248
339
|
|
|
@@ -252,4 +343,4 @@ otherwise they would be overwritten upon the next generated release. Feel free t
|
|
|
252
343
|
a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
|
|
253
344
|
an issue first to discuss with us!
|
|
254
345
|
|
|
255
|
-
On the other hand, contributions to the README are always very welcome!
|
|
346
|
+
On the other hand, contributions to the README are always very welcome!
|
package/dist/cjs/BaseClient.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
+
import { OAuthAuthProvider } from "./auth/OAuthAuthProvider.js";
|
|
1
2
|
import * as core from "./core/index.js";
|
|
2
3
|
import type * as environments from "./environments.js";
|
|
3
|
-
export
|
|
4
|
+
export type BaseClientOptions = {
|
|
4
5
|
environment?: core.Supplier<environments.KardApiEnvironment | string>;
|
|
5
6
|
/** Specify a custom URL to connect the client to. */
|
|
6
7
|
baseUrl?: core.Supplier<string>;
|
|
7
|
-
clientId?: core.Supplier<string>;
|
|
8
|
-
clientSecret?: core.Supplier<string>;
|
|
9
8
|
/** Additional headers to include in requests. */
|
|
10
9
|
headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
|
|
11
10
|
/** The default maximum time to wait for a response in seconds. */
|
|
@@ -16,7 +15,7 @@ export interface BaseClientOptions {
|
|
|
16
15
|
fetch?: typeof fetch;
|
|
17
16
|
/** Configure logging for the client. */
|
|
18
17
|
logging?: core.logging.LogConfig | core.logging.Logger;
|
|
19
|
-
}
|
|
18
|
+
} & OAuthAuthProvider.AuthOptions;
|
|
20
19
|
export interface BaseRequestOptions {
|
|
21
20
|
/** The maximum time to wait for a response in seconds. */
|
|
22
21
|
timeoutInSeconds?: number;
|
|
@@ -29,12 +28,12 @@ export interface BaseRequestOptions {
|
|
|
29
28
|
/** Additional headers to include in the request. */
|
|
30
29
|
headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
|
|
31
30
|
}
|
|
32
|
-
export type NormalizedClientOptions<T extends BaseClientOptions> = T & {
|
|
31
|
+
export type NormalizedClientOptions<T extends BaseClientOptions = BaseClientOptions> = T & {
|
|
33
32
|
logging: core.logging.Logger;
|
|
34
33
|
authProvider?: core.AuthProvider;
|
|
35
34
|
};
|
|
36
|
-
export type NormalizedClientOptionsWithAuth<T extends BaseClientOptions> = NormalizedClientOptions<T> & {
|
|
35
|
+
export type NormalizedClientOptionsWithAuth<T extends BaseClientOptions = BaseClientOptions> = NormalizedClientOptions<T> & {
|
|
37
36
|
authProvider: core.AuthProvider;
|
|
38
37
|
};
|
|
39
|
-
export declare function normalizeClientOptions<T extends BaseClientOptions>(options: T): NormalizedClientOptions<T>;
|
|
40
|
-
export declare function normalizeClientOptionsWithAuth<T extends BaseClientOptions>(options: T): NormalizedClientOptionsWithAuth<T>;
|
|
38
|
+
export declare function normalizeClientOptions<T extends BaseClientOptions = BaseClientOptions>(options: T): NormalizedClientOptions<T>;
|
|
39
|
+
export declare function normalizeClientOptionsWithAuth<T extends BaseClientOptions = BaseClientOptions>(options: T): NormalizedClientOptionsWithAuth<T>;
|
package/dist/cjs/BaseClient.js
CHANGED
|
@@ -43,8 +43,8 @@ function normalizeClientOptions(options) {
|
|
|
43
43
|
const headers = (0, headers_js_1.mergeHeaders)({
|
|
44
44
|
"X-Fern-Language": "JavaScript",
|
|
45
45
|
"X-Fern-SDK-Name": "@kard-financial/sdk",
|
|
46
|
-
"X-Fern-SDK-Version": "12.
|
|
47
|
-
"User-Agent": "@kard-financial/sdk/12.
|
|
46
|
+
"X-Fern-SDK-Version": "12.4.0",
|
|
47
|
+
"User-Agent": "@kard-financial/sdk/12.4.0",
|
|
48
48
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
49
49
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
50
50
|
}, options === null || options === void 0 ? void 0 : options.headers);
|
|
@@ -54,7 +54,7 @@ function normalizeClientOptionsWithAuth(options) {
|
|
|
54
54
|
var _a;
|
|
55
55
|
const normalized = normalizeClientOptions(options);
|
|
56
56
|
const normalizedWithNoOpAuthProvider = withNoOpAuthProvider(normalized);
|
|
57
|
-
(_a = normalized.authProvider) !== null && _a !== void 0 ? _a : (normalized.authProvider =
|
|
57
|
+
(_a = normalized.authProvider) !== null && _a !== void 0 ? _a : (normalized.authProvider = OAuthAuthProvider_js_1.OAuthAuthProvider.createInstance(normalizedWithNoOpAuthProvider));
|
|
58
58
|
return normalized;
|
|
59
59
|
}
|
|
60
60
|
function withNoOpAuthProvider(options) {
|
package/dist/cjs/Client.d.ts
CHANGED
|
@@ -6,9 +6,9 @@ import { TransactionsClient } from "./api/resources/transactions/client/Client.j
|
|
|
6
6
|
import { UsersClient } from "./api/resources/users/client/Client.js";
|
|
7
7
|
import type { BaseClientOptions, BaseRequestOptions } from "./BaseClient.js";
|
|
8
8
|
import { type NormalizedClientOptionsWithAuth } from "./BaseClient.js";
|
|
9
|
+
import * as core from "./core/index.js";
|
|
9
10
|
export declare namespace KardApiClient {
|
|
10
|
-
|
|
11
|
-
}
|
|
11
|
+
type Options = BaseClientOptions;
|
|
12
12
|
interface RequestOptions extends BaseRequestOptions {
|
|
13
13
|
}
|
|
14
14
|
}
|
|
@@ -27,4 +27,15 @@ export declare class KardApiClient {
|
|
|
27
27
|
get ping(): PingClient;
|
|
28
28
|
get transactions(): TransactionsClient;
|
|
29
29
|
get users(): UsersClient;
|
|
30
|
+
/**
|
|
31
|
+
* Make a passthrough request using the SDK's configured auth, retry, logging, etc.
|
|
32
|
+
* This is useful for making requests to endpoints not yet supported in the SDK.
|
|
33
|
+
* The input can be a URL string, URL object, or Request object. Relative paths are resolved against the configured base URL.
|
|
34
|
+
*
|
|
35
|
+
* @param {Request | string | URL} input - The URL, path, or Request object.
|
|
36
|
+
* @param {RequestInit} init - Standard fetch RequestInit options.
|
|
37
|
+
* @param {core.PassthroughRequest.RequestOptions} requestOptions - Per-request overrides (timeout, retries, headers, abort signal).
|
|
38
|
+
* @returns {Promise<Response>} A standard Response object.
|
|
39
|
+
*/
|
|
40
|
+
fetch(input: Request | string | URL, init?: RequestInit, requestOptions?: core.PassthroughRequest.RequestOptions): Promise<Response>;
|
|
30
41
|
}
|
package/dist/cjs/Client.js
CHANGED
|
@@ -1,5 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
36
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
+
});
|
|
44
|
+
};
|
|
3
45
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
46
|
exports.KardApiClient = void 0;
|
|
5
47
|
const Client_js_1 = require("./api/resources/auth/client/Client.js");
|
|
@@ -9,6 +51,7 @@ const Client_js_4 = require("./api/resources/ping/client/Client.js");
|
|
|
9
51
|
const Client_js_5 = require("./api/resources/transactions/client/Client.js");
|
|
10
52
|
const Client_js_6 = require("./api/resources/users/client/Client.js");
|
|
11
53
|
const BaseClient_js_1 = require("./BaseClient.js");
|
|
54
|
+
const core = __importStar(require("./core/index.js"));
|
|
12
55
|
class KardApiClient {
|
|
13
56
|
constructor(options = {}) {
|
|
14
57
|
this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
|
|
@@ -37,5 +80,29 @@ class KardApiClient {
|
|
|
37
80
|
var _a;
|
|
38
81
|
return ((_a = this._users) !== null && _a !== void 0 ? _a : (this._users = new Client_js_6.UsersClient(this._options)));
|
|
39
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Make a passthrough request using the SDK's configured auth, retry, logging, etc.
|
|
85
|
+
* This is useful for making requests to endpoints not yet supported in the SDK.
|
|
86
|
+
* The input can be a URL string, URL object, or Request object. Relative paths are resolved against the configured base URL.
|
|
87
|
+
*
|
|
88
|
+
* @param {Request | string | URL} input - The URL, path, or Request object.
|
|
89
|
+
* @param {RequestInit} init - Standard fetch RequestInit options.
|
|
90
|
+
* @param {core.PassthroughRequest.RequestOptions} requestOptions - Per-request overrides (timeout, retries, headers, abort signal).
|
|
91
|
+
* @returns {Promise<Response>} A standard Response object.
|
|
92
|
+
*/
|
|
93
|
+
fetch(input, init, requestOptions) {
|
|
94
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
+
var _a;
|
|
96
|
+
return core.makePassthroughRequest(input, init, {
|
|
97
|
+
baseUrl: (_a = this._options.baseUrl) !== null && _a !== void 0 ? _a : this._options.environment,
|
|
98
|
+
headers: this._options.headers,
|
|
99
|
+
timeoutInSeconds: this._options.timeoutInSeconds,
|
|
100
|
+
maxRetries: this._options.maxRetries,
|
|
101
|
+
fetch: this._options.fetch,
|
|
102
|
+
logging: this._options.logging,
|
|
103
|
+
getAuthHeaders: () => __awaiter(this, void 0, void 0, function* () { return (yield this._options.authProvider.getAuthRequest()).headers; }),
|
|
104
|
+
}, requestOptions);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
40
107
|
}
|
|
41
108
|
exports.KardApiClient = KardApiClient;
|
|
@@ -3,8 +3,7 @@ import { type NormalizedClientOptions } from "../../../../BaseClient.js";
|
|
|
3
3
|
import * as core from "../../../../core/index.js";
|
|
4
4
|
import type * as KardApi from "../../../index.js";
|
|
5
5
|
export declare namespace AuthClient {
|
|
6
|
-
|
|
7
|
-
}
|
|
6
|
+
type Options = BaseClientOptions;
|
|
8
7
|
interface RequestOptions extends BaseRequestOptions {
|
|
9
8
|
}
|
|
10
9
|
}
|
|
@@ -59,6 +59,7 @@ const BaseClient_js_1 = require("../../../../BaseClient.js");
|
|
|
59
59
|
const headers_js_1 = require("../../../../core/headers.js");
|
|
60
60
|
const core = __importStar(require("../../../../core/index.js"));
|
|
61
61
|
const environments = __importStar(require("../../../../environments.js"));
|
|
62
|
+
const handleNonStatusCodeError_js_1 = require("../../../../errors/handleNonStatusCodeError.js");
|
|
62
63
|
const errors = __importStar(require("../../../../errors/index.js"));
|
|
63
64
|
class AuthClient {
|
|
64
65
|
constructor(options = {}) {
|
|
@@ -81,9 +82,7 @@ class AuthClient {
|
|
|
81
82
|
return __awaiter(this, void 0, void 0, function* () {
|
|
82
83
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
83
84
|
const { "X-Kard-Target-Issuer": xKardTargetIssuer } = request, _body = __rest(request, ["X-Kard-Target-Issuer"]);
|
|
84
|
-
const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({
|
|
85
|
-
"X-Kard-Target-Issuer": xKardTargetIssuer != null ? xKardTargetIssuer : undefined,
|
|
86
|
-
}), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
85
|
+
const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ "X-Kard-Target-Issuer": xKardTargetIssuer }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
87
86
|
const _response = yield core.fetcher({
|
|
88
87
|
url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.KardApiEnvironment.Production, "/v2/auth/token"),
|
|
89
88
|
method: "POST",
|
|
@@ -108,26 +107,7 @@ class AuthClient {
|
|
|
108
107
|
rawResponse: _response.rawResponse,
|
|
109
108
|
});
|
|
110
109
|
}
|
|
111
|
-
|
|
112
|
-
case "non-json":
|
|
113
|
-
throw new errors.KardApiError({
|
|
114
|
-
statusCode: _response.error.statusCode,
|
|
115
|
-
body: _response.error.rawBody,
|
|
116
|
-
rawResponse: _response.rawResponse,
|
|
117
|
-
});
|
|
118
|
-
case "body-is-null":
|
|
119
|
-
throw new errors.KardApiError({
|
|
120
|
-
statusCode: _response.error.statusCode,
|
|
121
|
-
rawResponse: _response.rawResponse,
|
|
122
|
-
});
|
|
123
|
-
case "timeout":
|
|
124
|
-
throw new errors.KardApiTimeoutError("Timeout exceeded when calling POST /v2/auth/token.");
|
|
125
|
-
case "unknown":
|
|
126
|
-
throw new errors.KardApiError({
|
|
127
|
-
message: _response.error.errorMessage,
|
|
128
|
-
rawResponse: _response.rawResponse,
|
|
129
|
-
});
|
|
130
|
-
}
|
|
110
|
+
return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "POST", "/v2/auth/token");
|
|
131
111
|
});
|
|
132
112
|
}
|
|
133
113
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.AuthClient = void 0;
|
|
19
|
+
var Client_js_1 = require("./client/Client.js");
|
|
20
|
+
Object.defineProperty(exports, "AuthClient", { enumerable: true, get: function () { return Client_js_1.AuthClient; } });
|
|
21
|
+
__exportStar(require("./client/index.js"), exports);
|
|
@@ -44,7 +44,11 @@ class ConflictError extends errors.KardApiError {
|
|
|
44
44
|
body: body,
|
|
45
45
|
rawResponse: rawResponse,
|
|
46
46
|
});
|
|
47
|
-
Object.setPrototypeOf(this,
|
|
47
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
48
|
+
if (Error.captureStackTrace) {
|
|
49
|
+
Error.captureStackTrace(this, this.constructor);
|
|
50
|
+
}
|
|
51
|
+
this.name = this.constructor.name;
|
|
48
52
|
}
|
|
49
53
|
}
|
|
50
54
|
exports.ConflictError = ConflictError;
|
|
@@ -44,7 +44,11 @@ class DoesNotExistError extends errors.KardApiError {
|
|
|
44
44
|
body: body,
|
|
45
45
|
rawResponse: rawResponse,
|
|
46
46
|
});
|
|
47
|
-
Object.setPrototypeOf(this,
|
|
47
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
48
|
+
if (Error.captureStackTrace) {
|
|
49
|
+
Error.captureStackTrace(this, this.constructor);
|
|
50
|
+
}
|
|
51
|
+
this.name = this.constructor.name;
|
|
48
52
|
}
|
|
49
53
|
}
|
|
50
54
|
exports.DoesNotExistError = DoesNotExistError;
|
|
@@ -44,7 +44,11 @@ class ForbiddenError extends errors.KardApiError {
|
|
|
44
44
|
body: body,
|
|
45
45
|
rawResponse: rawResponse,
|
|
46
46
|
});
|
|
47
|
-
Object.setPrototypeOf(this,
|
|
47
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
48
|
+
if (Error.captureStackTrace) {
|
|
49
|
+
Error.captureStackTrace(this, this.constructor);
|
|
50
|
+
}
|
|
51
|
+
this.name = this.constructor.name;
|
|
48
52
|
}
|
|
49
53
|
}
|
|
50
54
|
exports.ForbiddenError = ForbiddenError;
|
|
@@ -44,7 +44,11 @@ class InternalServerError extends errors.KardApiError {
|
|
|
44
44
|
body: body,
|
|
45
45
|
rawResponse: rawResponse,
|
|
46
46
|
});
|
|
47
|
-
Object.setPrototypeOf(this,
|
|
47
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
48
|
+
if (Error.captureStackTrace) {
|
|
49
|
+
Error.captureStackTrace(this, this.constructor);
|
|
50
|
+
}
|
|
51
|
+
this.name = this.constructor.name;
|
|
48
52
|
}
|
|
49
53
|
}
|
|
50
54
|
exports.InternalServerError = InternalServerError;
|
|
@@ -44,7 +44,11 @@ class InvalidRequest extends errors.KardApiError {
|
|
|
44
44
|
body: body,
|
|
45
45
|
rawResponse: rawResponse,
|
|
46
46
|
});
|
|
47
|
-
Object.setPrototypeOf(this,
|
|
47
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
48
|
+
if (Error.captureStackTrace) {
|
|
49
|
+
Error.captureStackTrace(this, this.constructor);
|
|
50
|
+
}
|
|
51
|
+
this.name = this.constructor.name;
|
|
48
52
|
}
|
|
49
53
|
}
|
|
50
54
|
exports.InvalidRequest = InvalidRequest;
|
|
@@ -44,7 +44,11 @@ class UnauthorizedError extends errors.KardApiError {
|
|
|
44
44
|
body: body,
|
|
45
45
|
rawResponse: rawResponse,
|
|
46
46
|
});
|
|
47
|
-
Object.setPrototypeOf(this,
|
|
47
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
48
|
+
if (Error.captureStackTrace) {
|
|
49
|
+
Error.captureStackTrace(this, this.constructor);
|
|
50
|
+
}
|
|
51
|
+
this.name = this.constructor.name;
|
|
48
52
|
}
|
|
49
53
|
}
|
|
50
54
|
exports.UnauthorizedError = UnauthorizedError;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./index.js";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
__exportStar(require("./index.js"), exports);
|
|
@@ -7,7 +7,7 @@ export interface ErrorObject {
|
|
|
7
7
|
/** Description of the specific occurance of the error */
|
|
8
8
|
detail: string;
|
|
9
9
|
/** An object containing a reference to the primary source of the error */
|
|
10
|
-
source?: KardApi.ErrorSource;
|
|
10
|
+
source?: KardApi.ErrorSource | undefined;
|
|
11
11
|
/** The id of the resource which caused the error. Always returned for multi-status errors. */
|
|
12
|
-
id?: string;
|
|
12
|
+
id?: string | undefined;
|
|
13
13
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export interface ErrorSource {
|
|
2
2
|
/** A JSON pointer to the value in the request document that caused the error */
|
|
3
|
-
pointer?: string;
|
|
3
|
+
pointer?: string | undefined;
|
|
4
4
|
/** A string indicating which URI query parameter caused the error */
|
|
5
|
-
parameter?: string;
|
|
5
|
+
parameter?: string | undefined;
|
|
6
6
|
/** A string indicating the name of a single request header which caused the error */
|
|
7
|
-
header?: string;
|
|
7
|
+
header?: string | undefined;
|
|
8
8
|
}
|
|
@@ -3,8 +3,7 @@ import { type NormalizedClientOptionsWithAuth } from "../../../../BaseClient.js"
|
|
|
3
3
|
import * as core from "../../../../core/index.js";
|
|
4
4
|
import * as KardApi from "../../../index.js";
|
|
5
5
|
export declare namespace FilesClient {
|
|
6
|
-
|
|
7
|
-
}
|
|
6
|
+
type Options = BaseClientOptions;
|
|
8
7
|
interface RequestOptions extends BaseRequestOptions {
|
|
9
8
|
}
|
|
10
9
|
}
|
|
@@ -48,6 +48,7 @@ const BaseClient_js_1 = require("../../../../BaseClient.js");
|
|
|
48
48
|
const headers_js_1 = require("../../../../core/headers.js");
|
|
49
49
|
const core = __importStar(require("../../../../core/index.js"));
|
|
50
50
|
const environments = __importStar(require("../../../../environments.js"));
|
|
51
|
+
const handleNonStatusCodeError_js_1 = require("../../../../errors/handleNonStatusCodeError.js");
|
|
51
52
|
const errors = __importStar(require("../../../../errors/index.js"));
|
|
52
53
|
const KardApi = __importStar(require("../../../index.js"));
|
|
53
54
|
class FilesClient {
|
|
@@ -85,33 +86,15 @@ class FilesClient {
|
|
|
85
86
|
return __awaiter(this, arguments, void 0, function* (organizationId, request = {}, requestOptions) {
|
|
86
87
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
87
88
|
const { "filter[dateFrom]": filterDateFrom, "filter[dateTo]": filterDateTo, "filter[fileType]": filterFileType, "page[size]": pageSize, "page[after]": pageAfter, "page[before]": pageBefore, sort, } = request;
|
|
88
|
-
const _queryParams = {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
if (pageSize != null) {
|
|
99
|
-
_queryParams["page[size]"] = pageSize.toString();
|
|
100
|
-
}
|
|
101
|
-
if (pageAfter != null) {
|
|
102
|
-
_queryParams["page[after]"] = pageAfter;
|
|
103
|
-
}
|
|
104
|
-
if (pageBefore != null) {
|
|
105
|
-
_queryParams["page[before]"] = pageBefore;
|
|
106
|
-
}
|
|
107
|
-
if (sort != null) {
|
|
108
|
-
if (Array.isArray(sort)) {
|
|
109
|
-
_queryParams.sort = sort.map((item) => item);
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
_queryParams.sort = sort;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
89
|
+
const _queryParams = {
|
|
90
|
+
"filter[dateFrom]": filterDateFrom,
|
|
91
|
+
"filter[dateTo]": filterDateTo,
|
|
92
|
+
"filter[fileType]": filterFileType != null ? filterFileType : undefined,
|
|
93
|
+
"page[size]": pageSize,
|
|
94
|
+
"page[after]": pageAfter,
|
|
95
|
+
"page[before]": pageBefore,
|
|
96
|
+
sort: Array.isArray(sort) ? sort.map((item) => item) : sort != null ? sort : undefined,
|
|
97
|
+
};
|
|
115
98
|
const _authRequest = yield this._options.authProvider.getAuthRequest();
|
|
116
99
|
const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
|
|
117
100
|
const _response = yield core.fetcher({
|
|
@@ -146,26 +129,7 @@ class FilesClient {
|
|
|
146
129
|
});
|
|
147
130
|
}
|
|
148
131
|
}
|
|
149
|
-
|
|
150
|
-
case "non-json":
|
|
151
|
-
throw new errors.KardApiError({
|
|
152
|
-
statusCode: _response.error.statusCode,
|
|
153
|
-
body: _response.error.rawBody,
|
|
154
|
-
rawResponse: _response.rawResponse,
|
|
155
|
-
});
|
|
156
|
-
case "body-is-null":
|
|
157
|
-
throw new errors.KardApiError({
|
|
158
|
-
statusCode: _response.error.statusCode,
|
|
159
|
-
rawResponse: _response.rawResponse,
|
|
160
|
-
});
|
|
161
|
-
case "timeout":
|
|
162
|
-
throw new errors.KardApiTimeoutError("Timeout exceeded when calling GET /v2/issuers/{organizationId}/files/metadata.");
|
|
163
|
-
case "unknown":
|
|
164
|
-
throw new errors.KardApiError({
|
|
165
|
-
message: _response.error.errorMessage,
|
|
166
|
-
rawResponse: _response.rawResponse,
|
|
167
|
-
});
|
|
168
|
-
}
|
|
132
|
+
return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/v2/issuers/{organizationId}/files/metadata");
|
|
169
133
|
});
|
|
170
134
|
}
|
|
171
135
|
}
|