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

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/VERSION CHANGED
@@ -1,2 +1,2 @@
1
- version=1.0.0-dev.4
2
- commit=c09e81b17f3f5e8ea24aa8df3681741dad15a710
1
+ version=1.0.0-dev.5
2
+ commit=7451666189ca42c9ef358346e8998e3e35640e42
package/dist/billing.cjs CHANGED
@@ -332,6 +332,63 @@ var BillingApiClient = class {
332
332
  return resp.json();
333
333
  }
334
334
  // ==========================================================================
335
+ // Admin - Coupon Methods
336
+ // ==========================================================================
337
+ async createCoupon(amountCents) {
338
+ const endpoint = `${this.config.billingApiServerURL}/admin/coupons`;
339
+ const resp = await this.makeAuthenticatedRequest(endpoint, "POST", "compute", { amountCents });
340
+ return resp.json();
341
+ }
342
+ async listCoupons(opts) {
343
+ const params = new URLSearchParams();
344
+ if (opts?.offset !== void 0) params.set("offset", opts.offset.toString());
345
+ if (opts?.limit !== void 0) params.set("limit", opts.limit.toString());
346
+ if (opts?.active !== void 0) params.set("active", opts.active.toString());
347
+ if (opts?.redeemed !== void 0) params.set("redeemed", opts.redeemed.toString());
348
+ const qs = params.toString();
349
+ const endpoint = `${this.config.billingApiServerURL}/admin/coupons${qs ? `?${qs}` : ""}`;
350
+ const resp = await this.makeAuthenticatedRequest(endpoint, "GET", "compute");
351
+ return resp.json();
352
+ }
353
+ async getCoupon(id) {
354
+ const endpoint = `${this.config.billingApiServerURL}/admin/coupons/${id}`;
355
+ const resp = await this.makeAuthenticatedRequest(endpoint, "GET", "compute");
356
+ return resp.json();
357
+ }
358
+ async deactivateCoupon(id) {
359
+ const endpoint = `${this.config.billingApiServerURL}/admin/coupons/${id}/deactivate`;
360
+ await this.makeAuthenticatedRequest(endpoint, "POST", "compute");
361
+ }
362
+ async redeemCouponForUser(id, address) {
363
+ const endpoint = `${this.config.billingApiServerURL}/admin/coupons/${id}/redeem`;
364
+ await this.makeAuthenticatedRequest(endpoint, "POST", "compute", { address });
365
+ }
366
+ // ==========================================================================
367
+ // Admin - Admin Management Methods
368
+ // ==========================================================================
369
+ async addAdmin(address) {
370
+ const endpoint = `${this.config.billingApiServerURL}/admin/admins`;
371
+ const resp = await this.makeAuthenticatedRequest(endpoint, "POST", "compute", { address });
372
+ return resp.json();
373
+ }
374
+ async removeAdmin(address) {
375
+ const endpoint = `${this.config.billingApiServerURL}/admin/admins/${address}`;
376
+ await this.makeAuthenticatedRequest(endpoint, "DELETE", "compute");
377
+ }
378
+ async listAdmins() {
379
+ const endpoint = `${this.config.billingApiServerURL}/admin/admins`;
380
+ const resp = await this.makeAuthenticatedRequest(endpoint, "GET", "compute");
381
+ return resp.json();
382
+ }
383
+ // ==========================================================================
384
+ // User - Coupon Redemption
385
+ // ==========================================================================
386
+ async redeemCoupon(code) {
387
+ const endpoint = `${this.config.billingApiServerURL}/v1/coupons/redeem`;
388
+ const resp = await this.makeAuthenticatedRequest(endpoint, "POST", "compute", { code });
389
+ return resp.json();
390
+ }
391
+ // ==========================================================================
335
392
  // Internal Methods
336
393
  // ==========================================================================
337
394
  /**
@@ -2355,6 +2412,9 @@ function createBillingModule(config) {
2355
2412
  },
2356
2413
  hasBaseSupport() {
2357
2414
  return !!baseUsdcCreditsAddress && !!baseRPCURL;
2415
+ },
2416
+ async redeemCoupon(code) {
2417
+ return billingApi.redeemCoupon(code);
2358
2418
  }
2359
2419
  };
2360
2420
  return module2;