@layr-labs/ecloud-sdk 1.0.0-dev.4 → 1.0.0-dev.6

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.
@@ -1,5 +1,5 @@
1
1
  import { Address, Hex, WalletClient, PublicClient } from 'viem';
2
- import { a6 as SubscriptionOpts, a4 as SubscribeResponse, a0 as ProductSubscriptionResponse, g as CancelResponse, M as PaymentMethodsResponse, m as CreditPurchaseResponse } from './index-BoCE0hIh.cjs';
2
+ import { ae as SubscriptionOpts, ac as SubscribeResponse, a7 as ProductSubscriptionResponse, j as CancelResponse, V as PaymentMethodsResponse, q as CreditPurchaseResponse, a8 as RedeemCouponResponse } from './index-CLhRJNai.cjs';
3
3
 
4
4
  /**
5
5
  * Main Billing namespace entry point
@@ -42,6 +42,7 @@ interface BillingModule {
42
42
  purchaseCredits: (amountCents: number, paymentMethodId?: string) => Promise<CreditPurchaseResponse>;
43
43
  /** Check if Base chain is configured for this environment */
44
44
  hasBaseSupport: () => boolean;
45
+ redeemCoupon: (code: string) => Promise<RedeemCouponResponse>;
45
46
  }
46
47
  interface BillingModuleConfig {
47
48
  verbose?: boolean;
package/dist/billing.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Address, Hex, WalletClient, PublicClient } from 'viem';
2
- import { a6 as SubscriptionOpts, a4 as SubscribeResponse, a0 as ProductSubscriptionResponse, g as CancelResponse, M as PaymentMethodsResponse, m as CreditPurchaseResponse } from './index-BoCE0hIh.js';
2
+ import { ae as SubscriptionOpts, ac as SubscribeResponse, a7 as ProductSubscriptionResponse, j as CancelResponse, V as PaymentMethodsResponse, q as CreditPurchaseResponse, a8 as RedeemCouponResponse } from './index-CLhRJNai.js';
3
3
 
4
4
  /**
5
5
  * Main Billing namespace entry point
@@ -42,6 +42,7 @@ interface BillingModule {
42
42
  purchaseCredits: (amountCents: number, paymentMethodId?: string) => Promise<CreditPurchaseResponse>;
43
43
  /** Check if Base chain is configured for this environment */
44
44
  hasBaseSupport: () => boolean;
45
+ redeemCoupon: (code: string) => Promise<RedeemCouponResponse>;
45
46
  }
46
47
  interface BillingModuleConfig {
47
48
  verbose?: boolean;
package/dist/billing.js CHANGED
@@ -298,6 +298,63 @@ var BillingApiClient = class {
298
298
  return resp.json();
299
299
  }
300
300
  // ==========================================================================
301
+ // Admin - Coupon Methods
302
+ // ==========================================================================
303
+ async createCoupon(amountCents) {
304
+ const endpoint = `${this.config.billingApiServerURL}/admin/coupons`;
305
+ const resp = await this.makeAuthenticatedRequest(endpoint, "POST", "compute", { amountCents });
306
+ return resp.json();
307
+ }
308
+ async listCoupons(opts) {
309
+ const params = new URLSearchParams();
310
+ if (opts?.offset !== void 0) params.set("offset", opts.offset.toString());
311
+ if (opts?.limit !== void 0) params.set("limit", opts.limit.toString());
312
+ if (opts?.active !== void 0) params.set("active", opts.active.toString());
313
+ if (opts?.redeemed !== void 0) params.set("redeemed", opts.redeemed.toString());
314
+ const qs = params.toString();
315
+ const endpoint = `${this.config.billingApiServerURL}/admin/coupons${qs ? `?${qs}` : ""}`;
316
+ const resp = await this.makeAuthenticatedRequest(endpoint, "GET", "compute");
317
+ return resp.json();
318
+ }
319
+ async getCoupon(id) {
320
+ const endpoint = `${this.config.billingApiServerURL}/admin/coupons/${id}`;
321
+ const resp = await this.makeAuthenticatedRequest(endpoint, "GET", "compute");
322
+ return resp.json();
323
+ }
324
+ async deactivateCoupon(id) {
325
+ const endpoint = `${this.config.billingApiServerURL}/admin/coupons/${id}/deactivate`;
326
+ await this.makeAuthenticatedRequest(endpoint, "POST", "compute");
327
+ }
328
+ async redeemCouponForUser(id, address) {
329
+ const endpoint = `${this.config.billingApiServerURL}/admin/coupons/${id}/redeem`;
330
+ await this.makeAuthenticatedRequest(endpoint, "POST", "compute", { address });
331
+ }
332
+ // ==========================================================================
333
+ // Admin - Admin Management Methods
334
+ // ==========================================================================
335
+ async addAdmin(address) {
336
+ const endpoint = `${this.config.billingApiServerURL}/admin/admins`;
337
+ const resp = await this.makeAuthenticatedRequest(endpoint, "POST", "compute", { address });
338
+ return resp.json();
339
+ }
340
+ async removeAdmin(address) {
341
+ const endpoint = `${this.config.billingApiServerURL}/admin/admins/${address}`;
342
+ await this.makeAuthenticatedRequest(endpoint, "DELETE", "compute");
343
+ }
344
+ async listAdmins() {
345
+ const endpoint = `${this.config.billingApiServerURL}/admin/admins`;
346
+ const resp = await this.makeAuthenticatedRequest(endpoint, "GET", "compute");
347
+ return resp.json();
348
+ }
349
+ // ==========================================================================
350
+ // User - Coupon Redemption
351
+ // ==========================================================================
352
+ async redeemCoupon(code) {
353
+ const endpoint = `${this.config.billingApiServerURL}/v1/coupons/redeem`;
354
+ const resp = await this.makeAuthenticatedRequest(endpoint, "POST", "compute", { code });
355
+ return resp.json();
356
+ }
357
+ // ==========================================================================
301
358
  // Internal Methods
302
359
  // ==========================================================================
303
360
  /**
@@ -2321,6 +2378,9 @@ function createBillingModule(config) {
2321
2378
  },
2322
2379
  hasBaseSupport() {
2323
2380
  return !!baseUsdcCreditsAddress && !!baseRPCURL;
2381
+ },
2382
+ async redeemCoupon(code) {
2383
+ return billingApi.redeemCoupon(code);
2324
2384
  }
2325
2385
  };
2326
2386
  return module;