@gpt-platform/admin 0.4.2 → 0.4.3

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/index.js CHANGED
@@ -853,7 +853,7 @@ var createClient = (config = {}) => {
853
853
  };
854
854
 
855
855
  // src/version.ts
856
- var SDK_VERSION = "0.4.2";
856
+ var SDK_VERSION = "0.4.3";
857
857
  var DEFAULT_API_VERSION = "2026-02-27";
858
858
 
859
859
  // src/base-client.ts
@@ -1370,6 +1370,11 @@ var client = createClient(
1370
1370
  );
1371
1371
 
1372
1372
  // src/_internal/sdk.gen.ts
1373
+ var getAdminWallet = (options) => (options.client ?? client).get({
1374
+ security: [{ scheme: "bearer", type: "http" }],
1375
+ url: "/admin/wallet",
1376
+ ...options
1377
+ });
1373
1378
  var getAdminFieldTemplates = (options) => (options.client ?? client).get({
1374
1379
  security: [{ scheme: "bearer", type: "http" }],
1375
1380
  url: "/admin/field-templates",
@@ -1413,6 +1418,20 @@ var getAdminTrainingSessionsAgentsByAgentIdSessions = (options) => (options.clie
1413
1418
  url: "/admin/training-sessions/agents/{agent_id}/sessions",
1414
1419
  ...options
1415
1420
  });
1421
+ var getAdminTenantPricingOverrides = (options) => (options.client ?? client).get({
1422
+ security: [{ scheme: "bearer", type: "http" }],
1423
+ url: "/admin/tenant-pricing-overrides",
1424
+ ...options
1425
+ });
1426
+ var postAdminTenantPricingOverrides = (options) => (options.client ?? client).post({
1427
+ security: [{ scheme: "bearer", type: "http" }],
1428
+ url: "/admin/tenant-pricing-overrides",
1429
+ ...options,
1430
+ headers: {
1431
+ "Content-Type": "application/vnd.api+json",
1432
+ ...options.headers
1433
+ }
1434
+ });
1416
1435
  var patchAdminApiKeysByIdSetBudget = (options) => (options.client ?? client).patch({
1417
1436
  security: [{ scheme: "bearer", type: "http" }],
1418
1437
  url: "/admin/api-keys/{id}/set-budget",
@@ -1441,11 +1460,39 @@ var getAdminAgentsById = (options) => (options.client ?? client).get({
1441
1460
  url: "/admin/agents/{id}",
1442
1461
  ...options
1443
1462
  });
1463
+ var getAdminSettlements = (options) => (options.client ?? client).get({
1464
+ security: [{ scheme: "bearer", type: "http" }],
1465
+ url: "/admin/settlements",
1466
+ ...options
1467
+ });
1468
+ var postAdminSettlements = (options) => (options.client ?? client).post({
1469
+ security: [{ scheme: "bearer", type: "http" }],
1470
+ url: "/admin/settlements",
1471
+ ...options,
1472
+ headers: {
1473
+ "Content-Type": "application/vnd.api+json",
1474
+ ...options.headers
1475
+ }
1476
+ });
1444
1477
  var postAdminAgentsByIdExport = (options) => (options.client ?? client).post({
1445
1478
  security: [{ scheme: "bearer", type: "http" }],
1446
1479
  url: "/admin/agents/{id}/export",
1447
1480
  ...options
1448
1481
  });
1482
+ var patchAdminApplicationsByIdGrantCredits = (options) => (options.client ?? client).patch({
1483
+ security: [{ scheme: "bearer", type: "http" }],
1484
+ url: "/admin/applications/{id}/grant-credits",
1485
+ ...options,
1486
+ headers: {
1487
+ "Content-Type": "application/vnd.api+json",
1488
+ ...options.headers
1489
+ }
1490
+ });
1491
+ var getAdminSettlementsById = (options) => (options.client ?? client).get({
1492
+ security: [{ scheme: "bearer", type: "http" }],
1493
+ url: "/admin/settlements/{id}",
1494
+ ...options
1495
+ });
1449
1496
  var postAdminAgentsByIdRestoreVersion = (options) => (options.client ?? client).post({
1450
1497
  security: [{ scheme: "bearer", type: "http" }],
1451
1498
  url: "/admin/agents/{id}/restore-version",
@@ -1460,6 +1507,25 @@ var getAdminAgentsByIdTrainingExamples = (options) => (options.client ?? client)
1460
1507
  url: "/admin/agents/{id}/training-examples",
1461
1508
  ...options
1462
1509
  });
1510
+ var deleteAdminTenantPricingOverridesById = (options) => (options.client ?? client).delete({
1511
+ security: [{ scheme: "bearer", type: "http" }],
1512
+ url: "/admin/tenant-pricing-overrides/{id}",
1513
+ ...options
1514
+ });
1515
+ var getAdminTenantPricingOverridesById = (options) => (options.client ?? client).get({
1516
+ security: [{ scheme: "bearer", type: "http" }],
1517
+ url: "/admin/tenant-pricing-overrides/{id}",
1518
+ ...options
1519
+ });
1520
+ var patchAdminTenantPricingOverridesById = (options) => (options.client ?? client).patch({
1521
+ security: [{ scheme: "bearer", type: "http" }],
1522
+ url: "/admin/tenant-pricing-overrides/{id}",
1523
+ ...options,
1524
+ headers: {
1525
+ "Content-Type": "application/vnd.api+json",
1526
+ ...options.headers
1527
+ }
1528
+ });
1463
1529
  var deleteAdminEmailMarketingCampaignsById = (options) => (options.client ?? client).delete({
1464
1530
  security: [{ scheme: "bearer", type: "http" }],
1465
1531
  url: "/admin/email-marketing/campaigns/{id}",
@@ -1603,6 +1669,20 @@ var getAdminFieldTemplatesById = (options) => (options.client ?? client).get({
1603
1669
  url: "/admin/field-templates/{id}",
1604
1670
  ...options
1605
1671
  });
1672
+ var getAdminPlans = (options) => (options.client ?? client).get({
1673
+ security: [{ scheme: "bearer", type: "http" }],
1674
+ url: "/admin/plans",
1675
+ ...options
1676
+ });
1677
+ var postAdminPlans = (options) => (options.client ?? client).post({
1678
+ security: [{ scheme: "bearer", type: "http" }],
1679
+ url: "/admin/plans",
1680
+ ...options,
1681
+ headers: {
1682
+ "Content-Type": "application/vnd.api+json",
1683
+ ...options.headers
1684
+ }
1685
+ });
1606
1686
  var getAdminVoiceSessionsById = (options) => (options.client ?? client).get({
1607
1687
  security: [{ scheme: "bearer", type: "http" }],
1608
1688
  url: "/admin/voice/sessions/{id}",
@@ -1659,6 +1739,20 @@ var getAdminVoiceTranscriptionResultsById = (options) => (options.client ?? clie
1659
1739
  url: "/admin/voice/transcription-results/{id}",
1660
1740
  ...options
1661
1741
  });
1742
+ var getAdminPricingStrategies = (options) => (options.client ?? client).get({
1743
+ security: [{ scheme: "bearer", type: "http" }],
1744
+ url: "/admin/pricing-strategies",
1745
+ ...options
1746
+ });
1747
+ var postAdminPricingStrategies = (options) => (options.client ?? client).post({
1748
+ security: [{ scheme: "bearer", type: "http" }],
1749
+ url: "/admin/pricing-strategies",
1750
+ ...options,
1751
+ headers: {
1752
+ "Content-Type": "application/vnd.api+json",
1753
+ ...options.headers
1754
+ }
1755
+ });
1662
1756
  var getAdminApiKeys = (options) => (options.client ?? client).get({
1663
1757
  security: [{ scheme: "bearer", type: "http" }],
1664
1758
  url: "/admin/api-keys",
@@ -1678,6 +1772,15 @@ var getAdminExtractionDocumentsById = (options) => (options.client ?? client).ge
1678
1772
  url: "/admin/extraction/documents/{id}",
1679
1773
  ...options
1680
1774
  });
1775
+ var patchAdminWalletCredits = (options) => (options.client ?? client).patch({
1776
+ security: [{ scheme: "bearer", type: "http" }],
1777
+ url: "/admin/wallet/credits",
1778
+ ...options,
1779
+ headers: {
1780
+ "Content-Type": "application/vnd.api+json",
1781
+ ...options.headers
1782
+ }
1783
+ });
1681
1784
  var getAdminAccounts = (options) => (options.client ?? client).get({
1682
1785
  security: [{ scheme: "bearer", type: "http" }],
1683
1786
  url: "/admin/accounts",
@@ -1717,6 +1820,15 @@ var getAdminAccountsById = (options) => (options.client ?? client).get({
1717
1820
  url: "/admin/accounts/{id}",
1718
1821
  ...options
1719
1822
  });
1823
+ var patchAdminWalletPlan = (options) => (options.client ?? client).patch({
1824
+ security: [{ scheme: "bearer", type: "http" }],
1825
+ url: "/admin/wallet/plan",
1826
+ ...options,
1827
+ headers: {
1828
+ "Content-Type": "application/vnd.api+json",
1829
+ ...options.headers
1830
+ }
1831
+ });
1720
1832
  var deleteAdminUsersById = (options) => (options.client ?? client).delete({
1721
1833
  security: [{ scheme: "bearer", type: "http" }],
1722
1834
  url: "/admin/users/{id}",
@@ -1756,6 +1868,11 @@ var patchAdminEmailMarketingSenderProfilesById = (options) => (options.client ??
1756
1868
  ...options.headers
1757
1869
  }
1758
1870
  });
1871
+ var getAdminWalletUsage = (options) => (options.client ?? client).get({
1872
+ security: [{ scheme: "bearer", type: "http" }],
1873
+ url: "/admin/wallet/usage",
1874
+ ...options
1875
+ });
1759
1876
  var getAdminAgentVersions = (options) => (options.client ?? client).get({
1760
1877
  security: [{ scheme: "bearer", type: "http" }],
1761
1878
  url: "/admin/agent-versions",
@@ -1889,6 +2006,34 @@ var patchAdminUsersByIdAdmin = (options) => (options.client ?? client).patch({
1889
2006
  ...options.headers
1890
2007
  }
1891
2008
  });
2009
+ var getAdminWholesaleAgreementsById = (options) => (options.client ?? client).get({
2010
+ security: [{ scheme: "bearer", type: "http" }],
2011
+ url: "/admin/wholesale-agreements/{id}",
2012
+ ...options
2013
+ });
2014
+ var patchAdminWholesaleAgreementsById = (options) => (options.client ?? client).patch({
2015
+ security: [{ scheme: "bearer", type: "http" }],
2016
+ url: "/admin/wholesale-agreements/{id}",
2017
+ ...options,
2018
+ headers: {
2019
+ "Content-Type": "application/vnd.api+json",
2020
+ ...options.headers
2021
+ }
2022
+ });
2023
+ var getAdminPricingStrategiesById = (options) => (options.client ?? client).get({
2024
+ security: [{ scheme: "bearer", type: "http" }],
2025
+ url: "/admin/pricing-strategies/{id}",
2026
+ ...options
2027
+ });
2028
+ var patchAdminPricingStrategiesById = (options) => (options.client ?? client).patch({
2029
+ security: [{ scheme: "bearer", type: "http" }],
2030
+ url: "/admin/pricing-strategies/{id}",
2031
+ ...options,
2032
+ headers: {
2033
+ "Content-Type": "application/vnd.api+json",
2034
+ ...options.headers
2035
+ }
2036
+ });
1892
2037
  var getAdminAgentsByIdTrainingStats = (options) => (options.client ?? client).get({
1893
2038
  security: [{ scheme: "bearer", type: "http" }],
1894
2039
  url: "/admin/agents/{id}/training-stats",
@@ -1940,6 +2085,20 @@ var postAdminAgentsByIdTeach = (options) => (options.client ?? client).post({
1940
2085
  ...options.headers
1941
2086
  }
1942
2087
  });
2088
+ var getAdminWholesaleAgreements = (options) => (options.client ?? client).get({
2089
+ security: [{ scheme: "bearer", type: "http" }],
2090
+ url: "/admin/wholesale-agreements",
2091
+ ...options
2092
+ });
2093
+ var postAdminWholesaleAgreements = (options) => (options.client ?? client).post({
2094
+ security: [{ scheme: "bearer", type: "http" }],
2095
+ url: "/admin/wholesale-agreements",
2096
+ ...options,
2097
+ headers: {
2098
+ "Content-Type": "application/vnd.api+json",
2099
+ ...options.headers
2100
+ }
2101
+ });
1943
2102
  var patchAdminAgentsByIdSchemaVersionsByVersionId = (options) => (options.client ?? client).patch({
1944
2103
  security: [{ scheme: "bearer", type: "http" }],
1945
2104
  url: "/admin/agents/{id}/schema-versions/{version_id}",
@@ -1996,6 +2155,25 @@ var getAdminBucketsById = (options) => (options.client ?? client).get({
1996
2155
  url: "/admin/buckets/{id}",
1997
2156
  ...options
1998
2157
  });
2158
+ var deleteAdminPlansById = (options) => (options.client ?? client).delete({
2159
+ security: [{ scheme: "bearer", type: "http" }],
2160
+ url: "/admin/plans/{id}",
2161
+ ...options
2162
+ });
2163
+ var getAdminPlansById = (options) => (options.client ?? client).get({
2164
+ security: [{ scheme: "bearer", type: "http" }],
2165
+ url: "/admin/plans/{id}",
2166
+ ...options
2167
+ });
2168
+ var patchAdminPlansById = (options) => (options.client ?? client).patch({
2169
+ security: [{ scheme: "bearer", type: "http" }],
2170
+ url: "/admin/plans/{id}",
2171
+ ...options,
2172
+ headers: {
2173
+ "Content-Type": "application/vnd.api+json",
2174
+ ...options.headers
2175
+ }
2176
+ });
1999
2177
  var patchAdminUsersByIdResetPassword = (options) => (options.client ?? client).patch({
2000
2178
  security: [{ scheme: "bearer", type: "http" }],
2001
2179
  url: "/admin/users/{id}/reset-password",
@@ -4848,6 +5026,457 @@ function createEmailNamespace(rb) {
4848
5026
  };
4849
5027
  }
4850
5028
 
5029
+ // src/namespaces/billing.ts
5030
+ function createBillingNamespace(rb) {
5031
+ return {
5032
+ wallet: {
5033
+ /**
5034
+ * Fetch the wallet for the current authenticated context.
5035
+ *
5036
+ * @param options - Optional request-level overrides.
5037
+ * @returns A promise resolving to the {@link Wallet}.
5038
+ *
5039
+ * @example
5040
+ * ```typescript
5041
+ * const admin = new GptAdmin({ apiKey: 'sk_srv_...' });
5042
+ * const wallet = await admin.billing.wallet.get();
5043
+ * console.log(`Balance: ${wallet.attributes?.balance_credits} credits`);
5044
+ * ```
5045
+ */
5046
+ get: async (options) => {
5047
+ return rb.execute(getAdminWallet, {}, options);
5048
+ },
5049
+ /**
5050
+ * Change the subscription plan on the wallet.
5051
+ *
5052
+ * Upgrades charge a prorated amount immediately against the default payment
5053
+ * method. Downgrades are deferred to the end of the current billing period.
5054
+ *
5055
+ * @param walletId - The wallet UUID from `wallet.get()`.
5056
+ * @param planSlug - The slug of the target plan (e.g. `"pro-monthly"`).
5057
+ * @param options - Optional request-level overrides.
5058
+ * @returns A promise resolving to the updated {@link Wallet}.
5059
+ *
5060
+ * @example
5061
+ * ```typescript
5062
+ * const admin = new GptAdmin({ apiKey: 'sk_srv_...' });
5063
+ * const wallet = await admin.billing.wallet.get();
5064
+ * await admin.billing.wallet.changePlan(wallet.id as string, 'enterprise-annual');
5065
+ * ```
5066
+ */
5067
+ changePlan: async (walletId, planSlug, options) => {
5068
+ return rb.execute(
5069
+ patchAdminWalletPlan,
5070
+ {
5071
+ body: {
5072
+ data: {
5073
+ id: walletId,
5074
+ type: "wallet",
5075
+ attributes: { plan_slug: planSlug }
5076
+ }
5077
+ }
5078
+ },
5079
+ options
5080
+ );
5081
+ },
5082
+ /**
5083
+ * Adjust credits on the wallet by purchasing a credit package.
5084
+ *
5085
+ * @param walletId - The wallet UUID from `wallet.get()`.
5086
+ * @param packageSlug - The slug of the credit package to purchase.
5087
+ * @param paymentMethodId - Optional payment method UUID. Uses the default if omitted.
5088
+ * @param options - Optional request-level overrides.
5089
+ * @returns A promise resolving to the updated {@link Wallet}.
5090
+ *
5091
+ * @example
5092
+ * ```typescript
5093
+ * const admin = new GptAdmin({ apiKey: 'sk_srv_...' });
5094
+ * const wallet = await admin.billing.wallet.get();
5095
+ * await admin.billing.wallet.adjustCredits(wallet.id as string, 'starter-1000');
5096
+ * ```
5097
+ */
5098
+ adjustCredits: async (walletId, packageSlug, paymentMethodId, options) => {
5099
+ const attributes = {
5100
+ package_slug: packageSlug
5101
+ };
5102
+ if (paymentMethodId !== void 0) {
5103
+ attributes.payment_method_id = paymentMethodId;
5104
+ }
5105
+ return rb.execute(
5106
+ patchAdminWalletCredits,
5107
+ {
5108
+ body: {
5109
+ data: {
5110
+ id: walletId,
5111
+ type: "wallet",
5112
+ attributes
5113
+ }
5114
+ }
5115
+ },
5116
+ options
5117
+ );
5118
+ },
5119
+ /**
5120
+ * Get credit usage history for the wallet.
5121
+ *
5122
+ * @param tenantId - Optional tenant ID to scope the usage query.
5123
+ * @param options - Optional request-level overrides.
5124
+ * @returns A promise resolving to a {@link Wallet} with usage data.
5125
+ *
5126
+ * @example
5127
+ * ```typescript
5128
+ * const admin = new GptAdmin({ apiKey: 'sk_srv_...' });
5129
+ * const usage = await admin.billing.wallet.getUsage('tenant_abc123');
5130
+ * ```
5131
+ */
5132
+ getUsage: async (tenantId, options) => {
5133
+ const query = {};
5134
+ if (tenantId !== void 0) {
5135
+ query.tenant_id = tenantId;
5136
+ }
5137
+ return rb.execute(
5138
+ getAdminWalletUsage,
5139
+ Object.keys(query).length > 0 ? { query } : {},
5140
+ options
5141
+ );
5142
+ }
5143
+ },
5144
+ /**
5145
+ * Plan management — create, read, update, delete subscription plans available to tenants.
5146
+ *
5147
+ * Plans define subscription tiers with monthly prices, credit grants, storage quotas,
5148
+ * and capability tiers. ISVs configure their plan catalogue here.
5149
+ */
5150
+ plans: {
5151
+ /** List all plans for the application. */
5152
+ list: async (options) => {
5153
+ const result = await rb.execute(getAdminPlans, {}, options);
5154
+ return result.data ?? result;
5155
+ },
5156
+ /** Get a plan by ID. */
5157
+ get: async (planId, options) => {
5158
+ return rb.execute(
5159
+ getAdminPlansById,
5160
+ { path: { id: planId } },
5161
+ options
5162
+ );
5163
+ },
5164
+ /**
5165
+ * Create a new plan.
5166
+ *
5167
+ * @param attrs - Plan attributes (name, slug, monthly_price, monthly_credits, etc.)
5168
+ */
5169
+ create: async (attrs, options) => {
5170
+ return rb.execute(
5171
+ postAdminPlans,
5172
+ { body: { data: { type: "plan", attributes: attrs } } },
5173
+ options
5174
+ );
5175
+ },
5176
+ /**
5177
+ * Update an existing plan.
5178
+ *
5179
+ * @param planId - The plan UUID.
5180
+ * @param attrs - Attributes to update.
5181
+ */
5182
+ update: async (planId, attrs, options) => {
5183
+ return rb.execute(
5184
+ patchAdminPlansById,
5185
+ {
5186
+ path: { id: planId },
5187
+ body: { data: { id: planId, type: "plan", attributes: attrs } }
5188
+ },
5189
+ options
5190
+ );
5191
+ },
5192
+ /** Delete a plan by ID. */
5193
+ delete: async (planId, options) => {
5194
+ await rb.execute(
5195
+ deleteAdminPlansById,
5196
+ { path: { id: planId } },
5197
+ options
5198
+ );
5199
+ }
5200
+ },
5201
+ /**
5202
+ * Pricing strategy management — configure per-service floor prices and margins
5203
+ * for your application. These are the Tier 2 prices in the 5-tier pricing resolution.
5204
+ */
5205
+ pricingStrategies: {
5206
+ /** List all pricing strategies for the application. */
5207
+ list: async (options) => {
5208
+ const result = await rb.execute(
5209
+ getAdminPricingStrategies,
5210
+ {},
5211
+ options
5212
+ );
5213
+ return result.data ?? result;
5214
+ },
5215
+ /** Get a pricing strategy by ID. */
5216
+ get: async (id, options) => {
5217
+ return rb.execute(
5218
+ getAdminPricingStrategiesById,
5219
+ { path: { id } },
5220
+ options
5221
+ );
5222
+ },
5223
+ /**
5224
+ * Create a pricing strategy for a service.
5225
+ *
5226
+ * @param attrs - Strategy attributes: `service_id`, `metric`, `floor_price`, `margin_percent`.
5227
+ * The `floor_price` cannot be below the ISV minimum retail floor set in the WholesaleAgreement.
5228
+ */
5229
+ create: async (attrs, options) => {
5230
+ return rb.execute(
5231
+ postAdminPricingStrategies,
5232
+ { body: { data: { type: "pricing_strategy", attributes: attrs } } },
5233
+ options
5234
+ );
5235
+ },
5236
+ /**
5237
+ * Update a pricing strategy.
5238
+ *
5239
+ * @param id - The pricing strategy UUID.
5240
+ * @param attrs - Attributes to update (`floor_price`, `margin_percent`).
5241
+ */
5242
+ update: async (id, attrs, options) => {
5243
+ return rb.execute(
5244
+ patchAdminPricingStrategiesById,
5245
+ {
5246
+ path: { id },
5247
+ body: { data: { id, type: "pricing_strategy", attributes: attrs } }
5248
+ },
5249
+ options
5250
+ );
5251
+ }
5252
+ },
5253
+ /**
5254
+ * Tenant pricing override management — set per-tenant, per-service custom prices.
5255
+ * These are Tier 1 in the 5-tier pricing resolution (highest priority).
5256
+ *
5257
+ * Use for enterprise contracts, volume discounts, and promotional pricing.
5258
+ * Always provide a `reason` for audit trail purposes.
5259
+ */
5260
+ tenantPricingOverrides: {
5261
+ /** List all tenant pricing overrides for the application. */
5262
+ list: async (options) => {
5263
+ const result = await rb.execute(
5264
+ getAdminTenantPricingOverrides,
5265
+ {},
5266
+ options
5267
+ );
5268
+ return result.data ?? result;
5269
+ },
5270
+ /** Get a tenant pricing override by ID. */
5271
+ get: async (id, options) => {
5272
+ return rb.execute(
5273
+ getAdminTenantPricingOverridesById,
5274
+ { path: { id } },
5275
+ options
5276
+ );
5277
+ },
5278
+ /**
5279
+ * Create a tenant-specific pricing override.
5280
+ *
5281
+ * @param attrs - Override attributes: `service_id`, `tenant_id`, `application_id`,
5282
+ * `floor_price`, `margin_percent`, `expires_at`, `reason`.
5283
+ * The `reason` field is required for audit compliance.
5284
+ */
5285
+ create: async (attrs, options) => {
5286
+ return rb.execute(
5287
+ postAdminTenantPricingOverrides,
5288
+ {
5289
+ body: {
5290
+ data: { type: "tenant_pricing_override", attributes: attrs }
5291
+ }
5292
+ },
5293
+ options
5294
+ );
5295
+ },
5296
+ /**
5297
+ * Update a tenant pricing override.
5298
+ *
5299
+ * @param id - The override UUID.
5300
+ * @param attrs - Attributes to update (`floor_price`, `margin_percent`, `expires_at`, `reason`).
5301
+ */
5302
+ update: async (id, attrs, options) => {
5303
+ return rb.execute(
5304
+ patchAdminTenantPricingOverridesById,
5305
+ {
5306
+ path: { id },
5307
+ body: {
5308
+ data: { id, type: "tenant_pricing_override", attributes: attrs }
5309
+ }
5310
+ },
5311
+ options
5312
+ );
5313
+ },
5314
+ /**
5315
+ * Delete a tenant pricing override. The tenant's pricing reverts to the
5316
+ * PricingStrategy (or platform default) immediately.
5317
+ *
5318
+ * @param id - The override UUID to delete.
5319
+ */
5320
+ delete: async (id, options) => {
5321
+ await rb.execute(
5322
+ deleteAdminTenantPricingOverridesById,
5323
+ { path: { id } },
5324
+ options
5325
+ );
5326
+ }
5327
+ },
5328
+ /**
5329
+ * Wholesale agreement management — configure the economic relationship between
5330
+ * your ISV account and the platform. Defines take rates, minimum retail floors,
5331
+ * and settlement terms.
5332
+ *
5333
+ * Wholesale agreements are typically configured once during ISV onboarding and
5334
+ * updated only when contract terms change.
5335
+ */
5336
+ wholesaleAgreements: {
5337
+ /** List all wholesale agreements for the ISV account. */
5338
+ list: async (options) => {
5339
+ const result = await rb.execute(
5340
+ getAdminWholesaleAgreements,
5341
+ {},
5342
+ options
5343
+ );
5344
+ return result.data ?? result;
5345
+ },
5346
+ /** Get a wholesale agreement by ID. */
5347
+ get: async (id, options) => {
5348
+ return rb.execute(
5349
+ getAdminWholesaleAgreementsById,
5350
+ { path: { id } },
5351
+ options
5352
+ );
5353
+ },
5354
+ /**
5355
+ * Create a wholesale agreement.
5356
+ *
5357
+ * @param attrs - Agreement attributes: `model` (`"percentage"` or `"interchange_plus"`),
5358
+ * `take_rate_percent`, `minimum_retail_floors`, `settlement_frequency`, etc.
5359
+ */
5360
+ create: async (attrs, options) => {
5361
+ return rb.execute(
5362
+ postAdminWholesaleAgreements,
5363
+ {
5364
+ body: { data: { type: "wholesale_agreement", attributes: attrs } }
5365
+ },
5366
+ options
5367
+ );
5368
+ },
5369
+ /**
5370
+ * Update a wholesale agreement.
5371
+ *
5372
+ * @param id - The wholesale agreement UUID.
5373
+ * @param attrs - Attributes to update.
5374
+ */
5375
+ update: async (id, attrs, options) => {
5376
+ return rb.execute(
5377
+ patchAdminWholesaleAgreementsById,
5378
+ {
5379
+ path: { id },
5380
+ body: {
5381
+ data: { id, type: "wholesale_agreement", attributes: attrs }
5382
+ }
5383
+ },
5384
+ options
5385
+ );
5386
+ }
5387
+ },
5388
+ /**
5389
+ * Settlement management — view and initiate ISV revenue settlements.
5390
+ *
5391
+ * The platform calculates net position (retail collected minus wholesale owed)
5392
+ * and releases settlements based on your WholesaleAgreement terms.
5393
+ */
5394
+ settlements: {
5395
+ /** List all settlements for the ISV account. */
5396
+ list: async (options) => {
5397
+ const result = await rb.execute(
5398
+ getAdminSettlements,
5399
+ {},
5400
+ options
5401
+ );
5402
+ return result.data ?? result;
5403
+ },
5404
+ /** Get a settlement by ID. */
5405
+ get: async (id, options) => {
5406
+ return rb.execute(
5407
+ getAdminSettlementsById,
5408
+ { path: { id } },
5409
+ options
5410
+ );
5411
+ },
5412
+ /**
5413
+ * Initiate a settlement calculation for a given period.
5414
+ *
5415
+ * @param attrs - Settlement attributes: `period_start`, `period_end`, `isv_tenant_id`.
5416
+ */
5417
+ create: async (attrs, options) => {
5418
+ return rb.execute(
5419
+ postAdminSettlements,
5420
+ { body: { data: { type: "settlement", attributes: attrs } } },
5421
+ options
5422
+ );
5423
+ }
5424
+ },
5425
+ /**
5426
+ * Account credit management — grant promotional or purchased credits to tenant applications.
5427
+ *
5428
+ * Use this for:
5429
+ * - Onboarding bonuses
5430
+ * - Service credits (compensation for downtime)
5431
+ * - Referral rewards
5432
+ * - Marketing campaigns
5433
+ */
5434
+ accounts: {
5435
+ /**
5436
+ * Grant credits to an application (and its tenants).
5437
+ *
5438
+ * @param applicationId - The application UUID.
5439
+ * @param opts - Credit grant options: `amount` (integer credits), `type`
5440
+ * (`"promotional"` | `"purchased"` | `"subscription"`), optional `reason` and `expires_at`.
5441
+ *
5442
+ * @example
5443
+ * ```typescript
5444
+ * // Apology credits — permanent, no expiry
5445
+ * await admin.billing.accounts.grantCredits(applicationId, {
5446
+ * amount: 10000,
5447
+ * type: 'purchased',
5448
+ * reason: 'Service incident 2026-03-04 compensation',
5449
+ * });
5450
+ *
5451
+ * // Promotional trial credits — expire in 14 days
5452
+ * await admin.billing.accounts.grantCredits(applicationId, {
5453
+ * amount: 25000,
5454
+ * type: 'promotional',
5455
+ * expires_at: new Date(Date.now() + 14 * 86400 * 1000).toISOString(),
5456
+ * });
5457
+ * ```
5458
+ */
5459
+ grantCredits: async (applicationId, opts, options) => {
5460
+ const attributes = {
5461
+ amount: opts.amount,
5462
+ type: opts.type
5463
+ };
5464
+ if (opts.reason !== void 0) attributes.reason = opts.reason;
5465
+ if (opts.expires_at !== void 0)
5466
+ attributes.expires_at = opts.expires_at;
5467
+ return rb.execute(
5468
+ patchAdminApplicationsByIdGrantCredits,
5469
+ {
5470
+ path: { id: applicationId },
5471
+ body: { data: { type: "application", attributes } }
5472
+ },
5473
+ options
5474
+ );
5475
+ }
5476
+ }
5477
+ };
5478
+ }
5479
+
4851
5480
  // src/gpt-admin.ts
4852
5481
  var GptAdmin = class extends BaseClient {
4853
5482
  constructor(config) {
@@ -4871,6 +5500,7 @@ var GptAdmin = class extends BaseClient {
4871
5500
  this.webhooks = createWebhooksNamespace(rb);
4872
5501
  this.campaigns = createCampaignsNamespace(rb);
4873
5502
  this.email = createEmailNamespace(rb);
5503
+ this.billing = createBillingNamespace(rb);
4874
5504
  }
4875
5505
  };
4876
5506