@heymantle/core-api-client 0.1.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.
@@ -0,0 +1,2907 @@
1
+ /**
2
+ * Configuration for the MantleCoreClient
3
+ */
4
+ interface MantleCoreClientConfig {
5
+ /** Base URL for API requests. Defaults to "https://api.heymantle.com/v1" */
6
+ baseURL?: string;
7
+ /** API key for authentication (server-side only) */
8
+ apiKey?: string;
9
+ /** OAuth access token for authentication */
10
+ accessToken?: string;
11
+ /** Request timeout in milliseconds. Defaults to 30000 */
12
+ timeout?: number;
13
+ }
14
+ /**
15
+ * Generic paginated list response
16
+ */
17
+ interface PaginatedResponse {
18
+ hasNextPage: boolean;
19
+ hasPreviousPage: boolean;
20
+ total?: number;
21
+ cursor?: string;
22
+ }
23
+ /**
24
+ * Common list parameters for paginated endpoints
25
+ */
26
+ interface ListParams {
27
+ /** Page number for offset pagination (0-indexed) */
28
+ page?: number;
29
+ /** Number of items per page */
30
+ take?: number;
31
+ /** Cursor for cursor-based pagination */
32
+ cursor?: string;
33
+ /** Field to sort by */
34
+ sort?: string;
35
+ /** Sort direction */
36
+ sortDirection?: 'asc' | 'desc';
37
+ /** Search query */
38
+ search?: string;
39
+ /** Minimum updated date filter (ISO 8601) */
40
+ minUpdatedAt?: string;
41
+ /** Maximum updated date filter (ISO 8601) */
42
+ maxUpdatedAt?: string;
43
+ /** Allow additional string keys */
44
+ [key: string]: unknown;
45
+ }
46
+ /**
47
+ * Request options for internal HTTP client
48
+ */
49
+ interface RequestOptions {
50
+ method: 'GET' | 'POST' | 'PUT' | 'DELETE';
51
+ body?: string;
52
+ headers?: Record<string, string>;
53
+ }
54
+ /**
55
+ * Standard success response for delete operations
56
+ */
57
+ interface DeleteResponse {
58
+ success: boolean;
59
+ }
60
+
61
+ /**
62
+ * Base resource class that all resources extend.
63
+ * Provides common HTTP methods that delegate to the client.
64
+ */
65
+ declare abstract class BaseResource {
66
+ protected readonly client: MantleCoreClient;
67
+ constructor(client: MantleCoreClient);
68
+ protected get<T>(endpoint: string, params?: Record<string, unknown> | object): Promise<T>;
69
+ protected post<T>(endpoint: string, data?: Record<string, unknown> | object): Promise<T>;
70
+ protected put<T>(endpoint: string, data?: Record<string, unknown> | object): Promise<T>;
71
+ protected _delete<T>(endpoint: string): Promise<T>;
72
+ }
73
+
74
+ /**
75
+ * App installation on a customer
76
+ */
77
+ interface AppInstallation {
78
+ id: string;
79
+ appId: string;
80
+ installedAt?: string;
81
+ uninstalledAt?: string;
82
+ test?: boolean;
83
+ active?: boolean;
84
+ plan?: {
85
+ id: string;
86
+ name: string;
87
+ };
88
+ subscription?: {
89
+ id: string;
90
+ status: string;
91
+ };
92
+ }
93
+ /**
94
+ * App installation params for creating/updating
95
+ */
96
+ interface AppInstallationParams {
97
+ appId: string;
98
+ installedAt?: string;
99
+ test?: boolean;
100
+ }
101
+ /**
102
+ * Account owner for a customer
103
+ */
104
+ interface AccountOwner {
105
+ id: string;
106
+ email: string;
107
+ name?: string;
108
+ createdAt: string;
109
+ updatedAt: string;
110
+ }
111
+ /**
112
+ * Customer entity
113
+ */
114
+ interface Customer {
115
+ id: string;
116
+ name?: string;
117
+ email?: string;
118
+ domain?: string;
119
+ url?: string;
120
+ shopifyDomain?: string;
121
+ shopifyShopId?: string;
122
+ countryCode?: string;
123
+ preferredCurrency?: string;
124
+ description?: string;
125
+ tags: string[];
126
+ customFields?: Record<string, unknown>;
127
+ lifetimeValue?: number;
128
+ test?: boolean;
129
+ createdAt: string;
130
+ updatedAt: string;
131
+ appInstallations?: AppInstallation[];
132
+ accountOwners?: AccountOwner[];
133
+ company?: {
134
+ id: string;
135
+ name: string;
136
+ };
137
+ }
138
+ /**
139
+ * Parameters for listing customers
140
+ */
141
+ interface CustomerListParams extends ListParams {
142
+ appIds?: string[];
143
+ shopifyShopDomain?: string;
144
+ shopifyShopId?: string;
145
+ includeUsageMetrics?: boolean;
146
+ includeContactCount?: boolean;
147
+ }
148
+ /**
149
+ * Response from listing customers
150
+ */
151
+ interface CustomerListResponse extends PaginatedResponse {
152
+ customers: Customer[];
153
+ }
154
+ /**
155
+ * Parameters for creating a customer
156
+ */
157
+ interface CustomerCreateParams {
158
+ name?: string;
159
+ email?: string;
160
+ domain?: string;
161
+ url?: string;
162
+ shopifyDomain?: string;
163
+ shopifyShopId?: string;
164
+ tags?: string[];
165
+ customFields?: Record<string, unknown>;
166
+ companyId?: string;
167
+ countryCode?: string;
168
+ preferredCurrency?: string;
169
+ description?: string;
170
+ appInstallations?: AppInstallationParams[];
171
+ }
172
+ /**
173
+ * Parameters for updating a customer
174
+ */
175
+ interface CustomerUpdateParams extends Partial<CustomerCreateParams> {
176
+ }
177
+ /**
178
+ * Parameters for retrieving a customer
179
+ */
180
+ interface CustomerRetrieveParams {
181
+ includeContactCount?: boolean;
182
+ includeCurrentInvoice?: boolean;
183
+ }
184
+ /**
185
+ * Timeline event for a customer
186
+ */
187
+ interface TimelineEvent {
188
+ id: string;
189
+ type: string;
190
+ description?: string;
191
+ occurredAt: string;
192
+ metadata?: Record<string, unknown>;
193
+ }
194
+ /**
195
+ * Response from listing timeline events
196
+ */
197
+ interface TimelineListResponse extends PaginatedResponse {
198
+ events: TimelineEvent[];
199
+ }
200
+ /**
201
+ * Parameters for listing timeline events
202
+ */
203
+ interface TimelineListParams {
204
+ appId?: string;
205
+ type?: string;
206
+ limit?: number;
207
+ cursor?: string;
208
+ }
209
+ /**
210
+ * Response from listing account owners
211
+ */
212
+ interface AccountOwnersListResponse {
213
+ accountOwners: AccountOwner[];
214
+ }
215
+ /**
216
+ * Custom field definition
217
+ */
218
+ interface CustomField {
219
+ id: string;
220
+ name: string;
221
+ type: 'string' | 'number' | 'boolean' | 'date' | 'select';
222
+ defaultValue?: unknown;
223
+ options?: string[];
224
+ appLevel?: boolean;
225
+ showOnCustomerDetail?: boolean;
226
+ private?: boolean;
227
+ filterable?: boolean;
228
+ createdAt: string;
229
+ updatedAt: string;
230
+ }
231
+ /**
232
+ * Parameters for creating a custom field
233
+ */
234
+ interface CustomFieldCreateParams {
235
+ appId: string;
236
+ name: string;
237
+ type: 'string' | 'number' | 'boolean' | 'date' | 'select';
238
+ defaultValue?: unknown;
239
+ options?: string[];
240
+ appLevel?: boolean;
241
+ showOnCustomerDetail?: boolean;
242
+ private?: boolean;
243
+ filterable?: boolean;
244
+ }
245
+ /**
246
+ * Parameters for updating a custom field
247
+ */
248
+ interface CustomFieldUpdateParams extends Partial<Omit<CustomFieldCreateParams, 'appId'>> {
249
+ }
250
+
251
+ /**
252
+ * Social profile for a contact
253
+ */
254
+ interface SocialProfile {
255
+ platform: string;
256
+ url: string;
257
+ username?: string;
258
+ }
259
+ /**
260
+ * Contact entity
261
+ */
262
+ interface Contact {
263
+ id: string;
264
+ name?: string;
265
+ email?: string;
266
+ phone?: string;
267
+ jobTitle?: string;
268
+ notes?: string;
269
+ tags: string[];
270
+ socialProfiles?: SocialProfile[];
271
+ customers?: Array<{
272
+ id: string;
273
+ name?: string;
274
+ }>;
275
+ createdAt: string;
276
+ updatedAt: string;
277
+ }
278
+ /**
279
+ * Parameters for listing contacts
280
+ */
281
+ interface ContactListParams extends ListParams {
282
+ }
283
+ /**
284
+ * Response from listing contacts
285
+ */
286
+ interface ContactListResponse extends PaginatedResponse {
287
+ contacts: Contact[];
288
+ }
289
+ /**
290
+ * Parameters for creating a contact
291
+ */
292
+ interface ContactCreateParams {
293
+ name?: string;
294
+ email?: string;
295
+ phone?: string;
296
+ jobTitle?: string;
297
+ notes?: string;
298
+ tags?: string[];
299
+ customers?: string[];
300
+ socialProfiles?: SocialProfile[];
301
+ }
302
+ /**
303
+ * Parameters for updating a contact
304
+ */
305
+ interface ContactUpdateParams extends Partial<ContactCreateParams> {
306
+ }
307
+
308
+ /**
309
+ * Subscription entity
310
+ */
311
+ interface Subscription {
312
+ id: string;
313
+ customerId: string;
314
+ appId: string;
315
+ planId?: string;
316
+ status: string;
317
+ currentPeriodStart?: string;
318
+ currentPeriodEnd?: string;
319
+ canceledAt?: string;
320
+ cancelAtPeriodEnd?: boolean;
321
+ trialStart?: string;
322
+ trialEnd?: string;
323
+ amount?: number;
324
+ currencyCode?: string;
325
+ interval?: string;
326
+ test?: boolean;
327
+ createdAt: string;
328
+ updatedAt: string;
329
+ plan?: {
330
+ id: string;
331
+ name: string;
332
+ amount: number;
333
+ currencyCode: string;
334
+ interval: string;
335
+ };
336
+ customer?: {
337
+ id: string;
338
+ name?: string;
339
+ email?: string;
340
+ };
341
+ }
342
+ /**
343
+ * Parameters for listing subscriptions
344
+ */
345
+ interface SubscriptionListParams extends ListParams {
346
+ appId?: string;
347
+ customerId?: string;
348
+ startDate?: string;
349
+ endDate?: string;
350
+ ids?: string[];
351
+ active?: boolean;
352
+ }
353
+ /**
354
+ * Response from listing subscriptions
355
+ */
356
+ interface SubscriptionListResponse extends PaginatedResponse {
357
+ subscriptions: Subscription[];
358
+ }
359
+
360
+ /**
361
+ * App entity
362
+ */
363
+ interface App {
364
+ id: string;
365
+ name: string;
366
+ slug?: string;
367
+ platform?: string;
368
+ description?: string;
369
+ iconUrl?: string;
370
+ listingUrl?: string;
371
+ websiteUrl?: string;
372
+ supportEmail?: string;
373
+ privacyPolicyUrl?: string;
374
+ termsOfServiceUrl?: string;
375
+ createdAt: string;
376
+ updatedAt: string;
377
+ }
378
+ /**
379
+ * Parameters for listing apps
380
+ */
381
+ interface AppListParams {
382
+ minUpdatedAt?: string;
383
+ maxUpdatedAt?: string;
384
+ }
385
+ /**
386
+ * Plan usage charge configuration
387
+ */
388
+ interface PlanUsageCharge {
389
+ id?: string;
390
+ usageMetricId: string;
391
+ cappedAmount?: number;
392
+ terms?: string;
393
+ balanceUsed?: boolean;
394
+ interval?: string;
395
+ }
396
+ /**
397
+ * Plan feature configuration
398
+ */
399
+ interface PlanFeature {
400
+ id: string;
401
+ featureId: string;
402
+ value?: unknown;
403
+ valueType?: string;
404
+ }
405
+ /**
406
+ * Plan entity
407
+ */
408
+ interface Plan {
409
+ id: string;
410
+ appId: string;
411
+ name: string;
412
+ description?: string;
413
+ interval: 'month' | 'year' | 'one_time';
414
+ currencyCode: string;
415
+ amount: number;
416
+ trialDays?: number;
417
+ public?: boolean;
418
+ visible?: boolean;
419
+ archived?: boolean;
420
+ customerTags?: string[];
421
+ customerExcludeTags?: string[];
422
+ shopifyPlans?: string[];
423
+ type?: string;
424
+ flexBilling?: boolean;
425
+ flexBillingTerms?: string;
426
+ planUsageCharges?: PlanUsageCharge[];
427
+ features?: PlanFeature[];
428
+ customFields?: Record<string, unknown>;
429
+ createdAt: string;
430
+ updatedAt: string;
431
+ }
432
+ /**
433
+ * Parameters for listing plans
434
+ */
435
+ interface PlanListParams {
436
+ public?: boolean;
437
+ page?: number;
438
+ perPage?: number;
439
+ search?: string;
440
+ }
441
+ /**
442
+ * Response from listing plans
443
+ */
444
+ interface PlanListResponse {
445
+ plans: Plan[];
446
+ total: number;
447
+ hasMore: boolean;
448
+ nextCursor?: string;
449
+ }
450
+ /**
451
+ * Parameters for creating a plan
452
+ */
453
+ interface PlanCreateParams {
454
+ name: string;
455
+ description?: string;
456
+ interval: 'month' | 'year' | 'one_time';
457
+ currencyCode: string;
458
+ amount: number;
459
+ trialDays?: number;
460
+ public?: boolean;
461
+ visible?: boolean;
462
+ customerTags?: string[];
463
+ customerExcludeTags?: string[];
464
+ shopifyPlans?: string[];
465
+ type?: string;
466
+ flexBilling?: boolean;
467
+ flexBillingTerms?: string;
468
+ planUsageCharges?: Omit<PlanUsageCharge, 'id'>[];
469
+ features?: Array<{
470
+ featureId: string;
471
+ value?: unknown;
472
+ }>;
473
+ customFields?: Record<string, unknown>;
474
+ }
475
+ /**
476
+ * Parameters for updating a plan
477
+ */
478
+ interface PlanUpdateParams extends Partial<PlanCreateParams> {
479
+ }
480
+ /**
481
+ * Feature entity
482
+ */
483
+ interface Feature {
484
+ id: string;
485
+ appId: string;
486
+ name: string;
487
+ type: 'boolean' | 'limit' | 'unlimited';
488
+ description?: string;
489
+ usageMetricId?: string;
490
+ createdAt: string;
491
+ updatedAt: string;
492
+ }
493
+ /**
494
+ * Parameters for creating a feature
495
+ */
496
+ interface FeatureCreateParams {
497
+ name: string;
498
+ type: 'boolean' | 'limit' | 'unlimited';
499
+ description?: string;
500
+ usageMetricId?: string;
501
+ }
502
+ /**
503
+ * Parameters for updating a feature
504
+ */
505
+ interface FeatureUpdateParams extends Partial<Omit<FeatureCreateParams, 'type'>> {
506
+ }
507
+ /**
508
+ * App review entity
509
+ */
510
+ interface Review {
511
+ id: string;
512
+ appId: string;
513
+ rating: number;
514
+ title?: string;
515
+ body?: string;
516
+ author?: string;
517
+ reviewedAt?: string;
518
+ createdAt: string;
519
+ updatedAt: string;
520
+ }
521
+ /**
522
+ * Parameters for creating a review
523
+ */
524
+ interface ReviewCreateParams {
525
+ rating: number;
526
+ title?: string;
527
+ body?: string;
528
+ }
529
+ /**
530
+ * Parameters for updating a review
531
+ */
532
+ interface ReviewUpdateParams extends Partial<ReviewCreateParams> {
533
+ }
534
+ /**
535
+ * Usage metric entity
536
+ */
537
+ interface UsageMetric {
538
+ id: string;
539
+ appId: string;
540
+ name: string;
541
+ description?: string;
542
+ eventName?: string;
543
+ aggregationType?: string;
544
+ createdAt: string;
545
+ updatedAt: string;
546
+ }
547
+ /**
548
+ * Parameters for creating a usage metric
549
+ */
550
+ interface UsageMetricCreateParams {
551
+ name: string;
552
+ description?: string;
553
+ eventName?: string;
554
+ aggregationType?: string;
555
+ }
556
+ /**
557
+ * Parameters for updating a usage metric
558
+ */
559
+ interface UsageMetricUpdateParams extends Partial<UsageMetricCreateParams> {
560
+ }
561
+ /**
562
+ * App event entity
563
+ */
564
+ interface AppEvent {
565
+ id: string;
566
+ appId: string;
567
+ customerId?: string;
568
+ name: string;
569
+ description?: string;
570
+ occurredAt: string;
571
+ properties?: Record<string, unknown>;
572
+ createdAt: string;
573
+ }
574
+ /**
575
+ * Parameters for listing app events
576
+ */
577
+ interface AppEventListParams extends ListParams {
578
+ customerId?: string;
579
+ }
580
+ /**
581
+ * Response from listing app events
582
+ */
583
+ interface AppEventListResponse extends PaginatedResponse {
584
+ appEvents: AppEvent[];
585
+ }
586
+
587
+ /**
588
+ * Usage event entity
589
+ */
590
+ interface UsageEvent {
591
+ id: string;
592
+ appId: string;
593
+ customerId: string;
594
+ eventName: string;
595
+ eventId?: string;
596
+ timestamp: string;
597
+ properties?: Record<string, unknown>;
598
+ billingStatus?: string;
599
+ countryCode?: string;
600
+ createdAt: string;
601
+ }
602
+ /**
603
+ * Parameters for listing usage events
604
+ */
605
+ interface UsageEventListParams extends ListParams {
606
+ appId?: string;
607
+ customerId?: string;
608
+ eventName?: string;
609
+ propertiesFilters?: Record<string, unknown>;
610
+ billingStatus?: string;
611
+ countryCode?: string;
612
+ startDate?: string;
613
+ endDate?: string;
614
+ }
615
+ /**
616
+ * Response from listing usage events
617
+ */
618
+ interface UsageEventListResponse extends PaginatedResponse {
619
+ usageEvents: UsageEvent[];
620
+ events?: UsageEvent[];
621
+ }
622
+ /**
623
+ * Single usage event for creation
624
+ */
625
+ interface UsageEventCreateData {
626
+ timestamp?: string;
627
+ eventName: string;
628
+ eventId?: string;
629
+ customerId: string;
630
+ appId: string;
631
+ properties?: Record<string, unknown>;
632
+ }
633
+ /**
634
+ * Parameters for creating usage event(s)
635
+ */
636
+ interface UsageEventCreateParams {
637
+ /** Single event data */
638
+ timestamp?: string;
639
+ eventName?: string;
640
+ eventId?: string;
641
+ customerId?: string;
642
+ appId?: string;
643
+ properties?: Record<string, unknown>;
644
+ private?: boolean;
645
+ /** Multiple events */
646
+ events?: UsageEventCreateData[];
647
+ }
648
+ /**
649
+ * Response from creating usage events
650
+ */
651
+ interface UsageEventCreateResponse {
652
+ success: boolean;
653
+ }
654
+
655
+ /**
656
+ * Deal entity
657
+ */
658
+ interface Deal {
659
+ id: string;
660
+ name: string;
661
+ amount?: number;
662
+ amountCurrencyCode?: string;
663
+ currentAmount?: number;
664
+ acquisitionChannel?: string;
665
+ acquisitionSource?: string;
666
+ firstInteractionAt?: string;
667
+ closingAt?: string;
668
+ closedAt?: string;
669
+ stage?: string;
670
+ step?: number;
671
+ dealFlowId?: string;
672
+ dealStageId?: string;
673
+ customerId?: string;
674
+ domain?: string;
675
+ shopifyDomain?: string;
676
+ companyId?: string;
677
+ appId?: string;
678
+ planId?: string;
679
+ ownerIds?: string[];
680
+ contactIds?: string[];
681
+ notes?: string;
682
+ affiliateId?: string;
683
+ partnershipId?: string;
684
+ archived?: boolean;
685
+ createdAt: string;
686
+ updatedAt: string;
687
+ customer?: {
688
+ id: string;
689
+ name?: string;
690
+ };
691
+ dealFlow?: {
692
+ id: string;
693
+ name: string;
694
+ };
695
+ dealStage?: {
696
+ id: string;
697
+ name: string;
698
+ };
699
+ }
700
+ /**
701
+ * Parameters for listing deals
702
+ */
703
+ interface DealListParams extends ListParams {
704
+ customerId?: string;
705
+ appId?: string;
706
+ planId?: string;
707
+ dealStageId?: string;
708
+ dealFlowId?: string;
709
+ affiliateId?: string;
710
+ partnershipId?: string;
711
+ acquirerId?: string;
712
+ ownerId?: string;
713
+ contactId?: string;
714
+ stage?: string;
715
+ step?: number;
716
+ minAmount?: number;
717
+ maxAmount?: number;
718
+ minCurrentAmount?: number;
719
+ maxCurrentAmount?: number;
720
+ acquisitionChannel?: string;
721
+ acquisitionSource?: string;
722
+ includeArchived?: boolean;
723
+ }
724
+ /**
725
+ * Response from listing deals
726
+ */
727
+ interface DealListResponse extends PaginatedResponse {
728
+ deals: Deal[];
729
+ }
730
+ /**
731
+ * Parameters for creating a deal
732
+ */
733
+ interface DealCreateParams {
734
+ name: string;
735
+ amount?: number;
736
+ amountCurrencyCode?: string;
737
+ acquisitionChannel?: string;
738
+ acquisitionSource?: string;
739
+ firstInteractionAt?: string;
740
+ closingAt?: string;
741
+ closedAt?: string;
742
+ dealFlowId?: string;
743
+ dealStageId?: string;
744
+ customerId?: string;
745
+ domain?: string;
746
+ shopifyDomain?: string;
747
+ companyId?: string;
748
+ appId?: string;
749
+ planId?: string;
750
+ ownerIds?: string[];
751
+ contactIds?: string[];
752
+ notes?: string;
753
+ affiliateId?: string;
754
+ partnershipId?: string;
755
+ }
756
+ /**
757
+ * Parameters for updating a deal
758
+ */
759
+ interface DealUpdateParams extends Partial<DealCreateParams> {
760
+ }
761
+ /**
762
+ * Deal flow entity
763
+ */
764
+ interface DealFlow {
765
+ id: string;
766
+ name: string;
767
+ description?: string;
768
+ stages?: DealStage[];
769
+ createdAt: string;
770
+ updatedAt: string;
771
+ }
772
+ /**
773
+ * Deal stage within a flow
774
+ */
775
+ interface DealStage {
776
+ id: string;
777
+ name: string;
778
+ order: number;
779
+ color?: string;
780
+ }
781
+ /**
782
+ * Parameters for creating a deal flow
783
+ */
784
+ interface DealFlowCreateParams {
785
+ name: string;
786
+ description?: string;
787
+ }
788
+ /**
789
+ * Parameters for updating a deal flow
790
+ */
791
+ interface DealFlowUpdateParams extends Partial<DealFlowCreateParams> {
792
+ }
793
+ /**
794
+ * Deal activity entity
795
+ */
796
+ interface DealActivity {
797
+ id: string;
798
+ name: string;
799
+ dealFlowId: string;
800
+ description?: string;
801
+ order: number;
802
+ createdAt: string;
803
+ updatedAt: string;
804
+ }
805
+ /**
806
+ * Parameters for creating a deal activity
807
+ */
808
+ interface DealActivityCreateParams {
809
+ name: string;
810
+ dealFlowId: string;
811
+ description?: string;
812
+ order?: number;
813
+ }
814
+ /**
815
+ * Parameters for updating a deal activity
816
+ */
817
+ interface DealActivityUpdateParams extends Partial<Omit<DealActivityCreateParams, 'dealFlowId'>> {
818
+ }
819
+
820
+ /**
821
+ * Ticket entity
822
+ */
823
+ interface Ticket {
824
+ id: string;
825
+ subject: string;
826
+ status: 'open' | 'pending' | 'resolved' | 'closed';
827
+ priority: 'low' | 'medium' | 'high' | 'urgent';
828
+ tags: string[];
829
+ contactId?: string;
830
+ customerId?: string;
831
+ channelId?: string;
832
+ appId?: string;
833
+ assignedToId?: string;
834
+ createdAt: string;
835
+ updatedAt: string;
836
+ contact?: {
837
+ id: string;
838
+ name?: string;
839
+ email?: string;
840
+ };
841
+ customer?: {
842
+ id: string;
843
+ name?: string;
844
+ };
845
+ assignedTo?: {
846
+ id: string;
847
+ name?: string;
848
+ email?: string;
849
+ };
850
+ }
851
+ /**
852
+ * Parameters for listing tickets
853
+ */
854
+ interface TicketListParams extends ListParams {
855
+ status?: 'open' | 'pending' | 'resolved' | 'closed';
856
+ priority?: 'low' | 'medium' | 'high' | 'urgent';
857
+ assignedToId?: string;
858
+ appId?: string;
859
+ customerId?: string;
860
+ contactId?: string;
861
+ channelId?: string;
862
+ tags?: string[];
863
+ }
864
+ /**
865
+ * Response from listing tickets
866
+ */
867
+ interface TicketListResponse extends PaginatedResponse {
868
+ tickets: Ticket[];
869
+ }
870
+ /**
871
+ * Contact data for ticket creation
872
+ */
873
+ interface TicketContactData {
874
+ email: string;
875
+ name?: string;
876
+ }
877
+ /**
878
+ * Parameters for creating a ticket
879
+ */
880
+ interface TicketCreateParams {
881
+ subject: string;
882
+ status?: 'open' | 'pending' | 'resolved' | 'closed';
883
+ priority?: 'low' | 'medium' | 'high' | 'urgent';
884
+ tags?: string[];
885
+ contactId?: string;
886
+ customerId?: string;
887
+ channelId?: string;
888
+ appId?: string;
889
+ assignedToId?: string;
890
+ contact?: TicketContactData;
891
+ }
892
+ /**
893
+ * Parameters for updating a ticket
894
+ */
895
+ interface TicketUpdateParams {
896
+ subject?: string;
897
+ status?: 'open' | 'pending' | 'resolved' | 'closed';
898
+ priority?: 'low' | 'medium' | 'high' | 'urgent';
899
+ tags?: string[];
900
+ assignedToId?: string;
901
+ }
902
+ /**
903
+ * Ticket message attachment
904
+ */
905
+ interface MessageAttachment {
906
+ id?: string;
907
+ filename: string;
908
+ url: string;
909
+ contentType?: string;
910
+ size?: number;
911
+ }
912
+ /**
913
+ * Ticket message entity
914
+ */
915
+ interface TicketMessage {
916
+ id: string;
917
+ ticketId: string;
918
+ body: string;
919
+ from: 'customer' | 'agent';
920
+ attachments?: MessageAttachment[];
921
+ createdAt: string;
922
+ updatedAt: string;
923
+ author?: {
924
+ id: string;
925
+ name?: string;
926
+ email?: string;
927
+ };
928
+ }
929
+ /**
930
+ * Parameters for creating a ticket message
931
+ */
932
+ interface TicketMessageCreateParams {
933
+ body: string;
934
+ from: 'customer' | 'agent';
935
+ attachments?: Omit<MessageAttachment, 'id'>[];
936
+ }
937
+ /**
938
+ * Parameters for updating a ticket message
939
+ */
940
+ interface TicketMessageUpdateParams {
941
+ body?: string;
942
+ }
943
+ /**
944
+ * Channel entity (email or chat)
945
+ */
946
+ interface Channel {
947
+ id: string;
948
+ type: 'email' | 'chat';
949
+ name: string;
950
+ createdAt: string;
951
+ updatedAt: string;
952
+ }
953
+ /**
954
+ * Parameters for listing channels
955
+ */
956
+ interface ChannelListParams {
957
+ type?: 'email' | 'chat';
958
+ }
959
+ /**
960
+ * Parameters for creating a channel
961
+ */
962
+ interface ChannelCreateParams {
963
+ type: 'email' | 'chat';
964
+ name: string;
965
+ }
966
+
967
+ /**
968
+ * Affiliate entity
969
+ */
970
+ interface Affiliate {
971
+ id: string;
972
+ email: string;
973
+ name?: string;
974
+ status: 'pending' | 'active' | 'rejected' | 'suspended';
975
+ affiliateProgramId: string;
976
+ appId?: string;
977
+ commissionRate?: number;
978
+ referralCode?: string;
979
+ referralUrl?: string;
980
+ paypalEmail?: string;
981
+ totalReferrals?: number;
982
+ totalCommissions?: number;
983
+ unpaidCommissions?: number;
984
+ createdAt: string;
985
+ updatedAt: string;
986
+ affiliateProgram?: {
987
+ id: string;
988
+ name: string;
989
+ };
990
+ }
991
+ /**
992
+ * Parameters for listing affiliates
993
+ */
994
+ interface AffiliateListParams extends ListParams {
995
+ affiliateProgramId?: string;
996
+ status?: 'pending' | 'active' | 'rejected' | 'suspended';
997
+ appId?: string;
998
+ email?: string;
999
+ }
1000
+ /**
1001
+ * Response from listing affiliates
1002
+ */
1003
+ interface AffiliateListResponse extends PaginatedResponse {
1004
+ affiliates: Affiliate[];
1005
+ }
1006
+ /**
1007
+ * Parameters for updating an affiliate
1008
+ */
1009
+ interface AffiliateUpdateParams {
1010
+ status?: 'pending' | 'active' | 'rejected' | 'suspended';
1011
+ commissionRate?: number;
1012
+ }
1013
+ /**
1014
+ * Affiliate program entity
1015
+ */
1016
+ interface AffiliateProgram {
1017
+ id: string;
1018
+ name: string;
1019
+ description?: string;
1020
+ commissionType: 'percentage' | 'fixed';
1021
+ commissionValue: number;
1022
+ commissionDurationMonths?: number;
1023
+ cookieDurationDays?: number;
1024
+ minimumPayoutAmount?: number;
1025
+ payoutCurrency?: string;
1026
+ active?: boolean;
1027
+ createdAt: string;
1028
+ updatedAt: string;
1029
+ }
1030
+ /**
1031
+ * Parameters for creating an affiliate program
1032
+ */
1033
+ interface AffiliateProgramCreateParams {
1034
+ name: string;
1035
+ description?: string;
1036
+ commissionType: 'percentage' | 'fixed';
1037
+ commissionValue: number;
1038
+ commissionDurationMonths?: number;
1039
+ cookieDurationDays?: number;
1040
+ minimumPayoutAmount?: number;
1041
+ payoutCurrency?: string;
1042
+ active?: boolean;
1043
+ }
1044
+ /**
1045
+ * Parameters for updating an affiliate program
1046
+ */
1047
+ interface AffiliateProgramUpdateParams extends Partial<AffiliateProgramCreateParams> {
1048
+ }
1049
+ /**
1050
+ * Affiliate commission entity
1051
+ */
1052
+ interface AffiliateCommission {
1053
+ id: string;
1054
+ affiliateId: string;
1055
+ referralId?: string;
1056
+ amount: number;
1057
+ currencyCode: string;
1058
+ status: 'pending' | 'approved' | 'paid' | 'rejected';
1059
+ paidAt?: string;
1060
+ createdAt: string;
1061
+ updatedAt: string;
1062
+ affiliate?: {
1063
+ id: string;
1064
+ name?: string;
1065
+ email: string;
1066
+ };
1067
+ }
1068
+ /**
1069
+ * Parameters for listing affiliate commissions
1070
+ */
1071
+ interface AffiliateCommissionListParams extends ListParams {
1072
+ affiliateId?: string;
1073
+ status?: 'pending' | 'approved' | 'paid' | 'rejected';
1074
+ }
1075
+ /**
1076
+ * Response from listing affiliate commissions
1077
+ */
1078
+ interface AffiliateCommissionListResponse extends PaginatedResponse {
1079
+ commissions: AffiliateCommission[];
1080
+ }
1081
+ /**
1082
+ * Affiliate payout entity
1083
+ */
1084
+ interface AffiliatePayout {
1085
+ id: string;
1086
+ affiliateId: string;
1087
+ amount: number;
1088
+ currencyCode: string;
1089
+ status: 'pending' | 'processing' | 'completed' | 'failed';
1090
+ method?: string;
1091
+ processedAt?: string;
1092
+ createdAt: string;
1093
+ updatedAt: string;
1094
+ affiliate?: {
1095
+ id: string;
1096
+ name?: string;
1097
+ email: string;
1098
+ };
1099
+ }
1100
+ /**
1101
+ * Parameters for listing affiliate payouts
1102
+ */
1103
+ interface AffiliatePayoutListParams extends ListParams {
1104
+ affiliateId?: string;
1105
+ status?: 'pending' | 'processing' | 'completed' | 'failed';
1106
+ }
1107
+ /**
1108
+ * Response from listing affiliate payouts
1109
+ */
1110
+ interface AffiliatePayoutListResponse extends PaginatedResponse {
1111
+ payouts: AffiliatePayout[];
1112
+ }
1113
+ /**
1114
+ * Affiliate referral entity
1115
+ */
1116
+ interface AffiliateReferral {
1117
+ id: string;
1118
+ affiliateId: string;
1119
+ customerId?: string;
1120
+ subscriptionId?: string;
1121
+ status: 'pending' | 'converted' | 'expired';
1122
+ referredAt: string;
1123
+ convertedAt?: string;
1124
+ createdAt: string;
1125
+ updatedAt: string;
1126
+ affiliate?: {
1127
+ id: string;
1128
+ name?: string;
1129
+ email: string;
1130
+ };
1131
+ customer?: {
1132
+ id: string;
1133
+ name?: string;
1134
+ };
1135
+ }
1136
+ /**
1137
+ * Parameters for listing affiliate referrals
1138
+ */
1139
+ interface AffiliateReferralListParams extends ListParams {
1140
+ affiliateId?: string;
1141
+ status?: 'pending' | 'converted' | 'expired';
1142
+ }
1143
+ /**
1144
+ * Response from listing affiliate referrals
1145
+ */
1146
+ interface AffiliateReferralListResponse extends PaginatedResponse {
1147
+ referrals: AffiliateReferral[];
1148
+ }
1149
+
1150
+ /**
1151
+ * Available metrics for the Mantle API
1152
+ */
1153
+ type MetricType = 'PlatformApp.activeInstalls' | 'PlatformApp.activeSubscriptions' | 'PlatformApp.arr' | 'PlatformApp.arpu' | 'PlatformApp.charges' | 'PlatformApp.logoChurn' | 'PlatformApp.ltv' | 'PlatformApp.mrr' | 'PlatformApp.netInstalls' | 'PlatformApp.netRevenue' | 'PlatformApp.netRevenueRetention' | 'PlatformApp.payout' | 'PlatformApp.predictedLtv' | 'PlatformApp.revenueChurn' | 'PlatformApp.revenueRetention' | 'PlatformApp.usageEvent' | 'PlatformApp.usageMetric';
1154
+ /**
1155
+ * Available date ranges for metrics
1156
+ */
1157
+ type DateRangeType = 'last_30_minutes' | 'last_60_minutes' | 'last_12_hours' | 'last_24_hours' | 'last_7_days' | 'last_14_days' | 'last_30_days' | 'last_90_days' | 'last_12_months' | 'last_24_months' | 'today' | 'yesterday' | 'last_month' | 'month_to_date' | 'quarter_to_date' | 'year_to_date' | 'all_time' | 'custom';
1158
+ /**
1159
+ * Base parameters for metrics requests
1160
+ */
1161
+ interface MetricsBaseParams {
1162
+ appId: string;
1163
+ dateRange?: DateRangeType;
1164
+ startDate?: string;
1165
+ endDate?: string;
1166
+ includes?: string[];
1167
+ appEventsForMrr?: boolean;
1168
+ }
1169
+ /**
1170
+ * Parameters for generic metric request
1171
+ */
1172
+ interface MetricsGetParams extends MetricsBaseParams {
1173
+ metric: MetricType | string;
1174
+ nf?: boolean;
1175
+ }
1176
+ /**
1177
+ * Metric data point
1178
+ */
1179
+ interface MetricDataPoint {
1180
+ date?: string;
1181
+ value?: number;
1182
+ total?: number;
1183
+ startingTotal?: number;
1184
+ change?: number;
1185
+ changePercentage?: number;
1186
+ formattedTotal?: string;
1187
+ formattedChange?: string;
1188
+ formattedChangePercentage?: string;
1189
+ }
1190
+ /**
1191
+ * Response from metrics endpoint
1192
+ */
1193
+ interface MetricsResponse {
1194
+ data: MetricDataPoint[];
1195
+ total?: number;
1196
+ startingTotal?: number;
1197
+ change?: number;
1198
+ changePercentage?: number;
1199
+ formattedTotal?: string;
1200
+ formattedChange?: string;
1201
+ formattedChangePercentage?: string;
1202
+ }
1203
+ /**
1204
+ * Parameters for usage event metrics
1205
+ */
1206
+ interface UsageEventMetricsParams extends MetricsBaseParams {
1207
+ eventName: string;
1208
+ propertyKey?: string;
1209
+ aggregation?: 'count' | 'sum' | 'avg' | 'min' | 'max';
1210
+ }
1211
+ /**
1212
+ * Parameters for usage metric request
1213
+ */
1214
+ interface UsageMetricParams extends MetricsBaseParams {
1215
+ metricId: string;
1216
+ }
1217
+
1218
+ /**
1219
+ * Webhook topic types
1220
+ */
1221
+ type WebhookTopic = 'customer.created' | 'customer.updated' | 'customer.deleted' | 'subscription.created' | 'subscription.updated' | 'subscription.canceled' | 'usage_event.created' | 'app_event.created' | 'deal.created' | 'deal.updated' | 'deal.deleted' | 'ticket.created' | 'ticket.updated';
1222
+ /**
1223
+ * Webhook filter configuration
1224
+ */
1225
+ interface WebhookFilter {
1226
+ eventName?: string;
1227
+ }
1228
+ /**
1229
+ * Webhook entity
1230
+ */
1231
+ interface Webhook {
1232
+ id: string;
1233
+ topic: WebhookTopic | string;
1234
+ address: string;
1235
+ appIds?: string[];
1236
+ filter?: WebhookFilter;
1237
+ active?: boolean;
1238
+ createdAt: string;
1239
+ updatedAt: string;
1240
+ }
1241
+ /**
1242
+ * Response from listing webhooks
1243
+ */
1244
+ interface WebhookListResponse extends PaginatedResponse {
1245
+ webhooks: Webhook[];
1246
+ }
1247
+ /**
1248
+ * Parameters for creating a webhook
1249
+ */
1250
+ interface WebhookCreateParams {
1251
+ topic: WebhookTopic | string;
1252
+ address: string;
1253
+ appIds?: string[];
1254
+ filter?: WebhookFilter;
1255
+ }
1256
+ /**
1257
+ * Parameters for updating a webhook
1258
+ */
1259
+ interface WebhookUpdateParams extends Partial<WebhookCreateParams> {
1260
+ }
1261
+
1262
+ /**
1263
+ * Flow status
1264
+ */
1265
+ type FlowStatus = 'draft' | 'active' | 'paused' | 'archived';
1266
+ /**
1267
+ * Flow entity (email/automation)
1268
+ */
1269
+ interface Flow {
1270
+ id: string;
1271
+ name: string;
1272
+ status: FlowStatus;
1273
+ allowRepeatRuns?: boolean;
1274
+ blockRepeatsTimeValue?: number;
1275
+ blockRepeatsTimeUnit?: 'minutes' | 'hours' | 'days' | 'weeks';
1276
+ createdAt: string;
1277
+ updatedAt: string;
1278
+ }
1279
+ /**
1280
+ * Parameters for listing flows
1281
+ */
1282
+ interface FlowListParams extends ListParams {
1283
+ status?: FlowStatus;
1284
+ }
1285
+ /**
1286
+ * Response from listing flows
1287
+ */
1288
+ interface FlowListResponse extends PaginatedResponse {
1289
+ flows: Flow[];
1290
+ }
1291
+ /**
1292
+ * Parameters for creating a flow
1293
+ */
1294
+ interface FlowCreateParams {
1295
+ name: string;
1296
+ allowRepeatRuns?: boolean;
1297
+ blockRepeatsTimeValue?: number;
1298
+ blockRepeatsTimeUnit?: 'minutes' | 'hours' | 'days' | 'weeks';
1299
+ }
1300
+ /**
1301
+ * Parameters for updating a flow
1302
+ */
1303
+ interface FlowUpdateParams extends Partial<FlowCreateParams> {
1304
+ status?: FlowStatus;
1305
+ }
1306
+
1307
+ /**
1308
+ * Doc collection entity
1309
+ */
1310
+ interface DocCollection {
1311
+ id: string;
1312
+ name: string;
1313
+ slug?: string;
1314
+ description?: string;
1315
+ createdAt: string;
1316
+ updatedAt: string;
1317
+ }
1318
+ /**
1319
+ * Parameters for creating a doc collection
1320
+ */
1321
+ interface DocCollectionCreateParams {
1322
+ name: string;
1323
+ slug?: string;
1324
+ description?: string;
1325
+ }
1326
+ /**
1327
+ * Parameters for updating a doc collection
1328
+ */
1329
+ interface DocCollectionUpdateParams extends Partial<DocCollectionCreateParams> {
1330
+ }
1331
+ /**
1332
+ * Doc group entity
1333
+ */
1334
+ interface DocGroup {
1335
+ id: string;
1336
+ collectionId: string;
1337
+ name: string;
1338
+ slug?: string;
1339
+ order?: number;
1340
+ createdAt: string;
1341
+ updatedAt: string;
1342
+ }
1343
+ /**
1344
+ * Parameters for creating a doc group
1345
+ */
1346
+ interface DocGroupCreateParams {
1347
+ name: string;
1348
+ collectionId: string;
1349
+ slug?: string;
1350
+ order?: number;
1351
+ }
1352
+ /**
1353
+ * Parameters for updating a doc group
1354
+ */
1355
+ interface DocGroupUpdateParams extends Partial<Omit<DocGroupCreateParams, 'collectionId'>> {
1356
+ }
1357
+ /**
1358
+ * Doc page status
1359
+ */
1360
+ type DocPageStatus = 'draft' | 'published' | 'archived';
1361
+ /**
1362
+ * Doc page entity
1363
+ */
1364
+ interface DocPage {
1365
+ id: string;
1366
+ collectionId: string;
1367
+ groupId?: string;
1368
+ title: string;
1369
+ slug?: string;
1370
+ content?: string;
1371
+ status: DocPageStatus;
1372
+ order?: number;
1373
+ publishedAt?: string;
1374
+ archivedAt?: string;
1375
+ createdAt: string;
1376
+ updatedAt: string;
1377
+ }
1378
+ /**
1379
+ * Parameters for listing doc pages
1380
+ */
1381
+ interface DocPageListParams {
1382
+ collectionId?: string;
1383
+ groupId?: string;
1384
+ status?: DocPageStatus;
1385
+ }
1386
+ /**
1387
+ * Response from listing doc pages
1388
+ */
1389
+ interface DocPageListResponse extends PaginatedResponse {
1390
+ pages: DocPage[];
1391
+ }
1392
+ /**
1393
+ * Parameters for creating a doc page
1394
+ */
1395
+ interface DocPageCreateParams {
1396
+ title: string;
1397
+ collectionId: string;
1398
+ groupId?: string;
1399
+ slug?: string;
1400
+ content?: string;
1401
+ order?: number;
1402
+ }
1403
+ /**
1404
+ * Parameters for updating a doc page
1405
+ */
1406
+ interface DocPageUpdateParams extends Partial<Omit<DocPageCreateParams, 'collectionId'>> {
1407
+ }
1408
+ /**
1409
+ * Doc tree node
1410
+ */
1411
+ interface DocTreeNode {
1412
+ id: string;
1413
+ type: 'collection' | 'group' | 'page';
1414
+ name: string;
1415
+ slug?: string;
1416
+ children?: DocTreeNode[];
1417
+ }
1418
+ /**
1419
+ * Doc tree response
1420
+ */
1421
+ interface DocTreeResponse {
1422
+ tree: DocTreeNode[];
1423
+ }
1424
+
1425
+ /**
1426
+ * Organization entity
1427
+ */
1428
+ interface Organization {
1429
+ id: string;
1430
+ name: string;
1431
+ customerTags?: string[];
1432
+ contactTags?: string[];
1433
+ websiteUrl?: string;
1434
+ supportEmail?: string;
1435
+ socialNetworks?: Record<string, string>;
1436
+ mantleFeatures?: string[];
1437
+ createdAt: string;
1438
+ updatedAt: string;
1439
+ }
1440
+ /**
1441
+ * User entity
1442
+ */
1443
+ interface User {
1444
+ id: string;
1445
+ email: string;
1446
+ name?: string;
1447
+ role?: string;
1448
+ avatarUrl?: string;
1449
+ createdAt: string;
1450
+ updatedAt: string;
1451
+ }
1452
+ /**
1453
+ * Parameters for listing users
1454
+ */
1455
+ interface UserListParams extends ListParams {
1456
+ }
1457
+ /**
1458
+ * Response from listing users
1459
+ */
1460
+ interface UserListResponse extends PaginatedResponse {
1461
+ users: User[];
1462
+ }
1463
+ /**
1464
+ * Response from /me endpoint
1465
+ */
1466
+ interface MeResponse {
1467
+ user: User;
1468
+ organization: Organization;
1469
+ }
1470
+ /**
1471
+ * Agent entity (support agent)
1472
+ */
1473
+ interface Agent {
1474
+ id: string;
1475
+ userId: string;
1476
+ name?: string;
1477
+ email: string;
1478
+ active?: boolean;
1479
+ createdAt: string;
1480
+ updatedAt: string;
1481
+ }
1482
+ /**
1483
+ * Response from listing agents
1484
+ */
1485
+ interface AgentListResponse {
1486
+ agents: Agent[];
1487
+ }
1488
+
1489
+ /**
1490
+ * Task status
1491
+ */
1492
+ type TaskStatus = 'pending' | 'in_progress' | 'completed' | 'canceled';
1493
+ /**
1494
+ * Task priority
1495
+ */
1496
+ type TaskPriority = 'low' | 'medium' | 'high' | 'urgent';
1497
+ /**
1498
+ * Task entity
1499
+ */
1500
+ interface Task {
1501
+ id: string;
1502
+ title: string;
1503
+ description?: string;
1504
+ descriptionHtml?: string;
1505
+ priority: TaskPriority;
1506
+ status: TaskStatus;
1507
+ dueDate?: string;
1508
+ assigneeId?: string;
1509
+ customerId?: string;
1510
+ contactId?: string;
1511
+ dealId?: string;
1512
+ dealActivityId?: string;
1513
+ appInstallationId?: string;
1514
+ tags: string[];
1515
+ createdAt: string;
1516
+ updatedAt: string;
1517
+ assignee?: {
1518
+ id: string;
1519
+ name?: string;
1520
+ email?: string;
1521
+ };
1522
+ customer?: {
1523
+ id: string;
1524
+ name?: string;
1525
+ };
1526
+ contact?: {
1527
+ id: string;
1528
+ name?: string;
1529
+ };
1530
+ deal?: {
1531
+ id: string;
1532
+ name?: string;
1533
+ };
1534
+ }
1535
+ /**
1536
+ * Parameters for listing tasks
1537
+ */
1538
+ interface TaskListParams extends ListParams {
1539
+ dealId?: string;
1540
+ customerId?: string;
1541
+ assigneeId?: string;
1542
+ status?: TaskStatus;
1543
+ priority?: TaskPriority;
1544
+ }
1545
+ /**
1546
+ * Response from listing tasks
1547
+ */
1548
+ interface TaskListResponse extends PaginatedResponse {
1549
+ tasks: Task[];
1550
+ }
1551
+ /**
1552
+ * Parameters for creating a task
1553
+ */
1554
+ interface TaskCreateParams {
1555
+ title: string;
1556
+ description?: string;
1557
+ descriptionHtml?: string;
1558
+ priority?: TaskPriority;
1559
+ status?: TaskStatus;
1560
+ dueDate?: string;
1561
+ assigneeId?: string;
1562
+ customerId?: string;
1563
+ contactId?: string;
1564
+ dealId?: string;
1565
+ dealActivityId?: string;
1566
+ appInstallationId?: string;
1567
+ tags?: string[];
1568
+ }
1569
+ /**
1570
+ * Parameters for updating a task
1571
+ */
1572
+ interface TaskUpdateParams extends Partial<TaskCreateParams> {
1573
+ }
1574
+
1575
+ /**
1576
+ * Company entity
1577
+ */
1578
+ interface Company {
1579
+ id: string;
1580
+ name: string;
1581
+ parentCustomerId?: string;
1582
+ createdAt: string;
1583
+ updatedAt: string;
1584
+ parentCustomer?: {
1585
+ id: string;
1586
+ name?: string;
1587
+ };
1588
+ }
1589
+ /**
1590
+ * Parameters for listing companies
1591
+ */
1592
+ interface CompanyListParams extends ListParams {
1593
+ }
1594
+ /**
1595
+ * Response from listing companies
1596
+ */
1597
+ interface CompanyListResponse extends PaginatedResponse {
1598
+ companies: Company[];
1599
+ }
1600
+ /**
1601
+ * Parameters for creating a company
1602
+ */
1603
+ interface CompanyCreateParams {
1604
+ name: string;
1605
+ parentCustomerId?: string;
1606
+ }
1607
+ /**
1608
+ * Parameters for updating a company
1609
+ */
1610
+ interface CompanyUpdateParams extends Partial<CompanyCreateParams> {
1611
+ }
1612
+
1613
+ /**
1614
+ * Charge entity
1615
+ */
1616
+ interface Charge {
1617
+ id: string;
1618
+ customerId: string;
1619
+ appId?: string;
1620
+ subscriptionId?: string;
1621
+ amount: number;
1622
+ currencyCode: string;
1623
+ status: string;
1624
+ type?: string;
1625
+ description?: string;
1626
+ billedAt?: string;
1627
+ createdAt: string;
1628
+ updatedAt: string;
1629
+ customer?: {
1630
+ id: string;
1631
+ name?: string;
1632
+ };
1633
+ }
1634
+ /**
1635
+ * Parameters for listing charges
1636
+ */
1637
+ interface ChargeListParams extends ListParams {
1638
+ groupBy?: 'customer';
1639
+ customerId?: string;
1640
+ appId?: string;
1641
+ subscriptionId?: string;
1642
+ status?: string;
1643
+ startDate?: string;
1644
+ endDate?: string;
1645
+ }
1646
+ /**
1647
+ * Response from listing charges
1648
+ */
1649
+ interface ChargeListResponse extends PaginatedResponse {
1650
+ charges: Charge[];
1651
+ }
1652
+
1653
+ /**
1654
+ * Transaction entity
1655
+ */
1656
+ interface Transaction {
1657
+ id: string;
1658
+ customerId: string;
1659
+ appId?: string;
1660
+ subscriptionId?: string;
1661
+ chargeId?: string;
1662
+ amount: number;
1663
+ currencyCode: string;
1664
+ type: string;
1665
+ status: string;
1666
+ description?: string;
1667
+ processedAt?: string;
1668
+ createdAt: string;
1669
+ updatedAt: string;
1670
+ customer?: {
1671
+ id: string;
1672
+ name?: string;
1673
+ };
1674
+ }
1675
+ /**
1676
+ * Parameters for listing transactions
1677
+ */
1678
+ interface TransactionListParams extends ListParams {
1679
+ customerId?: string;
1680
+ appId?: string;
1681
+ subscriptionId?: string;
1682
+ type?: string;
1683
+ status?: string;
1684
+ startDate?: string;
1685
+ endDate?: string;
1686
+ }
1687
+ /**
1688
+ * Response from listing transactions
1689
+ */
1690
+ interface TransactionListResponse extends PaginatedResponse {
1691
+ transactions: Transaction[];
1692
+ }
1693
+
1694
+ /**
1695
+ * Customer segment entity
1696
+ */
1697
+ interface CustomerSegment {
1698
+ id: string;
1699
+ name: string;
1700
+ description?: string;
1701
+ filters?: Record<string, unknown>;
1702
+ customerCount?: number;
1703
+ public?: boolean;
1704
+ createdAt: string;
1705
+ updatedAt: string;
1706
+ }
1707
+ /**
1708
+ * Parameters for listing customer segments
1709
+ */
1710
+ interface CustomerSegmentListParams extends ListParams {
1711
+ }
1712
+ /**
1713
+ * Response from listing customer segments
1714
+ */
1715
+ interface CustomerSegmentListResponse extends PaginatedResponse {
1716
+ customerSegments: CustomerSegment[];
1717
+ }
1718
+
1719
+ /**
1720
+ * Resource for managing customers
1721
+ */
1722
+ declare class CustomersResource extends BaseResource {
1723
+ /**
1724
+ * List customers with optional filters and pagination
1725
+ */
1726
+ list(params?: CustomerListParams): Promise<CustomerListResponse>;
1727
+ /**
1728
+ * Retrieve a single customer by ID
1729
+ */
1730
+ retrieve(customerId: string, params?: CustomerRetrieveParams): Promise<{
1731
+ customer: Customer;
1732
+ }>;
1733
+ /**
1734
+ * Create a new customer
1735
+ */
1736
+ create(data: CustomerCreateParams): Promise<{
1737
+ customer: Customer;
1738
+ }>;
1739
+ /**
1740
+ * Update an existing customer
1741
+ */
1742
+ update(customerId: string, data: CustomerUpdateParams): Promise<{
1743
+ customer: Customer;
1744
+ }>;
1745
+ /**
1746
+ * Add tags to a customer
1747
+ */
1748
+ addTags(customerId: string, tags: string[]): Promise<{
1749
+ customer: Customer;
1750
+ }>;
1751
+ /**
1752
+ * Remove tags from a customer
1753
+ */
1754
+ removeTags(customerId: string, tags: string[]): Promise<{
1755
+ customer: Customer;
1756
+ }>;
1757
+ /**
1758
+ * Get customer activity timeline
1759
+ */
1760
+ getTimeline(customerId: string, params?: TimelineListParams): Promise<TimelineListResponse>;
1761
+ /**
1762
+ * List account owners for a customer
1763
+ */
1764
+ listAccountOwners(customerId: string): Promise<AccountOwnersListResponse>;
1765
+ /**
1766
+ * Add an account owner to a customer
1767
+ */
1768
+ addAccountOwner(customerId: string, data: {
1769
+ email: string;
1770
+ name?: string;
1771
+ }): Promise<{
1772
+ accountOwner: {
1773
+ id: string;
1774
+ email: string;
1775
+ name?: string;
1776
+ };
1777
+ }>;
1778
+ /**
1779
+ * Remove an account owner from a customer
1780
+ */
1781
+ removeAccountOwner(customerId: string, ownerId: string): Promise<DeleteResponse>;
1782
+ /**
1783
+ * List custom fields
1784
+ */
1785
+ listCustomFields(params?: {
1786
+ appId?: string;
1787
+ }): Promise<{
1788
+ customFields: CustomField[];
1789
+ }>;
1790
+ /**
1791
+ * Create a custom field
1792
+ */
1793
+ createCustomField(data: CustomFieldCreateParams): Promise<{
1794
+ customField: CustomField;
1795
+ }>;
1796
+ /**
1797
+ * Retrieve a custom field by ID
1798
+ */
1799
+ retrieveCustomField(fieldId: string): Promise<{
1800
+ customField: CustomField;
1801
+ }>;
1802
+ /**
1803
+ * Update a custom field
1804
+ */
1805
+ updateCustomField(fieldId: string, data: CustomFieldUpdateParams): Promise<{
1806
+ customField: CustomField;
1807
+ }>;
1808
+ /**
1809
+ * Delete a custom field
1810
+ */
1811
+ deleteCustomField(fieldId: string): Promise<DeleteResponse>;
1812
+ }
1813
+
1814
+ /**
1815
+ * Resource for managing contacts
1816
+ */
1817
+ declare class ContactsResource extends BaseResource {
1818
+ /**
1819
+ * List contacts with optional filters and pagination
1820
+ */
1821
+ list(params?: ContactListParams): Promise<ContactListResponse>;
1822
+ /**
1823
+ * Retrieve a single contact by ID
1824
+ */
1825
+ retrieve(contactId: string): Promise<{
1826
+ contact: Contact;
1827
+ }>;
1828
+ /**
1829
+ * Create a new contact
1830
+ */
1831
+ create(data: ContactCreateParams): Promise<{
1832
+ contact: Contact;
1833
+ }>;
1834
+ /**
1835
+ * Update an existing contact
1836
+ */
1837
+ update(contactId: string, data: ContactUpdateParams): Promise<{
1838
+ contact: Contact;
1839
+ }>;
1840
+ /**
1841
+ * Delete a contact
1842
+ */
1843
+ del(contactId: string): Promise<DeleteResponse>;
1844
+ /**
1845
+ * Add tags to a contact
1846
+ */
1847
+ addTags(contactId: string, tags: string[]): Promise<{
1848
+ contact: Contact;
1849
+ }>;
1850
+ /**
1851
+ * Remove tags from a contact
1852
+ */
1853
+ removeTags(contactId: string, tags: string[]): Promise<{
1854
+ contact: Contact;
1855
+ }>;
1856
+ }
1857
+
1858
+ /**
1859
+ * Resource for managing subscriptions
1860
+ */
1861
+ declare class SubscriptionsResource extends BaseResource {
1862
+ /**
1863
+ * List subscriptions with optional filters and pagination
1864
+ */
1865
+ list(params?: SubscriptionListParams): Promise<SubscriptionListResponse>;
1866
+ /**
1867
+ * Retrieve a single subscription by ID
1868
+ */
1869
+ retrieve(subscriptionId: string): Promise<{
1870
+ subscription: Subscription;
1871
+ }>;
1872
+ }
1873
+
1874
+ /**
1875
+ * Resource for managing usage events
1876
+ */
1877
+ declare class UsageEventsResource extends BaseResource {
1878
+ /**
1879
+ * List usage events with optional filters and pagination
1880
+ */
1881
+ list(params?: UsageEventListParams): Promise<UsageEventListResponse>;
1882
+ /**
1883
+ * Create usage event(s)
1884
+ *
1885
+ * @example
1886
+ * // Single event
1887
+ * await client.usageEvents.create({
1888
+ * eventName: 'api_call',
1889
+ * customerId: 'cust_123',
1890
+ * appId: 'app_456',
1891
+ * properties: { endpoint: '/users' },
1892
+ * });
1893
+ *
1894
+ * @example
1895
+ * // Multiple events
1896
+ * await client.usageEvents.create({
1897
+ * events: [
1898
+ * { eventName: 'api_call', customerId: 'cust_123', appId: 'app_456' },
1899
+ * { eventName: 'api_call', customerId: 'cust_789', appId: 'app_456' },
1900
+ * ],
1901
+ * });
1902
+ */
1903
+ create(data: UsageEventCreateParams): Promise<UsageEventCreateResponse>;
1904
+ }
1905
+
1906
+ /**
1907
+ * Resource for managing apps and their related entities (plans, features, reviews, etc.)
1908
+ */
1909
+ declare class AppsResource extends BaseResource {
1910
+ /**
1911
+ * List all apps
1912
+ */
1913
+ list(params?: AppListParams): Promise<{
1914
+ apps: App[];
1915
+ }>;
1916
+ /**
1917
+ * Retrieve a single app by ID
1918
+ */
1919
+ retrieve(appId: string): Promise<{
1920
+ app: App;
1921
+ }>;
1922
+ /**
1923
+ * List plans for an app
1924
+ */
1925
+ listPlans(appId: string, params?: PlanListParams): Promise<PlanListResponse>;
1926
+ /**
1927
+ * Retrieve a single plan
1928
+ */
1929
+ retrievePlan(appId: string, planId: string): Promise<{
1930
+ plan: Plan;
1931
+ }>;
1932
+ /**
1933
+ * Create a new plan for an app
1934
+ */
1935
+ createPlan(appId: string, data: PlanCreateParams): Promise<{
1936
+ plan: Plan;
1937
+ }>;
1938
+ /**
1939
+ * Update an existing plan
1940
+ */
1941
+ updatePlan(appId: string, planId: string, data: PlanUpdateParams): Promise<{
1942
+ plan: Plan;
1943
+ }>;
1944
+ /**
1945
+ * Archive a plan
1946
+ */
1947
+ archivePlan(appId: string, planId: string): Promise<{
1948
+ plan: Plan;
1949
+ }>;
1950
+ /**
1951
+ * Unarchive a plan
1952
+ */
1953
+ unarchivePlan(appId: string, planId: string): Promise<{
1954
+ plan: Plan;
1955
+ }>;
1956
+ /**
1957
+ * List features for an app
1958
+ */
1959
+ listFeatures(appId: string): Promise<{
1960
+ features: Feature[];
1961
+ }>;
1962
+ /**
1963
+ * Retrieve a single feature
1964
+ */
1965
+ retrieveFeature(appId: string, featureId: string): Promise<{
1966
+ feature: Feature;
1967
+ }>;
1968
+ /**
1969
+ * Create a new feature for an app
1970
+ */
1971
+ createFeature(appId: string, data: FeatureCreateParams): Promise<{
1972
+ feature: Feature;
1973
+ }>;
1974
+ /**
1975
+ * Update an existing feature
1976
+ */
1977
+ updateFeature(appId: string, featureId: string, data: FeatureUpdateParams): Promise<{
1978
+ feature: Feature;
1979
+ }>;
1980
+ /**
1981
+ * Delete a feature
1982
+ */
1983
+ deleteFeature(appId: string, featureId: string): Promise<DeleteResponse>;
1984
+ /**
1985
+ * List reviews for an app
1986
+ */
1987
+ listReviews(appId: string): Promise<{
1988
+ reviews: Review[];
1989
+ }>;
1990
+ /**
1991
+ * Retrieve a single review
1992
+ */
1993
+ retrieveReview(appId: string, reviewId: string): Promise<{
1994
+ review: Review;
1995
+ }>;
1996
+ /**
1997
+ * Create a new review for an app
1998
+ */
1999
+ createReview(appId: string, data: ReviewCreateParams): Promise<{
2000
+ review: Review;
2001
+ }>;
2002
+ /**
2003
+ * Update an existing review
2004
+ */
2005
+ updateReview(appId: string, reviewId: string, data: ReviewUpdateParams): Promise<{
2006
+ review: Review;
2007
+ }>;
2008
+ /**
2009
+ * Delete a review
2010
+ */
2011
+ deleteReview(appId: string, reviewId: string): Promise<DeleteResponse>;
2012
+ /**
2013
+ * Get usage event names for an app
2014
+ */
2015
+ listEventNames(appId: string): Promise<{
2016
+ eventNames: string[];
2017
+ }>;
2018
+ /**
2019
+ * Get property keys for a specific event name
2020
+ */
2021
+ listPropertyKeys(appId: string, eventName: string): Promise<{
2022
+ propertyKeys: string[];
2023
+ }>;
2024
+ /**
2025
+ * List usage metrics for an app
2026
+ */
2027
+ listUsageMetrics(appId: string): Promise<{
2028
+ usageMetrics: UsageMetric[];
2029
+ }>;
2030
+ /**
2031
+ * Retrieve a single usage metric
2032
+ */
2033
+ retrieveUsageMetric(appId: string, usageMetricId: string): Promise<{
2034
+ usageMetric: UsageMetric;
2035
+ }>;
2036
+ /**
2037
+ * Create a new usage metric for an app
2038
+ */
2039
+ createUsageMetric(appId: string, data: UsageMetricCreateParams): Promise<{
2040
+ usageMetric: UsageMetric;
2041
+ }>;
2042
+ /**
2043
+ * Update an existing usage metric
2044
+ */
2045
+ updateUsageMetric(appId: string, usageMetricId: string, data: UsageMetricUpdateParams): Promise<{
2046
+ usageMetric: UsageMetric;
2047
+ }>;
2048
+ /**
2049
+ * Delete a usage metric
2050
+ */
2051
+ deleteUsageMetric(appId: string, usageMetricId: string): Promise<DeleteResponse>;
2052
+ /**
2053
+ * List app events
2054
+ */
2055
+ listAppEvents(appId: string, params?: AppEventListParams): Promise<AppEventListResponse>;
2056
+ }
2057
+
2058
+ /**
2059
+ * Resource for managing deals
2060
+ */
2061
+ declare class DealsResource extends BaseResource {
2062
+ /**
2063
+ * List deals with optional filters and pagination
2064
+ */
2065
+ list(params?: DealListParams): Promise<DealListResponse>;
2066
+ /**
2067
+ * Retrieve a single deal by ID
2068
+ */
2069
+ retrieve(dealId: string): Promise<{
2070
+ deal: Deal;
2071
+ }>;
2072
+ /**
2073
+ * Create a new deal
2074
+ */
2075
+ create(data: DealCreateParams): Promise<{
2076
+ deal: Deal;
2077
+ }>;
2078
+ /**
2079
+ * Update an existing deal
2080
+ */
2081
+ update(dealId: string, data: DealUpdateParams): Promise<{
2082
+ deal: Deal;
2083
+ }>;
2084
+ /**
2085
+ * Archive (soft delete) a deal
2086
+ */
2087
+ del(dealId: string): Promise<DeleteResponse>;
2088
+ /**
2089
+ * Get deal activity timeline
2090
+ */
2091
+ getTimeline(dealId: string): Promise<TimelineListResponse>;
2092
+ /**
2093
+ * Get deal events
2094
+ */
2095
+ getEvents(dealId: string): Promise<{
2096
+ events: unknown[];
2097
+ }>;
2098
+ }
2099
+
2100
+ /**
2101
+ * Resource for managing deal flows
2102
+ */
2103
+ declare class DealFlowsResource extends BaseResource {
2104
+ /**
2105
+ * List all deal flows
2106
+ */
2107
+ list(): Promise<{
2108
+ dealFlows: DealFlow[];
2109
+ }>;
2110
+ /**
2111
+ * Retrieve a single deal flow by ID
2112
+ */
2113
+ retrieve(dealFlowId: string): Promise<{
2114
+ dealFlow: DealFlow;
2115
+ }>;
2116
+ /**
2117
+ * Create a new deal flow
2118
+ */
2119
+ create(data: DealFlowCreateParams): Promise<{
2120
+ dealFlow: DealFlow;
2121
+ }>;
2122
+ /**
2123
+ * Update an existing deal flow
2124
+ */
2125
+ update(dealFlowId: string, data: DealFlowUpdateParams): Promise<{
2126
+ dealFlow: DealFlow;
2127
+ }>;
2128
+ /**
2129
+ * Delete a deal flow
2130
+ */
2131
+ del(dealFlowId: string): Promise<DeleteResponse>;
2132
+ }
2133
+
2134
+ /**
2135
+ * Resource for managing deal activities
2136
+ */
2137
+ declare class DealActivitiesResource extends BaseResource {
2138
+ /**
2139
+ * List all deal activities
2140
+ */
2141
+ list(): Promise<{
2142
+ dealActivities: DealActivity[];
2143
+ }>;
2144
+ /**
2145
+ * Retrieve a single deal activity by ID
2146
+ */
2147
+ retrieve(dealActivityId: string): Promise<{
2148
+ dealActivity: DealActivity;
2149
+ }>;
2150
+ /**
2151
+ * Create a new deal activity
2152
+ */
2153
+ create(data: DealActivityCreateParams): Promise<{
2154
+ dealActivity: DealActivity;
2155
+ }>;
2156
+ /**
2157
+ * Update an existing deal activity
2158
+ */
2159
+ update(dealActivityId: string, data: DealActivityUpdateParams): Promise<{
2160
+ dealActivity: DealActivity;
2161
+ }>;
2162
+ /**
2163
+ * Delete a deal activity
2164
+ */
2165
+ del(dealActivityId: string): Promise<DeleteResponse>;
2166
+ }
2167
+
2168
+ /**
2169
+ * Resource for managing tickets and ticket messages
2170
+ */
2171
+ declare class TicketsResource extends BaseResource {
2172
+ /**
2173
+ * List tickets with optional filters and pagination
2174
+ */
2175
+ list(params?: TicketListParams): Promise<TicketListResponse>;
2176
+ /**
2177
+ * Retrieve a single ticket by ID
2178
+ */
2179
+ retrieve(ticketId: string): Promise<{
2180
+ ticket: Ticket;
2181
+ }>;
2182
+ /**
2183
+ * Create a new ticket
2184
+ */
2185
+ create(data: TicketCreateParams): Promise<{
2186
+ ticket: Ticket;
2187
+ }>;
2188
+ /**
2189
+ * Update an existing ticket
2190
+ */
2191
+ update(ticketId: string, data: TicketUpdateParams): Promise<{
2192
+ ticket: Ticket;
2193
+ }>;
2194
+ /**
2195
+ * Delete a ticket
2196
+ */
2197
+ del(ticketId: string): Promise<DeleteResponse>;
2198
+ /**
2199
+ * List messages for a ticket
2200
+ */
2201
+ listMessages(ticketId: string): Promise<{
2202
+ messages: TicketMessage[];
2203
+ }>;
2204
+ /**
2205
+ * Retrieve a single message
2206
+ */
2207
+ retrieveMessage(ticketId: string, messageId: string): Promise<{
2208
+ message: TicketMessage;
2209
+ }>;
2210
+ /**
2211
+ * Create a new message on a ticket
2212
+ */
2213
+ createMessage(ticketId: string, data: TicketMessageCreateParams): Promise<{
2214
+ message: TicketMessage;
2215
+ }>;
2216
+ /**
2217
+ * Update a message
2218
+ */
2219
+ updateMessage(ticketId: string, messageId: string, data: TicketMessageUpdateParams): Promise<{
2220
+ message: TicketMessage;
2221
+ }>;
2222
+ /**
2223
+ * Delete a message
2224
+ */
2225
+ deleteMessage(ticketId: string, messageId: string): Promise<DeleteResponse>;
2226
+ }
2227
+
2228
+ /**
2229
+ * Resource for managing CX channels
2230
+ */
2231
+ declare class ChannelsResource extends BaseResource {
2232
+ /**
2233
+ * List CX channels
2234
+ */
2235
+ list(params?: ChannelListParams): Promise<{
2236
+ channels: Channel[];
2237
+ }>;
2238
+ /**
2239
+ * Create a new CX channel
2240
+ */
2241
+ create(data: ChannelCreateParams): Promise<{
2242
+ channel: Channel;
2243
+ }>;
2244
+ }
2245
+
2246
+ /**
2247
+ * Resource for managing flows (email/automation)
2248
+ */
2249
+ declare class FlowsResource extends BaseResource {
2250
+ /**
2251
+ * List flows with optional filters and pagination
2252
+ */
2253
+ list(params?: FlowListParams): Promise<FlowListResponse>;
2254
+ /**
2255
+ * Retrieve a single flow by ID
2256
+ */
2257
+ retrieve(flowId: string): Promise<{
2258
+ flow: Flow;
2259
+ }>;
2260
+ /**
2261
+ * Create a new flow
2262
+ */
2263
+ create(data: FlowCreateParams): Promise<{
2264
+ flow: Flow;
2265
+ }>;
2266
+ /**
2267
+ * Update an existing flow
2268
+ */
2269
+ update(flowId: string, data: FlowUpdateParams): Promise<{
2270
+ flow: Flow;
2271
+ }>;
2272
+ /**
2273
+ * Delete a flow
2274
+ */
2275
+ del(flowId: string): Promise<DeleteResponse>;
2276
+ }
2277
+
2278
+ /**
2279
+ * Resource for managing tasks
2280
+ */
2281
+ declare class TasksResource extends BaseResource {
2282
+ /**
2283
+ * List tasks with optional filters and pagination
2284
+ */
2285
+ list(params?: TaskListParams): Promise<TaskListResponse>;
2286
+ /**
2287
+ * Retrieve a single task by ID
2288
+ */
2289
+ retrieve(taskId: string): Promise<{
2290
+ task: Task;
2291
+ }>;
2292
+ /**
2293
+ * Create a new task
2294
+ */
2295
+ create(data: TaskCreateParams): Promise<{
2296
+ task: Task;
2297
+ }>;
2298
+ /**
2299
+ * Update an existing task
2300
+ */
2301
+ update(taskId: string, data: TaskUpdateParams): Promise<{
2302
+ task: Task;
2303
+ }>;
2304
+ /**
2305
+ * Delete a task
2306
+ */
2307
+ del(taskId: string): Promise<DeleteResponse>;
2308
+ }
2309
+
2310
+ /**
2311
+ * Resource for managing webhooks
2312
+ */
2313
+ declare class WebhooksResource extends BaseResource {
2314
+ /**
2315
+ * List all webhooks
2316
+ */
2317
+ list(): Promise<WebhookListResponse>;
2318
+ /**
2319
+ * Retrieve a single webhook by ID
2320
+ */
2321
+ retrieve(webhookId: string): Promise<{
2322
+ webhook: Webhook;
2323
+ }>;
2324
+ /**
2325
+ * Create a new webhook
2326
+ */
2327
+ create(data: WebhookCreateParams): Promise<{
2328
+ webhook: Webhook;
2329
+ }>;
2330
+ /**
2331
+ * Update an existing webhook
2332
+ */
2333
+ update(webhookId: string, data: WebhookUpdateParams): Promise<{
2334
+ webhook: Webhook;
2335
+ }>;
2336
+ /**
2337
+ * Delete a webhook
2338
+ */
2339
+ del(webhookId: string): Promise<DeleteResponse>;
2340
+ }
2341
+
2342
+ /**
2343
+ * Resource for managing companies
2344
+ */
2345
+ declare class CompaniesResource extends BaseResource {
2346
+ /**
2347
+ * List companies with optional pagination
2348
+ */
2349
+ list(params?: CompanyListParams): Promise<CompanyListResponse>;
2350
+ /**
2351
+ * Retrieve a single company by ID
2352
+ */
2353
+ retrieve(companyId: string): Promise<{
2354
+ company: Company;
2355
+ }>;
2356
+ /**
2357
+ * Create a new company
2358
+ */
2359
+ create(data: CompanyCreateParams): Promise<{
2360
+ company: Company;
2361
+ }>;
2362
+ /**
2363
+ * Update an existing company
2364
+ */
2365
+ update(companyId: string, data: CompanyUpdateParams): Promise<{
2366
+ company: Company;
2367
+ }>;
2368
+ /**
2369
+ * Delete a company
2370
+ */
2371
+ del(companyId: string): Promise<DeleteResponse>;
2372
+ }
2373
+
2374
+ /**
2375
+ * Resource for managing customer segments
2376
+ */
2377
+ declare class CustomerSegmentsResource extends BaseResource {
2378
+ /**
2379
+ * List public customer segments with optional pagination
2380
+ */
2381
+ list(params?: CustomerSegmentListParams): Promise<CustomerSegmentListResponse>;
2382
+ /**
2383
+ * Retrieve a single customer segment by ID
2384
+ */
2385
+ retrieve(segmentId: string): Promise<{
2386
+ customerSegment: CustomerSegment;
2387
+ }>;
2388
+ }
2389
+
2390
+ /**
2391
+ * Resource for managing affiliates
2392
+ */
2393
+ declare class AffiliatesResource extends BaseResource {
2394
+ /**
2395
+ * List affiliates with optional filters and pagination
2396
+ */
2397
+ list(params?: AffiliateListParams): Promise<AffiliateListResponse>;
2398
+ /**
2399
+ * Retrieve a single affiliate by ID
2400
+ */
2401
+ retrieve(affiliateId: string): Promise<{
2402
+ affiliate: Affiliate;
2403
+ }>;
2404
+ /**
2405
+ * Update an existing affiliate
2406
+ */
2407
+ update(affiliateId: string, data: AffiliateUpdateParams): Promise<{
2408
+ affiliate: Affiliate;
2409
+ }>;
2410
+ }
2411
+
2412
+ /**
2413
+ * Resource for managing affiliate programs
2414
+ */
2415
+ declare class AffiliateProgramsResource extends BaseResource {
2416
+ /**
2417
+ * List all affiliate programs
2418
+ */
2419
+ list(): Promise<{
2420
+ affiliatePrograms: AffiliateProgram[];
2421
+ }>;
2422
+ /**
2423
+ * Retrieve a single affiliate program by ID
2424
+ */
2425
+ retrieve(programId: string): Promise<{
2426
+ affiliateProgram: AffiliateProgram;
2427
+ }>;
2428
+ /**
2429
+ * Create a new affiliate program
2430
+ */
2431
+ create(data: AffiliateProgramCreateParams): Promise<{
2432
+ affiliateProgram: AffiliateProgram;
2433
+ }>;
2434
+ /**
2435
+ * Update an existing affiliate program
2436
+ */
2437
+ update(programId: string, data: AffiliateProgramUpdateParams): Promise<{
2438
+ affiliateProgram: AffiliateProgram;
2439
+ }>;
2440
+ /**
2441
+ * Delete an affiliate program
2442
+ */
2443
+ del(programId: string): Promise<DeleteResponse>;
2444
+ }
2445
+
2446
+ /**
2447
+ * Resource for managing affiliate commissions
2448
+ */
2449
+ declare class AffiliateCommissionsResource extends BaseResource {
2450
+ /**
2451
+ * List affiliate commissions with optional filters and pagination
2452
+ */
2453
+ list(params?: AffiliateCommissionListParams): Promise<AffiliateCommissionListResponse>;
2454
+ /**
2455
+ * Retrieve a single affiliate commission by ID
2456
+ */
2457
+ retrieve(commissionId: string): Promise<{
2458
+ commission: AffiliateCommission;
2459
+ }>;
2460
+ }
2461
+
2462
+ /**
2463
+ * Resource for managing affiliate payouts
2464
+ */
2465
+ declare class AffiliatePayoutsResource extends BaseResource {
2466
+ /**
2467
+ * List affiliate payouts with optional filters and pagination
2468
+ */
2469
+ list(params?: AffiliatePayoutListParams): Promise<AffiliatePayoutListResponse>;
2470
+ /**
2471
+ * Retrieve a single affiliate payout by ID
2472
+ */
2473
+ retrieve(payoutId: string): Promise<{
2474
+ payout: AffiliatePayout;
2475
+ }>;
2476
+ }
2477
+
2478
+ /**
2479
+ * Resource for managing affiliate referrals
2480
+ */
2481
+ declare class AffiliateReferralsResource extends BaseResource {
2482
+ /**
2483
+ * List affiliate referrals with optional filters and pagination
2484
+ */
2485
+ list(params?: AffiliateReferralListParams): Promise<AffiliateReferralListResponse>;
2486
+ /**
2487
+ * Retrieve a single affiliate referral by ID
2488
+ */
2489
+ retrieve(referralId: string): Promise<{
2490
+ referral: AffiliateReferral;
2491
+ }>;
2492
+ }
2493
+
2494
+ /**
2495
+ * Resource for managing charges
2496
+ */
2497
+ declare class ChargesResource extends BaseResource {
2498
+ /**
2499
+ * List charges with optional filters and pagination
2500
+ */
2501
+ list(params?: ChargeListParams): Promise<ChargeListResponse>;
2502
+ }
2503
+
2504
+ /**
2505
+ * Resource for managing transactions
2506
+ */
2507
+ declare class TransactionsResource extends BaseResource {
2508
+ /**
2509
+ * List transactions with optional filters and pagination
2510
+ */
2511
+ list(params?: TransactionListParams): Promise<TransactionListResponse>;
2512
+ /**
2513
+ * Retrieve a single transaction by ID
2514
+ */
2515
+ retrieve(transactionId: string): Promise<{
2516
+ transaction: Transaction;
2517
+ }>;
2518
+ }
2519
+
2520
+ /**
2521
+ * Resource for retrieving metrics and analytics
2522
+ */
2523
+ declare class MetricsResource extends BaseResource {
2524
+ /**
2525
+ * Fetch metrics with custom parameters
2526
+ */
2527
+ fetch(params: MetricsGetParams): Promise<MetricsResponse>;
2528
+ /**
2529
+ * Get Annual Recurring Revenue (ARR)
2530
+ */
2531
+ arr(params: MetricsBaseParams & {
2532
+ dateRange?: DateRangeType;
2533
+ }): Promise<MetricsResponse>;
2534
+ /**
2535
+ * Get Monthly Recurring Revenue (MRR)
2536
+ */
2537
+ mrr(params: MetricsBaseParams & {
2538
+ dateRange?: DateRangeType;
2539
+ }): Promise<MetricsResponse>;
2540
+ /**
2541
+ * Get active subscriptions count
2542
+ */
2543
+ activeSubscriptions(params: MetricsBaseParams & {
2544
+ dateRange?: DateRangeType;
2545
+ }): Promise<MetricsResponse>;
2546
+ /**
2547
+ * Get active installations count
2548
+ */
2549
+ activeInstalls(params: MetricsBaseParams & {
2550
+ dateRange?: DateRangeType;
2551
+ }): Promise<MetricsResponse>;
2552
+ /**
2553
+ * Get net new installations
2554
+ */
2555
+ netInstalls(params: MetricsBaseParams & {
2556
+ dateRange?: DateRangeType;
2557
+ }): Promise<MetricsResponse>;
2558
+ /**
2559
+ * Get Average Revenue Per User (ARPU)
2560
+ */
2561
+ arpu(params: MetricsBaseParams & {
2562
+ dateRange?: DateRangeType;
2563
+ }): Promise<MetricsResponse>;
2564
+ /**
2565
+ * Get Lifetime Value (LTV)
2566
+ */
2567
+ ltv(params: MetricsBaseParams & {
2568
+ dateRange?: DateRangeType;
2569
+ }): Promise<MetricsResponse>;
2570
+ /**
2571
+ * Get revenue churn rate
2572
+ */
2573
+ revenueChurn(params: MetricsBaseParams & {
2574
+ dateRange?: DateRangeType;
2575
+ }): Promise<MetricsResponse>;
2576
+ /**
2577
+ * Get logo (customer) churn rate
2578
+ */
2579
+ logoChurn(params: MetricsBaseParams & {
2580
+ dateRange?: DateRangeType;
2581
+ }): Promise<MetricsResponse>;
2582
+ /**
2583
+ * Get revenue retention rate
2584
+ */
2585
+ revenueRetention(params: MetricsBaseParams & {
2586
+ dateRange?: DateRangeType;
2587
+ }): Promise<MetricsResponse>;
2588
+ /**
2589
+ * Get net revenue retention rate
2590
+ */
2591
+ netRevenueRetention(params: MetricsBaseParams & {
2592
+ dateRange?: DateRangeType;
2593
+ }): Promise<MetricsResponse>;
2594
+ /**
2595
+ * Get net revenue
2596
+ */
2597
+ netRevenue(params: MetricsBaseParams & {
2598
+ dateRange?: DateRangeType;
2599
+ }): Promise<MetricsResponse>;
2600
+ /**
2601
+ * Get payout amount
2602
+ */
2603
+ payout(params: MetricsBaseParams & {
2604
+ dateRange?: DateRangeType;
2605
+ }): Promise<MetricsResponse>;
2606
+ /**
2607
+ * Get predicted Lifetime Value
2608
+ */
2609
+ predictedLtv(params: MetricsBaseParams & {
2610
+ dateRange?: DateRangeType;
2611
+ }): Promise<MetricsResponse>;
2612
+ /**
2613
+ * Get charges
2614
+ */
2615
+ charges(params: MetricsBaseParams & {
2616
+ dateRange?: DateRangeType;
2617
+ }): Promise<MetricsResponse>;
2618
+ /**
2619
+ * Get usage event metrics
2620
+ */
2621
+ usageEvent(params: UsageEventMetricsParams): Promise<MetricsResponse>;
2622
+ /**
2623
+ * Get usage metric data
2624
+ */
2625
+ usageMetric(params: UsageMetricParams): Promise<MetricsResponse>;
2626
+ }
2627
+
2628
+ /**
2629
+ * Resource for managing organization users
2630
+ */
2631
+ declare class UsersResource extends BaseResource {
2632
+ /**
2633
+ * List organization users with optional pagination
2634
+ */
2635
+ list(params?: UserListParams): Promise<UserListResponse>;
2636
+ /**
2637
+ * Retrieve a single user by ID
2638
+ */
2639
+ retrieve(userId: string): Promise<{
2640
+ user: User;
2641
+ }>;
2642
+ }
2643
+
2644
+ /**
2645
+ * Resource for retrieving current user and organization info
2646
+ */
2647
+ declare class MeResource extends BaseResource {
2648
+ /**
2649
+ * Get current user and organization info
2650
+ */
2651
+ retrieve(): Promise<MeResponse>;
2652
+ }
2653
+
2654
+ /**
2655
+ * Resource for retrieving organization info
2656
+ */
2657
+ declare class OrganizationResource extends BaseResource {
2658
+ /**
2659
+ * Get organization details
2660
+ */
2661
+ retrieve(): Promise<{
2662
+ organization: Organization;
2663
+ }>;
2664
+ }
2665
+
2666
+ /**
2667
+ * Resource for managing support agents
2668
+ */
2669
+ declare class AgentsResource extends BaseResource {
2670
+ /**
2671
+ * List support agents
2672
+ */
2673
+ list(): Promise<AgentListResponse>;
2674
+ }
2675
+
2676
+ /**
2677
+ * Resource for managing documentation (collections, groups, pages)
2678
+ */
2679
+ declare class DocsResource extends BaseResource {
2680
+ /**
2681
+ * List all doc collections
2682
+ */
2683
+ listCollections(): Promise<{
2684
+ collections: DocCollection[];
2685
+ }>;
2686
+ /**
2687
+ * Retrieve a single doc collection
2688
+ */
2689
+ retrieveCollection(collectionId: string): Promise<{
2690
+ collection: DocCollection;
2691
+ }>;
2692
+ /**
2693
+ * Create a new doc collection
2694
+ */
2695
+ createCollection(data: DocCollectionCreateParams): Promise<{
2696
+ collection: DocCollection;
2697
+ }>;
2698
+ /**
2699
+ * Update a doc collection
2700
+ */
2701
+ updateCollection(collectionId: string, data: DocCollectionUpdateParams): Promise<{
2702
+ collection: DocCollection;
2703
+ }>;
2704
+ /**
2705
+ * Delete a doc collection
2706
+ */
2707
+ deleteCollection(collectionId: string): Promise<DeleteResponse>;
2708
+ /**
2709
+ * List all doc groups
2710
+ */
2711
+ listGroups(): Promise<{
2712
+ groups: DocGroup[];
2713
+ }>;
2714
+ /**
2715
+ * Retrieve a single doc group
2716
+ */
2717
+ retrieveGroup(groupId: string): Promise<{
2718
+ group: DocGroup;
2719
+ }>;
2720
+ /**
2721
+ * Create a new doc group
2722
+ */
2723
+ createGroup(data: DocGroupCreateParams): Promise<{
2724
+ group: DocGroup;
2725
+ }>;
2726
+ /**
2727
+ * Update a doc group
2728
+ */
2729
+ updateGroup(groupId: string, data: DocGroupUpdateParams): Promise<{
2730
+ group: DocGroup;
2731
+ }>;
2732
+ /**
2733
+ * Delete a doc group
2734
+ */
2735
+ deleteGroup(groupId: string): Promise<DeleteResponse>;
2736
+ /**
2737
+ * List doc pages with optional filters
2738
+ */
2739
+ listPages(params?: DocPageListParams): Promise<DocPageListResponse>;
2740
+ /**
2741
+ * Retrieve a single doc page
2742
+ */
2743
+ retrievePage(pageId: string): Promise<{
2744
+ page: DocPage;
2745
+ }>;
2746
+ /**
2747
+ * Create a new doc page
2748
+ */
2749
+ createPage(data: DocPageCreateParams): Promise<{
2750
+ page: DocPage;
2751
+ }>;
2752
+ /**
2753
+ * Update a doc page
2754
+ */
2755
+ updatePage(pageId: string, data: DocPageUpdateParams): Promise<{
2756
+ page: DocPage;
2757
+ }>;
2758
+ /**
2759
+ * Publish a doc page
2760
+ */
2761
+ publishPage(pageId: string): Promise<{
2762
+ page: DocPage;
2763
+ }>;
2764
+ /**
2765
+ * Archive a doc page
2766
+ */
2767
+ archivePage(pageId: string): Promise<{
2768
+ page: DocPage;
2769
+ }>;
2770
+ /**
2771
+ * Delete a doc page
2772
+ */
2773
+ deletePage(pageId: string): Promise<DeleteResponse>;
2774
+ /**
2775
+ * Get the full documentation tree structure
2776
+ */
2777
+ getTree(): Promise<DocTreeResponse>;
2778
+ }
2779
+
2780
+ /**
2781
+ * Mantle Core API Client
2782
+ *
2783
+ * A TypeScript SDK for interacting with the Mantle Core API.
2784
+ * Provides a resource-based interface similar to the Stripe SDK.
2785
+ *
2786
+ * @example
2787
+ * ```typescript
2788
+ * const client = new MantleCoreClient({
2789
+ * apiKey: 'your-api-key',
2790
+ * });
2791
+ *
2792
+ * // List customers
2793
+ * const { customers } = await client.customers.list({ take: 25 });
2794
+ *
2795
+ * // Get a specific customer
2796
+ * const { customer } = await client.customers.retrieve('cust_123');
2797
+ * ```
2798
+ */
2799
+ declare class MantleCoreClient {
2800
+ private readonly baseURL;
2801
+ private readonly apiKey?;
2802
+ private readonly accessToken?;
2803
+ private readonly timeout;
2804
+ readonly customers: CustomersResource;
2805
+ readonly contacts: ContactsResource;
2806
+ readonly subscriptions: SubscriptionsResource;
2807
+ readonly usageEvents: UsageEventsResource;
2808
+ readonly apps: AppsResource;
2809
+ readonly deals: DealsResource;
2810
+ readonly dealFlows: DealFlowsResource;
2811
+ readonly dealActivities: DealActivitiesResource;
2812
+ readonly tickets: TicketsResource;
2813
+ readonly channels: ChannelsResource;
2814
+ readonly flows: FlowsResource;
2815
+ readonly tasks: TasksResource;
2816
+ readonly webhooks: WebhooksResource;
2817
+ readonly companies: CompaniesResource;
2818
+ readonly customerSegments: CustomerSegmentsResource;
2819
+ readonly affiliates: AffiliatesResource;
2820
+ readonly affiliatePrograms: AffiliateProgramsResource;
2821
+ readonly affiliateCommissions: AffiliateCommissionsResource;
2822
+ readonly affiliatePayouts: AffiliatePayoutsResource;
2823
+ readonly affiliateReferrals: AffiliateReferralsResource;
2824
+ readonly charges: ChargesResource;
2825
+ readonly transactions: TransactionsResource;
2826
+ readonly metrics: MetricsResource;
2827
+ readonly users: UsersResource;
2828
+ readonly me: MeResource;
2829
+ readonly organization: OrganizationResource;
2830
+ readonly agents: AgentsResource;
2831
+ readonly docs: DocsResource;
2832
+ constructor(config: MantleCoreClientConfig);
2833
+ /**
2834
+ * Performs a GET request to the API
2835
+ */
2836
+ get<T>(endpoint: string, params?: Record<string, unknown>): Promise<T>;
2837
+ /**
2838
+ * Performs a POST request to the API
2839
+ */
2840
+ post<T>(endpoint: string, data?: Record<string, unknown>): Promise<T>;
2841
+ /**
2842
+ * Performs a PUT request to the API
2843
+ */
2844
+ put<T>(endpoint: string, data?: Record<string, unknown>): Promise<T>;
2845
+ /**
2846
+ * Performs a DELETE request to the API
2847
+ */
2848
+ delete<T>(endpoint: string): Promise<T>;
2849
+ /**
2850
+ * Makes an HTTP request to the API
2851
+ */
2852
+ private makeRequest;
2853
+ /**
2854
+ * Gets the authorization header value
2855
+ */
2856
+ private getAuthHeader;
2857
+ /**
2858
+ * Handles error responses from the API
2859
+ */
2860
+ private handleErrorResponse;
2861
+ }
2862
+
2863
+ /**
2864
+ * Base error class for Mantle API errors
2865
+ */
2866
+ declare class MantleAPIError extends Error {
2867
+ readonly statusCode: number;
2868
+ readonly details?: string;
2869
+ constructor(message: string, statusCode: number, details?: string);
2870
+ static fromResponse(response: {
2871
+ error: string;
2872
+ details?: string;
2873
+ }, statusCode: number): MantleAPIError;
2874
+ }
2875
+ /**
2876
+ * Authentication failed (401)
2877
+ */
2878
+ declare class MantleAuthenticationError extends MantleAPIError {
2879
+ constructor(message?: string);
2880
+ }
2881
+ /**
2882
+ * Permission denied (403)
2883
+ */
2884
+ declare class MantlePermissionError extends MantleAPIError {
2885
+ constructor(message?: string);
2886
+ }
2887
+ /**
2888
+ * Resource not found (404)
2889
+ */
2890
+ declare class MantleNotFoundError extends MantleAPIError {
2891
+ constructor(resource: string, id: string);
2892
+ }
2893
+ /**
2894
+ * Validation error (422)
2895
+ */
2896
+ declare class MantleValidationError extends MantleAPIError {
2897
+ constructor(message: string, details?: string);
2898
+ }
2899
+ /**
2900
+ * Rate limit exceeded (429)
2901
+ */
2902
+ declare class MantleRateLimitError extends MantleAPIError {
2903
+ readonly retryAfter?: number;
2904
+ constructor(message?: string, retryAfter?: number);
2905
+ }
2906
+
2907
+ export { type AccountOwner, type AccountOwnersListResponse, type Affiliate, type AffiliateCommission, type AffiliateCommissionListParams, type AffiliateCommissionListResponse, AffiliateCommissionsResource, type AffiliateListParams, type AffiliateListResponse, type AffiliatePayout, type AffiliatePayoutListParams, type AffiliatePayoutListResponse, AffiliatePayoutsResource, type AffiliateProgram, type AffiliateProgramCreateParams, type AffiliateProgramUpdateParams, AffiliateProgramsResource, type AffiliateReferral, type AffiliateReferralListParams, type AffiliateReferralListResponse, AffiliateReferralsResource, type AffiliateUpdateParams, AffiliatesResource, type Agent, type AgentListResponse, AgentsResource, type App, type AppEvent, type AppEventListParams, type AppEventListResponse, type AppInstallation, type AppInstallationParams, type AppListParams, AppsResource, BaseResource, type Channel, type ChannelCreateParams, type ChannelListParams, ChannelsResource, type Charge, type ChargeListParams, type ChargeListResponse, ChargesResource, CompaniesResource, type Company, type CompanyCreateParams, type CompanyListParams, type CompanyListResponse, type CompanyUpdateParams, type Contact, type ContactCreateParams, type ContactListParams, type ContactListResponse, type ContactUpdateParams, ContactsResource, type CustomField, type CustomFieldCreateParams, type CustomFieldUpdateParams, type Customer, type CustomerCreateParams, type CustomerListParams, type CustomerListResponse, type CustomerRetrieveParams, type CustomerSegment, type CustomerSegmentListParams, type CustomerSegmentListResponse, CustomerSegmentsResource, type CustomerUpdateParams, CustomersResource, type DateRangeType, type Deal, DealActivitiesResource, type DealActivity, type DealActivityCreateParams, type DealActivityUpdateParams, type DealCreateParams, type DealFlow, type DealFlowCreateParams, type DealFlowUpdateParams, DealFlowsResource, type DealListParams, type DealListResponse, type DealStage, type DealUpdateParams, DealsResource, type DeleteResponse, type DocCollection, type DocCollectionCreateParams, type DocCollectionUpdateParams, type DocGroup, type DocGroupCreateParams, type DocGroupUpdateParams, type DocPage, type DocPageCreateParams, type DocPageListParams, type DocPageListResponse, type DocPageStatus, type DocPageUpdateParams, type DocTreeNode, type DocTreeResponse, DocsResource, type Feature, type FeatureCreateParams, type FeatureUpdateParams, type Flow, type FlowCreateParams, type FlowListParams, type FlowListResponse, type FlowStatus, type FlowUpdateParams, FlowsResource, type ListParams, MantleAPIError, MantleAuthenticationError, MantleCoreClient, type MantleCoreClientConfig, MantleNotFoundError, MantlePermissionError, MantleRateLimitError, MantleValidationError, MeResource, type MeResponse, type MessageAttachment, type MetricDataPoint, type MetricType, type MetricsBaseParams, type MetricsGetParams, MetricsResource, type MetricsResponse, type Organization, OrganizationResource, type PaginatedResponse, type Plan, type PlanCreateParams, type PlanFeature, type PlanListParams, type PlanListResponse, type PlanUpdateParams, type PlanUsageCharge, type RequestOptions, type Review, type ReviewCreateParams, type ReviewUpdateParams, type SocialProfile, type Subscription, type SubscriptionListParams, type SubscriptionListResponse, SubscriptionsResource, type Task, type TaskCreateParams, type TaskListParams, type TaskListResponse, type TaskPriority, type TaskStatus, type TaskUpdateParams, TasksResource, type Ticket, type TicketContactData, type TicketCreateParams, type TicketListParams, type TicketListResponse, type TicketMessage, type TicketMessageCreateParams, type TicketMessageUpdateParams, type TicketUpdateParams, TicketsResource, type TimelineEvent, type TimelineListParams, type TimelineListResponse, type Transaction, type TransactionListParams, type TransactionListResponse, TransactionsResource, type UsageEvent, type UsageEventCreateData, type UsageEventCreateParams, type UsageEventCreateResponse, type UsageEventListParams, type UsageEventListResponse, type UsageEventMetricsParams, UsageEventsResource, type UsageMetric, type UsageMetricCreateParams, type UsageMetricParams, type UsageMetricUpdateParams, type User, type UserListParams, type UserListResponse, UsersResource, type Webhook, type WebhookCreateParams, type WebhookFilter, type WebhookListResponse, type WebhookTopic, type WebhookUpdateParams, WebhooksResource };