Skip to content

Commit 950e866

Browse files
2.0.0
1 parent 512d864 commit 950e866

22 files changed

Lines changed: 264 additions & 183 deletions

examples/advanced-usage.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ async function advancedUsageExample(): Promise<void> {
2121

2222
async function customWorkflowExample(linkedapi: LinkedApi): Promise<void> {
2323
console.log('🚀 Linked API custom workflow example starting...');
24-
const workflowId = await linkedapi.customWorkflow.execute({
24+
const workflow = await linkedapi.customWorkflow.execute({
2525
actionType: 'st.searchPeople',
2626
limit: 3,
2727
filter: {
@@ -38,27 +38,29 @@ async function customWorkflowExample(linkedapi: LinkedApi): Promise<void> {
3838
}
3939
}
4040
});
41-
console.log('🔍 Workflow started: ', workflowId);
42-
const result = await linkedapi.customWorkflow.result(workflowId);
41+
console.log('🔍 Workflow started: ', workflow.workflowId);
42+
console.log('💬 Workflow message: ', workflow.message);
43+
const result = await linkedapi.customWorkflow.result(workflow.workflowId);
4344

4445
console.log('✅ Custom workflow executed successfully');
4546
console.log('🔍 Result: ', JSON.stringify(result.data, null, 2));
4647
}
4748

4849
async function cancelWorkflowExample(linkedapi: LinkedApi): Promise<void> {
4950
console.log('🚀 Linked API cancel workflow example starting...');
50-
const workflowId = await linkedapi.searchPeople.execute({
51+
const workflow = await linkedapi.searchPeople.execute({
5152
limit: 3,
5253
filter: {
5354
locations: ["San Francisco"],
5455
},
5556
});
56-
console.log('🔍 Workflow started: ', workflowId);
57-
const result = await linkedapi.searchPeople.cancel(workflowId);
57+
console.log('🔍 Workflow started: ', workflow.workflowId);
58+
console.log('💬 Workflow message: ', workflow.message);
59+
const result = await linkedapi.searchPeople.cancel(workflow.workflowId);
5860
console.log('✅ Workflow cancelled: ', result);
5961
}
6062

6163

6264
if (require.main === module) {
6365
advancedUsageExample();
64-
}
66+
}

examples/connections.ts

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@ async function checkConnectionStatus(linkedapi: LinkedApi, personUrl: string): P
3737
personUrl: personUrl,
3838
};
3939

40-
const workflowId = await linkedapi.checkConnectionStatus.execute(statusParams);
41-
console.log('🔍 Connection status workflow started:', workflowId);
40+
const workflow = await linkedapi.checkConnectionStatus.execute(statusParams);
41+
console.log('🔍 Connection status workflow started:', workflow.workflowId);
42+
console.log('💬 Workflow message:', workflow.message);
4243

43-
const statusResult = await linkedapi.checkConnectionStatus.result(workflowId);
44+
const statusResult = await linkedapi.checkConnectionStatus.result(workflow.workflowId);
4445
if (statusResult.data) {
4546
console.log('✅ Connection status check completed');
4647
console.log(`📊 Connection status: ${statusResult.data.connectionStatus}`);
@@ -59,10 +60,11 @@ async function sendConnectionRequest(linkedapi: LinkedApi, personUrl: string): P
5960
email: 'example@gmail.com',
6061
};
6162

62-
const workflowId = await linkedapi.sendConnectionRequest.execute(requestParams);
63-
console.log('📤 Send connection request workflow started:', workflowId);
63+
const workflow = await linkedapi.sendConnectionRequest.execute(requestParams);
64+
console.log('📤 Send connection request workflow started:', workflow.workflowId);
65+
console.log('💬 Workflow message:', workflow.message);
6466

65-
const requestResult = await linkedapi.sendConnectionRequest.result(workflowId);
67+
const requestResult = await linkedapi.sendConnectionRequest.result(workflow.workflowId);
6668
if (requestResult.errors.length > 0) {
6769
console.error('🚨 Errors:', JSON.stringify(requestResult.errors, null, 2));
6870
} else {
@@ -74,10 +76,11 @@ async function sendConnectionRequest(linkedapi: LinkedApi, personUrl: string): P
7476
async function retrievePendingRequests(linkedapi: LinkedApi): Promise<void> {
7577
console.log('\n📋 Retrieving pending connection requests...');
7678

77-
const workflowId = await linkedapi.retrievePendingRequests.execute();
78-
console.log('📋 Retrieve pending requests workflow started:', workflowId);
79+
const workflow = await linkedapi.retrievePendingRequests.execute();
80+
console.log('📋 Retrieve pending requests workflow started:', workflow.workflowId);
81+
console.log('💬 Workflow message:', workflow.message);
7982

80-
const pendingResults = await linkedapi.retrievePendingRequests.result(workflowId);
83+
const pendingResults = await linkedapi.retrievePendingRequests.result(workflow.workflowId);
8184
if (pendingResults.data) {
8285
const pendingRequests = pendingResults.data;
8386
console.log('✅ Pending requests retrieval completed');
@@ -101,10 +104,11 @@ async function withdrawConnectionRequest(linkedapi: LinkedApi, personUrl: string
101104
unfollow: true,
102105
};
103106

104-
const workflowId = await linkedapi.withdrawConnectionRequest.execute(withdrawParams);
105-
console.log('🔙 Withdraw connection request workflow started:', workflowId);
107+
const workflow = await linkedapi.withdrawConnectionRequest.execute(withdrawParams);
108+
console.log('🔙 Withdraw connection request workflow started:', workflow.workflowId);
109+
console.log('💬 Workflow message:', workflow.message);
106110

107-
const withdrawResult = await linkedapi.withdrawConnectionRequest.result(workflowId);
111+
const withdrawResult = await linkedapi.withdrawConnectionRequest.result(workflow.workflowId);
108112
if (withdrawResult.errors.length > 0) {
109113
console.error('🚨 Errors:', JSON.stringify(withdrawResult.errors, null, 2));
110114
} else {
@@ -125,10 +129,11 @@ async function retrieveConnections(linkedapi: LinkedApi): Promise<void> {
125129
},
126130
};
127131

128-
const workflowId = await linkedapi.retrieveConnections.execute(connectionsParams);
129-
console.log('👥 Retrieve connections workflow started:', workflowId);
132+
const workflow = await linkedapi.retrieveConnections.execute(connectionsParams);
133+
console.log('👥 Retrieve connections workflow started:', workflow.workflowId);
134+
console.log('💬 Workflow message:', workflow.message);
130135

131-
const connectionsResults = await linkedapi.retrieveConnections.result(workflowId);
136+
const connectionsResults = await linkedapi.retrieveConnections.result(workflow.workflowId);
132137

133138
if (connectionsResults.data) {
134139
const connections = connectionsResults.data;
@@ -146,13 +151,14 @@ async function retrieveConnections(linkedapi: LinkedApi): Promise<void> {
146151
}
147152

148153
// Example 2: Retrieve recent connections using since (returns connectedAt field)
149-
const recentWorkflowId = await linkedapi.retrieveConnections.execute({
154+
const recentWorkflow = await linkedapi.retrieveConnections.execute({
150155
since: '2025-01-01',
151156
limit: 10,
152157
});
153-
console.log('👥 Retrieve recent connections workflow started:', recentWorkflowId);
158+
console.log('👥 Retrieve recent connections workflow started:', recentWorkflow.workflowId);
159+
console.log('💬 Workflow message:', recentWorkflow.message);
154160

155-
const recentResults = await linkedapi.retrieveConnections.result(recentWorkflowId);
161+
const recentResults = await linkedapi.retrieveConnections.result(recentWorkflow.workflowId);
156162

157163
if (recentResults.data) {
158164
const connections = recentResults.data;
@@ -177,10 +183,11 @@ async function removeConnection(linkedapi: LinkedApi, personUrl: string): Promis
177183
personUrl: personUrl,
178184
};
179185

180-
const workflowId = await linkedapi.removeConnection.execute(removeParams);
181-
console.log('❌ Remove connection workflow started:', workflowId);
186+
const workflow = await linkedapi.removeConnection.execute(removeParams);
187+
console.log('❌ Remove connection workflow started:', workflow.workflowId);
188+
console.log('💬 Workflow message:', workflow.message);
182189

183-
const removeResult = await linkedapi.removeConnection.result(workflowId);
190+
const removeResult = await linkedapi.removeConnection.result(workflow.workflowId);
184191
if (removeResult.errors.length > 0) {
185192
console.error('🚨 Errors:', JSON.stringify(removeResult.errors, null, 2));
186193
} else {
@@ -191,4 +198,4 @@ async function removeConnection(linkedapi: LinkedApi, personUrl: string): Promis
191198

192199
if (require.main === module) {
193200
connectionsExample();
194-
}
201+
}

examples/fetch-company.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ async function fetchCompanyExample(): Promise<void> {
2121
}
2222

2323
async function standardExample(linkedapi: LinkedApi): Promise<void> {
24-
const workflowId = await linkedapi.fetchCompany.execute({
24+
const workflow = await linkedapi.fetchCompany.execute({
2525
companyUrl: 'https://www.linkedin.com/company/linkedin/',
2626
retrieveEmployees: true,
2727
retrieveDMs: true,
@@ -42,8 +42,9 @@ async function standardExample(linkedapi: LinkedApi): Promise<void> {
4242
},
4343
});
4444

45-
console.log('🔍 Company workflow started: ', workflowId);
46-
const companyData = await linkedapi.fetchCompany.result(workflowId);
45+
console.log('🔍 Company workflow started: ', workflow.workflowId);
46+
console.log('💬 Workflow message: ', workflow.message);
47+
const companyData = await linkedapi.fetchCompany.result(workflow.workflowId);
4748
if (companyData.data) {
4849
const company = companyData.data;
4950
console.log('✅ Company page opened successfully');
@@ -62,7 +63,7 @@ async function standardExample(linkedapi: LinkedApi): Promise<void> {
6263
}
6364

6465
async function salesNavigatorExample(linkedapi: LinkedApi): Promise<void> {
65-
const workflowId = await linkedapi.nvFetchCompany.execute({
66+
const workflow = await linkedapi.nvFetchCompany.execute({
6667
companyHashedUrl: 'https://www.linkedin.com/sales/company/1035',
6768
retrieveEmployees: true,
6869
retrieveDMs: true,
@@ -77,8 +78,9 @@ async function salesNavigatorExample(linkedapi: LinkedApi): Promise<void> {
7778
},
7879
});
7980

80-
console.log('🔍 Sales Navigator workflow started: ', workflowId);
81-
const nvCompanyData = await linkedapi.nvFetchCompany.result(workflowId);
81+
console.log('🔍 Sales Navigator workflow started: ', workflow.workflowId);
82+
console.log('💬 Workflow message: ', workflow.message);
83+
const nvCompanyData = await linkedapi.nvFetchCompany.result(workflow.workflowId);
8284
if (nvCompanyData.data) {
8385
const nvCompany = nvCompanyData.data;
8486
console.log('✅ Sales Navigator company page opened successfully');
@@ -99,4 +101,4 @@ async function salesNavigatorExample(linkedapi: LinkedApi): Promise<void> {
99101

100102
if (require.main === module) {
101103
fetchCompanyExample();
102-
}
104+
}

examples/fetch-person.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ async function fetchPersonExample(): Promise<void> {
2323
}
2424

2525
async function standardExample(linkedapi: LinkedApi): Promise<void> {
26-
const workflowId = await linkedapi.fetchPerson.execute({
26+
const workflow = await linkedapi.fetchPerson.execute({
2727
personUrl: 'https://www.linkedin.com/in/example-person/',
2828
retrieveExperience: true,
2929
retrieveEducation: true,
@@ -43,8 +43,9 @@ async function standardExample(linkedapi: LinkedApi): Promise<void> {
4343
limit: 5,
4444
},
4545
});
46-
console.log('🔍 Workflow started: ', workflowId);
47-
const personResult = await linkedapi.fetchPerson.result(workflowId);
46+
console.log('🔍 Workflow started: ', workflow.workflowId);
47+
console.log('💬 Workflow message: ', workflow.message);
48+
const personResult = await linkedapi.fetchPerson.result(workflow.workflowId);
4849
if (personResult.data) {
4950
const person = personResult.data;
5051
console.log('✅ Person page opened successfully');
@@ -65,9 +66,10 @@ async function salesNavigatorExample(linkedapi: LinkedApi): Promise<void> {
6566
personHashedUrl: 'https://www.linkedin.com/in/abc123',
6667
};
6768

68-
const workflowId = await linkedapi.nvFetchPerson.execute(fetchParams);
69-
console.log('🔍 Workflow started: ', workflowId);
70-
const personResult = await linkedapi.nvFetchPerson.result(workflowId);
69+
const workflow = await linkedapi.nvFetchPerson.execute(fetchParams);
70+
console.log('🔍 Workflow started: ', workflow.workflowId);
71+
console.log('💬 Workflow message: ', workflow.message);
72+
const personResult = await linkedapi.nvFetchPerson.result(workflow.workflowId);
7173
if (personResult.data) {
7274
const person = personResult.data;
7375
console.log('✅ Person page opened successfully');

examples/fetch-post.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ async function fetchPostExample(): Promise<void> {
2020
}
2121

2222
async function standardExample(linkedapi: LinkedApi): Promise<void> {
23-
const workflowId = await linkedapi.fetchPost.execute({
23+
const workflow = await linkedapi.fetchPost.execute({
2424
postUrl: 'https://www.linkedin.com/posts/post-url',
2525
retrieveComments: true,
2626
retrieveReactions: true,
@@ -32,8 +32,9 @@ async function standardExample(linkedapi: LinkedApi): Promise<void> {
3232
limit: 100,
3333
},
3434
});
35-
console.log('🔍 Workflow started:', workflowId);
36-
const postResult = await linkedapi.fetchPost.result(workflowId);
35+
console.log('🔍 Workflow started:', workflow.workflowId);
36+
console.log('💬 Workflow message:', workflow.message);
37+
const postResult = await linkedapi.fetchPost.result(workflow.workflowId);
3738
if (postResult.data) {
3839
const post = postResult.data;
3940
console.log('✅ Post fetched successfully');
@@ -58,4 +59,4 @@ async function standardExample(linkedapi: LinkedApi): Promise<void> {
5859

5960
if (require.main === module) {
6061
fetchPostExample();
61-
}
62+
}

examples/messaging.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ async function sendMessage(linkedapi: LinkedApi, personUrl: string): Promise<voi
3838
text: 'Hi! I hope you\'re doing well. I came across your profile and was impressed by your work. I\'d love to connect and discuss potential collaboration opportunities.',
3939
};
4040

41-
const workflowId = await linkedapi.sendMessage.execute(messageParams);
42-
console.log('💬 Send message workflow started:', workflowId);
41+
const workflow = await linkedapi.sendMessage.execute(messageParams);
42+
console.log('💬 Send message workflow started:', workflow.workflowId);
43+
console.log('💬 Workflow message:', workflow.message);
4344

44-
const sendMessageResult = await linkedapi.sendMessage.result(workflowId);
45+
const sendMessageResult = await linkedapi.sendMessage.result(workflow.workflowId);
4546
if (sendMessageResult.errors.length > 0) {
4647
console.error('🚨 Errors:', JSON.stringify(sendMessageResult.errors, null, 2));
4748
} else {
@@ -58,10 +59,11 @@ async function syncConversation(linkedapi: LinkedApi, personUrl: string): Promis
5859
personUrl: personUrl,
5960
};
6061

61-
const workflowId = await linkedapi.syncConversation.execute(syncParams);
62-
console.log('🔄 Sync conversation workflow started:', workflowId);
62+
const workflow = await linkedapi.syncConversation.execute(syncParams);
63+
console.log('🔄 Sync conversation workflow started:', workflow.workflowId);
64+
console.log('💬 Workflow message:', workflow.message);
6365

64-
const syncResult = await linkedapi.syncConversation.result(workflowId);
66+
const syncResult = await linkedapi.syncConversation.result(workflow.workflowId);
6567
if (syncResult.errors.length > 0) {
6668
console.error('🚨 Errors:', JSON.stringify(syncResult.errors, null, 2));
6769
} else {
@@ -80,10 +82,11 @@ async function salesNavigatorSendMessage(linkedapi: LinkedApi, personUrl: string
8082
subject: 'Let\'s connect!',
8183
};
8284

83-
const workflowId = await linkedapi.nvSendMessage.execute(nvMessageParams);
84-
console.log('🎯 Sales Navigator send message workflow started:', workflowId);
85+
const workflow = await linkedapi.nvSendMessage.execute(nvMessageParams);
86+
console.log('🎯 Sales Navigator send message workflow started:', workflow.workflowId);
87+
console.log('💬 Workflow message:', workflow.message);
8588

86-
const nvMessageResult = await linkedapi.nvSendMessage.result(workflowId);
89+
const nvMessageResult = await linkedapi.nvSendMessage.result(workflow.workflowId);
8790
if (nvMessageResult.errors.length > 0) {
8891
console.error('🚨 Errors:', JSON.stringify(nvMessageResult.errors, null, 2));
8992
} else {
@@ -100,10 +103,11 @@ async function salesNavigatorSyncConversation(linkedapi: LinkedApi, personUrl: s
100103
personUrl: personUrl,
101104
};
102105

103-
const workflowId = await linkedapi.nvSyncConversation.execute(nvSyncParams);
104-
console.log('🎯 Sales Navigator sync conversation workflow started:', workflowId);
106+
const workflow = await linkedapi.nvSyncConversation.execute(nvSyncParams);
107+
console.log('🎯 Sales Navigator sync conversation workflow started:', workflow.workflowId);
108+
console.log('💬 Workflow message:', workflow.message);
105109

106-
const nvSyncResult = await linkedapi.nvSyncConversation.result(workflowId);
110+
const nvSyncResult = await linkedapi.nvSyncConversation.result(workflow.workflowId);
107111
if (nvSyncResult.errors.length > 0) {
108112
console.error('🚨 Errors:', JSON.stringify(nvSyncResult.errors, null, 2));
109113
} else {
@@ -153,4 +157,4 @@ async function pollConversations(linkedapi: LinkedApi, standardPersonUrl: string
153157

154158
if (require.main === module) {
155159
messagingExample();
156-
}
160+
}

0 commit comments

Comments
 (0)