@gravity-rail/sdk 0.11.0 → 0.13.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.
@@ -4724,26 +4724,41 @@ var OrgApi = class extends BaseApiClient {
4724
4724
  return this.fetch(`o/${orgUuid}/phone-numbers/a2p/status`);
4725
4725
  }
4726
4726
  /**
4727
- * Start org-level A2P brand registration.
4727
+ * Start A2P brand registration under a legal entity. `legalEntityUuid`
4728
+ * is required — brands register per legal entity (Customer Profile);
4729
+ * there is no primary-entity fallback.
4728
4730
  */
4729
- async startA2PRegistration(orgUuid, brandName, brandDescription) {
4730
- return this.fetch(
4731
- `o/${orgUuid}/phone-numbers/a2p/start`,
4732
- {
4733
- method: "POST",
4734
- body: JSON.stringify({ brandName, brandDescription })
4735
- }
4736
- );
4731
+ async startA2PRegistration(orgUuid, legalEntityUuid, brandName, brandDescription) {
4732
+ return this.fetch(`o/${orgUuid}/phone-numbers/a2p/start`, {
4733
+ method: "POST",
4734
+ body: JSON.stringify({ legalEntityUuid, brandName, brandDescription })
4735
+ });
4737
4736
  }
4738
4737
  /**
4739
- * Approve sample messages for the org's A2P campaign.
4738
+ * Approve sample messages for one brand's A2P campaign. Signals the
4739
+ * brand's registration workflow to create the TCR campaign.
4740
4740
  */
4741
- async approveA2PMessages(orgUuid, sampleMessages) {
4741
+ async approveA2PMessages(orgUuid, brandUuid, sampleMessages) {
4742
4742
  return this.fetch(`o/${orgUuid}/phone-numbers/a2p/approve-messages`, {
4743
4743
  method: "POST",
4744
- body: JSON.stringify({ sampleMessages })
4744
+ body: JSON.stringify({ brandUuid, sampleMessages })
4745
4745
  });
4746
4746
  }
4747
+ /**
4748
+ * Activate SMS on a workspace-assigned number: attach it to the given
4749
+ * brand's Messaging Service (A2P 10DLC). Preconditions (412 otherwise):
4750
+ * campaign VERIFIED, brand has a Messaging Service, phone assigned to a
4751
+ * workspace with a Twilio SID.
4752
+ */
4753
+ async activateA2PNumber(orgUuid, providerPhoneUuid, brandUuid) {
4754
+ return this.fetch(
4755
+ `o/${orgUuid}/phone-numbers/a2p/activate-number`,
4756
+ {
4757
+ method: "POST",
4758
+ body: JSON.stringify({ providerPhoneUuid, brandUuid })
4759
+ }
4760
+ );
4761
+ }
4747
4762
  // ============================================================================
4748
4763
  // Organization Business Profile API (Twilio Trust Hub Secondary CP)
4749
4764
  // ============================================================================
@@ -4757,8 +4772,8 @@ var OrgApi = class extends BaseApiClient {
4757
4772
  * which is impossible (lifecycle status is one of `draft` /
4758
4773
  * `pending-review` / `in-review` / `twilio-approved` / `twilio-rejected`).
4759
4774
  */
4760
- async getBusinessProfile(orgUuid) {
4761
- return this.fetch(`o/${orgUuid}/business-profile`);
4775
+ async getBusinessProfile(orgUuid, legalEntityUuid) {
4776
+ return this.fetch(businessProfilePath(orgUuid, legalEntityUuid));
4762
4777
  }
4763
4778
  /**
4764
4779
  * Upsert the org's business profile. Idempotent via cached SIDs.
@@ -4766,8 +4781,8 @@ var OrgApi = class extends BaseApiClient {
4766
4781
  * compliance evaluation result so the frontend can immediately enable
4767
4782
  * Submit without a second round-trip.
4768
4783
  */
4769
- async updateBusinessProfile(orgUuid, data) {
4770
- return this.fetch(`o/${orgUuid}/business-profile`, {
4784
+ async updateBusinessProfile(orgUuid, data, legalEntityUuid) {
4785
+ return this.fetch(businessProfilePath(orgUuid, legalEntityUuid), {
4771
4786
  method: "PUT",
4772
4787
  body: JSON.stringify(data)
4773
4788
  });
@@ -4777,20 +4792,70 @@ var OrgApi = class extends BaseApiClient {
4777
4792
  * compliance live and returns 412 if the profile is not currently
4778
4793
  * `compliant`; returns 409 if a review is already in flight.
4779
4794
  */
4780
- async submitBusinessProfile(orgUuid) {
4781
- return this.fetch(`o/${orgUuid}/business-profile/submit`, {
4782
- method: "POST"
4783
- });
4795
+ async submitBusinessProfile(orgUuid, legalEntityUuid) {
4796
+ return this.fetch(
4797
+ `${businessProfilePath(orgUuid, legalEntityUuid)}/submit`,
4798
+ { method: "POST" }
4799
+ );
4784
4800
  }
4785
4801
  /**
4786
4802
  * Cancel an in-flight Twilio review. Resets the cached profile state
4787
4803
  * to `draft` so the user can edit and resubmit.
4788
4804
  */
4789
- async cancelBusinessProfile(orgUuid) {
4790
- return this.fetch(`o/${orgUuid}/business-profile/cancel`, {
4791
- method: "POST"
4805
+ async cancelBusinessProfile(orgUuid, legalEntityUuid) {
4806
+ return this.fetch(
4807
+ `${businessProfilePath(orgUuid, legalEntityUuid)}/cancel`,
4808
+ { method: "POST" }
4809
+ );
4810
+ }
4811
+ // ============================================================================
4812
+ // Legal entities (Twilio Secondary Customer Profiles)
4813
+ // ============================================================================
4814
+ /** List the org's legal entities (one Customer Profile each). */
4815
+ async listLegalEntities(orgUuid) {
4816
+ return this.fetch(`o/${orgUuid}/legal-entities`);
4817
+ }
4818
+ /** Create a legal entity. Its business profile is edited via the entity-scoped business-profile methods. */
4819
+ async createLegalEntity(orgUuid, data) {
4820
+ return this.fetch(`o/${orgUuid}/legal-entities`, {
4821
+ method: "POST",
4822
+ body: JSON.stringify(data)
4792
4823
  });
4793
4824
  }
4825
+ async getLegalEntity(orgUuid, legalEntityUuid) {
4826
+ return this.fetch(`o/${orgUuid}/legal-entities/${legalEntityUuid}`);
4827
+ }
4828
+ /** Cached voice trust product state (CNAM / SHAKEN-STIR / Voice Integrity) for one legal entity. */
4829
+ async getVoiceTrustProducts(orgUuid, legalEntityUuid) {
4830
+ return this.fetch(
4831
+ `o/${orgUuid}/legal-entities/${legalEntityUuid}/trust-products`
4832
+ );
4833
+ }
4834
+ /** Reconcile trust product state against Twilio (discovery + status refresh). */
4835
+ async syncVoiceTrustProducts(orgUuid, legalEntityUuid) {
4836
+ return this.fetch(
4837
+ `o/${orgUuid}/legal-entities/${legalEntityUuid}/trust-products/sync`,
4838
+ // Empty JSON body is the CSRF barrier the route requires (GRA-6284).
4839
+ { method: "POST", body: JSON.stringify({}) }
4840
+ );
4841
+ }
4842
+ /**
4843
+ * Set up + submit one voice trust product for a legal entity. Requires
4844
+ * the entity's business profile to be twilio-approved (412 otherwise).
4845
+ */
4846
+ async setupVoiceTrustProduct(orgUuid, legalEntityUuid, product, data) {
4847
+ return this.fetch(
4848
+ `o/${orgUuid}/legal-entities/${legalEntityUuid}/trust-products/${product}`,
4849
+ { method: "POST", body: JSON.stringify(data) }
4850
+ );
4851
+ }
4852
+ /**
4853
+ * Brand detail with live registration-workflow state (`workflowStatus`,
4854
+ * `pendingSampleMessages`) for the sample-approval step.
4855
+ */
4856
+ async getA2PBrand(orgUuid, brandUuid) {
4857
+ return this.fetch(`o/${orgUuid}/a2p-brands/${brandUuid}`);
4858
+ }
4794
4859
  /**
4795
4860
  * List the org's A2P brands (broker resources). The SMS-consent editor uses
4796
4861
  * this to pick which brand's consent config to edit.
@@ -4894,6 +4959,9 @@ var OrgApi = class extends BaseApiClient {
4894
4959
  );
4895
4960
  }
4896
4961
  };
4962
+ function businessProfilePath(orgUuid, legalEntityUuid) {
4963
+ return legalEntityUuid ? `o/${orgUuid}/legal-entities/${legalEntityUuid}/business-profile` : `o/${orgUuid}/business-profile`;
4964
+ }
4897
4965
 
4898
4966
  // src/api/oauth.ts
4899
4967
  function getOAuthPath(providerSlug, action) {
@@ -6186,11 +6254,11 @@ var SubscriptionsApi = class extends BaseApiClient {
6186
6254
  * customer, and subscription are created on payment by the checkout
6187
6255
  * completion handler.
6188
6256
  */
6189
- async createCheckoutSession(productId, planPeriod = "month") {
6257
+ async createCheckoutSession(productId, planPeriod = "month", options = {}) {
6190
6258
  return this.fetch(`subscriptions/checkout-session`, {
6191
6259
  method: "POST",
6192
6260
  credentials: "include",
6193
- body: JSON.stringify({ productId, planPeriod }),
6261
+ body: JSON.stringify({ productId, planPeriod, ...options }),
6194
6262
  headers: { "Content-Type": "application/json" }
6195
6263
  });
6196
6264
  }
@@ -6247,12 +6315,15 @@ var SubscriptionsApi = class extends BaseApiClient {
6247
6315
  return this.fetch(`subscriptions/${subscriptionId}/items`);
6248
6316
  }
6249
6317
  /** Purchase extra credits on a subscription (org-level). */
6250
- async purchaseCredits(subscriptionId, amountCents) {
6318
+ async purchaseCredits(subscriptionId, amountCents, idempotencyKey = crypto.randomUUID()) {
6251
6319
  return this.fetch(`subscriptions/${subscriptionId}/purchase-credits`, {
6252
6320
  method: "POST",
6253
6321
  credentials: "include",
6254
6322
  body: JSON.stringify({ amount_cents: amountCents }),
6255
- headers: { "Content-Type": "application/json" }
6323
+ headers: {
6324
+ "Content-Type": "application/json",
6325
+ "Idempotency-Key": idempotencyKey
6326
+ }
6256
6327
  });
6257
6328
  }
6258
6329
  };
@@ -6395,6 +6466,13 @@ var CustomersApi = class extends BaseApiClient {
6395
6466
  async getMyCustomerInvoices(uuid) {
6396
6467
  return this.fetch(`customers/${uuid}/invoices`);
6397
6468
  }
6469
+ async createMyCustomerPortalSession(uuid, returnUrl) {
6470
+ return this.fetch(`customers/${uuid}/stripe/portal-session`, {
6471
+ method: "POST",
6472
+ body: JSON.stringify({ returnUrl }),
6473
+ headers: { "Content-Type": "application/json" }
6474
+ });
6475
+ }
6398
6476
  async updateMyCustomer(uuid, data) {
6399
6477
  return this.fetch(`customers/${uuid}`, {
6400
6478
  method: "PUT",
@@ -6412,7 +6490,8 @@ var CustomersApi = class extends BaseApiClient {
6412
6490
  async attachMyCustomerPaymentMethod(uuid, paymentMethodId, setAsDefault = false) {
6413
6491
  return this.fetch(`customers/${uuid}/stripe/payment-methods/${paymentMethodId}/attach`, {
6414
6492
  method: "POST",
6415
- body: JSON.stringify({ setAsDefault })
6493
+ body: JSON.stringify({ setAsDefault }),
6494
+ headers: { "Content-Type": "application/json" }
6416
6495
  });
6417
6496
  }
6418
6497
  async detachMyCustomerPaymentMethod(uuid, paymentMethodId) {
@@ -7411,6 +7490,7 @@ var EventRuleObjectType = /* @__PURE__ */ ((EventRuleObjectType2) => {
7411
7490
  EventRuleObjectType2["CALENDAR_EVENT_TYPE"] = "calendar_event_type";
7412
7491
  EventRuleObjectType2["JOURNEY"] = "journey";
7413
7492
  EventRuleObjectType2["CALL"] = "call";
7493
+ EventRuleObjectType2["VOICEMAIL"] = "voicemail";
7414
7494
  return EventRuleObjectType2;
7415
7495
  })(EventRuleObjectType || {});
7416
7496
  var EventRuleEventType = /* @__PURE__ */ ((EventRuleEventType2) => {
@@ -7442,6 +7522,7 @@ var EventRuleEventType = /* @__PURE__ */ ((EventRuleEventType2) => {
7442
7522
  EventRuleEventType2["CALL_STARTED"] = "call:started";
7443
7523
  EventRuleEventType2["CALL_COMPLETED"] = "call:completed";
7444
7524
  EventRuleEventType2["CALL_SUMMARY"] = "call:summary";
7525
+ EventRuleEventType2["VOICEMAIL_RECEIVED"] = "voicemail:received";
7445
7526
  return EventRuleEventType2;
7446
7527
  })(EventRuleEventType || {});
7447
7528
  var EventRuleActionType = /* @__PURE__ */ ((EventRuleActionType2) => {
@@ -7492,11 +7573,9 @@ var WorkspaceFeature = /* @__PURE__ */ ((WorkspaceFeature2) => {
7492
7573
  WorkspaceFeature2["BROWSER"] = "browser";
7493
7574
  WorkspaceFeature2["WEB_SEARCH"] = "web_search";
7494
7575
  WorkspaceFeature2["CALENDAR"] = "calendar";
7495
- WorkspaceFeature2["DIRECT_MESSAGES"] = "direct_messages";
7496
7576
  WorkspaceFeature2["JOURNEYS"] = "journeys";
7497
7577
  WorkspaceFeature2["EXPERIMENTS"] = "experiments";
7498
7578
  WorkspaceFeature2["OPERATOR"] = "operator";
7499
- WorkspaceFeature2["PRESENCE"] = "presence";
7500
7579
  WorkspaceFeature2["GMAIL"] = "gmail";
7501
7580
  WorkspaceFeature2["GCALENDAR"] = "gcalendar";
7502
7581
  WorkspaceFeature2["MONDAY"] = "monday";
@@ -10337,6 +10416,7 @@ function bindCustomersMethods(target, customers) {
10337
10416
  target.getMyCustomerAccounts = customers.getMyCustomerAccounts.bind(customers);
10338
10417
  target.getMyCustomerSubscriptions = customers.getMyCustomerSubscriptions.bind(customers);
10339
10418
  target.getMyCustomerInvoices = customers.getMyCustomerInvoices.bind(customers);
10419
+ target.createMyCustomerPortalSession = customers.createMyCustomerPortalSession.bind(customers);
10340
10420
  target.updateMyCustomer = customers.updateMyCustomer.bind(customers);
10341
10421
  target.createMyCustomerSetupIntent = customers.createMyCustomerSetupIntent.bind(customers);
10342
10422
  target.getMyCustomerPaymentMethods = customers.getMyCustomerPaymentMethods.bind(customers);
@@ -11323,6 +11403,7 @@ var GravityRailClient = class {
11323
11403
  getMyCustomerAccounts;
11324
11404
  getMyCustomerSubscriptions;
11325
11405
  getMyCustomerInvoices;
11406
+ createMyCustomerPortalSession;
11326
11407
  updateMyCustomer;
11327
11408
  createMyCustomerSetupIntent;
11328
11409
  getMyCustomerPaymentMethods;
@@ -12885,4 +12966,4 @@ export {
12885
12966
  SCOPE_PRESETS,
12886
12967
  getRevisionState
12887
12968
  };
12888
- //# sourceMappingURL=chunk-YESHLUL7.js.map
12969
+ //# sourceMappingURL=chunk-MUEM2BLY.js.map