@heymantle/core-api-client 0.1.8 → 0.1.10
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.d.mts +189 -6
- package/dist/index.d.ts +189 -6
- package/dist/index.js +108 -4
- package/dist/index.mjs +107 -4
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1059,6 +1059,76 @@ interface DealActivityCreateParams {
|
|
|
1059
1059
|
*/
|
|
1060
1060
|
interface DealActivityUpdateParams extends Partial<Omit<DealActivityCreateParams, 'dealFlowId'>> {
|
|
1061
1061
|
}
|
|
1062
|
+
/**
|
|
1063
|
+
* Deal event entity
|
|
1064
|
+
*/
|
|
1065
|
+
interface DealEvent {
|
|
1066
|
+
id: string;
|
|
1067
|
+
type: string;
|
|
1068
|
+
notes?: string;
|
|
1069
|
+
occurredAt: string;
|
|
1070
|
+
user?: {
|
|
1071
|
+
id: string;
|
|
1072
|
+
name?: string;
|
|
1073
|
+
email?: string;
|
|
1074
|
+
} | null;
|
|
1075
|
+
previousDealStage?: {
|
|
1076
|
+
id: string;
|
|
1077
|
+
name: string;
|
|
1078
|
+
} | null;
|
|
1079
|
+
dealStage?: {
|
|
1080
|
+
id: string;
|
|
1081
|
+
name: string;
|
|
1082
|
+
} | null;
|
|
1083
|
+
dealActivity?: {
|
|
1084
|
+
id: string;
|
|
1085
|
+
name: string;
|
|
1086
|
+
} | null;
|
|
1087
|
+
task?: {
|
|
1088
|
+
id: string;
|
|
1089
|
+
name?: string;
|
|
1090
|
+
} | null;
|
|
1091
|
+
appEvent?: {
|
|
1092
|
+
id: string;
|
|
1093
|
+
} | null;
|
|
1094
|
+
}
|
|
1095
|
+
/**
|
|
1096
|
+
* Parameters for creating a deal event
|
|
1097
|
+
*/
|
|
1098
|
+
interface DealEventCreateParams {
|
|
1099
|
+
/** Notes or description for the event */
|
|
1100
|
+
notes?: string;
|
|
1101
|
+
/** Associated deal activity ID */
|
|
1102
|
+
dealActivityId?: string;
|
|
1103
|
+
/** Custom activity name (for ad-hoc activities not in the predefined list) */
|
|
1104
|
+
customActivityName?: string;
|
|
1105
|
+
/** Stage to progress the deal to */
|
|
1106
|
+
dealStageId?: string;
|
|
1107
|
+
/** Associated task ID */
|
|
1108
|
+
taskId?: string;
|
|
1109
|
+
/** Associated app event ID */
|
|
1110
|
+
appEventId?: string;
|
|
1111
|
+
/** When the event occurred (default: now) */
|
|
1112
|
+
occurredAt?: string;
|
|
1113
|
+
/** User ID who created the event (default: authenticated user) */
|
|
1114
|
+
userId?: string;
|
|
1115
|
+
}
|
|
1116
|
+
/**
|
|
1117
|
+
* Response from listing deal events
|
|
1118
|
+
*/
|
|
1119
|
+
interface DealEventListResponse extends PaginatedResponse {
|
|
1120
|
+
events: DealEvent[];
|
|
1121
|
+
}
|
|
1122
|
+
/**
|
|
1123
|
+
* Response from creating a deal event
|
|
1124
|
+
*/
|
|
1125
|
+
interface DealEventCreateResponse {
|
|
1126
|
+
event: DealEvent;
|
|
1127
|
+
/** Whether the deal was progressed to a new stage */
|
|
1128
|
+
dealProgressed?: boolean;
|
|
1129
|
+
/** The updated deal if progression occurred */
|
|
1130
|
+
deal?: Deal;
|
|
1131
|
+
}
|
|
1062
1132
|
|
|
1063
1133
|
/**
|
|
1064
1134
|
* Ticket entity
|
|
@@ -1728,6 +1798,19 @@ interface Agent {
|
|
|
1728
1798
|
interface AgentListResponse {
|
|
1729
1799
|
agents: Agent[];
|
|
1730
1800
|
}
|
|
1801
|
+
/**
|
|
1802
|
+
* Parameters for creating an agent
|
|
1803
|
+
*/
|
|
1804
|
+
interface AgentCreateParams {
|
|
1805
|
+
email: string;
|
|
1806
|
+
name?: string;
|
|
1807
|
+
}
|
|
1808
|
+
/**
|
|
1809
|
+
* Response from creating/retrieving an agent
|
|
1810
|
+
*/
|
|
1811
|
+
interface AgentResponse {
|
|
1812
|
+
agent: Agent;
|
|
1813
|
+
}
|
|
1731
1814
|
|
|
1732
1815
|
/**
|
|
1733
1816
|
* Task status
|
|
@@ -1993,6 +2076,45 @@ interface EntitiesSearchResponse {
|
|
|
1993
2076
|
entities: Entity[];
|
|
1994
2077
|
}
|
|
1995
2078
|
|
|
2079
|
+
/**
|
|
2080
|
+
* Resource type for custom data
|
|
2081
|
+
*/
|
|
2082
|
+
type CustomDataResourceType = 'ticket' | 'customer' | 'contact';
|
|
2083
|
+
/**
|
|
2084
|
+
* Parameters for setting custom data
|
|
2085
|
+
*/
|
|
2086
|
+
interface CustomDataSetParams {
|
|
2087
|
+
resourceId: string;
|
|
2088
|
+
resourceType: CustomDataResourceType;
|
|
2089
|
+
key: string;
|
|
2090
|
+
value: string;
|
|
2091
|
+
}
|
|
2092
|
+
/**
|
|
2093
|
+
* Parameters for getting custom data
|
|
2094
|
+
*/
|
|
2095
|
+
interface CustomDataGetParams {
|
|
2096
|
+
resourceId: string;
|
|
2097
|
+
resourceType: CustomDataResourceType;
|
|
2098
|
+
key: string;
|
|
2099
|
+
}
|
|
2100
|
+
/**
|
|
2101
|
+
* Response from getting custom data
|
|
2102
|
+
*/
|
|
2103
|
+
interface CustomDataResponse {
|
|
2104
|
+
resourceId: string;
|
|
2105
|
+
resourceType: CustomDataResourceType;
|
|
2106
|
+
key: string;
|
|
2107
|
+
value: string;
|
|
2108
|
+
}
|
|
2109
|
+
/**
|
|
2110
|
+
* Parameters for deleting custom data
|
|
2111
|
+
*/
|
|
2112
|
+
interface CustomDataDeleteParams {
|
|
2113
|
+
resourceId: string;
|
|
2114
|
+
resourceType: CustomDataResourceType;
|
|
2115
|
+
key: string;
|
|
2116
|
+
}
|
|
2117
|
+
|
|
1996
2118
|
/**
|
|
1997
2119
|
* Resource for managing customers
|
|
1998
2120
|
*/
|
|
@@ -2429,13 +2551,29 @@ declare class DealsResource extends BaseResource {
|
|
|
2429
2551
|
/**
|
|
2430
2552
|
* Get deal activity timeline
|
|
2431
2553
|
*/
|
|
2432
|
-
|
|
2554
|
+
timeline(dealId: string): Promise<TimelineListResponse>;
|
|
2433
2555
|
/**
|
|
2434
|
-
*
|
|
2556
|
+
* List deal events
|
|
2435
2557
|
*/
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2558
|
+
listEvents(dealId: string): Promise<DealEventListResponse>;
|
|
2559
|
+
/**
|
|
2560
|
+
* Create a deal event
|
|
2561
|
+
*
|
|
2562
|
+
* Creates an event on a deal. If `dealStageId` is provided, the deal will
|
|
2563
|
+
* progress to that stage. If `dealActivityId` is provided and the activity
|
|
2564
|
+
* is configured for a future stage, the deal will automatically progress.
|
|
2565
|
+
*
|
|
2566
|
+
* @example
|
|
2567
|
+
* // Create a simple note
|
|
2568
|
+
* await client.deals.createEvent('deal_123', { notes: 'Follow-up call completed' });
|
|
2569
|
+
*
|
|
2570
|
+
* // Create an event and progress to a new stage
|
|
2571
|
+
* await client.deals.createEvent('deal_123', {
|
|
2572
|
+
* dealStageId: 'stage_456',
|
|
2573
|
+
* notes: 'Moving to negotiation phase',
|
|
2574
|
+
* });
|
|
2575
|
+
*/
|
|
2576
|
+
createEvent(dealId: string, data: DealEventCreateParams): Promise<DealEventCreateResponse>;
|
|
2439
2577
|
}
|
|
2440
2578
|
|
|
2441
2579
|
/**
|
|
@@ -3012,6 +3150,23 @@ declare class AgentsResource extends BaseResource {
|
|
|
3012
3150
|
* List support agents
|
|
3013
3151
|
*/
|
|
3014
3152
|
list(): Promise<AgentListResponse>;
|
|
3153
|
+
/**
|
|
3154
|
+
* Retrieve a specific agent by ID
|
|
3155
|
+
*/
|
|
3156
|
+
retrieve(agentId: string): Promise<AgentResponse>;
|
|
3157
|
+
/**
|
|
3158
|
+
* Create a new agent
|
|
3159
|
+
*/
|
|
3160
|
+
create(params: AgentCreateParams): Promise<AgentResponse>;
|
|
3161
|
+
/**
|
|
3162
|
+
* Find an existing agent by email, or create one if not found.
|
|
3163
|
+
* This is useful for sync operations where you want to ensure
|
|
3164
|
+
* an agent exists without duplicating.
|
|
3165
|
+
*
|
|
3166
|
+
* @param params - Agent data (email required, name optional)
|
|
3167
|
+
* @returns The existing or newly created agent
|
|
3168
|
+
*/
|
|
3169
|
+
findOrCreate(params: AgentCreateParams): Promise<AgentResponse>;
|
|
3015
3170
|
}
|
|
3016
3171
|
|
|
3017
3172
|
/**
|
|
@@ -3129,6 +3284,33 @@ declare class EntitiesResource extends BaseResource {
|
|
|
3129
3284
|
search(params?: EntitiesSearchParams): Promise<EntitiesSearchResponse>;
|
|
3130
3285
|
}
|
|
3131
3286
|
|
|
3287
|
+
/**
|
|
3288
|
+
* Resource for managing custom data on entities.
|
|
3289
|
+
* Custom data allows storing arbitrary key-value pairs on tickets, customers, and contacts.
|
|
3290
|
+
*/
|
|
3291
|
+
declare class CustomDataResource extends BaseResource {
|
|
3292
|
+
/**
|
|
3293
|
+
* Set custom data on a resource.
|
|
3294
|
+
* This will create or update the value for the given key.
|
|
3295
|
+
*
|
|
3296
|
+
* @param params - The custom data parameters
|
|
3297
|
+
*/
|
|
3298
|
+
set(params: CustomDataSetParams): Promise<void>;
|
|
3299
|
+
/**
|
|
3300
|
+
* Get custom data from a resource.
|
|
3301
|
+
*
|
|
3302
|
+
* @param params - Parameters identifying the custom data to retrieve
|
|
3303
|
+
* @returns The custom data value
|
|
3304
|
+
*/
|
|
3305
|
+
getValue(params: CustomDataGetParams): Promise<CustomDataResponse>;
|
|
3306
|
+
/**
|
|
3307
|
+
* Delete custom data from a resource.
|
|
3308
|
+
*
|
|
3309
|
+
* @param params - Parameters identifying the custom data to delete
|
|
3310
|
+
*/
|
|
3311
|
+
del(params: CustomDataDeleteParams): Promise<void>;
|
|
3312
|
+
}
|
|
3313
|
+
|
|
3132
3314
|
/**
|
|
3133
3315
|
* Mantle Core API Client
|
|
3134
3316
|
*
|
|
@@ -3183,6 +3365,7 @@ declare class MantleCoreClient {
|
|
|
3183
3365
|
readonly agents: AgentsResource;
|
|
3184
3366
|
readonly docs: DocsResource;
|
|
3185
3367
|
readonly entities: EntitiesResource;
|
|
3368
|
+
readonly customData: CustomDataResource;
|
|
3186
3369
|
constructor(config: MantleCoreClientConfig);
|
|
3187
3370
|
/**
|
|
3188
3371
|
* Register a middleware function
|
|
@@ -3388,4 +3571,4 @@ interface AuthRefreshOptions {
|
|
|
3388
3571
|
*/
|
|
3389
3572
|
declare function createAuthRefreshMiddleware(options: AuthRefreshOptions): Middleware;
|
|
3390
3573
|
|
|
3391
|
-
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, type AuthRefreshOptions, 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 ContactEntity, type ContactListParams, type ContactListResponse, type ContactUpdateParams, ContactsResource, type CustomField, type CustomFieldCreateParams, type CustomFieldUpdateParams, type Customer, type CustomerCreateParams, type CustomerEntity, 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 DealContactInput, type DealCreateParams, type DealCustomerInput, 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, EntitiesResource, type EntitiesSearchParams, type EntitiesSearchResponse, type Entity, type EntityType, type Feature, type FeatureCreateParams, type FeatureUpdateParams, type Flow, type FlowCreateParams, type FlowListParams, type FlowListResponse, type FlowStatus, type FlowUpdateParams, FlowsResource, type HttpMethod, 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 Middleware, type MiddlewareContext, MiddlewareManager, type MiddlewareOptions, type MiddlewareRequest, type MiddlewareResponse, type NextFunction, 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 SocialProfileType, 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, createAuthRefreshMiddleware };
|
|
3574
|
+
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 AgentCreateParams, type AgentListResponse, type AgentResponse, AgentsResource, type App, type AppEvent, type AppEventListParams, type AppEventListResponse, type AppInstallation, type AppInstallationParams, type AppListParams, AppsResource, type AuthRefreshOptions, 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 ContactEntity, type ContactListParams, type ContactListResponse, type ContactUpdateParams, ContactsResource, type CustomDataDeleteParams, type CustomDataGetParams, CustomDataResource, type CustomDataResourceType, type CustomDataResponse, type CustomDataSetParams, type CustomField, type CustomFieldCreateParams, type CustomFieldUpdateParams, type Customer, type CustomerCreateParams, type CustomerEntity, 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 DealContactInput, type DealCreateParams, type DealCustomerInput, type DealEvent, type DealEventCreateParams, type DealEventCreateResponse, type DealEventListResponse, 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, EntitiesResource, type EntitiesSearchParams, type EntitiesSearchResponse, type Entity, type EntityType, type Feature, type FeatureCreateParams, type FeatureUpdateParams, type Flow, type FlowCreateParams, type FlowListParams, type FlowListResponse, type FlowStatus, type FlowUpdateParams, FlowsResource, type HttpMethod, 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 Middleware, type MiddlewareContext, MiddlewareManager, type MiddlewareOptions, type MiddlewareRequest, type MiddlewareResponse, type NextFunction, 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 SocialProfileType, 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, createAuthRefreshMiddleware };
|
package/dist/index.d.ts
CHANGED
|
@@ -1059,6 +1059,76 @@ interface DealActivityCreateParams {
|
|
|
1059
1059
|
*/
|
|
1060
1060
|
interface DealActivityUpdateParams extends Partial<Omit<DealActivityCreateParams, 'dealFlowId'>> {
|
|
1061
1061
|
}
|
|
1062
|
+
/**
|
|
1063
|
+
* Deal event entity
|
|
1064
|
+
*/
|
|
1065
|
+
interface DealEvent {
|
|
1066
|
+
id: string;
|
|
1067
|
+
type: string;
|
|
1068
|
+
notes?: string;
|
|
1069
|
+
occurredAt: string;
|
|
1070
|
+
user?: {
|
|
1071
|
+
id: string;
|
|
1072
|
+
name?: string;
|
|
1073
|
+
email?: string;
|
|
1074
|
+
} | null;
|
|
1075
|
+
previousDealStage?: {
|
|
1076
|
+
id: string;
|
|
1077
|
+
name: string;
|
|
1078
|
+
} | null;
|
|
1079
|
+
dealStage?: {
|
|
1080
|
+
id: string;
|
|
1081
|
+
name: string;
|
|
1082
|
+
} | null;
|
|
1083
|
+
dealActivity?: {
|
|
1084
|
+
id: string;
|
|
1085
|
+
name: string;
|
|
1086
|
+
} | null;
|
|
1087
|
+
task?: {
|
|
1088
|
+
id: string;
|
|
1089
|
+
name?: string;
|
|
1090
|
+
} | null;
|
|
1091
|
+
appEvent?: {
|
|
1092
|
+
id: string;
|
|
1093
|
+
} | null;
|
|
1094
|
+
}
|
|
1095
|
+
/**
|
|
1096
|
+
* Parameters for creating a deal event
|
|
1097
|
+
*/
|
|
1098
|
+
interface DealEventCreateParams {
|
|
1099
|
+
/** Notes or description for the event */
|
|
1100
|
+
notes?: string;
|
|
1101
|
+
/** Associated deal activity ID */
|
|
1102
|
+
dealActivityId?: string;
|
|
1103
|
+
/** Custom activity name (for ad-hoc activities not in the predefined list) */
|
|
1104
|
+
customActivityName?: string;
|
|
1105
|
+
/** Stage to progress the deal to */
|
|
1106
|
+
dealStageId?: string;
|
|
1107
|
+
/** Associated task ID */
|
|
1108
|
+
taskId?: string;
|
|
1109
|
+
/** Associated app event ID */
|
|
1110
|
+
appEventId?: string;
|
|
1111
|
+
/** When the event occurred (default: now) */
|
|
1112
|
+
occurredAt?: string;
|
|
1113
|
+
/** User ID who created the event (default: authenticated user) */
|
|
1114
|
+
userId?: string;
|
|
1115
|
+
}
|
|
1116
|
+
/**
|
|
1117
|
+
* Response from listing deal events
|
|
1118
|
+
*/
|
|
1119
|
+
interface DealEventListResponse extends PaginatedResponse {
|
|
1120
|
+
events: DealEvent[];
|
|
1121
|
+
}
|
|
1122
|
+
/**
|
|
1123
|
+
* Response from creating a deal event
|
|
1124
|
+
*/
|
|
1125
|
+
interface DealEventCreateResponse {
|
|
1126
|
+
event: DealEvent;
|
|
1127
|
+
/** Whether the deal was progressed to a new stage */
|
|
1128
|
+
dealProgressed?: boolean;
|
|
1129
|
+
/** The updated deal if progression occurred */
|
|
1130
|
+
deal?: Deal;
|
|
1131
|
+
}
|
|
1062
1132
|
|
|
1063
1133
|
/**
|
|
1064
1134
|
* Ticket entity
|
|
@@ -1728,6 +1798,19 @@ interface Agent {
|
|
|
1728
1798
|
interface AgentListResponse {
|
|
1729
1799
|
agents: Agent[];
|
|
1730
1800
|
}
|
|
1801
|
+
/**
|
|
1802
|
+
* Parameters for creating an agent
|
|
1803
|
+
*/
|
|
1804
|
+
interface AgentCreateParams {
|
|
1805
|
+
email: string;
|
|
1806
|
+
name?: string;
|
|
1807
|
+
}
|
|
1808
|
+
/**
|
|
1809
|
+
* Response from creating/retrieving an agent
|
|
1810
|
+
*/
|
|
1811
|
+
interface AgentResponse {
|
|
1812
|
+
agent: Agent;
|
|
1813
|
+
}
|
|
1731
1814
|
|
|
1732
1815
|
/**
|
|
1733
1816
|
* Task status
|
|
@@ -1993,6 +2076,45 @@ interface EntitiesSearchResponse {
|
|
|
1993
2076
|
entities: Entity[];
|
|
1994
2077
|
}
|
|
1995
2078
|
|
|
2079
|
+
/**
|
|
2080
|
+
* Resource type for custom data
|
|
2081
|
+
*/
|
|
2082
|
+
type CustomDataResourceType = 'ticket' | 'customer' | 'contact';
|
|
2083
|
+
/**
|
|
2084
|
+
* Parameters for setting custom data
|
|
2085
|
+
*/
|
|
2086
|
+
interface CustomDataSetParams {
|
|
2087
|
+
resourceId: string;
|
|
2088
|
+
resourceType: CustomDataResourceType;
|
|
2089
|
+
key: string;
|
|
2090
|
+
value: string;
|
|
2091
|
+
}
|
|
2092
|
+
/**
|
|
2093
|
+
* Parameters for getting custom data
|
|
2094
|
+
*/
|
|
2095
|
+
interface CustomDataGetParams {
|
|
2096
|
+
resourceId: string;
|
|
2097
|
+
resourceType: CustomDataResourceType;
|
|
2098
|
+
key: string;
|
|
2099
|
+
}
|
|
2100
|
+
/**
|
|
2101
|
+
* Response from getting custom data
|
|
2102
|
+
*/
|
|
2103
|
+
interface CustomDataResponse {
|
|
2104
|
+
resourceId: string;
|
|
2105
|
+
resourceType: CustomDataResourceType;
|
|
2106
|
+
key: string;
|
|
2107
|
+
value: string;
|
|
2108
|
+
}
|
|
2109
|
+
/**
|
|
2110
|
+
* Parameters for deleting custom data
|
|
2111
|
+
*/
|
|
2112
|
+
interface CustomDataDeleteParams {
|
|
2113
|
+
resourceId: string;
|
|
2114
|
+
resourceType: CustomDataResourceType;
|
|
2115
|
+
key: string;
|
|
2116
|
+
}
|
|
2117
|
+
|
|
1996
2118
|
/**
|
|
1997
2119
|
* Resource for managing customers
|
|
1998
2120
|
*/
|
|
@@ -2429,13 +2551,29 @@ declare class DealsResource extends BaseResource {
|
|
|
2429
2551
|
/**
|
|
2430
2552
|
* Get deal activity timeline
|
|
2431
2553
|
*/
|
|
2432
|
-
|
|
2554
|
+
timeline(dealId: string): Promise<TimelineListResponse>;
|
|
2433
2555
|
/**
|
|
2434
|
-
*
|
|
2556
|
+
* List deal events
|
|
2435
2557
|
*/
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2558
|
+
listEvents(dealId: string): Promise<DealEventListResponse>;
|
|
2559
|
+
/**
|
|
2560
|
+
* Create a deal event
|
|
2561
|
+
*
|
|
2562
|
+
* Creates an event on a deal. If `dealStageId` is provided, the deal will
|
|
2563
|
+
* progress to that stage. If `dealActivityId` is provided and the activity
|
|
2564
|
+
* is configured for a future stage, the deal will automatically progress.
|
|
2565
|
+
*
|
|
2566
|
+
* @example
|
|
2567
|
+
* // Create a simple note
|
|
2568
|
+
* await client.deals.createEvent('deal_123', { notes: 'Follow-up call completed' });
|
|
2569
|
+
*
|
|
2570
|
+
* // Create an event and progress to a new stage
|
|
2571
|
+
* await client.deals.createEvent('deal_123', {
|
|
2572
|
+
* dealStageId: 'stage_456',
|
|
2573
|
+
* notes: 'Moving to negotiation phase',
|
|
2574
|
+
* });
|
|
2575
|
+
*/
|
|
2576
|
+
createEvent(dealId: string, data: DealEventCreateParams): Promise<DealEventCreateResponse>;
|
|
2439
2577
|
}
|
|
2440
2578
|
|
|
2441
2579
|
/**
|
|
@@ -3012,6 +3150,23 @@ declare class AgentsResource extends BaseResource {
|
|
|
3012
3150
|
* List support agents
|
|
3013
3151
|
*/
|
|
3014
3152
|
list(): Promise<AgentListResponse>;
|
|
3153
|
+
/**
|
|
3154
|
+
* Retrieve a specific agent by ID
|
|
3155
|
+
*/
|
|
3156
|
+
retrieve(agentId: string): Promise<AgentResponse>;
|
|
3157
|
+
/**
|
|
3158
|
+
* Create a new agent
|
|
3159
|
+
*/
|
|
3160
|
+
create(params: AgentCreateParams): Promise<AgentResponse>;
|
|
3161
|
+
/**
|
|
3162
|
+
* Find an existing agent by email, or create one if not found.
|
|
3163
|
+
* This is useful for sync operations where you want to ensure
|
|
3164
|
+
* an agent exists without duplicating.
|
|
3165
|
+
*
|
|
3166
|
+
* @param params - Agent data (email required, name optional)
|
|
3167
|
+
* @returns The existing or newly created agent
|
|
3168
|
+
*/
|
|
3169
|
+
findOrCreate(params: AgentCreateParams): Promise<AgentResponse>;
|
|
3015
3170
|
}
|
|
3016
3171
|
|
|
3017
3172
|
/**
|
|
@@ -3129,6 +3284,33 @@ declare class EntitiesResource extends BaseResource {
|
|
|
3129
3284
|
search(params?: EntitiesSearchParams): Promise<EntitiesSearchResponse>;
|
|
3130
3285
|
}
|
|
3131
3286
|
|
|
3287
|
+
/**
|
|
3288
|
+
* Resource for managing custom data on entities.
|
|
3289
|
+
* Custom data allows storing arbitrary key-value pairs on tickets, customers, and contacts.
|
|
3290
|
+
*/
|
|
3291
|
+
declare class CustomDataResource extends BaseResource {
|
|
3292
|
+
/**
|
|
3293
|
+
* Set custom data on a resource.
|
|
3294
|
+
* This will create or update the value for the given key.
|
|
3295
|
+
*
|
|
3296
|
+
* @param params - The custom data parameters
|
|
3297
|
+
*/
|
|
3298
|
+
set(params: CustomDataSetParams): Promise<void>;
|
|
3299
|
+
/**
|
|
3300
|
+
* Get custom data from a resource.
|
|
3301
|
+
*
|
|
3302
|
+
* @param params - Parameters identifying the custom data to retrieve
|
|
3303
|
+
* @returns The custom data value
|
|
3304
|
+
*/
|
|
3305
|
+
getValue(params: CustomDataGetParams): Promise<CustomDataResponse>;
|
|
3306
|
+
/**
|
|
3307
|
+
* Delete custom data from a resource.
|
|
3308
|
+
*
|
|
3309
|
+
* @param params - Parameters identifying the custom data to delete
|
|
3310
|
+
*/
|
|
3311
|
+
del(params: CustomDataDeleteParams): Promise<void>;
|
|
3312
|
+
}
|
|
3313
|
+
|
|
3132
3314
|
/**
|
|
3133
3315
|
* Mantle Core API Client
|
|
3134
3316
|
*
|
|
@@ -3183,6 +3365,7 @@ declare class MantleCoreClient {
|
|
|
3183
3365
|
readonly agents: AgentsResource;
|
|
3184
3366
|
readonly docs: DocsResource;
|
|
3185
3367
|
readonly entities: EntitiesResource;
|
|
3368
|
+
readonly customData: CustomDataResource;
|
|
3186
3369
|
constructor(config: MantleCoreClientConfig);
|
|
3187
3370
|
/**
|
|
3188
3371
|
* Register a middleware function
|
|
@@ -3388,4 +3571,4 @@ interface AuthRefreshOptions {
|
|
|
3388
3571
|
*/
|
|
3389
3572
|
declare function createAuthRefreshMiddleware(options: AuthRefreshOptions): Middleware;
|
|
3390
3573
|
|
|
3391
|
-
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, type AuthRefreshOptions, 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 ContactEntity, type ContactListParams, type ContactListResponse, type ContactUpdateParams, ContactsResource, type CustomField, type CustomFieldCreateParams, type CustomFieldUpdateParams, type Customer, type CustomerCreateParams, type CustomerEntity, 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 DealContactInput, type DealCreateParams, type DealCustomerInput, 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, EntitiesResource, type EntitiesSearchParams, type EntitiesSearchResponse, type Entity, type EntityType, type Feature, type FeatureCreateParams, type FeatureUpdateParams, type Flow, type FlowCreateParams, type FlowListParams, type FlowListResponse, type FlowStatus, type FlowUpdateParams, FlowsResource, type HttpMethod, 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 Middleware, type MiddlewareContext, MiddlewareManager, type MiddlewareOptions, type MiddlewareRequest, type MiddlewareResponse, type NextFunction, 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 SocialProfileType, 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, createAuthRefreshMiddleware };
|
|
3574
|
+
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 AgentCreateParams, type AgentListResponse, type AgentResponse, AgentsResource, type App, type AppEvent, type AppEventListParams, type AppEventListResponse, type AppInstallation, type AppInstallationParams, type AppListParams, AppsResource, type AuthRefreshOptions, 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 ContactEntity, type ContactListParams, type ContactListResponse, type ContactUpdateParams, ContactsResource, type CustomDataDeleteParams, type CustomDataGetParams, CustomDataResource, type CustomDataResourceType, type CustomDataResponse, type CustomDataSetParams, type CustomField, type CustomFieldCreateParams, type CustomFieldUpdateParams, type Customer, type CustomerCreateParams, type CustomerEntity, 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 DealContactInput, type DealCreateParams, type DealCustomerInput, type DealEvent, type DealEventCreateParams, type DealEventCreateResponse, type DealEventListResponse, 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, EntitiesResource, type EntitiesSearchParams, type EntitiesSearchResponse, type Entity, type EntityType, type Feature, type FeatureCreateParams, type FeatureUpdateParams, type Flow, type FlowCreateParams, type FlowListParams, type FlowListResponse, type FlowStatus, type FlowUpdateParams, FlowsResource, type HttpMethod, 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 Middleware, type MiddlewareContext, MiddlewareManager, type MiddlewareOptions, type MiddlewareRequest, type MiddlewareResponse, type NextFunction, 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 SocialProfileType, 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, createAuthRefreshMiddleware };
|
package/dist/index.js
CHANGED
|
@@ -32,6 +32,7 @@ __export(index_exports, {
|
|
|
32
32
|
ChargesResource: () => ChargesResource,
|
|
33
33
|
CompaniesResource: () => CompaniesResource,
|
|
34
34
|
ContactsResource: () => ContactsResource,
|
|
35
|
+
CustomDataResource: () => CustomDataResource,
|
|
35
36
|
CustomerSegmentsResource: () => CustomerSegmentsResource,
|
|
36
37
|
CustomersResource: () => CustomersResource,
|
|
37
38
|
DealActivitiesResource: () => DealActivitiesResource,
|
|
@@ -849,7 +850,7 @@ var DealsResource = class extends BaseResource {
|
|
|
849
850
|
/**
|
|
850
851
|
* Get deal activity timeline
|
|
851
852
|
*/
|
|
852
|
-
async
|
|
853
|
+
async timeline(dealId) {
|
|
853
854
|
const response = await this.get(
|
|
854
855
|
`/deals/${dealId}/timeline`
|
|
855
856
|
);
|
|
@@ -861,10 +862,39 @@ var DealsResource = class extends BaseResource {
|
|
|
861
862
|
};
|
|
862
863
|
}
|
|
863
864
|
/**
|
|
864
|
-
*
|
|
865
|
+
* List deal events
|
|
865
866
|
*/
|
|
866
|
-
async
|
|
867
|
-
|
|
867
|
+
async listEvents(dealId) {
|
|
868
|
+
const response = await this.get(
|
|
869
|
+
`/deals/${dealId}/events`
|
|
870
|
+
);
|
|
871
|
+
return {
|
|
872
|
+
events: response.events || [],
|
|
873
|
+
hasNextPage: response.hasNextPage || false,
|
|
874
|
+
hasPreviousPage: response.hasPreviousPage || false,
|
|
875
|
+
total: response.total,
|
|
876
|
+
cursor: response.cursor
|
|
877
|
+
};
|
|
878
|
+
}
|
|
879
|
+
/**
|
|
880
|
+
* Create a deal event
|
|
881
|
+
*
|
|
882
|
+
* Creates an event on a deal. If `dealStageId` is provided, the deal will
|
|
883
|
+
* progress to that stage. If `dealActivityId` is provided and the activity
|
|
884
|
+
* is configured for a future stage, the deal will automatically progress.
|
|
885
|
+
*
|
|
886
|
+
* @example
|
|
887
|
+
* // Create a simple note
|
|
888
|
+
* await client.deals.createEvent('deal_123', { notes: 'Follow-up call completed' });
|
|
889
|
+
*
|
|
890
|
+
* // Create an event and progress to a new stage
|
|
891
|
+
* await client.deals.createEvent('deal_123', {
|
|
892
|
+
* dealStageId: 'stage_456',
|
|
893
|
+
* notes: 'Moving to negotiation phase',
|
|
894
|
+
* });
|
|
895
|
+
*/
|
|
896
|
+
async createEvent(dealId, data) {
|
|
897
|
+
return this.post(`/deals/${dealId}/events`, data);
|
|
868
898
|
}
|
|
869
899
|
};
|
|
870
900
|
|
|
@@ -1682,6 +1712,42 @@ var AgentsResource = class extends BaseResource {
|
|
|
1682
1712
|
async list() {
|
|
1683
1713
|
return this.get("/agents");
|
|
1684
1714
|
}
|
|
1715
|
+
/**
|
|
1716
|
+
* Retrieve a specific agent by ID
|
|
1717
|
+
*/
|
|
1718
|
+
async retrieve(agentId) {
|
|
1719
|
+
return this.get(`/agents/${agentId}`);
|
|
1720
|
+
}
|
|
1721
|
+
/**
|
|
1722
|
+
* Create a new agent
|
|
1723
|
+
*/
|
|
1724
|
+
async create(params) {
|
|
1725
|
+
return this.post("/agents", params);
|
|
1726
|
+
}
|
|
1727
|
+
/**
|
|
1728
|
+
* Find an existing agent by email, or create one if not found.
|
|
1729
|
+
* This is useful for sync operations where you want to ensure
|
|
1730
|
+
* an agent exists without duplicating.
|
|
1731
|
+
*
|
|
1732
|
+
* @param params - Agent data (email required, name optional)
|
|
1733
|
+
* @returns The existing or newly created agent
|
|
1734
|
+
*/
|
|
1735
|
+
async findOrCreate(params) {
|
|
1736
|
+
try {
|
|
1737
|
+
return await this.create(params);
|
|
1738
|
+
} catch (error) {
|
|
1739
|
+
if (error instanceof MantleAPIError && error.statusCode === 409) {
|
|
1740
|
+
const { agents } = await this.list();
|
|
1741
|
+
const existingAgent = agents.find(
|
|
1742
|
+
(agent) => agent.email.toLowerCase() === params.email.toLowerCase()
|
|
1743
|
+
);
|
|
1744
|
+
if (existingAgent) {
|
|
1745
|
+
return { agent: existingAgent };
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
throw error;
|
|
1749
|
+
}
|
|
1750
|
+
}
|
|
1685
1751
|
};
|
|
1686
1752
|
|
|
1687
1753
|
// src/resources/docs.ts
|
|
@@ -1824,6 +1890,42 @@ var EntitiesResource = class extends BaseResource {
|
|
|
1824
1890
|
}
|
|
1825
1891
|
};
|
|
1826
1892
|
|
|
1893
|
+
// src/resources/custom-data.ts
|
|
1894
|
+
var CustomDataResource = class extends BaseResource {
|
|
1895
|
+
/**
|
|
1896
|
+
* Set custom data on a resource.
|
|
1897
|
+
* This will create or update the value for the given key.
|
|
1898
|
+
*
|
|
1899
|
+
* @param params - The custom data parameters
|
|
1900
|
+
*/
|
|
1901
|
+
async set(params) {
|
|
1902
|
+
await this.put("/custom_data", params);
|
|
1903
|
+
}
|
|
1904
|
+
/**
|
|
1905
|
+
* Get custom data from a resource.
|
|
1906
|
+
*
|
|
1907
|
+
* @param params - Parameters identifying the custom data to retrieve
|
|
1908
|
+
* @returns The custom data value
|
|
1909
|
+
*/
|
|
1910
|
+
async getValue(params) {
|
|
1911
|
+
const { resourceType, resourceId, key } = params;
|
|
1912
|
+
return this.get(
|
|
1913
|
+
`/custom_data/${resourceType}/${resourceId}/${encodeURIComponent(key)}`
|
|
1914
|
+
);
|
|
1915
|
+
}
|
|
1916
|
+
/**
|
|
1917
|
+
* Delete custom data from a resource.
|
|
1918
|
+
*
|
|
1919
|
+
* @param params - Parameters identifying the custom data to delete
|
|
1920
|
+
*/
|
|
1921
|
+
async del(params) {
|
|
1922
|
+
const { resourceType, resourceId, key } = params;
|
|
1923
|
+
await this._delete(
|
|
1924
|
+
`/custom_data/${resourceType}/${resourceId}/${encodeURIComponent(key)}`
|
|
1925
|
+
);
|
|
1926
|
+
}
|
|
1927
|
+
};
|
|
1928
|
+
|
|
1827
1929
|
// src/client.ts
|
|
1828
1930
|
var MantleCoreClient = class {
|
|
1829
1931
|
constructor(config) {
|
|
@@ -1875,6 +1977,7 @@ var MantleCoreClient = class {
|
|
|
1875
1977
|
this.agents = new AgentsResource(this);
|
|
1876
1978
|
this.docs = new DocsResource(this);
|
|
1877
1979
|
this.entities = new EntitiesResource(this);
|
|
1980
|
+
this.customData = new CustomDataResource(this);
|
|
1878
1981
|
}
|
|
1879
1982
|
/**
|
|
1880
1983
|
* Register a middleware function
|
|
@@ -2165,6 +2268,7 @@ function createAuthRefreshMiddleware(options) {
|
|
|
2165
2268
|
ChargesResource,
|
|
2166
2269
|
CompaniesResource,
|
|
2167
2270
|
ContactsResource,
|
|
2271
|
+
CustomDataResource,
|
|
2168
2272
|
CustomerSegmentsResource,
|
|
2169
2273
|
CustomersResource,
|
|
2170
2274
|
DealActivitiesResource,
|
package/dist/index.mjs
CHANGED
|
@@ -785,7 +785,7 @@ var DealsResource = class extends BaseResource {
|
|
|
785
785
|
/**
|
|
786
786
|
* Get deal activity timeline
|
|
787
787
|
*/
|
|
788
|
-
async
|
|
788
|
+
async timeline(dealId) {
|
|
789
789
|
const response = await this.get(
|
|
790
790
|
`/deals/${dealId}/timeline`
|
|
791
791
|
);
|
|
@@ -797,10 +797,39 @@ var DealsResource = class extends BaseResource {
|
|
|
797
797
|
};
|
|
798
798
|
}
|
|
799
799
|
/**
|
|
800
|
-
*
|
|
800
|
+
* List deal events
|
|
801
801
|
*/
|
|
802
|
-
async
|
|
803
|
-
|
|
802
|
+
async listEvents(dealId) {
|
|
803
|
+
const response = await this.get(
|
|
804
|
+
`/deals/${dealId}/events`
|
|
805
|
+
);
|
|
806
|
+
return {
|
|
807
|
+
events: response.events || [],
|
|
808
|
+
hasNextPage: response.hasNextPage || false,
|
|
809
|
+
hasPreviousPage: response.hasPreviousPage || false,
|
|
810
|
+
total: response.total,
|
|
811
|
+
cursor: response.cursor
|
|
812
|
+
};
|
|
813
|
+
}
|
|
814
|
+
/**
|
|
815
|
+
* Create a deal event
|
|
816
|
+
*
|
|
817
|
+
* Creates an event on a deal. If `dealStageId` is provided, the deal will
|
|
818
|
+
* progress to that stage. If `dealActivityId` is provided and the activity
|
|
819
|
+
* is configured for a future stage, the deal will automatically progress.
|
|
820
|
+
*
|
|
821
|
+
* @example
|
|
822
|
+
* // Create a simple note
|
|
823
|
+
* await client.deals.createEvent('deal_123', { notes: 'Follow-up call completed' });
|
|
824
|
+
*
|
|
825
|
+
* // Create an event and progress to a new stage
|
|
826
|
+
* await client.deals.createEvent('deal_123', {
|
|
827
|
+
* dealStageId: 'stage_456',
|
|
828
|
+
* notes: 'Moving to negotiation phase',
|
|
829
|
+
* });
|
|
830
|
+
*/
|
|
831
|
+
async createEvent(dealId, data) {
|
|
832
|
+
return this.post(`/deals/${dealId}/events`, data);
|
|
804
833
|
}
|
|
805
834
|
};
|
|
806
835
|
|
|
@@ -1618,6 +1647,42 @@ var AgentsResource = class extends BaseResource {
|
|
|
1618
1647
|
async list() {
|
|
1619
1648
|
return this.get("/agents");
|
|
1620
1649
|
}
|
|
1650
|
+
/**
|
|
1651
|
+
* Retrieve a specific agent by ID
|
|
1652
|
+
*/
|
|
1653
|
+
async retrieve(agentId) {
|
|
1654
|
+
return this.get(`/agents/${agentId}`);
|
|
1655
|
+
}
|
|
1656
|
+
/**
|
|
1657
|
+
* Create a new agent
|
|
1658
|
+
*/
|
|
1659
|
+
async create(params) {
|
|
1660
|
+
return this.post("/agents", params);
|
|
1661
|
+
}
|
|
1662
|
+
/**
|
|
1663
|
+
* Find an existing agent by email, or create one if not found.
|
|
1664
|
+
* This is useful for sync operations where you want to ensure
|
|
1665
|
+
* an agent exists without duplicating.
|
|
1666
|
+
*
|
|
1667
|
+
* @param params - Agent data (email required, name optional)
|
|
1668
|
+
* @returns The existing or newly created agent
|
|
1669
|
+
*/
|
|
1670
|
+
async findOrCreate(params) {
|
|
1671
|
+
try {
|
|
1672
|
+
return await this.create(params);
|
|
1673
|
+
} catch (error) {
|
|
1674
|
+
if (error instanceof MantleAPIError && error.statusCode === 409) {
|
|
1675
|
+
const { agents } = await this.list();
|
|
1676
|
+
const existingAgent = agents.find(
|
|
1677
|
+
(agent) => agent.email.toLowerCase() === params.email.toLowerCase()
|
|
1678
|
+
);
|
|
1679
|
+
if (existingAgent) {
|
|
1680
|
+
return { agent: existingAgent };
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
throw error;
|
|
1684
|
+
}
|
|
1685
|
+
}
|
|
1621
1686
|
};
|
|
1622
1687
|
|
|
1623
1688
|
// src/resources/docs.ts
|
|
@@ -1760,6 +1825,42 @@ var EntitiesResource = class extends BaseResource {
|
|
|
1760
1825
|
}
|
|
1761
1826
|
};
|
|
1762
1827
|
|
|
1828
|
+
// src/resources/custom-data.ts
|
|
1829
|
+
var CustomDataResource = class extends BaseResource {
|
|
1830
|
+
/**
|
|
1831
|
+
* Set custom data on a resource.
|
|
1832
|
+
* This will create or update the value for the given key.
|
|
1833
|
+
*
|
|
1834
|
+
* @param params - The custom data parameters
|
|
1835
|
+
*/
|
|
1836
|
+
async set(params) {
|
|
1837
|
+
await this.put("/custom_data", params);
|
|
1838
|
+
}
|
|
1839
|
+
/**
|
|
1840
|
+
* Get custom data from a resource.
|
|
1841
|
+
*
|
|
1842
|
+
* @param params - Parameters identifying the custom data to retrieve
|
|
1843
|
+
* @returns The custom data value
|
|
1844
|
+
*/
|
|
1845
|
+
async getValue(params) {
|
|
1846
|
+
const { resourceType, resourceId, key } = params;
|
|
1847
|
+
return this.get(
|
|
1848
|
+
`/custom_data/${resourceType}/${resourceId}/${encodeURIComponent(key)}`
|
|
1849
|
+
);
|
|
1850
|
+
}
|
|
1851
|
+
/**
|
|
1852
|
+
* Delete custom data from a resource.
|
|
1853
|
+
*
|
|
1854
|
+
* @param params - Parameters identifying the custom data to delete
|
|
1855
|
+
*/
|
|
1856
|
+
async del(params) {
|
|
1857
|
+
const { resourceType, resourceId, key } = params;
|
|
1858
|
+
await this._delete(
|
|
1859
|
+
`/custom_data/${resourceType}/${resourceId}/${encodeURIComponent(key)}`
|
|
1860
|
+
);
|
|
1861
|
+
}
|
|
1862
|
+
};
|
|
1863
|
+
|
|
1763
1864
|
// src/client.ts
|
|
1764
1865
|
var MantleCoreClient = class {
|
|
1765
1866
|
constructor(config) {
|
|
@@ -1811,6 +1912,7 @@ var MantleCoreClient = class {
|
|
|
1811
1912
|
this.agents = new AgentsResource(this);
|
|
1812
1913
|
this.docs = new DocsResource(this);
|
|
1813
1914
|
this.entities = new EntitiesResource(this);
|
|
1915
|
+
this.customData = new CustomDataResource(this);
|
|
1814
1916
|
}
|
|
1815
1917
|
/**
|
|
1816
1918
|
* Register a middleware function
|
|
@@ -2100,6 +2202,7 @@ export {
|
|
|
2100
2202
|
ChargesResource,
|
|
2101
2203
|
CompaniesResource,
|
|
2102
2204
|
ContactsResource,
|
|
2205
|
+
CustomDataResource,
|
|
2103
2206
|
CustomerSegmentsResource,
|
|
2104
2207
|
CustomersResource,
|
|
2105
2208
|
DealActivitiesResource,
|