@deeprelay/sdk 0.1.0 → 0.1.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/.openapi-generator/FILES +10 -0
- package/README.md +10 -2
- package/dist/apis/BillingApi.d.ts +38 -0
- package/dist/apis/BillingApi.js +96 -0
- package/dist/apis/InferenceApi.d.ts +18 -0
- package/dist/apis/InferenceApi.js +51 -0
- package/dist/esm/apis/BillingApi.d.ts +38 -0
- package/dist/esm/apis/BillingApi.js +96 -0
- package/dist/esm/apis/InferenceApi.d.ts +18 -0
- package/dist/esm/apis/InferenceApi.js +51 -0
- package/dist/esm/models/InferencePreflight.d.ts +92 -0
- package/dist/esm/models/InferencePreflight.js +86 -0
- package/dist/esm/models/SubscriptionCheckoutRequest.d.ts +45 -0
- package/dist/esm/models/SubscriptionCheckoutRequest.js +45 -0
- package/dist/esm/models/SubscriptionCheckoutSession.d.ts +45 -0
- package/dist/esm/models/SubscriptionCheckoutSession.js +52 -0
- package/dist/esm/models/SubscriptionPortalRequest.d.ts +32 -0
- package/dist/esm/models/SubscriptionPortalRequest.js +41 -0
- package/dist/esm/models/SubscriptionPortalSession.d.ts +32 -0
- package/dist/esm/models/SubscriptionPortalSession.js +43 -0
- package/dist/esm/models/index.d.ts +5 -0
- package/dist/esm/models/index.js +5 -0
- package/dist/esm/runtime.js +1 -1
- package/dist/models/InferencePreflight.d.ts +92 -0
- package/dist/models/InferencePreflight.js +94 -0
- package/dist/models/SubscriptionCheckoutRequest.d.ts +45 -0
- package/dist/models/SubscriptionCheckoutRequest.js +52 -0
- package/dist/models/SubscriptionCheckoutSession.d.ts +45 -0
- package/dist/models/SubscriptionCheckoutSession.js +59 -0
- package/dist/models/SubscriptionPortalRequest.d.ts +32 -0
- package/dist/models/SubscriptionPortalRequest.js +48 -0
- package/dist/models/SubscriptionPortalSession.d.ts +32 -0
- package/dist/models/SubscriptionPortalSession.js +50 -0
- package/dist/models/index.d.ts +5 -0
- package/dist/models/index.js +5 -0
- package/dist/runtime.js +1 -1
- package/docs/BillingApi.md +154 -0
- package/docs/InferenceApi.md +74 -0
- package/docs/InferencePreflight.md +47 -0
- package/docs/SubscriptionCheckoutRequest.md +39 -0
- package/docs/SubscriptionCheckoutSession.md +38 -0
- package/docs/SubscriptionPortalRequest.md +35 -0
- package/docs/SubscriptionPortalSession.md +34 -0
- package/package.json +1 -1
- package/src/apis/BillingApi.ts +128 -0
- package/src/apis/InferenceApi.ts +67 -0
- package/src/models/InferencePreflight.ts +147 -0
- package/src/models/SubscriptionCheckoutRequest.ts +82 -0
- package/src/models/SubscriptionCheckoutSession.ts +92 -0
- package/src/models/SubscriptionPortalRequest.ts +65 -0
- package/src/models/SubscriptionPortalSession.ts +66 -0
- package/src/models/index.ts +5 -0
- package/src/runtime.ts +1 -1
package/docs/BillingApi.md
CHANGED
|
@@ -5,6 +5,8 @@ All URIs are relative to *https://api.deeprelay.ai/v1*
|
|
|
5
5
|
| Method | HTTP request | Description |
|
|
6
6
|
|------------- | ------------- | -------------|
|
|
7
7
|
| [**createCryptoDeposit**](BillingApi.md#createcryptodepositoperation) | **POST** /billing/deposits/crypto | Create a stablecoin deposit |
|
|
8
|
+
| [**createSubscriptionCheckout**](BillingApi.md#createsubscriptioncheckout) | **POST** /billing/subscription/checkout | Start a subscription checkout session |
|
|
9
|
+
| [**createSubscriptionPortal**](BillingApi.md#createsubscriptionportal) | **POST** /billing/subscription/portal | Open the billing portal to cancel or manage the subscription |
|
|
8
10
|
| [**getBalance**](BillingApi.md#getbalance) | **GET** /billing/balance | Get the org credit balance |
|
|
9
11
|
| [**getDeposit**](BillingApi.md#getdeposit) | **GET** /billing/deposits/{id} | Get one stablecoin deposit |
|
|
10
12
|
| [**getSpendingLimit**](BillingApi.md#getspendinglimit) | **GET** /billing/spending-limit | Get the org spending limit |
|
|
@@ -91,6 +93,158 @@ example().catch(console.error);
|
|
|
91
93
|
[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)
|
|
92
94
|
|
|
93
95
|
|
|
96
|
+
## createSubscriptionCheckout
|
|
97
|
+
|
|
98
|
+
> SubscriptionCheckoutSession createSubscriptionCheckout(subscriptionCheckoutRequest)
|
|
99
|
+
|
|
100
|
+
Start a subscription checkout session
|
|
101
|
+
|
|
102
|
+
Opens a hosted checkout session for the flat tier and returns its URL. Requires the `billing:write` scope AND organization-admin privileges — subscribing spends organization money. This endpoint does NOT subscribe anyone. Checkout is a hosted page that needs a browser and a card, so the caller\'s job is to put the returned URL in front of a human. The subscription becomes active when payment completes, which is not synchronous with this call: poll `/billing/subscription` to confirm. `success_url` and `cancel_url` are optional and fall back to the deployment\'s configured redirects, which is what lets a command-line client start a purchase without having any URLs of its own. An empty request body is valid and means \"use every default\". `plan_key`, when sent, pins the plan the client DISPLAYED: an unknown key is a 400 rather than a silent purchase of a different tier. Today there is one tier, so the only accepted value is its key — but sending it is the forward-compatible choice. One flat tier means at most one subscription per organization: a second checkout while an entitling subscription exists is a 409.
|
|
103
|
+
|
|
104
|
+
### Example
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
import {
|
|
108
|
+
Configuration,
|
|
109
|
+
BillingApi,
|
|
110
|
+
} from '@deeprelay/sdk';
|
|
111
|
+
import type { CreateSubscriptionCheckoutRequest } from '@deeprelay/sdk';
|
|
112
|
+
|
|
113
|
+
async function example() {
|
|
114
|
+
console.log("🚀 Testing @deeprelay/sdk SDK...");
|
|
115
|
+
const config = new Configuration({
|
|
116
|
+
// Configure HTTP bearer authorization: bearerAuth
|
|
117
|
+
accessToken: "YOUR BEARER TOKEN",
|
|
118
|
+
});
|
|
119
|
+
const api = new BillingApi(config);
|
|
120
|
+
|
|
121
|
+
const body = {
|
|
122
|
+
// SubscriptionCheckoutRequest (optional)
|
|
123
|
+
subscriptionCheckoutRequest: ...,
|
|
124
|
+
} satisfies CreateSubscriptionCheckoutRequest;
|
|
125
|
+
|
|
126
|
+
try {
|
|
127
|
+
const data = await api.createSubscriptionCheckout(body);
|
|
128
|
+
console.log(data);
|
|
129
|
+
} catch (error) {
|
|
130
|
+
console.error(error);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Run the test
|
|
135
|
+
example().catch(console.error);
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Parameters
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
| Name | Type | Description | Notes |
|
|
142
|
+
|------------- | ------------- | ------------- | -------------|
|
|
143
|
+
| **subscriptionCheckoutRequest** | [SubscriptionCheckoutRequest](SubscriptionCheckoutRequest.md) | | [Optional] |
|
|
144
|
+
|
|
145
|
+
### Return type
|
|
146
|
+
|
|
147
|
+
[**SubscriptionCheckoutSession**](SubscriptionCheckoutSession.md)
|
|
148
|
+
|
|
149
|
+
### Authorization
|
|
150
|
+
|
|
151
|
+
[bearerAuth](../README.md#bearerAuth)
|
|
152
|
+
|
|
153
|
+
### HTTP request headers
|
|
154
|
+
|
|
155
|
+
- **Content-Type**: `application/json`
|
|
156
|
+
- **Accept**: `application/json`, `application/problem+json`
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
### HTTP response details
|
|
160
|
+
| Status code | Description | Response headers |
|
|
161
|
+
|-------------|-------------|------------------|
|
|
162
|
+
| **200** | OK | - |
|
|
163
|
+
| **403** | Not an organization admin | - |
|
|
164
|
+
| **409** | The organization already has an active subscription | - |
|
|
165
|
+
| **503** | Subscription billing is not configured on this deployment | - |
|
|
166
|
+
| **429** | Rate limit exceeded (RFC 7807). Retry-After header indicates seconds to wait. | * Retry-After - Seconds the client should wait before retrying. <br> |
|
|
167
|
+
| **0** | Error response (RFC 7807) | - |
|
|
168
|
+
|
|
169
|
+
[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
## createSubscriptionPortal
|
|
173
|
+
|
|
174
|
+
> SubscriptionPortalSession createSubscriptionPortal(subscriptionPortalRequest)
|
|
175
|
+
|
|
176
|
+
Open the billing portal to cancel or manage the subscription
|
|
177
|
+
|
|
178
|
+
Returns a URL for the hosted billing portal: where a customer cancels the subscription, resumes one they cancelled, changes payment method, or downloads invoices. Requires the `billing:write` scope AND organization-admin privileges. Cancellation lives here rather than on its own endpoint because it is one surface with the rest of the billing lifecycle. The common reason a subscription is about to lapse is a declined card, and the fix for that is a new card, not a cancellation — sending a customer somewhere that can only cancel would lose renewals. Cancelling in the portal ends the subscription at the close of the current period; coverage continues until then and `/billing/subscription` reports `cancel_at_period_end: true`. An organization that has never paid for anything gets 404: there is no billing account to manage, and this endpoint deliberately does not create one as a side effect of looking.
|
|
179
|
+
|
|
180
|
+
### Example
|
|
181
|
+
|
|
182
|
+
```ts
|
|
183
|
+
import {
|
|
184
|
+
Configuration,
|
|
185
|
+
BillingApi,
|
|
186
|
+
} from '@deeprelay/sdk';
|
|
187
|
+
import type { CreateSubscriptionPortalRequest } from '@deeprelay/sdk';
|
|
188
|
+
|
|
189
|
+
async function example() {
|
|
190
|
+
console.log("🚀 Testing @deeprelay/sdk SDK...");
|
|
191
|
+
const config = new Configuration({
|
|
192
|
+
// Configure HTTP bearer authorization: bearerAuth
|
|
193
|
+
accessToken: "YOUR BEARER TOKEN",
|
|
194
|
+
});
|
|
195
|
+
const api = new BillingApi(config);
|
|
196
|
+
|
|
197
|
+
const body = {
|
|
198
|
+
// SubscriptionPortalRequest (optional)
|
|
199
|
+
subscriptionPortalRequest: ...,
|
|
200
|
+
} satisfies CreateSubscriptionPortalRequest;
|
|
201
|
+
|
|
202
|
+
try {
|
|
203
|
+
const data = await api.createSubscriptionPortal(body);
|
|
204
|
+
console.log(data);
|
|
205
|
+
} catch (error) {
|
|
206
|
+
console.error(error);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Run the test
|
|
211
|
+
example().catch(console.error);
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Parameters
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
| Name | Type | Description | Notes |
|
|
218
|
+
|------------- | ------------- | ------------- | -------------|
|
|
219
|
+
| **subscriptionPortalRequest** | [SubscriptionPortalRequest](SubscriptionPortalRequest.md) | | [Optional] |
|
|
220
|
+
|
|
221
|
+
### Return type
|
|
222
|
+
|
|
223
|
+
[**SubscriptionPortalSession**](SubscriptionPortalSession.md)
|
|
224
|
+
|
|
225
|
+
### Authorization
|
|
226
|
+
|
|
227
|
+
[bearerAuth](../README.md#bearerAuth)
|
|
228
|
+
|
|
229
|
+
### HTTP request headers
|
|
230
|
+
|
|
231
|
+
- **Content-Type**: `application/json`
|
|
232
|
+
- **Accept**: `application/json`, `application/problem+json`
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
### HTTP response details
|
|
236
|
+
| Status code | Description | Response headers |
|
|
237
|
+
|-------------|-------------|------------------|
|
|
238
|
+
| **200** | OK | - |
|
|
239
|
+
| **403** | Not an organization admin | - |
|
|
240
|
+
| **404** | The organization has no billing account yet | - |
|
|
241
|
+
| **503** | Subscription billing is not configured on this deployment | - |
|
|
242
|
+
| **429** | Rate limit exceeded (RFC 7807). Retry-After header indicates seconds to wait. | * Retry-After - Seconds the client should wait before retrying. <br> |
|
|
243
|
+
| **0** | Error response (RFC 7807) | - |
|
|
244
|
+
|
|
245
|
+
[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)
|
|
246
|
+
|
|
247
|
+
|
|
94
248
|
## getBalance
|
|
95
249
|
|
|
96
250
|
> Balance getBalance()
|
package/docs/InferenceApi.md
CHANGED
|
@@ -12,6 +12,7 @@ All URIs are relative to *https://api.deeprelay.ai/v1*
|
|
|
12
12
|
| [**getModel**](InferenceApi.md#getmodel) | **GET** /models/{id} | Get a specific model (OpenAI-compatible) |
|
|
13
13
|
| [**getVideo**](InferenceApi.md#getvideo) | **GET** /videos/{id} | Get a video generation job |
|
|
14
14
|
| [**getVideoContent**](InferenceApi.md#getvideocontent) | **GET** /videos/{id}/content | Download a completed video artifact |
|
|
15
|
+
| [**inferencePreflight**](InferenceApi.md#inferencepreflight) | **GET** /inference/preflight | Check whether a model request would be served, and at whose expense |
|
|
15
16
|
| [**listModels**](InferenceApi.md#listmodels) | **GET** /models | List available models (OpenAI-compatible) |
|
|
16
17
|
| [**listVideos**](InferenceApi.md#listvideos) | **GET** /videos | List video generation jobs |
|
|
17
18
|
|
|
@@ -638,6 +639,79 @@ example().catch(console.error);
|
|
|
638
639
|
[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)
|
|
639
640
|
|
|
640
641
|
|
|
642
|
+
## inferencePreflight
|
|
643
|
+
|
|
644
|
+
> InferencePreflight inferencePreflight(model)
|
|
645
|
+
|
|
646
|
+
Check whether a model request would be served, and at whose expense
|
|
647
|
+
|
|
648
|
+
Answers \"what happens if I call this model right now?\" before the call is made: whether the plan covers the model, whether the organization is subscribed, and whether there is credit to pay if it is not covered. Requires the `serverless:read` scope. Nothing is sent, counted, charged, or reserved. The verdict is computed from the state of the SAME gates that judge the real request — plan coverage, subscription entitlement, remaining plan quota, credit balance and self-set spending caps — so the advice cannot drift from enforcement. It is deliberately NOT a dry run: no per-request cost estimate is quoted, because that figure changes with every prompt and quoting it would invite clients to cache it. The gates consulted depend on the model\'s MODALITY, because the endpoints do not all meet the same ones. Chat, embeddings and image requests meet the full gate (balance, then the organization\'s opt-in daily cap, then its monthly cap). Video creation meets only the balance check, so an organization past its own spending cap but holding credit is reported as fundable for video — which is what the video endpoint will in fact do. Predicting the strictest gate rather than the applicable one would make this endpoint refuse requests the API accepts. The same is true of the plan: video creation does not run the subscription gate, so `plan_covered` is false for a video model even if an operator has placed it on the plan\'s covered list. That is a deliberate divergence from the same-named field on `/v1/models`, which reports the platform\'s configuration. Here it means \"the plan covers this REQUEST\" — describing what will happen is the entire job of a preflight. One caveat on \"read-only\": resolving the balance creates the organization\'s balance row if it has never had one (idempotent, org-scoped, and the same row the first real request would create). Nothing else is written. The case this exists for is `warn` / `not_plan_covered`. A subscriber calling a model outside the plan IS served and IS charged pay-as-you-go, and nothing in the response to that request says so — the first signal used to be the invoice. `funded` is a boolean and never a figure. This route is on the inference read scope, so it must not disclose the organization\'s balance; use `/billing/balance` for the number. Failure posture is the opposite of the request gate\'s: any gate that cannot be read degrades the verdict toward `ok`, never toward `block`. A false `block` would stop a customer whose request would have succeeded, while a false `ok` costs them one honest error from the real call.
|
|
649
|
+
|
|
650
|
+
### Example
|
|
651
|
+
|
|
652
|
+
```ts
|
|
653
|
+
import {
|
|
654
|
+
Configuration,
|
|
655
|
+
InferenceApi,
|
|
656
|
+
} from '@deeprelay/sdk';
|
|
657
|
+
import type { InferencePreflightRequest } from '@deeprelay/sdk';
|
|
658
|
+
|
|
659
|
+
async function example() {
|
|
660
|
+
console.log("🚀 Testing @deeprelay/sdk SDK...");
|
|
661
|
+
const config = new Configuration({
|
|
662
|
+
// Configure HTTP bearer authorization: bearerAuth
|
|
663
|
+
accessToken: "YOUR BEARER TOKEN",
|
|
664
|
+
});
|
|
665
|
+
const api = new InferenceApi(config);
|
|
666
|
+
|
|
667
|
+
const body = {
|
|
668
|
+
// string | Model id or alias, optionally with a `:economy` tier suffix. It is resolved through the catalog exactly as the inference endpoints resolve it, so an alias and a tier view answer for the model that would actually serve.
|
|
669
|
+
model: model_example,
|
|
670
|
+
} satisfies InferencePreflightRequest;
|
|
671
|
+
|
|
672
|
+
try {
|
|
673
|
+
const data = await api.inferencePreflight(body);
|
|
674
|
+
console.log(data);
|
|
675
|
+
} catch (error) {
|
|
676
|
+
console.error(error);
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
// Run the test
|
|
681
|
+
example().catch(console.error);
|
|
682
|
+
```
|
|
683
|
+
|
|
684
|
+
### Parameters
|
|
685
|
+
|
|
686
|
+
|
|
687
|
+
| Name | Type | Description | Notes |
|
|
688
|
+
|------------- | ------------- | ------------- | -------------|
|
|
689
|
+
| **model** | `string` | Model id or alias, optionally with a `:economy` tier suffix. It is resolved through the catalog exactly as the inference endpoints resolve it, so an alias and a tier view answer for the model that would actually serve. | [Defaults to `undefined`] |
|
|
690
|
+
|
|
691
|
+
### Return type
|
|
692
|
+
|
|
693
|
+
[**InferencePreflight**](InferencePreflight.md)
|
|
694
|
+
|
|
695
|
+
### Authorization
|
|
696
|
+
|
|
697
|
+
[bearerAuth](../README.md#bearerAuth)
|
|
698
|
+
|
|
699
|
+
### HTTP request headers
|
|
700
|
+
|
|
701
|
+
- **Content-Type**: Not defined
|
|
702
|
+
- **Accept**: `application/json`
|
|
703
|
+
|
|
704
|
+
|
|
705
|
+
### HTTP response details
|
|
706
|
+
| Status code | Description | Response headers |
|
|
707
|
+
|-------------|-------------|------------------|
|
|
708
|
+
| **200** | OK | - |
|
|
709
|
+
| **404** | Model or resource not found (OpenAI error envelope). | - |
|
|
710
|
+
| **429** | Rate limit exceeded (OpenAI error envelope). Retry-After header indicates seconds to wait. | * Retry-After - Seconds the client should wait before retrying. <br> |
|
|
711
|
+
|
|
712
|
+
[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)
|
|
713
|
+
|
|
714
|
+
|
|
641
715
|
## listModels
|
|
642
716
|
|
|
643
717
|
> ModelList listModels(modality)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
|
|
2
|
+
# InferencePreflight
|
|
3
|
+
|
|
4
|
+
The verdict for one (organization, model) pair: what would happen if the model were invoked right now.
|
|
5
|
+
|
|
6
|
+
## Properties
|
|
7
|
+
|
|
8
|
+
Name | Type
|
|
9
|
+
------------ | -------------
|
|
10
|
+
`model` | string
|
|
11
|
+
`verdict` | string
|
|
12
|
+
`reason` | string
|
|
13
|
+
`message` | string
|
|
14
|
+
`planCovered` | boolean
|
|
15
|
+
`subscribed` | boolean
|
|
16
|
+
`funded` | boolean
|
|
17
|
+
|
|
18
|
+
## Example
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
import type { InferencePreflight } from '@deeprelay/sdk'
|
|
22
|
+
|
|
23
|
+
// TODO: Update the object below with actual values
|
|
24
|
+
const example = {
|
|
25
|
+
"model": null,
|
|
26
|
+
"verdict": null,
|
|
27
|
+
"reason": null,
|
|
28
|
+
"message": null,
|
|
29
|
+
"planCovered": null,
|
|
30
|
+
"subscribed": null,
|
|
31
|
+
"funded": null,
|
|
32
|
+
} satisfies InferencePreflight
|
|
33
|
+
|
|
34
|
+
console.log(example)
|
|
35
|
+
|
|
36
|
+
// Convert the instance to a JSON string
|
|
37
|
+
const exampleJSON: string = JSON.stringify(example)
|
|
38
|
+
console.log(exampleJSON)
|
|
39
|
+
|
|
40
|
+
// Parse the JSON string back to an object
|
|
41
|
+
const exampleParsed = JSON.parse(exampleJSON) as InferencePreflight
|
|
42
|
+
console.log(exampleParsed)
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)
|
|
46
|
+
|
|
47
|
+
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
|
|
2
|
+
# SubscriptionCheckoutRequest
|
|
3
|
+
|
|
4
|
+
Optional overrides for a checkout mint. Every field has a deployment default, so an empty body is the normal call.
|
|
5
|
+
|
|
6
|
+
## Properties
|
|
7
|
+
|
|
8
|
+
Name | Type
|
|
9
|
+
------------ | -------------
|
|
10
|
+
`successUrl` | string
|
|
11
|
+
`cancelUrl` | string
|
|
12
|
+
`planKey` | string
|
|
13
|
+
|
|
14
|
+
## Example
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
import type { SubscriptionCheckoutRequest } from '@deeprelay/sdk'
|
|
18
|
+
|
|
19
|
+
// TODO: Update the object below with actual values
|
|
20
|
+
const example = {
|
|
21
|
+
"successUrl": null,
|
|
22
|
+
"cancelUrl": null,
|
|
23
|
+
"planKey": null,
|
|
24
|
+
} satisfies SubscriptionCheckoutRequest
|
|
25
|
+
|
|
26
|
+
console.log(example)
|
|
27
|
+
|
|
28
|
+
// Convert the instance to a JSON string
|
|
29
|
+
const exampleJSON: string = JSON.stringify(example)
|
|
30
|
+
console.log(exampleJSON)
|
|
31
|
+
|
|
32
|
+
// Parse the JSON string back to an object
|
|
33
|
+
const exampleParsed = JSON.parse(exampleJSON) as SubscriptionCheckoutRequest
|
|
34
|
+
console.log(exampleParsed)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)
|
|
38
|
+
|
|
39
|
+
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
|
|
2
|
+
# SubscriptionCheckoutSession
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
Name | Type
|
|
8
|
+
------------ | -------------
|
|
9
|
+
`checkoutUrl` | string
|
|
10
|
+
`sessionId` | string
|
|
11
|
+
`plan` | [SubscriptionPlan](SubscriptionPlan.md)
|
|
12
|
+
|
|
13
|
+
## Example
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import type { SubscriptionCheckoutSession } from '@deeprelay/sdk'
|
|
17
|
+
|
|
18
|
+
// TODO: Update the object below with actual values
|
|
19
|
+
const example = {
|
|
20
|
+
"checkoutUrl": null,
|
|
21
|
+
"sessionId": null,
|
|
22
|
+
"plan": null,
|
|
23
|
+
} satisfies SubscriptionCheckoutSession
|
|
24
|
+
|
|
25
|
+
console.log(example)
|
|
26
|
+
|
|
27
|
+
// Convert the instance to a JSON string
|
|
28
|
+
const exampleJSON: string = JSON.stringify(example)
|
|
29
|
+
console.log(exampleJSON)
|
|
30
|
+
|
|
31
|
+
// Parse the JSON string back to an object
|
|
32
|
+
const exampleParsed = JSON.parse(exampleJSON) as SubscriptionCheckoutSession
|
|
33
|
+
console.log(exampleParsed)
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)
|
|
37
|
+
|
|
38
|
+
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
|
|
2
|
+
# SubscriptionPortalRequest
|
|
3
|
+
|
|
4
|
+
Optional overrides for a billing-portal mint.
|
|
5
|
+
|
|
6
|
+
## Properties
|
|
7
|
+
|
|
8
|
+
Name | Type
|
|
9
|
+
------------ | -------------
|
|
10
|
+
`returnUrl` | string
|
|
11
|
+
|
|
12
|
+
## Example
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
import type { SubscriptionPortalRequest } from '@deeprelay/sdk'
|
|
16
|
+
|
|
17
|
+
// TODO: Update the object below with actual values
|
|
18
|
+
const example = {
|
|
19
|
+
"returnUrl": null,
|
|
20
|
+
} satisfies SubscriptionPortalRequest
|
|
21
|
+
|
|
22
|
+
console.log(example)
|
|
23
|
+
|
|
24
|
+
// Convert the instance to a JSON string
|
|
25
|
+
const exampleJSON: string = JSON.stringify(example)
|
|
26
|
+
console.log(exampleJSON)
|
|
27
|
+
|
|
28
|
+
// Parse the JSON string back to an object
|
|
29
|
+
const exampleParsed = JSON.parse(exampleJSON) as SubscriptionPortalRequest
|
|
30
|
+
console.log(exampleParsed)
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)
|
|
34
|
+
|
|
35
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
|
|
2
|
+
# SubscriptionPortalSession
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
Name | Type
|
|
8
|
+
------------ | -------------
|
|
9
|
+
`portalUrl` | string
|
|
10
|
+
|
|
11
|
+
## Example
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import type { SubscriptionPortalSession } from '@deeprelay/sdk'
|
|
15
|
+
|
|
16
|
+
// TODO: Update the object below with actual values
|
|
17
|
+
const example = {
|
|
18
|
+
"portalUrl": null,
|
|
19
|
+
} satisfies SubscriptionPortalSession
|
|
20
|
+
|
|
21
|
+
console.log(example)
|
|
22
|
+
|
|
23
|
+
// Convert the instance to a JSON string
|
|
24
|
+
const exampleJSON: string = JSON.stringify(example)
|
|
25
|
+
console.log(exampleJSON)
|
|
26
|
+
|
|
27
|
+
// Parse the JSON string back to an object
|
|
28
|
+
const exampleParsed = JSON.parse(exampleJSON) as SubscriptionPortalSession
|
|
29
|
+
console.log(exampleParsed)
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)
|
|
33
|
+
|
|
34
|
+
|
package/package.json
CHANGED
package/src/apis/BillingApi.ts
CHANGED
|
@@ -48,6 +48,26 @@ import {
|
|
|
48
48
|
SubscriptionFromJSON,
|
|
49
49
|
SubscriptionToJSON,
|
|
50
50
|
} from '../models/Subscription';
|
|
51
|
+
import {
|
|
52
|
+
type SubscriptionCheckoutRequest,
|
|
53
|
+
SubscriptionCheckoutRequestFromJSON,
|
|
54
|
+
SubscriptionCheckoutRequestToJSON,
|
|
55
|
+
} from '../models/SubscriptionCheckoutRequest';
|
|
56
|
+
import {
|
|
57
|
+
type SubscriptionCheckoutSession,
|
|
58
|
+
SubscriptionCheckoutSessionFromJSON,
|
|
59
|
+
SubscriptionCheckoutSessionToJSON,
|
|
60
|
+
} from '../models/SubscriptionCheckoutSession';
|
|
61
|
+
import {
|
|
62
|
+
type SubscriptionPortalRequest,
|
|
63
|
+
SubscriptionPortalRequestFromJSON,
|
|
64
|
+
SubscriptionPortalRequestToJSON,
|
|
65
|
+
} from '../models/SubscriptionPortalRequest';
|
|
66
|
+
import {
|
|
67
|
+
type SubscriptionPortalSession,
|
|
68
|
+
SubscriptionPortalSessionFromJSON,
|
|
69
|
+
SubscriptionPortalSessionToJSON,
|
|
70
|
+
} from '../models/SubscriptionPortalSession';
|
|
51
71
|
import {
|
|
52
72
|
type UpdateSpendingLimitRequest,
|
|
53
73
|
UpdateSpendingLimitRequestFromJSON,
|
|
@@ -58,6 +78,14 @@ export interface CreateCryptoDepositOperationRequest {
|
|
|
58
78
|
createCryptoDepositRequest: CreateCryptoDepositRequest;
|
|
59
79
|
}
|
|
60
80
|
|
|
81
|
+
export interface CreateSubscriptionCheckoutRequest {
|
|
82
|
+
subscriptionCheckoutRequest?: SubscriptionCheckoutRequest;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface CreateSubscriptionPortalRequest {
|
|
86
|
+
subscriptionPortalRequest?: SubscriptionPortalRequest;
|
|
87
|
+
}
|
|
88
|
+
|
|
61
89
|
export interface GetDepositRequest {
|
|
62
90
|
id: string;
|
|
63
91
|
}
|
|
@@ -128,6 +156,106 @@ export class BillingApi extends runtime.BaseAPI {
|
|
|
128
156
|
return await response.value();
|
|
129
157
|
}
|
|
130
158
|
|
|
159
|
+
/**
|
|
160
|
+
* Creates request options for createSubscriptionCheckout without sending the request
|
|
161
|
+
*/
|
|
162
|
+
async createSubscriptionCheckoutRequestOpts(requestParameters: CreateSubscriptionCheckoutRequest): Promise<runtime.RequestOpts> {
|
|
163
|
+
const queryParameters: any = {};
|
|
164
|
+
|
|
165
|
+
const headerParameters: runtime.HTTPHeaders = {};
|
|
166
|
+
|
|
167
|
+
headerParameters['Content-Type'] = 'application/json';
|
|
168
|
+
|
|
169
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
170
|
+
const token = this.configuration.accessToken;
|
|
171
|
+
const tokenString = await token("bearerAuth", []);
|
|
172
|
+
|
|
173
|
+
if (tokenString) {
|
|
174
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
let urlPath = `/billing/subscription/checkout`;
|
|
179
|
+
|
|
180
|
+
return {
|
|
181
|
+
path: urlPath,
|
|
182
|
+
method: 'POST',
|
|
183
|
+
headers: headerParameters,
|
|
184
|
+
query: queryParameters,
|
|
185
|
+
body: SubscriptionCheckoutRequestToJSON(requestParameters['subscriptionCheckoutRequest']),
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Opens a hosted checkout session for the flat tier and returns its URL. Requires the `billing:write` scope AND organization-admin privileges — subscribing spends organization money. This endpoint does NOT subscribe anyone. Checkout is a hosted page that needs a browser and a card, so the caller\'s job is to put the returned URL in front of a human. The subscription becomes active when payment completes, which is not synchronous with this call: poll `/billing/subscription` to confirm. `success_url` and `cancel_url` are optional and fall back to the deployment\'s configured redirects, which is what lets a command-line client start a purchase without having any URLs of its own. An empty request body is valid and means \"use every default\". `plan_key`, when sent, pins the plan the client DISPLAYED: an unknown key is a 400 rather than a silent purchase of a different tier. Today there is one tier, so the only accepted value is its key — but sending it is the forward-compatible choice. One flat tier means at most one subscription per organization: a second checkout while an entitling subscription exists is a 409.
|
|
191
|
+
* Start a subscription checkout session
|
|
192
|
+
*/
|
|
193
|
+
async createSubscriptionCheckoutRaw(requestParameters: CreateSubscriptionCheckoutRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<SubscriptionCheckoutSession>> {
|
|
194
|
+
const requestOptions = await this.createSubscriptionCheckoutRequestOpts(requestParameters);
|
|
195
|
+
const response = await this.request(requestOptions, initOverrides);
|
|
196
|
+
|
|
197
|
+
return new runtime.JSONApiResponse(response, (jsonValue) => SubscriptionCheckoutSessionFromJSON(jsonValue));
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Opens a hosted checkout session for the flat tier and returns its URL. Requires the `billing:write` scope AND organization-admin privileges — subscribing spends organization money. This endpoint does NOT subscribe anyone. Checkout is a hosted page that needs a browser and a card, so the caller\'s job is to put the returned URL in front of a human. The subscription becomes active when payment completes, which is not synchronous with this call: poll `/billing/subscription` to confirm. `success_url` and `cancel_url` are optional and fall back to the deployment\'s configured redirects, which is what lets a command-line client start a purchase without having any URLs of its own. An empty request body is valid and means \"use every default\". `plan_key`, when sent, pins the plan the client DISPLAYED: an unknown key is a 400 rather than a silent purchase of a different tier. Today there is one tier, so the only accepted value is its key — but sending it is the forward-compatible choice. One flat tier means at most one subscription per organization: a second checkout while an entitling subscription exists is a 409.
|
|
202
|
+
* Start a subscription checkout session
|
|
203
|
+
*/
|
|
204
|
+
async createSubscriptionCheckout(requestParameters: CreateSubscriptionCheckoutRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<SubscriptionCheckoutSession> {
|
|
205
|
+
const response = await this.createSubscriptionCheckoutRaw(requestParameters, initOverrides);
|
|
206
|
+
return await response.value();
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Creates request options for createSubscriptionPortal without sending the request
|
|
211
|
+
*/
|
|
212
|
+
async createSubscriptionPortalRequestOpts(requestParameters: CreateSubscriptionPortalRequest): Promise<runtime.RequestOpts> {
|
|
213
|
+
const queryParameters: any = {};
|
|
214
|
+
|
|
215
|
+
const headerParameters: runtime.HTTPHeaders = {};
|
|
216
|
+
|
|
217
|
+
headerParameters['Content-Type'] = 'application/json';
|
|
218
|
+
|
|
219
|
+
if (this.configuration && this.configuration.accessToken) {
|
|
220
|
+
const token = this.configuration.accessToken;
|
|
221
|
+
const tokenString = await token("bearerAuth", []);
|
|
222
|
+
|
|
223
|
+
if (tokenString) {
|
|
224
|
+
headerParameters["Authorization"] = `Bearer ${tokenString}`;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
let urlPath = `/billing/subscription/portal`;
|
|
229
|
+
|
|
230
|
+
return {
|
|
231
|
+
path: urlPath,
|
|
232
|
+
method: 'POST',
|
|
233
|
+
headers: headerParameters,
|
|
234
|
+
query: queryParameters,
|
|
235
|
+
body: SubscriptionPortalRequestToJSON(requestParameters['subscriptionPortalRequest']),
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Returns a URL for the hosted billing portal: where a customer cancels the subscription, resumes one they cancelled, changes payment method, or downloads invoices. Requires the `billing:write` scope AND organization-admin privileges. Cancellation lives here rather than on its own endpoint because it is one surface with the rest of the billing lifecycle. The common reason a subscription is about to lapse is a declined card, and the fix for that is a new card, not a cancellation — sending a customer somewhere that can only cancel would lose renewals. Cancelling in the portal ends the subscription at the close of the current period; coverage continues until then and `/billing/subscription` reports `cancel_at_period_end: true`. An organization that has never paid for anything gets 404: there is no billing account to manage, and this endpoint deliberately does not create one as a side effect of looking.
|
|
241
|
+
* Open the billing portal to cancel or manage the subscription
|
|
242
|
+
*/
|
|
243
|
+
async createSubscriptionPortalRaw(requestParameters: CreateSubscriptionPortalRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<SubscriptionPortalSession>> {
|
|
244
|
+
const requestOptions = await this.createSubscriptionPortalRequestOpts(requestParameters);
|
|
245
|
+
const response = await this.request(requestOptions, initOverrides);
|
|
246
|
+
|
|
247
|
+
return new runtime.JSONApiResponse(response, (jsonValue) => SubscriptionPortalSessionFromJSON(jsonValue));
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Returns a URL for the hosted billing portal: where a customer cancels the subscription, resumes one they cancelled, changes payment method, or downloads invoices. Requires the `billing:write` scope AND organization-admin privileges. Cancellation lives here rather than on its own endpoint because it is one surface with the rest of the billing lifecycle. The common reason a subscription is about to lapse is a declined card, and the fix for that is a new card, not a cancellation — sending a customer somewhere that can only cancel would lose renewals. Cancelling in the portal ends the subscription at the close of the current period; coverage continues until then and `/billing/subscription` reports `cancel_at_period_end: true`. An organization that has never paid for anything gets 404: there is no billing account to manage, and this endpoint deliberately does not create one as a side effect of looking.
|
|
252
|
+
* Open the billing portal to cancel or manage the subscription
|
|
253
|
+
*/
|
|
254
|
+
async createSubscriptionPortal(requestParameters: CreateSubscriptionPortalRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<SubscriptionPortalSession> {
|
|
255
|
+
const response = await this.createSubscriptionPortalRaw(requestParameters, initOverrides);
|
|
256
|
+
return await response.value();
|
|
257
|
+
}
|
|
258
|
+
|
|
131
259
|
/**
|
|
132
260
|
* Creates request options for getBalance without sending the request
|
|
133
261
|
*/
|