@gravity-rail/sdk 0.11.0 → 0.12.0

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.cjs CHANGED
@@ -5610,24 +5610,24 @@ var OrgApi = class extends BaseApiClient {
5610
5610
  return this.fetch(`o/${orgUuid}/phone-numbers/a2p/status`);
5611
5611
  }
5612
5612
  /**
5613
- * Start org-level A2P brand registration.
5613
+ * Start A2P brand registration under a legal entity. `legalEntityUuid`
5614
+ * is required — brands register per legal entity (Customer Profile);
5615
+ * there is no primary-entity fallback.
5614
5616
  */
5615
- async startA2PRegistration(orgUuid, brandName, brandDescription) {
5616
- return this.fetch(
5617
- `o/${orgUuid}/phone-numbers/a2p/start`,
5618
- {
5619
- method: "POST",
5620
- body: JSON.stringify({ brandName, brandDescription })
5621
- }
5622
- );
5617
+ async startA2PRegistration(orgUuid, legalEntityUuid, brandName, brandDescription) {
5618
+ return this.fetch(`o/${orgUuid}/phone-numbers/a2p/start`, {
5619
+ method: "POST",
5620
+ body: JSON.stringify({ legalEntityUuid, brandName, brandDescription })
5621
+ });
5623
5622
  }
5624
5623
  /**
5625
- * Approve sample messages for the org's A2P campaign.
5624
+ * Approve sample messages for one brand's A2P campaign. Signals the
5625
+ * brand's registration workflow to create the TCR campaign.
5626
5626
  */
5627
- async approveA2PMessages(orgUuid, sampleMessages) {
5627
+ async approveA2PMessages(orgUuid, brandUuid, sampleMessages) {
5628
5628
  return this.fetch(`o/${orgUuid}/phone-numbers/a2p/approve-messages`, {
5629
5629
  method: "POST",
5630
- body: JSON.stringify({ sampleMessages })
5630
+ body: JSON.stringify({ brandUuid, sampleMessages })
5631
5631
  });
5632
5632
  }
5633
5633
  // ============================================================================
@@ -5643,8 +5643,8 @@ var OrgApi = class extends BaseApiClient {
5643
5643
  * which is impossible (lifecycle status is one of `draft` /
5644
5644
  * `pending-review` / `in-review` / `twilio-approved` / `twilio-rejected`).
5645
5645
  */
5646
- async getBusinessProfile(orgUuid) {
5647
- return this.fetch(`o/${orgUuid}/business-profile`);
5646
+ async getBusinessProfile(orgUuid, legalEntityUuid) {
5647
+ return this.fetch(businessProfilePath(orgUuid, legalEntityUuid));
5648
5648
  }
5649
5649
  /**
5650
5650
  * Upsert the org's business profile. Idempotent via cached SIDs.
@@ -5652,8 +5652,8 @@ var OrgApi = class extends BaseApiClient {
5652
5652
  * compliance evaluation result so the frontend can immediately enable
5653
5653
  * Submit without a second round-trip.
5654
5654
  */
5655
- async updateBusinessProfile(orgUuid, data) {
5656
- return this.fetch(`o/${orgUuid}/business-profile`, {
5655
+ async updateBusinessProfile(orgUuid, data, legalEntityUuid) {
5656
+ return this.fetch(businessProfilePath(orgUuid, legalEntityUuid), {
5657
5657
  method: "PUT",
5658
5658
  body: JSON.stringify(data)
5659
5659
  });
@@ -5663,20 +5663,46 @@ var OrgApi = class extends BaseApiClient {
5663
5663
  * compliance live and returns 412 if the profile is not currently
5664
5664
  * `compliant`; returns 409 if a review is already in flight.
5665
5665
  */
5666
- async submitBusinessProfile(orgUuid) {
5667
- return this.fetch(`o/${orgUuid}/business-profile/submit`, {
5668
- method: "POST"
5669
- });
5666
+ async submitBusinessProfile(orgUuid, legalEntityUuid) {
5667
+ return this.fetch(
5668
+ `${businessProfilePath(orgUuid, legalEntityUuid)}/submit`,
5669
+ { method: "POST" }
5670
+ );
5670
5671
  }
5671
5672
  /**
5672
5673
  * Cancel an in-flight Twilio review. Resets the cached profile state
5673
5674
  * to `draft` so the user can edit and resubmit.
5674
5675
  */
5675
- async cancelBusinessProfile(orgUuid) {
5676
- return this.fetch(`o/${orgUuid}/business-profile/cancel`, {
5677
- method: "POST"
5676
+ async cancelBusinessProfile(orgUuid, legalEntityUuid) {
5677
+ return this.fetch(
5678
+ `${businessProfilePath(orgUuid, legalEntityUuid)}/cancel`,
5679
+ { method: "POST" }
5680
+ );
5681
+ }
5682
+ // ============================================================================
5683
+ // Legal entities (Twilio Secondary Customer Profiles)
5684
+ // ============================================================================
5685
+ /** List the org's legal entities (one Customer Profile each). */
5686
+ async listLegalEntities(orgUuid) {
5687
+ return this.fetch(`o/${orgUuid}/legal-entities`);
5688
+ }
5689
+ /** Create a legal entity. Its business profile is edited via the entity-scoped business-profile methods. */
5690
+ async createLegalEntity(orgUuid, data) {
5691
+ return this.fetch(`o/${orgUuid}/legal-entities`, {
5692
+ method: "POST",
5693
+ body: JSON.stringify(data)
5678
5694
  });
5679
5695
  }
5696
+ async getLegalEntity(orgUuid, legalEntityUuid) {
5697
+ return this.fetch(`o/${orgUuid}/legal-entities/${legalEntityUuid}`);
5698
+ }
5699
+ /**
5700
+ * Brand detail with live registration-workflow state (`workflowStatus`,
5701
+ * `pendingSampleMessages`) for the sample-approval step.
5702
+ */
5703
+ async getA2PBrand(orgUuid, brandUuid) {
5704
+ return this.fetch(`o/${orgUuid}/a2p-brands/${brandUuid}`);
5705
+ }
5680
5706
  /**
5681
5707
  * List the org's A2P brands (broker resources). The SMS-consent editor uses
5682
5708
  * this to pick which brand's consent config to edit.
@@ -5780,6 +5806,9 @@ var OrgApi = class extends BaseApiClient {
5780
5806
  );
5781
5807
  }
5782
5808
  };
5809
+ function businessProfilePath(orgUuid, legalEntityUuid) {
5810
+ return legalEntityUuid ? `o/${orgUuid}/legal-entities/${legalEntityUuid}/business-profile` : `o/${orgUuid}/business-profile`;
5811
+ }
5783
5812
 
5784
5813
  // src/api/oauth.ts
5785
5814
  function getOAuthPath(providerSlug, action) {
@@ -7045,11 +7074,11 @@ var SubscriptionsApi = class extends BaseApiClient {
7045
7074
  * customer, and subscription are created on payment by the checkout
7046
7075
  * completion handler.
7047
7076
  */
7048
- async createCheckoutSession(productId, planPeriod = "month") {
7077
+ async createCheckoutSession(productId, planPeriod = "month", options = {}) {
7049
7078
  return this.fetch(`subscriptions/checkout-session`, {
7050
7079
  method: "POST",
7051
7080
  credentials: "include",
7052
- body: JSON.stringify({ productId, planPeriod }),
7081
+ body: JSON.stringify({ productId, planPeriod, ...options }),
7053
7082
  headers: { "Content-Type": "application/json" }
7054
7083
  });
7055
7084
  }
@@ -7106,12 +7135,15 @@ var SubscriptionsApi = class extends BaseApiClient {
7106
7135
  return this.fetch(`subscriptions/${subscriptionId}/items`);
7107
7136
  }
7108
7137
  /** Purchase extra credits on a subscription (org-level). */
7109
- async purchaseCredits(subscriptionId, amountCents) {
7138
+ async purchaseCredits(subscriptionId, amountCents, idempotencyKey = crypto.randomUUID()) {
7110
7139
  return this.fetch(`subscriptions/${subscriptionId}/purchase-credits`, {
7111
7140
  method: "POST",
7112
7141
  credentials: "include",
7113
7142
  body: JSON.stringify({ amount_cents: amountCents }),
7114
- headers: { "Content-Type": "application/json" }
7143
+ headers: {
7144
+ "Content-Type": "application/json",
7145
+ "Idempotency-Key": idempotencyKey
7146
+ }
7115
7147
  });
7116
7148
  }
7117
7149
  };
@@ -7254,6 +7286,13 @@ var CustomersApi = class extends BaseApiClient {
7254
7286
  async getMyCustomerInvoices(uuid) {
7255
7287
  return this.fetch(`customers/${uuid}/invoices`);
7256
7288
  }
7289
+ async createMyCustomerPortalSession(uuid, returnUrl) {
7290
+ return this.fetch(`customers/${uuid}/stripe/portal-session`, {
7291
+ method: "POST",
7292
+ body: JSON.stringify({ returnUrl }),
7293
+ headers: { "Content-Type": "application/json" }
7294
+ });
7295
+ }
7257
7296
  async updateMyCustomer(uuid, data) {
7258
7297
  return this.fetch(`customers/${uuid}`, {
7259
7298
  method: "PUT",
@@ -7271,7 +7310,8 @@ var CustomersApi = class extends BaseApiClient {
7271
7310
  async attachMyCustomerPaymentMethod(uuid, paymentMethodId, setAsDefault = false) {
7272
7311
  return this.fetch(`customers/${uuid}/stripe/payment-methods/${paymentMethodId}/attach`, {
7273
7312
  method: "POST",
7274
- body: JSON.stringify({ setAsDefault })
7313
+ body: JSON.stringify({ setAsDefault }),
7314
+ headers: { "Content-Type": "application/json" }
7275
7315
  });
7276
7316
  }
7277
7317
  async detachMyCustomerPaymentMethod(uuid, paymentMethodId) {
@@ -8270,6 +8310,7 @@ var EventRuleObjectType = /* @__PURE__ */ ((EventRuleObjectType2) => {
8270
8310
  EventRuleObjectType2["CALENDAR_EVENT_TYPE"] = "calendar_event_type";
8271
8311
  EventRuleObjectType2["JOURNEY"] = "journey";
8272
8312
  EventRuleObjectType2["CALL"] = "call";
8313
+ EventRuleObjectType2["VOICEMAIL"] = "voicemail";
8273
8314
  return EventRuleObjectType2;
8274
8315
  })(EventRuleObjectType || {});
8275
8316
  var EventRuleEventType = /* @__PURE__ */ ((EventRuleEventType2) => {
@@ -8301,6 +8342,7 @@ var EventRuleEventType = /* @__PURE__ */ ((EventRuleEventType2) => {
8301
8342
  EventRuleEventType2["CALL_STARTED"] = "call:started";
8302
8343
  EventRuleEventType2["CALL_COMPLETED"] = "call:completed";
8303
8344
  EventRuleEventType2["CALL_SUMMARY"] = "call:summary";
8345
+ EventRuleEventType2["VOICEMAIL_RECEIVED"] = "voicemail:received";
8304
8346
  return EventRuleEventType2;
8305
8347
  })(EventRuleEventType || {});
8306
8348
  var EventRuleActionType = /* @__PURE__ */ ((EventRuleActionType2) => {
@@ -8351,11 +8393,9 @@ var WorkspaceFeature = /* @__PURE__ */ ((WorkspaceFeature2) => {
8351
8393
  WorkspaceFeature2["BROWSER"] = "browser";
8352
8394
  WorkspaceFeature2["WEB_SEARCH"] = "web_search";
8353
8395
  WorkspaceFeature2["CALENDAR"] = "calendar";
8354
- WorkspaceFeature2["DIRECT_MESSAGES"] = "direct_messages";
8355
8396
  WorkspaceFeature2["JOURNEYS"] = "journeys";
8356
8397
  WorkspaceFeature2["EXPERIMENTS"] = "experiments";
8357
8398
  WorkspaceFeature2["OPERATOR"] = "operator";
8358
- WorkspaceFeature2["PRESENCE"] = "presence";
8359
8399
  WorkspaceFeature2["GMAIL"] = "gmail";
8360
8400
  WorkspaceFeature2["GCALENDAR"] = "gcalendar";
8361
8401
  WorkspaceFeature2["MONDAY"] = "monday";
@@ -11043,6 +11083,7 @@ function bindCustomersMethods(target, customers) {
11043
11083
  target.getMyCustomerAccounts = customers.getMyCustomerAccounts.bind(customers);
11044
11084
  target.getMyCustomerSubscriptions = customers.getMyCustomerSubscriptions.bind(customers);
11045
11085
  target.getMyCustomerInvoices = customers.getMyCustomerInvoices.bind(customers);
11086
+ target.createMyCustomerPortalSession = customers.createMyCustomerPortalSession.bind(customers);
11046
11087
  target.updateMyCustomer = customers.updateMyCustomer.bind(customers);
11047
11088
  target.createMyCustomerSetupIntent = customers.createMyCustomerSetupIntent.bind(customers);
11048
11089
  target.getMyCustomerPaymentMethods = customers.getMyCustomerPaymentMethods.bind(customers);
@@ -12029,6 +12070,7 @@ var GravityRailClient = class {
12029
12070
  getMyCustomerAccounts;
12030
12071
  getMyCustomerSubscriptions;
12031
12072
  getMyCustomerInvoices;
12073
+ createMyCustomerPortalSession;
12032
12074
  updateMyCustomer;
12033
12075
  createMyCustomerSetupIntent;
12034
12076
  getMyCustomerPaymentMethods;