@heymantle/core-api-client 0.1.26 → 0.1.27

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.mjs CHANGED
@@ -2634,6 +2634,167 @@ var MeetingsResource = class extends BaseResource {
2634
2634
  }
2635
2635
  };
2636
2636
 
2637
+ // src/resources/synced-emails.ts
2638
+ var SyncedEmailsResource = class extends BaseResource {
2639
+ /**
2640
+ * List synced email threads with optional filters and pagination
2641
+ *
2642
+ * @param params - Filter and pagination parameters
2643
+ * @returns Paginated list of synced email threads
2644
+ *
2645
+ * @example
2646
+ * ```typescript
2647
+ * // List all synced emails
2648
+ * const { syncedEmails } = await client.syncedEmails.list();
2649
+ *
2650
+ * // List synced emails for a specific customer
2651
+ * const { syncedEmails } = await client.syncedEmails.list({ customerId: 'cust_123' });
2652
+ *
2653
+ * // List Gmail synced emails
2654
+ * const { syncedEmails } = await client.syncedEmails.list({ source: 'gmail' });
2655
+ * ```
2656
+ */
2657
+ async list(params) {
2658
+ const response = await this.get("/synced_emails", params);
2659
+ return {
2660
+ syncedEmails: response.syncedEmails || [],
2661
+ hasNextPage: response.hasNextPage || false,
2662
+ hasPreviousPage: response.hasPreviousPage || false,
2663
+ total: response.total,
2664
+ page: response.page,
2665
+ totalPages: response.totalPages
2666
+ };
2667
+ }
2668
+ /**
2669
+ * Retrieve a single synced email thread by ID with all messages
2670
+ *
2671
+ * @param syncedEmailId - The synced email thread ID
2672
+ * @returns The synced email with all messages
2673
+ *
2674
+ * @example
2675
+ * ```typescript
2676
+ * const syncedEmail = await client.syncedEmails.retrieve('se_123');
2677
+ * console.log(syncedEmail.messages?.length);
2678
+ * ```
2679
+ */
2680
+ async retrieve(syncedEmailId) {
2681
+ return this.get(`/synced_emails/${syncedEmailId}`);
2682
+ }
2683
+ /**
2684
+ * Create or sync a synced email thread
2685
+ *
2686
+ * If `emailData.externalId` is provided, performs an upsert: updates the
2687
+ * existing thread and adds new messages if a thread with that externalId
2688
+ * already exists. Otherwise creates a new thread.
2689
+ *
2690
+ * @param data - Email thread and messages data
2691
+ * @returns The created or updated synced email thread
2692
+ *
2693
+ * @example
2694
+ * ```typescript
2695
+ * // Create a new thread (or upsert if externalId matches)
2696
+ * const syncedEmail = await client.syncedEmails.create({
2697
+ * emailData: {
2698
+ * externalId: 'gmail-thread-123',
2699
+ * subject: 'Sales Discussion',
2700
+ * source: 'gmail',
2701
+ * },
2702
+ * messages: [
2703
+ * {
2704
+ * externalId: 'msg-1',
2705
+ * fromEmail: 'prospect@example.com',
2706
+ * subject: 'Sales Discussion',
2707
+ * bodyText: 'Interested in your product...',
2708
+ * date: new Date().toISOString(),
2709
+ * isInbound: true,
2710
+ * },
2711
+ * ],
2712
+ * });
2713
+ * ```
2714
+ */
2715
+ async create(data) {
2716
+ return this.post("/synced_emails", data);
2717
+ }
2718
+ /**
2719
+ * Update synced email thread metadata
2720
+ *
2721
+ * @param syncedEmailId - The synced email thread ID
2722
+ * @param data - Fields to update
2723
+ * @returns The updated synced email thread
2724
+ *
2725
+ * @example
2726
+ * ```typescript
2727
+ * // Link email to a deal
2728
+ * const syncedEmail = await client.syncedEmails.update('se_123', {
2729
+ * dealId: 'deal_456',
2730
+ * });
2731
+ * ```
2732
+ */
2733
+ async update(syncedEmailId, data) {
2734
+ return this.put(`/synced_emails/${syncedEmailId}`, data);
2735
+ }
2736
+ /**
2737
+ * Archive (soft delete) a synced email thread
2738
+ *
2739
+ * @param syncedEmailId - The synced email thread ID
2740
+ * @returns Success response
2741
+ *
2742
+ * @example
2743
+ * ```typescript
2744
+ * await client.syncedEmails.del('se_123');
2745
+ * ```
2746
+ */
2747
+ async del(syncedEmailId) {
2748
+ return this._delete(`/synced_emails/${syncedEmailId}`);
2749
+ }
2750
+ /**
2751
+ * Add messages to an existing synced email thread
2752
+ *
2753
+ * @param syncedEmailId - The synced email thread ID
2754
+ * @param data - Messages to add
2755
+ * @returns The synced email thread with all messages
2756
+ *
2757
+ * @example
2758
+ * ```typescript
2759
+ * const syncedEmail = await client.syncedEmails.addMessages('se_123', {
2760
+ * messages: [
2761
+ * {
2762
+ * externalId: 'msg-2',
2763
+ * fromEmail: 'you@company.com',
2764
+ * toEmails: ['prospect@example.com'],
2765
+ * subject: 'Re: Sales Discussion',
2766
+ * bodyText: 'Thanks for your interest...',
2767
+ * date: new Date().toISOString(),
2768
+ * isInbound: false,
2769
+ * },
2770
+ * ],
2771
+ * });
2772
+ * ```
2773
+ */
2774
+ async addMessages(syncedEmailId, data) {
2775
+ return this.post(
2776
+ `/synced_emails/${syncedEmailId}/messages`,
2777
+ data
2778
+ );
2779
+ }
2780
+ /**
2781
+ * Get messages for a synced email thread
2782
+ *
2783
+ * @param syncedEmailId - The synced email thread ID
2784
+ * @returns List of messages in the thread
2785
+ *
2786
+ * @example
2787
+ * ```typescript
2788
+ * const { messages } = await client.syncedEmails.getMessages('se_123');
2789
+ * ```
2790
+ */
2791
+ async getMessages(syncedEmailId) {
2792
+ return this.get(
2793
+ `/synced_emails/${syncedEmailId}/messages`
2794
+ );
2795
+ }
2796
+ };
2797
+
2637
2798
  // src/client.ts
2638
2799
  var MantleCoreClient = class {
2639
2800
  constructor(config) {
@@ -2693,6 +2854,7 @@ var MantleCoreClient = class {
2693
2854
  this.flowExtensions = new FlowExtensionsResource(this);
2694
2855
  this.aiAgentRuns = new AiAgentRunsResource(this);
2695
2856
  this.meetings = new MeetingsResource(this);
2857
+ this.syncedEmails = new SyncedEmailsResource(this);
2696
2858
  }
2697
2859
  /**
2698
2860
  * Register a middleware function
@@ -3133,6 +3295,7 @@ export {
3133
3295
  MiddlewareManager,
3134
3296
  OrganizationResource,
3135
3297
  SubscriptionsResource,
3298
+ SyncedEmailsResource,
3136
3299
  TasksResource,
3137
3300
  TicketsResource,
3138
3301
  TransactionsResource,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heymantle/core-api-client",
3
- "version": "0.1.26",
3
+ "version": "0.1.27",
4
4
  "description": "TypeScript SDK for the Mantle Core API",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",