@heymantle/core-api-client 0.1.5 → 0.1.7

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
@@ -702,12 +702,76 @@ var DealsResource = class extends BaseResource {
702
702
  }
703
703
  /**
704
704
  * Create a new deal
705
+ *
706
+ * **Linking a Customer:**
707
+ * There are three ways to associate a customer with a deal (use only one):
708
+ *
709
+ * 1. `customerId` - Link to an existing customer by ID
710
+ * 2. `customer` - Create or update a customer inline. Matches existing customers
711
+ * by `domain` or `shopifyDomain`. If no match, creates a new customer.
712
+ * 3. `domain` and/or `shopifyDomain` - Find an existing customer by domain,
713
+ * or create a minimal customer record if not found.
714
+ *
715
+ * If `domain` or `shopifyDomain` are provided alongside `customerId` or `customer`,
716
+ * they will be used to update the customer's domain fields only if not already set.
717
+ *
718
+ * **Linking Contacts:**
719
+ * There are two ways to associate contacts with a deal (use only one):
720
+ *
721
+ * 1. `contactIds` - Link to existing contacts by their IDs
722
+ * 2. `contacts` - Create or update contacts inline. Matches existing contacts
723
+ * by email. Contacts are automatically linked to both the customer and the deal.
724
+ *
725
+ * @example
726
+ * // Using an existing customer
727
+ * await client.deals.create({ name: 'Deal', customerId: 'cust_123', dealFlowId: '...', dealStageId: '...' });
728
+ *
729
+ * // Creating a customer inline
730
+ * await client.deals.create({
731
+ * name: 'Deal',
732
+ * customer: { name: 'Acme Corp', domain: 'acme.com', email: 'info@acme.com' },
733
+ * contacts: [{ email: 'john@acme.com', name: 'John Doe', jobTitle: 'CEO' }],
734
+ * dealFlowId: '...',
735
+ * dealStageId: '...',
736
+ * });
737
+ *
738
+ * // Using domain to find/create customer
739
+ * await client.deals.create({ name: 'Deal', shopifyDomain: 'acme.myshopify.com', dealFlowId: '...', dealStageId: '...' });
705
740
  */
706
741
  async create(data) {
707
742
  return this.post("/deals", data);
708
743
  }
709
744
  /**
710
745
  * Update an existing deal
746
+ *
747
+ * **Updating Customer Association:**
748
+ * There are three ways to change or update the customer (use only one):
749
+ *
750
+ * 1. `customerId` - Change to a different existing customer
751
+ * 2. `customer` - Update the linked customer inline, or create/link a new one.
752
+ * Matches existing customers by `domain` or `shopifyDomain`.
753
+ * 3. `domain` and/or `shopifyDomain` - Find a different customer by domain,
754
+ * or create a minimal customer record if not found.
755
+ *
756
+ * If `domain` or `shopifyDomain` are provided alongside `customerId` or `customer`,
757
+ * they will be used to update the customer's domain fields only if not already set.
758
+ *
759
+ * **Updating Contacts:**
760
+ * There are two ways to update contacts (use only one):
761
+ *
762
+ * 1. `contactIds` - Replace deal contacts with the specified contact IDs
763
+ * 2. `contacts` - Create or update contacts inline. Matches existing contacts
764
+ * by email. Contacts are automatically linked to both the customer and the deal.
765
+ *
766
+ * @example
767
+ * // Update customer's domain if not set
768
+ * await client.deals.update('deal_123', { customerId: 'cust_456', domain: 'newdomain.com' });
769
+ *
770
+ * // Update customer and contacts inline
771
+ * await client.deals.update('deal_123', {
772
+ * customer: { name: 'Updated Name', domain: 'acme.com' },
773
+ * contacts: [{ email: 'new@acme.com', name: 'New Contact' }],
774
+ * });
711
775
  */
712
776
  async update(dealId, data) {
713
777
  return this.put(`/deals/${dealId}`, data);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heymantle/core-api-client",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "TypeScript SDK for the Mantle Core API",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",