@sendly/node 3.21.1 → 3.23.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.
- package/dist/index.d.mts +174 -2
- package/dist/index.d.ts +174 -2
- package/dist/index.js +167 -0
- package/dist/index.mjs +167 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -135,7 +135,7 @@ interface Message {
|
|
|
135
135
|
*/
|
|
136
136
|
senderType?: SenderType;
|
|
137
137
|
/**
|
|
138
|
-
*
|
|
138
|
+
* Carrier message ID for tracking
|
|
139
139
|
*/
|
|
140
140
|
telnyxMessageId?: string | null;
|
|
141
141
|
/**
|
|
@@ -158,6 +158,17 @@ interface Message {
|
|
|
158
158
|
* Custom JSON metadata attached to the message
|
|
159
159
|
*/
|
|
160
160
|
metadata?: Record<string, any>;
|
|
161
|
+
/**
|
|
162
|
+
* AI classification metadata (inbound messages only, when AI classification is enabled)
|
|
163
|
+
*/
|
|
164
|
+
aiMetadata?: {
|
|
165
|
+
intent: string;
|
|
166
|
+
intentConfidence: number;
|
|
167
|
+
sentiment: string;
|
|
168
|
+
sentimentConfidence: number;
|
|
169
|
+
classifiedAt: string;
|
|
170
|
+
model: string;
|
|
171
|
+
} | null;
|
|
161
172
|
}
|
|
162
173
|
/**
|
|
163
174
|
* Options for listing messages
|
|
@@ -191,6 +202,130 @@ interface MessageListResponse {
|
|
|
191
202
|
*/
|
|
192
203
|
count: number;
|
|
193
204
|
}
|
|
205
|
+
type ConversationStatus = "active" | "closed";
|
|
206
|
+
interface Conversation {
|
|
207
|
+
id: string;
|
|
208
|
+
phoneNumber: string;
|
|
209
|
+
status: ConversationStatus;
|
|
210
|
+
unreadCount: number;
|
|
211
|
+
messageCount: number;
|
|
212
|
+
lastMessageText: string | null;
|
|
213
|
+
lastMessageAt: string | null;
|
|
214
|
+
lastMessageDirection: "inbound" | "outbound" | null;
|
|
215
|
+
metadata: Record<string, any>;
|
|
216
|
+
tags: string[];
|
|
217
|
+
contactId: string | null;
|
|
218
|
+
createdAt: string;
|
|
219
|
+
updatedAt: string;
|
|
220
|
+
}
|
|
221
|
+
interface ListConversationsOptions {
|
|
222
|
+
limit?: number;
|
|
223
|
+
offset?: number;
|
|
224
|
+
status?: ConversationStatus;
|
|
225
|
+
}
|
|
226
|
+
interface ConversationListResponse {
|
|
227
|
+
data: Conversation[];
|
|
228
|
+
pagination: {
|
|
229
|
+
total: number;
|
|
230
|
+
limit: number;
|
|
231
|
+
offset: number;
|
|
232
|
+
hasMore: boolean;
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
interface ConversationWithMessages extends Conversation {
|
|
236
|
+
messages?: {
|
|
237
|
+
data: Message[];
|
|
238
|
+
pagination: {
|
|
239
|
+
total: number;
|
|
240
|
+
limit: number;
|
|
241
|
+
offset: number;
|
|
242
|
+
hasMore: boolean;
|
|
243
|
+
};
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
interface GetConversationOptions {
|
|
247
|
+
includeMessages?: boolean;
|
|
248
|
+
messageLimit?: number;
|
|
249
|
+
messageOffset?: number;
|
|
250
|
+
}
|
|
251
|
+
interface UpdateConversationRequest {
|
|
252
|
+
metadata?: Record<string, any>;
|
|
253
|
+
tags?: string[];
|
|
254
|
+
}
|
|
255
|
+
interface ReplyToConversationRequest {
|
|
256
|
+
text: string;
|
|
257
|
+
messageType?: MessageType;
|
|
258
|
+
metadata?: Record<string, any>;
|
|
259
|
+
mediaUrls?: string[];
|
|
260
|
+
}
|
|
261
|
+
interface SuggestedReply {
|
|
262
|
+
text: string;
|
|
263
|
+
tone: "professional" | "friendly" | "concise";
|
|
264
|
+
}
|
|
265
|
+
interface SuggestRepliesResponse {
|
|
266
|
+
suggestions: SuggestedReply[];
|
|
267
|
+
basedOnMessageId?: string;
|
|
268
|
+
model?: string;
|
|
269
|
+
}
|
|
270
|
+
interface Label {
|
|
271
|
+
id: string;
|
|
272
|
+
name: string;
|
|
273
|
+
color: string;
|
|
274
|
+
description?: string | null;
|
|
275
|
+
createdAt: string;
|
|
276
|
+
}
|
|
277
|
+
interface LabelListResponse {
|
|
278
|
+
data: Label[];
|
|
279
|
+
}
|
|
280
|
+
interface CreateLabelRequest {
|
|
281
|
+
name: string;
|
|
282
|
+
color?: string;
|
|
283
|
+
description?: string;
|
|
284
|
+
}
|
|
285
|
+
interface AddLabelsRequest {
|
|
286
|
+
labelIds: string[];
|
|
287
|
+
}
|
|
288
|
+
type DraftStatus = "pending" | "approved" | "rejected" | "sent" | "failed";
|
|
289
|
+
interface MessageDraft {
|
|
290
|
+
id: string;
|
|
291
|
+
conversationId: string;
|
|
292
|
+
text: string;
|
|
293
|
+
mediaUrls?: string[];
|
|
294
|
+
metadata?: Record<string, any>;
|
|
295
|
+
status: DraftStatus;
|
|
296
|
+
source?: string;
|
|
297
|
+
createdBy?: string;
|
|
298
|
+
reviewedBy?: string;
|
|
299
|
+
reviewedAt?: string | null;
|
|
300
|
+
rejectionReason?: string | null;
|
|
301
|
+
messageId?: string | null;
|
|
302
|
+
createdAt: string;
|
|
303
|
+
updatedAt: string;
|
|
304
|
+
}
|
|
305
|
+
interface CreateDraftRequest {
|
|
306
|
+
conversationId: string;
|
|
307
|
+
text: string;
|
|
308
|
+
mediaUrls?: string[];
|
|
309
|
+
metadata?: Record<string, any>;
|
|
310
|
+
source?: string;
|
|
311
|
+
}
|
|
312
|
+
interface UpdateDraftRequest {
|
|
313
|
+
text?: string;
|
|
314
|
+
mediaUrls?: string[];
|
|
315
|
+
metadata?: Record<string, any>;
|
|
316
|
+
}
|
|
317
|
+
interface DraftListResponse {
|
|
318
|
+
data: MessageDraft[];
|
|
319
|
+
pagination: {
|
|
320
|
+
total: number;
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
interface ListDraftsOptions {
|
|
324
|
+
conversationId?: string;
|
|
325
|
+
status?: DraftStatus;
|
|
326
|
+
limit?: number;
|
|
327
|
+
offset?: number;
|
|
328
|
+
}
|
|
194
329
|
/**
|
|
195
330
|
* An uploaded media file for MMS
|
|
196
331
|
*/
|
|
@@ -3544,6 +3679,40 @@ declare class EnterpriseResource {
|
|
|
3544
3679
|
provision(options: ProvisionWorkspaceOptions): Promise<ProvisionWorkspaceResult>;
|
|
3545
3680
|
}
|
|
3546
3681
|
|
|
3682
|
+
declare class ConversationsResource {
|
|
3683
|
+
private readonly http;
|
|
3684
|
+
constructor(http: HttpClient);
|
|
3685
|
+
list(options?: ListConversationsOptions): Promise<ConversationListResponse>;
|
|
3686
|
+
get(id: string, options?: GetConversationOptions): Promise<ConversationWithMessages>;
|
|
3687
|
+
reply(conversationId: string, request: ReplyToConversationRequest): Promise<Message>;
|
|
3688
|
+
update(id: string, request: UpdateConversationRequest): Promise<Conversation>;
|
|
3689
|
+
markRead(id: string): Promise<Conversation>;
|
|
3690
|
+
close(id: string): Promise<Conversation>;
|
|
3691
|
+
reopen(id: string): Promise<Conversation>;
|
|
3692
|
+
suggestReplies(conversationId: string): Promise<SuggestRepliesResponse>;
|
|
3693
|
+
addLabels(conversationId: string, labelIds: string[]): Promise<LabelListResponse>;
|
|
3694
|
+
removeLabel(conversationId: string, labelId: string): Promise<void>;
|
|
3695
|
+
}
|
|
3696
|
+
|
|
3697
|
+
declare class LabelsResource {
|
|
3698
|
+
private readonly http;
|
|
3699
|
+
constructor(http: HttpClient);
|
|
3700
|
+
create(request: CreateLabelRequest): Promise<Label>;
|
|
3701
|
+
list(): Promise<LabelListResponse>;
|
|
3702
|
+
delete(id: string): Promise<void>;
|
|
3703
|
+
}
|
|
3704
|
+
|
|
3705
|
+
declare class DraftsResource {
|
|
3706
|
+
private readonly http;
|
|
3707
|
+
constructor(http: HttpClient);
|
|
3708
|
+
create(request: CreateDraftRequest): Promise<MessageDraft>;
|
|
3709
|
+
list(options?: ListDraftsOptions): Promise<DraftListResponse>;
|
|
3710
|
+
get(id: string): Promise<MessageDraft>;
|
|
3711
|
+
update(id: string, request: UpdateDraftRequest): Promise<MessageDraft>;
|
|
3712
|
+
approve(id: string): Promise<MessageDraft>;
|
|
3713
|
+
reject(id: string, reason?: string): Promise<MessageDraft>;
|
|
3714
|
+
}
|
|
3715
|
+
|
|
3547
3716
|
/**
|
|
3548
3717
|
* Sendly Client
|
|
3549
3718
|
* @packageDocumentation
|
|
@@ -3597,6 +3766,9 @@ declare class Sendly {
|
|
|
3597
3766
|
* ```
|
|
3598
3767
|
*/
|
|
3599
3768
|
readonly messages: MessagesResource;
|
|
3769
|
+
readonly conversations: ConversationsResource;
|
|
3770
|
+
readonly labels: LabelsResource;
|
|
3771
|
+
readonly drafts: DraftsResource;
|
|
3600
3772
|
/**
|
|
3601
3773
|
* Webhooks API resource
|
|
3602
3774
|
*
|
|
@@ -4203,4 +4375,4 @@ declare class Webhooks {
|
|
|
4203
4375
|
*/
|
|
4204
4376
|
type WebhookMessageData = WebhookMessageObject;
|
|
4205
4377
|
|
|
4206
|
-
export { ALL_SUPPORTED_COUNTRIES, type Account, type AnalyticsOverview, type AnalyticsPeriod, type ApiErrorResponse, type ApiKey, AuthenticationError, type AutoTopUpSettings, type BatchListResponse, type BatchMessageItem, type BatchMessageRequest, type BatchMessageResponse, type BatchMessageResult, type BatchStatus, type BillingBreakdown, type BillingBreakdownOptions, type BulkProvisionResult, type BulkProvisionResultItem, type BulkProvisionWorkspace, CREDITS_PER_SMS, type Campaign, type CampaignListResponse, type CampaignPreview, type CampaignStatus, type CancelledMessageResponse, type CheckVerificationRequest, type CheckVerificationResponse, type CircuitState, type Contact, type ContactList, type ContactListResponse, type ContactListsResponse, type CreateCampaignRequest, type CreateContactListRequest, type CreateContactRequest, type CreateKeyOptions, type CreateOptInPageOptions, type CreateOptInPageResult, type CreateTemplateRequest, type CreateVerifySessionRequest, type CreateWebhookOptions, type CreateWorkspaceOptions, type CreatedApiKey, type CreditAnalytics, type CreditAnalyticsDataPoint, type CreditTransaction, type Credits, type DeliveryAnalyticsItem, type DeliveryStatus, type DnsRecord, type EnterpriseAccount, type EnterpriseWebhook, type EnterpriseWebhookTestResult, type EnterpriseWorkspace, type EnterpriseWorkspaceDetail, type EnterpriseWorkspaceSummary, type ImportContactItem, type ImportContactsError, type ImportContactsRequest, type ImportContactsResponse, InsufficientCreditsError, type Invitation, type ListBatchesOptions, type ListCampaignsOptions, type ListContactsOptions, type ListMessagesOptions, type ListScheduledMessagesOptions, type ListVerificationsOptions, type MediaFile, type MediaUploadOptions, type Message, type MessageAnalytics, type MessageAnalyticsDataPoint, type MessageListResponse, type MessageStatus, type MessageType, NetworkError, NotFoundError, type OptInPage, type PricingTier, type ProvisionWorkspaceOptions, type ProvisionWorkspaceResult, type QuotaSettings, RateLimitError, type RateLimitInfo, type ResumeWorkspaceResult, SANDBOX_TEST_NUMBERS, SUPPORTED_COUNTRIES, type ScheduleCampaignRequest, type ScheduleMessageRequest, type ScheduledMessage, type ScheduledMessageListResponse, type ScheduledMessageStatus, type SendInvitationOptions, type SendMessageRequest, type SendVerificationRequest, type SendVerificationResponse, type SenderType, Sendly, type SendlyConfig, SendlyError, type SendlyErrorCode, type SetCustomDomainResult, type SetWorkspaceWebhookOptions, type SetWorkspaceWebhookResult, type SuspendWorkspaceOptions, type SuspendWorkspaceResult, type Template, type TemplateListResponse, type TemplatePreview, type TemplateStatus, type TemplateVariable, TimeoutError, type TransferCreditsOptions, type TransferCreditsResult, type UpdateAutoTopUpOptions, type UpdateCampaignRequest, type UpdateContactListRequest, type UpdateContactRequest, type UpdateOptInPageOptions, type UpdateQuotaOptions, type UpdateTemplateRequest, type UpdateWebhookOptions, type ValidateSessionTokenRequest, type ValidateSessionTokenResponse, ValidationError, type Verification, type VerificationDeliveryStatus, type VerificationListResponse, type VerificationStatus, type VerifySession, type VerifySessionStatus, type Webhook, type WebhookCreatedResponse, type WebhookDelivery, type WebhookEvent, type WebhookEventType, type WebhookMessageData, type WebhookMessageStatus, type WebhookSecretRotation, WebhookSignatureError, type WebhookTestResult, Webhooks, type WorkspaceBillingItem, type WorkspaceCredits, type WorkspaceWebhook, calculateSegments, Sendly as default, generateWebhookSignature, getCountryFromPhone, isCountrySupported, parseWebhookEvent, validateMessageText, validatePhoneNumber, validateSenderId, verifyWebhookSignature };
|
|
4378
|
+
export { ALL_SUPPORTED_COUNTRIES, type Account, type AddLabelsRequest, type AnalyticsOverview, type AnalyticsPeriod, type ApiErrorResponse, type ApiKey, AuthenticationError, type AutoTopUpSettings, type BatchListResponse, type BatchMessageItem, type BatchMessageRequest, type BatchMessageResponse, type BatchMessageResult, type BatchStatus, type BillingBreakdown, type BillingBreakdownOptions, type BulkProvisionResult, type BulkProvisionResultItem, type BulkProvisionWorkspace, CREDITS_PER_SMS, type Campaign, type CampaignListResponse, type CampaignPreview, type CampaignStatus, type CancelledMessageResponse, type CheckVerificationRequest, type CheckVerificationResponse, type CircuitState, type Contact, type ContactList, type ContactListResponse, type ContactListsResponse, type Conversation, type ConversationListResponse, type ConversationStatus, type ConversationWithMessages, type CreateCampaignRequest, type CreateContactListRequest, type CreateContactRequest, type CreateDraftRequest, type CreateKeyOptions, type CreateLabelRequest, type CreateOptInPageOptions, type CreateOptInPageResult, type CreateTemplateRequest, type CreateVerifySessionRequest, type CreateWebhookOptions, type CreateWorkspaceOptions, type CreatedApiKey, type CreditAnalytics, type CreditAnalyticsDataPoint, type CreditTransaction, type Credits, type DeliveryAnalyticsItem, type DeliveryStatus, type DnsRecord, type DraftListResponse, type DraftStatus, type EnterpriseAccount, type EnterpriseWebhook, type EnterpriseWebhookTestResult, type EnterpriseWorkspace, type EnterpriseWorkspaceDetail, type EnterpriseWorkspaceSummary, type GetConversationOptions, type ImportContactItem, type ImportContactsError, type ImportContactsRequest, type ImportContactsResponse, InsufficientCreditsError, type Invitation, type Label, type LabelListResponse, type ListBatchesOptions, type ListCampaignsOptions, type ListContactsOptions, type ListConversationsOptions, type ListDraftsOptions, type ListMessagesOptions, type ListScheduledMessagesOptions, type ListVerificationsOptions, type MediaFile, type MediaUploadOptions, type Message, type MessageAnalytics, type MessageAnalyticsDataPoint, type MessageDraft, type MessageListResponse, type MessageStatus, type MessageType, NetworkError, NotFoundError, type OptInPage, type PricingTier, type ProvisionWorkspaceOptions, type ProvisionWorkspaceResult, type QuotaSettings, RateLimitError, type RateLimitInfo, type ReplyToConversationRequest, type ResumeWorkspaceResult, SANDBOX_TEST_NUMBERS, SUPPORTED_COUNTRIES, type ScheduleCampaignRequest, type ScheduleMessageRequest, type ScheduledMessage, type ScheduledMessageListResponse, type ScheduledMessageStatus, type SendInvitationOptions, type SendMessageRequest, type SendVerificationRequest, type SendVerificationResponse, type SenderType, Sendly, type SendlyConfig, SendlyError, type SendlyErrorCode, type SetCustomDomainResult, type SetWorkspaceWebhookOptions, type SetWorkspaceWebhookResult, type SuggestRepliesResponse, type SuggestedReply, type SuspendWorkspaceOptions, type SuspendWorkspaceResult, type Template, type TemplateListResponse, type TemplatePreview, type TemplateStatus, type TemplateVariable, TimeoutError, type TransferCreditsOptions, type TransferCreditsResult, type UpdateAutoTopUpOptions, type UpdateCampaignRequest, type UpdateContactListRequest, type UpdateContactRequest, type UpdateConversationRequest, type UpdateDraftRequest, type UpdateOptInPageOptions, type UpdateQuotaOptions, type UpdateTemplateRequest, type UpdateWebhookOptions, type ValidateSessionTokenRequest, type ValidateSessionTokenResponse, ValidationError, type Verification, type VerificationDeliveryStatus, type VerificationListResponse, type VerificationStatus, type VerifySession, type VerifySessionStatus, type Webhook, type WebhookCreatedResponse, type WebhookDelivery, type WebhookEvent, type WebhookEventType, type WebhookMessageData, type WebhookMessageStatus, type WebhookSecretRotation, WebhookSignatureError, type WebhookTestResult, Webhooks, type WorkspaceBillingItem, type WorkspaceCredits, type WorkspaceWebhook, calculateSegments, Sendly as default, generateWebhookSignature, getCountryFromPhone, isCountrySupported, parseWebhookEvent, validateMessageText, validatePhoneNumber, validateSenderId, verifyWebhookSignature };
|
package/dist/index.d.ts
CHANGED
|
@@ -135,7 +135,7 @@ interface Message {
|
|
|
135
135
|
*/
|
|
136
136
|
senderType?: SenderType;
|
|
137
137
|
/**
|
|
138
|
-
*
|
|
138
|
+
* Carrier message ID for tracking
|
|
139
139
|
*/
|
|
140
140
|
telnyxMessageId?: string | null;
|
|
141
141
|
/**
|
|
@@ -158,6 +158,17 @@ interface Message {
|
|
|
158
158
|
* Custom JSON metadata attached to the message
|
|
159
159
|
*/
|
|
160
160
|
metadata?: Record<string, any>;
|
|
161
|
+
/**
|
|
162
|
+
* AI classification metadata (inbound messages only, when AI classification is enabled)
|
|
163
|
+
*/
|
|
164
|
+
aiMetadata?: {
|
|
165
|
+
intent: string;
|
|
166
|
+
intentConfidence: number;
|
|
167
|
+
sentiment: string;
|
|
168
|
+
sentimentConfidence: number;
|
|
169
|
+
classifiedAt: string;
|
|
170
|
+
model: string;
|
|
171
|
+
} | null;
|
|
161
172
|
}
|
|
162
173
|
/**
|
|
163
174
|
* Options for listing messages
|
|
@@ -191,6 +202,130 @@ interface MessageListResponse {
|
|
|
191
202
|
*/
|
|
192
203
|
count: number;
|
|
193
204
|
}
|
|
205
|
+
type ConversationStatus = "active" | "closed";
|
|
206
|
+
interface Conversation {
|
|
207
|
+
id: string;
|
|
208
|
+
phoneNumber: string;
|
|
209
|
+
status: ConversationStatus;
|
|
210
|
+
unreadCount: number;
|
|
211
|
+
messageCount: number;
|
|
212
|
+
lastMessageText: string | null;
|
|
213
|
+
lastMessageAt: string | null;
|
|
214
|
+
lastMessageDirection: "inbound" | "outbound" | null;
|
|
215
|
+
metadata: Record<string, any>;
|
|
216
|
+
tags: string[];
|
|
217
|
+
contactId: string | null;
|
|
218
|
+
createdAt: string;
|
|
219
|
+
updatedAt: string;
|
|
220
|
+
}
|
|
221
|
+
interface ListConversationsOptions {
|
|
222
|
+
limit?: number;
|
|
223
|
+
offset?: number;
|
|
224
|
+
status?: ConversationStatus;
|
|
225
|
+
}
|
|
226
|
+
interface ConversationListResponse {
|
|
227
|
+
data: Conversation[];
|
|
228
|
+
pagination: {
|
|
229
|
+
total: number;
|
|
230
|
+
limit: number;
|
|
231
|
+
offset: number;
|
|
232
|
+
hasMore: boolean;
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
interface ConversationWithMessages extends Conversation {
|
|
236
|
+
messages?: {
|
|
237
|
+
data: Message[];
|
|
238
|
+
pagination: {
|
|
239
|
+
total: number;
|
|
240
|
+
limit: number;
|
|
241
|
+
offset: number;
|
|
242
|
+
hasMore: boolean;
|
|
243
|
+
};
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
interface GetConversationOptions {
|
|
247
|
+
includeMessages?: boolean;
|
|
248
|
+
messageLimit?: number;
|
|
249
|
+
messageOffset?: number;
|
|
250
|
+
}
|
|
251
|
+
interface UpdateConversationRequest {
|
|
252
|
+
metadata?: Record<string, any>;
|
|
253
|
+
tags?: string[];
|
|
254
|
+
}
|
|
255
|
+
interface ReplyToConversationRequest {
|
|
256
|
+
text: string;
|
|
257
|
+
messageType?: MessageType;
|
|
258
|
+
metadata?: Record<string, any>;
|
|
259
|
+
mediaUrls?: string[];
|
|
260
|
+
}
|
|
261
|
+
interface SuggestedReply {
|
|
262
|
+
text: string;
|
|
263
|
+
tone: "professional" | "friendly" | "concise";
|
|
264
|
+
}
|
|
265
|
+
interface SuggestRepliesResponse {
|
|
266
|
+
suggestions: SuggestedReply[];
|
|
267
|
+
basedOnMessageId?: string;
|
|
268
|
+
model?: string;
|
|
269
|
+
}
|
|
270
|
+
interface Label {
|
|
271
|
+
id: string;
|
|
272
|
+
name: string;
|
|
273
|
+
color: string;
|
|
274
|
+
description?: string | null;
|
|
275
|
+
createdAt: string;
|
|
276
|
+
}
|
|
277
|
+
interface LabelListResponse {
|
|
278
|
+
data: Label[];
|
|
279
|
+
}
|
|
280
|
+
interface CreateLabelRequest {
|
|
281
|
+
name: string;
|
|
282
|
+
color?: string;
|
|
283
|
+
description?: string;
|
|
284
|
+
}
|
|
285
|
+
interface AddLabelsRequest {
|
|
286
|
+
labelIds: string[];
|
|
287
|
+
}
|
|
288
|
+
type DraftStatus = "pending" | "approved" | "rejected" | "sent" | "failed";
|
|
289
|
+
interface MessageDraft {
|
|
290
|
+
id: string;
|
|
291
|
+
conversationId: string;
|
|
292
|
+
text: string;
|
|
293
|
+
mediaUrls?: string[];
|
|
294
|
+
metadata?: Record<string, any>;
|
|
295
|
+
status: DraftStatus;
|
|
296
|
+
source?: string;
|
|
297
|
+
createdBy?: string;
|
|
298
|
+
reviewedBy?: string;
|
|
299
|
+
reviewedAt?: string | null;
|
|
300
|
+
rejectionReason?: string | null;
|
|
301
|
+
messageId?: string | null;
|
|
302
|
+
createdAt: string;
|
|
303
|
+
updatedAt: string;
|
|
304
|
+
}
|
|
305
|
+
interface CreateDraftRequest {
|
|
306
|
+
conversationId: string;
|
|
307
|
+
text: string;
|
|
308
|
+
mediaUrls?: string[];
|
|
309
|
+
metadata?: Record<string, any>;
|
|
310
|
+
source?: string;
|
|
311
|
+
}
|
|
312
|
+
interface UpdateDraftRequest {
|
|
313
|
+
text?: string;
|
|
314
|
+
mediaUrls?: string[];
|
|
315
|
+
metadata?: Record<string, any>;
|
|
316
|
+
}
|
|
317
|
+
interface DraftListResponse {
|
|
318
|
+
data: MessageDraft[];
|
|
319
|
+
pagination: {
|
|
320
|
+
total: number;
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
interface ListDraftsOptions {
|
|
324
|
+
conversationId?: string;
|
|
325
|
+
status?: DraftStatus;
|
|
326
|
+
limit?: number;
|
|
327
|
+
offset?: number;
|
|
328
|
+
}
|
|
194
329
|
/**
|
|
195
330
|
* An uploaded media file for MMS
|
|
196
331
|
*/
|
|
@@ -3544,6 +3679,40 @@ declare class EnterpriseResource {
|
|
|
3544
3679
|
provision(options: ProvisionWorkspaceOptions): Promise<ProvisionWorkspaceResult>;
|
|
3545
3680
|
}
|
|
3546
3681
|
|
|
3682
|
+
declare class ConversationsResource {
|
|
3683
|
+
private readonly http;
|
|
3684
|
+
constructor(http: HttpClient);
|
|
3685
|
+
list(options?: ListConversationsOptions): Promise<ConversationListResponse>;
|
|
3686
|
+
get(id: string, options?: GetConversationOptions): Promise<ConversationWithMessages>;
|
|
3687
|
+
reply(conversationId: string, request: ReplyToConversationRequest): Promise<Message>;
|
|
3688
|
+
update(id: string, request: UpdateConversationRequest): Promise<Conversation>;
|
|
3689
|
+
markRead(id: string): Promise<Conversation>;
|
|
3690
|
+
close(id: string): Promise<Conversation>;
|
|
3691
|
+
reopen(id: string): Promise<Conversation>;
|
|
3692
|
+
suggestReplies(conversationId: string): Promise<SuggestRepliesResponse>;
|
|
3693
|
+
addLabels(conversationId: string, labelIds: string[]): Promise<LabelListResponse>;
|
|
3694
|
+
removeLabel(conversationId: string, labelId: string): Promise<void>;
|
|
3695
|
+
}
|
|
3696
|
+
|
|
3697
|
+
declare class LabelsResource {
|
|
3698
|
+
private readonly http;
|
|
3699
|
+
constructor(http: HttpClient);
|
|
3700
|
+
create(request: CreateLabelRequest): Promise<Label>;
|
|
3701
|
+
list(): Promise<LabelListResponse>;
|
|
3702
|
+
delete(id: string): Promise<void>;
|
|
3703
|
+
}
|
|
3704
|
+
|
|
3705
|
+
declare class DraftsResource {
|
|
3706
|
+
private readonly http;
|
|
3707
|
+
constructor(http: HttpClient);
|
|
3708
|
+
create(request: CreateDraftRequest): Promise<MessageDraft>;
|
|
3709
|
+
list(options?: ListDraftsOptions): Promise<DraftListResponse>;
|
|
3710
|
+
get(id: string): Promise<MessageDraft>;
|
|
3711
|
+
update(id: string, request: UpdateDraftRequest): Promise<MessageDraft>;
|
|
3712
|
+
approve(id: string): Promise<MessageDraft>;
|
|
3713
|
+
reject(id: string, reason?: string): Promise<MessageDraft>;
|
|
3714
|
+
}
|
|
3715
|
+
|
|
3547
3716
|
/**
|
|
3548
3717
|
* Sendly Client
|
|
3549
3718
|
* @packageDocumentation
|
|
@@ -3597,6 +3766,9 @@ declare class Sendly {
|
|
|
3597
3766
|
* ```
|
|
3598
3767
|
*/
|
|
3599
3768
|
readonly messages: MessagesResource;
|
|
3769
|
+
readonly conversations: ConversationsResource;
|
|
3770
|
+
readonly labels: LabelsResource;
|
|
3771
|
+
readonly drafts: DraftsResource;
|
|
3600
3772
|
/**
|
|
3601
3773
|
* Webhooks API resource
|
|
3602
3774
|
*
|
|
@@ -4203,4 +4375,4 @@ declare class Webhooks {
|
|
|
4203
4375
|
*/
|
|
4204
4376
|
type WebhookMessageData = WebhookMessageObject;
|
|
4205
4377
|
|
|
4206
|
-
export { ALL_SUPPORTED_COUNTRIES, type Account, type AnalyticsOverview, type AnalyticsPeriod, type ApiErrorResponse, type ApiKey, AuthenticationError, type AutoTopUpSettings, type BatchListResponse, type BatchMessageItem, type BatchMessageRequest, type BatchMessageResponse, type BatchMessageResult, type BatchStatus, type BillingBreakdown, type BillingBreakdownOptions, type BulkProvisionResult, type BulkProvisionResultItem, type BulkProvisionWorkspace, CREDITS_PER_SMS, type Campaign, type CampaignListResponse, type CampaignPreview, type CampaignStatus, type CancelledMessageResponse, type CheckVerificationRequest, type CheckVerificationResponse, type CircuitState, type Contact, type ContactList, type ContactListResponse, type ContactListsResponse, type CreateCampaignRequest, type CreateContactListRequest, type CreateContactRequest, type CreateKeyOptions, type CreateOptInPageOptions, type CreateOptInPageResult, type CreateTemplateRequest, type CreateVerifySessionRequest, type CreateWebhookOptions, type CreateWorkspaceOptions, type CreatedApiKey, type CreditAnalytics, type CreditAnalyticsDataPoint, type CreditTransaction, type Credits, type DeliveryAnalyticsItem, type DeliveryStatus, type DnsRecord, type EnterpriseAccount, type EnterpriseWebhook, type EnterpriseWebhookTestResult, type EnterpriseWorkspace, type EnterpriseWorkspaceDetail, type EnterpriseWorkspaceSummary, type ImportContactItem, type ImportContactsError, type ImportContactsRequest, type ImportContactsResponse, InsufficientCreditsError, type Invitation, type ListBatchesOptions, type ListCampaignsOptions, type ListContactsOptions, type ListMessagesOptions, type ListScheduledMessagesOptions, type ListVerificationsOptions, type MediaFile, type MediaUploadOptions, type Message, type MessageAnalytics, type MessageAnalyticsDataPoint, type MessageListResponse, type MessageStatus, type MessageType, NetworkError, NotFoundError, type OptInPage, type PricingTier, type ProvisionWorkspaceOptions, type ProvisionWorkspaceResult, type QuotaSettings, RateLimitError, type RateLimitInfo, type ResumeWorkspaceResult, SANDBOX_TEST_NUMBERS, SUPPORTED_COUNTRIES, type ScheduleCampaignRequest, type ScheduleMessageRequest, type ScheduledMessage, type ScheduledMessageListResponse, type ScheduledMessageStatus, type SendInvitationOptions, type SendMessageRequest, type SendVerificationRequest, type SendVerificationResponse, type SenderType, Sendly, type SendlyConfig, SendlyError, type SendlyErrorCode, type SetCustomDomainResult, type SetWorkspaceWebhookOptions, type SetWorkspaceWebhookResult, type SuspendWorkspaceOptions, type SuspendWorkspaceResult, type Template, type TemplateListResponse, type TemplatePreview, type TemplateStatus, type TemplateVariable, TimeoutError, type TransferCreditsOptions, type TransferCreditsResult, type UpdateAutoTopUpOptions, type UpdateCampaignRequest, type UpdateContactListRequest, type UpdateContactRequest, type UpdateOptInPageOptions, type UpdateQuotaOptions, type UpdateTemplateRequest, type UpdateWebhookOptions, type ValidateSessionTokenRequest, type ValidateSessionTokenResponse, ValidationError, type Verification, type VerificationDeliveryStatus, type VerificationListResponse, type VerificationStatus, type VerifySession, type VerifySessionStatus, type Webhook, type WebhookCreatedResponse, type WebhookDelivery, type WebhookEvent, type WebhookEventType, type WebhookMessageData, type WebhookMessageStatus, type WebhookSecretRotation, WebhookSignatureError, type WebhookTestResult, Webhooks, type WorkspaceBillingItem, type WorkspaceCredits, type WorkspaceWebhook, calculateSegments, Sendly as default, generateWebhookSignature, getCountryFromPhone, isCountrySupported, parseWebhookEvent, validateMessageText, validatePhoneNumber, validateSenderId, verifyWebhookSignature };
|
|
4378
|
+
export { ALL_SUPPORTED_COUNTRIES, type Account, type AddLabelsRequest, type AnalyticsOverview, type AnalyticsPeriod, type ApiErrorResponse, type ApiKey, AuthenticationError, type AutoTopUpSettings, type BatchListResponse, type BatchMessageItem, type BatchMessageRequest, type BatchMessageResponse, type BatchMessageResult, type BatchStatus, type BillingBreakdown, type BillingBreakdownOptions, type BulkProvisionResult, type BulkProvisionResultItem, type BulkProvisionWorkspace, CREDITS_PER_SMS, type Campaign, type CampaignListResponse, type CampaignPreview, type CampaignStatus, type CancelledMessageResponse, type CheckVerificationRequest, type CheckVerificationResponse, type CircuitState, type Contact, type ContactList, type ContactListResponse, type ContactListsResponse, type Conversation, type ConversationListResponse, type ConversationStatus, type ConversationWithMessages, type CreateCampaignRequest, type CreateContactListRequest, type CreateContactRequest, type CreateDraftRequest, type CreateKeyOptions, type CreateLabelRequest, type CreateOptInPageOptions, type CreateOptInPageResult, type CreateTemplateRequest, type CreateVerifySessionRequest, type CreateWebhookOptions, type CreateWorkspaceOptions, type CreatedApiKey, type CreditAnalytics, type CreditAnalyticsDataPoint, type CreditTransaction, type Credits, type DeliveryAnalyticsItem, type DeliveryStatus, type DnsRecord, type DraftListResponse, type DraftStatus, type EnterpriseAccount, type EnterpriseWebhook, type EnterpriseWebhookTestResult, type EnterpriseWorkspace, type EnterpriseWorkspaceDetail, type EnterpriseWorkspaceSummary, type GetConversationOptions, type ImportContactItem, type ImportContactsError, type ImportContactsRequest, type ImportContactsResponse, InsufficientCreditsError, type Invitation, type Label, type LabelListResponse, type ListBatchesOptions, type ListCampaignsOptions, type ListContactsOptions, type ListConversationsOptions, type ListDraftsOptions, type ListMessagesOptions, type ListScheduledMessagesOptions, type ListVerificationsOptions, type MediaFile, type MediaUploadOptions, type Message, type MessageAnalytics, type MessageAnalyticsDataPoint, type MessageDraft, type MessageListResponse, type MessageStatus, type MessageType, NetworkError, NotFoundError, type OptInPage, type PricingTier, type ProvisionWorkspaceOptions, type ProvisionWorkspaceResult, type QuotaSettings, RateLimitError, type RateLimitInfo, type ReplyToConversationRequest, type ResumeWorkspaceResult, SANDBOX_TEST_NUMBERS, SUPPORTED_COUNTRIES, type ScheduleCampaignRequest, type ScheduleMessageRequest, type ScheduledMessage, type ScheduledMessageListResponse, type ScheduledMessageStatus, type SendInvitationOptions, type SendMessageRequest, type SendVerificationRequest, type SendVerificationResponse, type SenderType, Sendly, type SendlyConfig, SendlyError, type SendlyErrorCode, type SetCustomDomainResult, type SetWorkspaceWebhookOptions, type SetWorkspaceWebhookResult, type SuggestRepliesResponse, type SuggestedReply, type SuspendWorkspaceOptions, type SuspendWorkspaceResult, type Template, type TemplateListResponse, type TemplatePreview, type TemplateStatus, type TemplateVariable, TimeoutError, type TransferCreditsOptions, type TransferCreditsResult, type UpdateAutoTopUpOptions, type UpdateCampaignRequest, type UpdateContactListRequest, type UpdateContactRequest, type UpdateConversationRequest, type UpdateDraftRequest, type UpdateOptInPageOptions, type UpdateQuotaOptions, type UpdateTemplateRequest, type UpdateWebhookOptions, type ValidateSessionTokenRequest, type ValidateSessionTokenResponse, ValidationError, type Verification, type VerificationDeliveryStatus, type VerificationListResponse, type VerificationStatus, type VerifySession, type VerifySessionStatus, type Webhook, type WebhookCreatedResponse, type WebhookDelivery, type WebhookEvent, type WebhookEventType, type WebhookMessageData, type WebhookMessageStatus, type WebhookSecretRotation, WebhookSignatureError, type WebhookTestResult, Webhooks, type WorkspaceBillingItem, type WorkspaceCredits, type WorkspaceWebhook, calculateSegments, Sendly as default, generateWebhookSignature, getCountryFromPhone, isCountrySupported, parseWebhookEvent, validateMessageText, validatePhoneNumber, validateSenderId, verifyWebhookSignature };
|
package/dist/index.js
CHANGED
|
@@ -3350,6 +3350,167 @@ var EnterpriseResource = class {
|
|
|
3350
3350
|
}
|
|
3351
3351
|
};
|
|
3352
3352
|
|
|
3353
|
+
// src/resources/conversations.ts
|
|
3354
|
+
var ConversationsResource = class {
|
|
3355
|
+
http;
|
|
3356
|
+
constructor(http) {
|
|
3357
|
+
this.http = http;
|
|
3358
|
+
}
|
|
3359
|
+
async list(options) {
|
|
3360
|
+
const params = new URLSearchParams();
|
|
3361
|
+
if (options?.limit) params.set("limit", String(options.limit));
|
|
3362
|
+
if (options?.offset) params.set("offset", String(options.offset));
|
|
3363
|
+
if (options?.status) params.set("status", options.status);
|
|
3364
|
+
const qs = params.toString();
|
|
3365
|
+
return this.http.request({
|
|
3366
|
+
method: "GET",
|
|
3367
|
+
path: `/conversations${qs ? `?${qs}` : ""}`
|
|
3368
|
+
});
|
|
3369
|
+
}
|
|
3370
|
+
async get(id, options) {
|
|
3371
|
+
const params = new URLSearchParams();
|
|
3372
|
+
if (options?.includeMessages) params.set("include_messages", "true");
|
|
3373
|
+
if (options?.messageLimit) params.set("message_limit", String(options.messageLimit));
|
|
3374
|
+
if (options?.messageOffset) params.set("message_offset", String(options.messageOffset));
|
|
3375
|
+
const qs = params.toString();
|
|
3376
|
+
return this.http.request({
|
|
3377
|
+
method: "GET",
|
|
3378
|
+
path: `/conversations/${id}${qs ? `?${qs}` : ""}`
|
|
3379
|
+
});
|
|
3380
|
+
}
|
|
3381
|
+
async reply(conversationId, request) {
|
|
3382
|
+
return this.http.request({
|
|
3383
|
+
method: "POST",
|
|
3384
|
+
path: `/conversations/${conversationId}/messages`,
|
|
3385
|
+
body: { ...request }
|
|
3386
|
+
});
|
|
3387
|
+
}
|
|
3388
|
+
async update(id, request) {
|
|
3389
|
+
return this.http.request({
|
|
3390
|
+
method: "PATCH",
|
|
3391
|
+
path: `/conversations/${id}`,
|
|
3392
|
+
body: { ...request }
|
|
3393
|
+
});
|
|
3394
|
+
}
|
|
3395
|
+
async markRead(id) {
|
|
3396
|
+
return this.http.request({
|
|
3397
|
+
method: "POST",
|
|
3398
|
+
path: `/conversations/${id}/mark-read`
|
|
3399
|
+
});
|
|
3400
|
+
}
|
|
3401
|
+
async close(id) {
|
|
3402
|
+
return this.http.request({
|
|
3403
|
+
method: "POST",
|
|
3404
|
+
path: `/conversations/${id}/close`
|
|
3405
|
+
});
|
|
3406
|
+
}
|
|
3407
|
+
async reopen(id) {
|
|
3408
|
+
return this.http.request({
|
|
3409
|
+
method: "POST",
|
|
3410
|
+
path: `/conversations/${id}/reopen`
|
|
3411
|
+
});
|
|
3412
|
+
}
|
|
3413
|
+
async suggestReplies(conversationId) {
|
|
3414
|
+
return this.http.request({
|
|
3415
|
+
method: "POST",
|
|
3416
|
+
path: `/conversations/${conversationId}/suggest-replies`
|
|
3417
|
+
});
|
|
3418
|
+
}
|
|
3419
|
+
async addLabels(conversationId, labelIds) {
|
|
3420
|
+
return this.http.request({
|
|
3421
|
+
method: "POST",
|
|
3422
|
+
path: `/conversations/${conversationId}/labels`,
|
|
3423
|
+
body: { labelIds }
|
|
3424
|
+
});
|
|
3425
|
+
}
|
|
3426
|
+
async removeLabel(conversationId, labelId) {
|
|
3427
|
+
await this.http.request({
|
|
3428
|
+
method: "DELETE",
|
|
3429
|
+
path: `/conversations/${conversationId}/labels/${labelId}`
|
|
3430
|
+
});
|
|
3431
|
+
}
|
|
3432
|
+
};
|
|
3433
|
+
|
|
3434
|
+
// src/resources/labels.ts
|
|
3435
|
+
var LabelsResource = class {
|
|
3436
|
+
http;
|
|
3437
|
+
constructor(http) {
|
|
3438
|
+
this.http = http;
|
|
3439
|
+
}
|
|
3440
|
+
async create(request) {
|
|
3441
|
+
return this.http.request({
|
|
3442
|
+
method: "POST",
|
|
3443
|
+
path: "/labels",
|
|
3444
|
+
body: { ...request }
|
|
3445
|
+
});
|
|
3446
|
+
}
|
|
3447
|
+
async list() {
|
|
3448
|
+
return this.http.request({
|
|
3449
|
+
method: "GET",
|
|
3450
|
+
path: "/labels"
|
|
3451
|
+
});
|
|
3452
|
+
}
|
|
3453
|
+
async delete(id) {
|
|
3454
|
+
await this.http.request({
|
|
3455
|
+
method: "DELETE",
|
|
3456
|
+
path: `/labels/${id}`
|
|
3457
|
+
});
|
|
3458
|
+
}
|
|
3459
|
+
};
|
|
3460
|
+
|
|
3461
|
+
// src/resources/drafts.ts
|
|
3462
|
+
var DraftsResource = class {
|
|
3463
|
+
http;
|
|
3464
|
+
constructor(http) {
|
|
3465
|
+
this.http = http;
|
|
3466
|
+
}
|
|
3467
|
+
async create(request) {
|
|
3468
|
+
return this.http.request({
|
|
3469
|
+
method: "POST",
|
|
3470
|
+
path: "/drafts",
|
|
3471
|
+
body: { ...request }
|
|
3472
|
+
});
|
|
3473
|
+
}
|
|
3474
|
+
async list(options) {
|
|
3475
|
+
const params = new URLSearchParams();
|
|
3476
|
+
if (options?.conversationId) params.set("conversation_id", options.conversationId);
|
|
3477
|
+
if (options?.status) params.set("status", options.status);
|
|
3478
|
+
if (options?.limit) params.set("limit", String(options.limit));
|
|
3479
|
+
if (options?.offset) params.set("offset", String(options.offset));
|
|
3480
|
+
const qs = params.toString();
|
|
3481
|
+
return this.http.request({
|
|
3482
|
+
method: "GET",
|
|
3483
|
+
path: `/drafts${qs ? `?${qs}` : ""}`
|
|
3484
|
+
});
|
|
3485
|
+
}
|
|
3486
|
+
async get(id) {
|
|
3487
|
+
return this.http.request({
|
|
3488
|
+
method: "GET",
|
|
3489
|
+
path: `/drafts/${id}`
|
|
3490
|
+
});
|
|
3491
|
+
}
|
|
3492
|
+
async update(id, request) {
|
|
3493
|
+
return this.http.request({
|
|
3494
|
+
method: "PATCH",
|
|
3495
|
+
path: `/drafts/${id}`,
|
|
3496
|
+
body: { ...request }
|
|
3497
|
+
});
|
|
3498
|
+
}
|
|
3499
|
+
async approve(id) {
|
|
3500
|
+
return this.http.request({
|
|
3501
|
+
method: "POST",
|
|
3502
|
+
path: `/drafts/${id}/approve`
|
|
3503
|
+
});
|
|
3504
|
+
}
|
|
3505
|
+
async reject(id, reason) {
|
|
3506
|
+
return this.http.request({
|
|
3507
|
+
method: "POST",
|
|
3508
|
+
path: `/drafts/${id}/reject`,
|
|
3509
|
+
body: reason ? { reason } : {}
|
|
3510
|
+
});
|
|
3511
|
+
}
|
|
3512
|
+
};
|
|
3513
|
+
|
|
3353
3514
|
// src/client.ts
|
|
3354
3515
|
var DEFAULT_BASE_URL2 = "https://sendly.live/api/v1";
|
|
3355
3516
|
var DEFAULT_TIMEOUT2 = 3e4;
|
|
@@ -3371,6 +3532,9 @@ var Sendly = class {
|
|
|
3371
3532
|
* ```
|
|
3372
3533
|
*/
|
|
3373
3534
|
messages;
|
|
3535
|
+
conversations;
|
|
3536
|
+
labels;
|
|
3537
|
+
drafts;
|
|
3374
3538
|
/**
|
|
3375
3539
|
* Webhooks API resource
|
|
3376
3540
|
*
|
|
@@ -3555,6 +3719,9 @@ var Sendly = class {
|
|
|
3555
3719
|
organizationId: typeof configOrApiKey === "string" ? void 0 : configOrApiKey.organizationId
|
|
3556
3720
|
});
|
|
3557
3721
|
this.messages = new MessagesResource(this.http);
|
|
3722
|
+
this.conversations = new ConversationsResource(this.http);
|
|
3723
|
+
this.labels = new LabelsResource(this.http);
|
|
3724
|
+
this.drafts = new DraftsResource(this.http);
|
|
3558
3725
|
this.webhooks = new WebhooksResource(this.http);
|
|
3559
3726
|
this.account = new AccountResource(this.http);
|
|
3560
3727
|
this.verify = new VerifyResource(this.http);
|
package/dist/index.mjs
CHANGED
|
@@ -3290,6 +3290,167 @@ var EnterpriseResource = class {
|
|
|
3290
3290
|
}
|
|
3291
3291
|
};
|
|
3292
3292
|
|
|
3293
|
+
// src/resources/conversations.ts
|
|
3294
|
+
var ConversationsResource = class {
|
|
3295
|
+
http;
|
|
3296
|
+
constructor(http) {
|
|
3297
|
+
this.http = http;
|
|
3298
|
+
}
|
|
3299
|
+
async list(options) {
|
|
3300
|
+
const params = new URLSearchParams();
|
|
3301
|
+
if (options?.limit) params.set("limit", String(options.limit));
|
|
3302
|
+
if (options?.offset) params.set("offset", String(options.offset));
|
|
3303
|
+
if (options?.status) params.set("status", options.status);
|
|
3304
|
+
const qs = params.toString();
|
|
3305
|
+
return this.http.request({
|
|
3306
|
+
method: "GET",
|
|
3307
|
+
path: `/conversations${qs ? `?${qs}` : ""}`
|
|
3308
|
+
});
|
|
3309
|
+
}
|
|
3310
|
+
async get(id, options) {
|
|
3311
|
+
const params = new URLSearchParams();
|
|
3312
|
+
if (options?.includeMessages) params.set("include_messages", "true");
|
|
3313
|
+
if (options?.messageLimit) params.set("message_limit", String(options.messageLimit));
|
|
3314
|
+
if (options?.messageOffset) params.set("message_offset", String(options.messageOffset));
|
|
3315
|
+
const qs = params.toString();
|
|
3316
|
+
return this.http.request({
|
|
3317
|
+
method: "GET",
|
|
3318
|
+
path: `/conversations/${id}${qs ? `?${qs}` : ""}`
|
|
3319
|
+
});
|
|
3320
|
+
}
|
|
3321
|
+
async reply(conversationId, request) {
|
|
3322
|
+
return this.http.request({
|
|
3323
|
+
method: "POST",
|
|
3324
|
+
path: `/conversations/${conversationId}/messages`,
|
|
3325
|
+
body: { ...request }
|
|
3326
|
+
});
|
|
3327
|
+
}
|
|
3328
|
+
async update(id, request) {
|
|
3329
|
+
return this.http.request({
|
|
3330
|
+
method: "PATCH",
|
|
3331
|
+
path: `/conversations/${id}`,
|
|
3332
|
+
body: { ...request }
|
|
3333
|
+
});
|
|
3334
|
+
}
|
|
3335
|
+
async markRead(id) {
|
|
3336
|
+
return this.http.request({
|
|
3337
|
+
method: "POST",
|
|
3338
|
+
path: `/conversations/${id}/mark-read`
|
|
3339
|
+
});
|
|
3340
|
+
}
|
|
3341
|
+
async close(id) {
|
|
3342
|
+
return this.http.request({
|
|
3343
|
+
method: "POST",
|
|
3344
|
+
path: `/conversations/${id}/close`
|
|
3345
|
+
});
|
|
3346
|
+
}
|
|
3347
|
+
async reopen(id) {
|
|
3348
|
+
return this.http.request({
|
|
3349
|
+
method: "POST",
|
|
3350
|
+
path: `/conversations/${id}/reopen`
|
|
3351
|
+
});
|
|
3352
|
+
}
|
|
3353
|
+
async suggestReplies(conversationId) {
|
|
3354
|
+
return this.http.request({
|
|
3355
|
+
method: "POST",
|
|
3356
|
+
path: `/conversations/${conversationId}/suggest-replies`
|
|
3357
|
+
});
|
|
3358
|
+
}
|
|
3359
|
+
async addLabels(conversationId, labelIds) {
|
|
3360
|
+
return this.http.request({
|
|
3361
|
+
method: "POST",
|
|
3362
|
+
path: `/conversations/${conversationId}/labels`,
|
|
3363
|
+
body: { labelIds }
|
|
3364
|
+
});
|
|
3365
|
+
}
|
|
3366
|
+
async removeLabel(conversationId, labelId) {
|
|
3367
|
+
await this.http.request({
|
|
3368
|
+
method: "DELETE",
|
|
3369
|
+
path: `/conversations/${conversationId}/labels/${labelId}`
|
|
3370
|
+
});
|
|
3371
|
+
}
|
|
3372
|
+
};
|
|
3373
|
+
|
|
3374
|
+
// src/resources/labels.ts
|
|
3375
|
+
var LabelsResource = class {
|
|
3376
|
+
http;
|
|
3377
|
+
constructor(http) {
|
|
3378
|
+
this.http = http;
|
|
3379
|
+
}
|
|
3380
|
+
async create(request) {
|
|
3381
|
+
return this.http.request({
|
|
3382
|
+
method: "POST",
|
|
3383
|
+
path: "/labels",
|
|
3384
|
+
body: { ...request }
|
|
3385
|
+
});
|
|
3386
|
+
}
|
|
3387
|
+
async list() {
|
|
3388
|
+
return this.http.request({
|
|
3389
|
+
method: "GET",
|
|
3390
|
+
path: "/labels"
|
|
3391
|
+
});
|
|
3392
|
+
}
|
|
3393
|
+
async delete(id) {
|
|
3394
|
+
await this.http.request({
|
|
3395
|
+
method: "DELETE",
|
|
3396
|
+
path: `/labels/${id}`
|
|
3397
|
+
});
|
|
3398
|
+
}
|
|
3399
|
+
};
|
|
3400
|
+
|
|
3401
|
+
// src/resources/drafts.ts
|
|
3402
|
+
var DraftsResource = class {
|
|
3403
|
+
http;
|
|
3404
|
+
constructor(http) {
|
|
3405
|
+
this.http = http;
|
|
3406
|
+
}
|
|
3407
|
+
async create(request) {
|
|
3408
|
+
return this.http.request({
|
|
3409
|
+
method: "POST",
|
|
3410
|
+
path: "/drafts",
|
|
3411
|
+
body: { ...request }
|
|
3412
|
+
});
|
|
3413
|
+
}
|
|
3414
|
+
async list(options) {
|
|
3415
|
+
const params = new URLSearchParams();
|
|
3416
|
+
if (options?.conversationId) params.set("conversation_id", options.conversationId);
|
|
3417
|
+
if (options?.status) params.set("status", options.status);
|
|
3418
|
+
if (options?.limit) params.set("limit", String(options.limit));
|
|
3419
|
+
if (options?.offset) params.set("offset", String(options.offset));
|
|
3420
|
+
const qs = params.toString();
|
|
3421
|
+
return this.http.request({
|
|
3422
|
+
method: "GET",
|
|
3423
|
+
path: `/drafts${qs ? `?${qs}` : ""}`
|
|
3424
|
+
});
|
|
3425
|
+
}
|
|
3426
|
+
async get(id) {
|
|
3427
|
+
return this.http.request({
|
|
3428
|
+
method: "GET",
|
|
3429
|
+
path: `/drafts/${id}`
|
|
3430
|
+
});
|
|
3431
|
+
}
|
|
3432
|
+
async update(id, request) {
|
|
3433
|
+
return this.http.request({
|
|
3434
|
+
method: "PATCH",
|
|
3435
|
+
path: `/drafts/${id}`,
|
|
3436
|
+
body: { ...request }
|
|
3437
|
+
});
|
|
3438
|
+
}
|
|
3439
|
+
async approve(id) {
|
|
3440
|
+
return this.http.request({
|
|
3441
|
+
method: "POST",
|
|
3442
|
+
path: `/drafts/${id}/approve`
|
|
3443
|
+
});
|
|
3444
|
+
}
|
|
3445
|
+
async reject(id, reason) {
|
|
3446
|
+
return this.http.request({
|
|
3447
|
+
method: "POST",
|
|
3448
|
+
path: `/drafts/${id}/reject`,
|
|
3449
|
+
body: reason ? { reason } : {}
|
|
3450
|
+
});
|
|
3451
|
+
}
|
|
3452
|
+
};
|
|
3453
|
+
|
|
3293
3454
|
// src/client.ts
|
|
3294
3455
|
var DEFAULT_BASE_URL2 = "https://sendly.live/api/v1";
|
|
3295
3456
|
var DEFAULT_TIMEOUT2 = 3e4;
|
|
@@ -3311,6 +3472,9 @@ var Sendly = class {
|
|
|
3311
3472
|
* ```
|
|
3312
3473
|
*/
|
|
3313
3474
|
messages;
|
|
3475
|
+
conversations;
|
|
3476
|
+
labels;
|
|
3477
|
+
drafts;
|
|
3314
3478
|
/**
|
|
3315
3479
|
* Webhooks API resource
|
|
3316
3480
|
*
|
|
@@ -3495,6 +3659,9 @@ var Sendly = class {
|
|
|
3495
3659
|
organizationId: typeof configOrApiKey === "string" ? void 0 : configOrApiKey.organizationId
|
|
3496
3660
|
});
|
|
3497
3661
|
this.messages = new MessagesResource(this.http);
|
|
3662
|
+
this.conversations = new ConversationsResource(this.http);
|
|
3663
|
+
this.labels = new LabelsResource(this.http);
|
|
3664
|
+
this.drafts = new DraftsResource(this.http);
|
|
3498
3665
|
this.webhooks = new WebhooksResource(this.http);
|
|
3499
3666
|
this.account = new AccountResource(this.http);
|
|
3500
3667
|
this.verify = new VerifyResource(this.http);
|