Skip to content

Commit 17613d6

Browse files
Add manage conversation actions for
1 parent 704ef1e commit 17613d6

7 files changed

Lines changed: 114 additions & 1 deletion

File tree

src/core/operation.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const OPERATION_NAME = {
1818
sendMessage: 'sendMessage',
1919
syncConversation: 'syncConversation',
2020
syncInbox: 'syncInbox',
21+
manageConversation: 'manageConversation',
2122
checkConnectionStatus: 'checkConnectionStatus',
2223
sendConnectionRequest: 'sendConnectionRequest',
2324
withdrawConnectionRequest: 'withdrawConnectionRequest',
@@ -39,6 +40,7 @@ export const OPERATION_NAME = {
3940
nvSendMessage: 'nvSendMessage',
4041
nvSyncConversation: 'nvSyncConversation',
4142
nvSyncInbox: 'nvSyncInbox',
43+
nvManageConversation: 'nvManageConversation',
4244
nvSearchCompanies: 'nvSearchCompanies',
4345
nvSearchPeople: 'nvSearchPeople',
4446
nvFetchCompany: 'nvFetchCompany',

src/index.ts

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ import {
1010
FetchJob,
1111
FetchPerson,
1212
FetchPost,
13+
ManageConversation,
1314
NvFetchCompany,
1415
NvFetchPerson,
16+
NvManageConversation,
1517
NvSearchCompanies,
1618
NvSearchPeople,
1719
NvSendMessage,
@@ -97,6 +99,7 @@ class LinkedApi {
9799
this.sendMessage = new SendMessage(this.httpClient);
98100
this.syncConversation = new SyncConversation(this.httpClient);
99101
this.syncInbox = new SyncInbox(this.httpClient);
102+
this.manageConversation = new ManageConversation(this.httpClient);
100103
this.checkConnectionStatus = new CheckConnectionStatus(this.httpClient);
101104
this.sendConnectionRequest = new SendConnectionRequest(this.httpClient);
102105
this.withdrawConnectionRequest = new WithdrawConnectionRequest(this.httpClient);
@@ -118,6 +121,7 @@ class LinkedApi {
118121
this.nvSendMessage = new NvSendMessage(this.httpClient);
119122
this.nvSyncConversation = new NvSyncConversation(this.httpClient);
120123
this.nvSyncInbox = new NvSyncInbox(this.httpClient);
124+
this.nvManageConversation = new NvManageConversation(this.httpClient);
121125
this.nvSearchCompanies = new NvSearchCompanies(this.httpClient);
122126
this.nvSearchPeople = new NvSearchPeople(this.httpClient);
123127
this.nvFetchCompany = new NvFetchCompany(this.httpClient);
@@ -128,6 +132,7 @@ class LinkedApi {
128132
this.sendMessage,
129133
this.syncConversation,
130134
this.syncInbox,
135+
this.manageConversation,
131136
this.checkConnectionStatus,
132137
this.sendConnectionRequest,
133138
this.withdrawConnectionRequest,
@@ -149,6 +154,7 @@ class LinkedApi {
149154
this.nvSendMessage,
150155
this.nvSyncConversation,
151156
this.nvSyncInbox,
157+
this.nvManageConversation,
152158
this.nvSearchCompanies,
153159
this.nvSearchPeople,
154160
this.nvFetchCompany,
@@ -273,6 +279,32 @@ class LinkedApi {
273279
*/
274280
public syncInbox: SyncInbox;
275281

282+
/**
283+
* Manage a standard LinkedIn conversation thread.
284+
*
285+
* This method applies a management operation to a conversation thread identified by its `threadId`
286+
* (as returned by {@link pollInbox} or {@link pollConversations}, or read from an open conversation URL).
287+
* Supported operations are `archive`, `unarchive`, `star`, `unstar`, `mute`, and `unmute`. This action
288+
* returns no data and can fail with a `threadNotFound` error if the thread does not exist.
289+
*
290+
* @param params - Parameters including the thread id and the operation to apply
291+
* @returns Promise resolving to the management action
292+
*
293+
* @see {@link https://linkedapi.io/docs/working-with-conversations/ Working with Conversations Documentation}
294+
*
295+
* @example
296+
* ```typescript
297+
* const workflow = await linkedapi.manageConversation.execute({
298+
* threadId: "2-Zjhm...",
299+
* operation: "archive"
300+
* });
301+
*
302+
* await linkedapi.manageConversation.result(workflow.workflowId);
303+
* console.log("Conversation updated successfully");
304+
* ```
305+
*/
306+
public manageConversation: ManageConversation;
307+
276308
/**
277309
* Send a message to a LinkedIn user via Sales Navigator.
278310
*
@@ -348,6 +380,33 @@ class LinkedApi {
348380
*/
349381
public nvSyncInbox: NvSyncInbox;
350382

383+
/**
384+
* Manage a Sales Navigator conversation thread.
385+
*
386+
* This method applies a management operation to a Sales Navigator conversation thread identified by its
387+
* `threadId` (as returned by {@link pollInbox} or {@link pollConversations}, or read from an open
388+
* conversation URL). Supported operations are `archive` and `unarchive`. This action returns no data and
389+
* can fail with a `noSalesNavigator` error if the account does not have Sales Navigator, or a
390+
* `threadNotFound` error if the thread does not exist.
391+
*
392+
* @param params - Parameters including the thread id and the operation to apply
393+
* @returns Promise resolving to the management action
394+
*
395+
* @see {@link https://linkedapi.io/docs/working-with-conversations/ Working with Conversations Documentation}
396+
*
397+
* @example
398+
* ```typescript
399+
* const workflow = await linkedapi.nvManageConversation.execute({
400+
* threadId: "2-Zjhm...",
401+
* operation: "archive"
402+
* });
403+
*
404+
* await linkedapi.nvManageConversation.result(workflow.workflowId);
405+
* console.log("Sales Navigator conversation updated successfully");
406+
* ```
407+
*/
408+
public nvManageConversation: NvManageConversation;
409+
351410
/**
352411
* Poll multiple conversations to retrieve message history and new messages.
353412
*

src/operations/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export * from './sync-conversation';
99
export * from './nv-sync-conversation';
1010
export * from './sync-inbox';
1111
export * from './nv-sync-inbox';
12+
export * from './manage-conversation';
13+
export * from './nv-manage-conversation';
1214
export * from './nv-fetch-person';
1315
export * from './nv-search-companies';
1416
export * from './fetch-post';
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Operation, TOperationName } from '../core';
2+
import { VoidWorkflowMapper } from '../mappers';
3+
import { TManageConversationParams } from '../types';
4+
5+
export class ManageConversation extends Operation<TManageConversationParams, void> {
6+
public override readonly operationName: TOperationName = 'manageConversation';
7+
protected override readonly mapper = new VoidWorkflowMapper<TManageConversationParams>(
8+
'st.manageConversation',
9+
);
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Operation, TOperationName } from '../core';
2+
import { VoidWorkflowMapper } from '../mappers';
3+
import { TNvManageConversationParams } from '../types';
4+
5+
export class NvManageConversation extends Operation<TNvManageConversationParams, void> {
6+
public override readonly operationName: TOperationName = 'nvManageConversation';
7+
protected override readonly mapper = new VoidWorkflowMapper<TNvManageConversationParams>(
8+
'nv.manageConversation',
9+
);
10+
}

src/types/actions/message.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ export interface TNvSyncConversationParams extends TBaseActionParams {
2525

2626
export interface TNvSyncInboxParams extends TBaseActionParams {}
2727

28+
export interface TManageConversationParams extends TBaseActionParams {
29+
threadId: string;
30+
operation: TManageConversationOperation;
31+
}
32+
33+
export interface TNvManageConversationParams extends TBaseActionParams {
34+
threadId: string;
35+
operation: TNvManageConversationOperation;
36+
}
37+
2838
export interface TConversationPollRequest {
2939
personUrl: string;
3040
since?: string;
@@ -77,3 +87,21 @@ export const MESSAGE_SENDER = {
7787
them: 'them',
7888
} as const;
7989
export type TMessageSender = (typeof MESSAGE_SENDER)[keyof typeof MESSAGE_SENDER];
90+
91+
export const MANAGE_CONVERSATION_OPERATION = {
92+
archive: 'archive',
93+
unarchive: 'unarchive',
94+
star: 'star',
95+
unstar: 'unstar',
96+
mute: 'mute',
97+
unmute: 'unmute',
98+
} as const;
99+
export type TManageConversationOperation =
100+
(typeof MANAGE_CONVERSATION_OPERATION)[keyof typeof MANAGE_CONVERSATION_OPERATION];
101+
102+
export const NV_MANAGE_CONVERSATION_OPERATION = {
103+
archive: 'archive',
104+
unarchive: 'unarchive',
105+
} as const;
106+
export type TNvManageConversationOperation =
107+
(typeof NV_MANAGE_CONVERSATION_OPERATION)[keyof typeof NV_MANAGE_CONVERSATION_OPERATION];

src/types/errors.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ import { TOperationName } from '../core';
2323
* - jobNotFound (fetchJob)
2424
* - commentingNotAllowed (commentOnPost)
2525
* - noPostingPermission (createPost, reactToPost, commentOnPost)
26-
* - noSalesNavigator (nvSendMessage, nvSyncConversation, nvSyncInbox, nvSearchCompanies, nvSearchPeople, nvFetchCompany, nvFetchPerson)
26+
* - noSalesNavigator (nvSendMessage, nvSyncConversation, nvSyncInbox, nvSearchCompanies, nvSearchPeople, nvFetchCompany, nvFetchPerson, nvManageConversation)
2727
* - conversationsNotSynced (pollConversations)
28+
* - threadNotFound (manageConversation, nvManageConversation)
2829
*/
2930
export const LINKED_API_ACTION_ERROR = {
3031
personNotFound: 'personNotFound',
@@ -47,6 +48,7 @@ export const LINKED_API_ACTION_ERROR = {
4748
noPostingPermission: 'noPostingPermission',
4849
noSalesNavigator: 'noSalesNavigator',
4950
conversationsNotSynced: 'conversationsNotSynced',
51+
threadNotFound: 'threadNotFound',
5052
} as const;
5153
export type TLinkedApiActionErrorType =
5254
(typeof LINKED_API_ACTION_ERROR)[keyof typeof LINKED_API_ACTION_ERROR];

0 commit comments

Comments
 (0)