@predictorsdk/client 0.3.0 → 0.3.1
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/dist/Client.d.ts +3 -1
- package/dist/Client.js +25 -7
- package/dist/api/errors/BadGatewayError.d.ts +1 -0
- package/dist/api/errors/BadRequestError.d.ts +1 -0
- package/dist/api/errors/ForbiddenError.d.ts +1 -0
- package/dist/api/errors/PaymentRequiredError.d.ts +7 -0
- package/dist/api/errors/{InternalServerError.js → PaymentRequiredError.js} +3 -3
- package/dist/api/errors/ServiceUnavailableError.d.ts +1 -0
- package/dist/api/errors/TooManyRequestsError.d.ts +1 -0
- package/dist/api/errors/UnauthorizedError.d.ts +1 -0
- package/dist/api/errors/index.d.ts +1 -1
- package/dist/api/errors/index.js +1 -1
- package/dist/api/types/PaymentRequiredErrorAction.d.ts +6 -0
- package/dist/api/types/PaymentRequiredErrorAction.js +6 -0
- package/dist/api/types/PaymentRequiredErrorBody.d.ts +20 -0
- package/dist/api/types/PaymentRequiredErrorBody.js +2 -0
- package/dist/api/types/index.d.ts +2 -0
- package/dist/api/types/index.js +2 -0
- package/dist/serialization/types/PaymentRequiredErrorAction.d.ts +7 -0
- package/dist/serialization/types/PaymentRequiredErrorAction.js +3 -0
- package/dist/serialization/types/PaymentRequiredErrorBody.d.ts +17 -0
- package/dist/serialization/types/PaymentRequiredErrorBody.js +13 -0
- package/dist/serialization/types/index.d.ts +2 -0
- package/dist/serialization/types/index.js +2 -0
- package/package.json +1 -1
- package/dist/api/errors/InternalServerError.d.ts +0 -6
package/dist/Client.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export declare class PredictorSDKClient {
|
|
|
18
18
|
*
|
|
19
19
|
* @throws {@link PredictorSDK.BadRequestError}
|
|
20
20
|
* @throws {@link PredictorSDK.UnauthorizedError}
|
|
21
|
+
* @throws {@link PredictorSDK.PaymentRequiredError}
|
|
21
22
|
* @throws {@link PredictorSDK.ForbiddenError}
|
|
22
23
|
* @throws {@link PredictorSDK.TooManyRequestsError}
|
|
23
24
|
* @throws {@link PredictorSDK.ServiceUnavailableError}
|
|
@@ -35,9 +36,9 @@ export declare class PredictorSDKClient {
|
|
|
35
36
|
*
|
|
36
37
|
* @throws {@link PredictorSDK.BadRequestError}
|
|
37
38
|
* @throws {@link PredictorSDK.UnauthorizedError}
|
|
39
|
+
* @throws {@link PredictorSDK.PaymentRequiredError}
|
|
38
40
|
* @throws {@link PredictorSDK.ForbiddenError}
|
|
39
41
|
* @throws {@link PredictorSDK.TooManyRequestsError}
|
|
40
|
-
* @throws {@link PredictorSDK.InternalServerError}
|
|
41
42
|
* @throws {@link PredictorSDK.ServiceUnavailableError}
|
|
42
43
|
*
|
|
43
44
|
* @example
|
|
@@ -53,6 +54,7 @@ export declare class PredictorSDKClient {
|
|
|
53
54
|
*
|
|
54
55
|
* @throws {@link PredictorSDK.BadRequestError}
|
|
55
56
|
* @throws {@link PredictorSDK.UnauthorizedError}
|
|
57
|
+
* @throws {@link PredictorSDK.PaymentRequiredError}
|
|
56
58
|
* @throws {@link PredictorSDK.ForbiddenError}
|
|
57
59
|
* @throws {@link PredictorSDK.TooManyRequestsError}
|
|
58
60
|
* @throws {@link PredictorSDK.BadGatewayError}
|
package/dist/Client.js
CHANGED
|
@@ -20,6 +20,7 @@ export class PredictorSDKClient {
|
|
|
20
20
|
*
|
|
21
21
|
* @throws {@link PredictorSDK.BadRequestError}
|
|
22
22
|
* @throws {@link PredictorSDK.UnauthorizedError}
|
|
23
|
+
* @throws {@link PredictorSDK.PaymentRequiredError}
|
|
23
24
|
* @throws {@link PredictorSDK.ForbiddenError}
|
|
24
25
|
* @throws {@link PredictorSDK.TooManyRequestsError}
|
|
25
26
|
* @throws {@link PredictorSDK.ServiceUnavailableError}
|
|
@@ -86,6 +87,14 @@ export class PredictorSDKClient {
|
|
|
86
87
|
skipValidation: true,
|
|
87
88
|
breadcrumbsPrefix: ["response"],
|
|
88
89
|
}), _response.rawResponse);
|
|
90
|
+
case 402:
|
|
91
|
+
throw new PredictorSDK.PaymentRequiredError(serializers.PaymentRequiredErrorBody.parseOrThrow(_response.error.body, {
|
|
92
|
+
unrecognizedObjectKeys: "passthrough",
|
|
93
|
+
allowUnrecognizedUnionMembers: true,
|
|
94
|
+
allowUnrecognizedEnumValues: true,
|
|
95
|
+
skipValidation: true,
|
|
96
|
+
breadcrumbsPrefix: ["response"],
|
|
97
|
+
}), _response.rawResponse);
|
|
89
98
|
case 403:
|
|
90
99
|
throw new PredictorSDK.ForbiddenError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
|
|
91
100
|
unrecognizedObjectKeys: "passthrough",
|
|
@@ -128,9 +137,9 @@ export class PredictorSDKClient {
|
|
|
128
137
|
*
|
|
129
138
|
* @throws {@link PredictorSDK.BadRequestError}
|
|
130
139
|
* @throws {@link PredictorSDK.UnauthorizedError}
|
|
140
|
+
* @throws {@link PredictorSDK.PaymentRequiredError}
|
|
131
141
|
* @throws {@link PredictorSDK.ForbiddenError}
|
|
132
142
|
* @throws {@link PredictorSDK.TooManyRequestsError}
|
|
133
|
-
* @throws {@link PredictorSDK.InternalServerError}
|
|
134
143
|
* @throws {@link PredictorSDK.ServiceUnavailableError}
|
|
135
144
|
*
|
|
136
145
|
* @example
|
|
@@ -190,24 +199,24 @@ export class PredictorSDKClient {
|
|
|
190
199
|
skipValidation: true,
|
|
191
200
|
breadcrumbsPrefix: ["response"],
|
|
192
201
|
}), _response.rawResponse);
|
|
193
|
-
case
|
|
194
|
-
throw new PredictorSDK.
|
|
202
|
+
case 402:
|
|
203
|
+
throw new PredictorSDK.PaymentRequiredError(serializers.PaymentRequiredErrorBody.parseOrThrow(_response.error.body, {
|
|
195
204
|
unrecognizedObjectKeys: "passthrough",
|
|
196
205
|
allowUnrecognizedUnionMembers: true,
|
|
197
206
|
allowUnrecognizedEnumValues: true,
|
|
198
207
|
skipValidation: true,
|
|
199
208
|
breadcrumbsPrefix: ["response"],
|
|
200
209
|
}), _response.rawResponse);
|
|
201
|
-
case
|
|
202
|
-
throw new PredictorSDK.
|
|
210
|
+
case 403:
|
|
211
|
+
throw new PredictorSDK.ForbiddenError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
|
|
203
212
|
unrecognizedObjectKeys: "passthrough",
|
|
204
213
|
allowUnrecognizedUnionMembers: true,
|
|
205
214
|
allowUnrecognizedEnumValues: true,
|
|
206
215
|
skipValidation: true,
|
|
207
216
|
breadcrumbsPrefix: ["response"],
|
|
208
217
|
}), _response.rawResponse);
|
|
209
|
-
case
|
|
210
|
-
throw new PredictorSDK.
|
|
218
|
+
case 429:
|
|
219
|
+
throw new PredictorSDK.TooManyRequestsError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
|
|
211
220
|
unrecognizedObjectKeys: "passthrough",
|
|
212
221
|
allowUnrecognizedUnionMembers: true,
|
|
213
222
|
allowUnrecognizedEnumValues: true,
|
|
@@ -240,6 +249,7 @@ export class PredictorSDKClient {
|
|
|
240
249
|
*
|
|
241
250
|
* @throws {@link PredictorSDK.BadRequestError}
|
|
242
251
|
* @throws {@link PredictorSDK.UnauthorizedError}
|
|
252
|
+
* @throws {@link PredictorSDK.PaymentRequiredError}
|
|
243
253
|
* @throws {@link PredictorSDK.ForbiddenError}
|
|
244
254
|
* @throws {@link PredictorSDK.TooManyRequestsError}
|
|
245
255
|
* @throws {@link PredictorSDK.BadGatewayError}
|
|
@@ -307,6 +317,14 @@ export class PredictorSDKClient {
|
|
|
307
317
|
skipValidation: true,
|
|
308
318
|
breadcrumbsPrefix: ["response"],
|
|
309
319
|
}), _response.rawResponse);
|
|
320
|
+
case 402:
|
|
321
|
+
throw new PredictorSDK.PaymentRequiredError(serializers.PaymentRequiredErrorBody.parseOrThrow(_response.error.body, {
|
|
322
|
+
unrecognizedObjectKeys: "passthrough",
|
|
323
|
+
allowUnrecognizedUnionMembers: true,
|
|
324
|
+
allowUnrecognizedEnumValues: true,
|
|
325
|
+
skipValidation: true,
|
|
326
|
+
breadcrumbsPrefix: ["response"],
|
|
327
|
+
}), _response.rawResponse);
|
|
310
328
|
case 403:
|
|
311
329
|
throw new PredictorSDK.ForbiddenError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
|
|
312
330
|
unrecognizedObjectKeys: "passthrough",
|
|
@@ -2,5 +2,6 @@ import type * as core from "../../core/index.js";
|
|
|
2
2
|
import * as errors from "../../errors/index.js";
|
|
3
3
|
import type * as PredictorSDK from "../index.js";
|
|
4
4
|
export declare class BadGatewayError extends errors.PredictorSDKError {
|
|
5
|
+
readonly body: PredictorSDK.ErrorResponse;
|
|
5
6
|
constructor(body: PredictorSDK.ErrorResponse, rawResponse?: core.RawResponse);
|
|
6
7
|
}
|
|
@@ -2,5 +2,6 @@ import type * as core from "../../core/index.js";
|
|
|
2
2
|
import * as errors from "../../errors/index.js";
|
|
3
3
|
import type * as PredictorSDK from "../index.js";
|
|
4
4
|
export declare class BadRequestError extends errors.PredictorSDKError {
|
|
5
|
+
readonly body: PredictorSDK.ErrorResponse;
|
|
5
6
|
constructor(body: PredictorSDK.ErrorResponse, rawResponse?: core.RawResponse);
|
|
6
7
|
}
|
|
@@ -2,5 +2,6 @@ import type * as core from "../../core/index.js";
|
|
|
2
2
|
import * as errors from "../../errors/index.js";
|
|
3
3
|
import type * as PredictorSDK from "../index.js";
|
|
4
4
|
export declare class ForbiddenError extends errors.PredictorSDKError {
|
|
5
|
+
readonly body: PredictorSDK.ErrorResponse;
|
|
5
6
|
constructor(body: PredictorSDK.ErrorResponse, rawResponse?: core.RawResponse);
|
|
6
7
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type * as core from "../../core/index.js";
|
|
2
|
+
import * as errors from "../../errors/index.js";
|
|
3
|
+
import type * as PredictorSDK from "../index.js";
|
|
4
|
+
export declare class PaymentRequiredError extends errors.PredictorSDKError {
|
|
5
|
+
readonly body: PredictorSDK.PaymentRequiredErrorBody;
|
|
6
|
+
constructor(body: PredictorSDK.PaymentRequiredErrorBody, rawResponse?: core.RawResponse);
|
|
7
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// This file was auto-generated by Fern from our API Definition.
|
|
2
2
|
import * as errors from "../../errors/index.js";
|
|
3
|
-
export class
|
|
3
|
+
export class PaymentRequiredError extends errors.PredictorSDKError {
|
|
4
4
|
constructor(body, rawResponse) {
|
|
5
5
|
super({
|
|
6
|
-
message: "
|
|
7
|
-
statusCode:
|
|
6
|
+
message: "PaymentRequiredError",
|
|
7
|
+
statusCode: 402,
|
|
8
8
|
body: body,
|
|
9
9
|
rawResponse: rawResponse,
|
|
10
10
|
});
|
|
@@ -2,5 +2,6 @@ import type * as core from "../../core/index.js";
|
|
|
2
2
|
import * as errors from "../../errors/index.js";
|
|
3
3
|
import type * as PredictorSDK from "../index.js";
|
|
4
4
|
export declare class ServiceUnavailableError extends errors.PredictorSDKError {
|
|
5
|
+
readonly body: PredictorSDK.ErrorResponse;
|
|
5
6
|
constructor(body: PredictorSDK.ErrorResponse, rawResponse?: core.RawResponse);
|
|
6
7
|
}
|
|
@@ -2,5 +2,6 @@ import type * as core from "../../core/index.js";
|
|
|
2
2
|
import * as errors from "../../errors/index.js";
|
|
3
3
|
import type * as PredictorSDK from "../index.js";
|
|
4
4
|
export declare class TooManyRequestsError extends errors.PredictorSDKError {
|
|
5
|
+
readonly body: PredictorSDK.ErrorResponse;
|
|
5
6
|
constructor(body: PredictorSDK.ErrorResponse, rawResponse?: core.RawResponse);
|
|
6
7
|
}
|
|
@@ -2,5 +2,6 @@ import type * as core from "../../core/index.js";
|
|
|
2
2
|
import * as errors from "../../errors/index.js";
|
|
3
3
|
import type * as PredictorSDK from "../index.js";
|
|
4
4
|
export declare class UnauthorizedError extends errors.PredictorSDKError {
|
|
5
|
+
readonly body: PredictorSDK.ErrorResponse;
|
|
5
6
|
constructor(body: PredictorSDK.ErrorResponse, rawResponse?: core.RawResponse);
|
|
6
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from "./BadGatewayError.js";
|
|
2
2
|
export * from "./BadRequestError.js";
|
|
3
3
|
export * from "./ForbiddenError.js";
|
|
4
|
-
export * from "./
|
|
4
|
+
export * from "./PaymentRequiredError.js";
|
|
5
5
|
export * from "./ServiceUnavailableError.js";
|
|
6
6
|
export * from "./TooManyRequestsError.js";
|
|
7
7
|
export * from "./UnauthorizedError.js";
|
package/dist/api/errors/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from "./BadGatewayError.js";
|
|
2
2
|
export * from "./BadRequestError.js";
|
|
3
3
|
export * from "./ForbiddenError.js";
|
|
4
|
-
export * from "./
|
|
4
|
+
export * from "./PaymentRequiredError.js";
|
|
5
5
|
export * from "./ServiceUnavailableError.js";
|
|
6
6
|
export * from "./TooManyRequestsError.js";
|
|
7
7
|
export * from "./UnauthorizedError.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Recommended client action for this 402. */
|
|
2
|
+
export declare const PaymentRequiredErrorAction: {
|
|
3
|
+
readonly UpgradePlan: "upgrade_plan";
|
|
4
|
+
readonly ResolvePayment: "resolve_payment";
|
|
5
|
+
};
|
|
6
|
+
export type PaymentRequiredErrorAction = (typeof PaymentRequiredErrorAction)[keyof typeof PaymentRequiredErrorAction];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type * as PredictorSDK from "../index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Error body returned with HTTP 402. The `action` discriminator lets clients route to the correct recovery flow: `upgrade_plan` means the caller is on a lower tier than the endpoint requires, or the Free monthly allowance is exhausted; `resolve_payment` means the caller had a paid subscription that entered a payment-recovery state (past_due/unpaid/paused/incomplete) and the backend has already downgraded them to Free — the fix is in the billing portal, not a new purchase. `required_tier` / `current_tier` are always populated; `included_requests_per_month` and `current_period_requests` are only set when a Free caller hits the monthly allowance.
|
|
4
|
+
*/
|
|
5
|
+
export interface PaymentRequiredErrorBody {
|
|
6
|
+
error: string;
|
|
7
|
+
/** Additional detail about the error. */
|
|
8
|
+
message?: string;
|
|
9
|
+
statusCode: number;
|
|
10
|
+
/** Recommended client action for this 402. */
|
|
11
|
+
action: PredictorSDK.PaymentRequiredErrorAction;
|
|
12
|
+
/** Billing tier that would satisfy the gate (e.g. `starter`, `pro`, `business`, `enterprise`). */
|
|
13
|
+
requiredTier: string;
|
|
14
|
+
/** Billing tier currently associated with the caller. */
|
|
15
|
+
currentTier: string;
|
|
16
|
+
/** Monthly Free-tier allowance. Present only when the 402 is caused by the Free cap. */
|
|
17
|
+
includedRequestsPerMonth?: number;
|
|
18
|
+
/** Requests the Free caller has made in the current calendar month. Present only when the 402 is caused by the Free cap. */
|
|
19
|
+
currentPeriodRequests?: number;
|
|
20
|
+
}
|
|
@@ -3,6 +3,8 @@ export * from "./CryptoPricesResponse.js";
|
|
|
3
3
|
export * from "./ErrorResponse.js";
|
|
4
4
|
export * from "./MarketsListResponse.js";
|
|
5
5
|
export * from "./PaginationBlock.js";
|
|
6
|
+
export * from "./PaymentRequiredErrorAction.js";
|
|
7
|
+
export * from "./PaymentRequiredErrorBody.js";
|
|
6
8
|
export * from "./PlatformMarket.js";
|
|
7
9
|
export * from "./PlatformMarketPlatform.js";
|
|
8
10
|
export * from "./SportsMatchingResponse.js";
|
package/dist/api/types/index.js
CHANGED
|
@@ -3,6 +3,8 @@ export * from "./CryptoPricesResponse.js";
|
|
|
3
3
|
export * from "./ErrorResponse.js";
|
|
4
4
|
export * from "./MarketsListResponse.js";
|
|
5
5
|
export * from "./PaginationBlock.js";
|
|
6
|
+
export * from "./PaymentRequiredErrorAction.js";
|
|
7
|
+
export * from "./PaymentRequiredErrorBody.js";
|
|
6
8
|
export * from "./PlatformMarket.js";
|
|
7
9
|
export * from "./PlatformMarketPlatform.js";
|
|
8
10
|
export * from "./SportsMatchingResponse.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type * as PredictorSDK from "../../api/index.js";
|
|
2
|
+
import * as core from "../../core/index.js";
|
|
3
|
+
import type * as serializers from "../index.js";
|
|
4
|
+
export declare const PaymentRequiredErrorAction: core.serialization.Schema<serializers.PaymentRequiredErrorAction.Raw, PredictorSDK.PaymentRequiredErrorAction>;
|
|
5
|
+
export declare namespace PaymentRequiredErrorAction {
|
|
6
|
+
type Raw = "upgrade_plan" | "resolve_payment";
|
|
7
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type * as PredictorSDK from "../../api/index.js";
|
|
2
|
+
import * as core from "../../core/index.js";
|
|
3
|
+
import type * as serializers from "../index.js";
|
|
4
|
+
import { PaymentRequiredErrorAction } from "./PaymentRequiredErrorAction.js";
|
|
5
|
+
export declare const PaymentRequiredErrorBody: core.serialization.ObjectSchema<serializers.PaymentRequiredErrorBody.Raw, PredictorSDK.PaymentRequiredErrorBody>;
|
|
6
|
+
export declare namespace PaymentRequiredErrorBody {
|
|
7
|
+
interface Raw {
|
|
8
|
+
error: string;
|
|
9
|
+
message?: string | null;
|
|
10
|
+
status_code: number;
|
|
11
|
+
action: PaymentRequiredErrorAction.Raw;
|
|
12
|
+
required_tier: string;
|
|
13
|
+
current_tier: string;
|
|
14
|
+
included_requests_per_month?: number | null;
|
|
15
|
+
current_period_requests?: number | null;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
import * as core from "../../core/index.js";
|
|
3
|
+
import { PaymentRequiredErrorAction } from "./PaymentRequiredErrorAction.js";
|
|
4
|
+
export const PaymentRequiredErrorBody = core.serialization.object({
|
|
5
|
+
error: core.serialization.string(),
|
|
6
|
+
message: core.serialization.string().optional(),
|
|
7
|
+
statusCode: core.serialization.property("status_code", core.serialization.number()),
|
|
8
|
+
action: PaymentRequiredErrorAction,
|
|
9
|
+
requiredTier: core.serialization.property("required_tier", core.serialization.string()),
|
|
10
|
+
currentTier: core.serialization.property("current_tier", core.serialization.string()),
|
|
11
|
+
includedRequestsPerMonth: core.serialization.property("included_requests_per_month", core.serialization.number().optional()),
|
|
12
|
+
currentPeriodRequests: core.serialization.property("current_period_requests", core.serialization.number().optional()),
|
|
13
|
+
});
|
|
@@ -3,6 +3,8 @@ export * from "./CryptoPricesResponse.js";
|
|
|
3
3
|
export * from "./ErrorResponse.js";
|
|
4
4
|
export * from "./MarketsListResponse.js";
|
|
5
5
|
export * from "./PaginationBlock.js";
|
|
6
|
+
export * from "./PaymentRequiredErrorAction.js";
|
|
7
|
+
export * from "./PaymentRequiredErrorBody.js";
|
|
6
8
|
export * from "./PlatformMarket.js";
|
|
7
9
|
export * from "./PlatformMarketPlatform.js";
|
|
8
10
|
export * from "./SportsMatchingResponse.js";
|
|
@@ -3,6 +3,8 @@ export * from "./CryptoPricesResponse.js";
|
|
|
3
3
|
export * from "./ErrorResponse.js";
|
|
4
4
|
export * from "./MarketsListResponse.js";
|
|
5
5
|
export * from "./PaginationBlock.js";
|
|
6
|
+
export * from "./PaymentRequiredErrorAction.js";
|
|
7
|
+
export * from "./PaymentRequiredErrorBody.js";
|
|
6
8
|
export * from "./PlatformMarket.js";
|
|
7
9
|
export * from "./PlatformMarketPlatform.js";
|
|
8
10
|
export * from "./SportsMatchingResponse.js";
|
package/package.json
CHANGED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type * as core from "../../core/index.js";
|
|
2
|
-
import * as errors from "../../errors/index.js";
|
|
3
|
-
import type * as PredictorSDK from "../index.js";
|
|
4
|
-
export declare class InternalServerError extends errors.PredictorSDKError {
|
|
5
|
-
constructor(body: PredictorSDK.ErrorResponse, rawResponse?: core.RawResponse);
|
|
6
|
-
}
|