Skip to content

Commit f9e8ae0

Browse files
Add admin reconnection methods
1 parent eb7f3da commit f9e8ae0

5 files changed

Lines changed: 66 additions & 5 deletions

File tree

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@linkedapi/node",
3-
"version": "2.0.2",
3+
"version": "2.0.3",
44
"description": "Control your LinkedIn accounts and retrieve real-time data, all through this Node.js SDK.",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",
@@ -16,7 +16,7 @@
1616
"test": "jest",
1717
"typecheck": "tsc --noEmit",
1818
"lint": "eslint src --fix",
19-
"format": "prettier --write \"src/**/*.ts\"",
19+
"format": "prettier --write --log-level warn \"src/**/*.ts\"",
2020
"prepublishOnly": "npm run clean && npm run build",
2121
"prepare": "husky"
2222
},

src/admin/admin-accounts.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@ import {
55
TCancelConnectionSessionParams,
66
TConnectionSessionResult,
77
TCreateConnectionSessionResult,
8+
TCreateReconnectionSessionParams,
9+
TCreateReconnectionSessionResult,
810
TDisconnectParams,
911
TGetConnectionSessionParams,
1012
TLinkedApiErrorType,
1113
TRegenerateTokenParams,
1214
TRegenerateTokenResult,
15+
TReparseAccountInfoParams,
16+
TReparseAccountInfoResult,
1317
} from '../types';
1418

1519
export class AdminAccounts {
@@ -37,6 +41,22 @@ export class AdminAccounts {
3741
);
3842
}
3943

44+
public async reparseAccountInfo(
45+
params: TReparseAccountInfoParams,
46+
): Promise<TReparseAccountInfoResult> {
47+
const response = await this.httpClient.post<TReparseAccountInfoResult>(
48+
'/admin/accounts.reparseAccountInfo',
49+
params,
50+
);
51+
if (response.success && response.result) {
52+
return response.result;
53+
}
54+
throw new LinkedApiError(
55+
(response.error?.type ?? 'httpError') as TLinkedApiErrorType,
56+
response.error?.message ?? 'Failed to reparse account info',
57+
);
58+
}
59+
4060
public async regenerateIdentificationToken(
4161
params: TRegenerateTokenParams,
4262
): Promise<TRegenerateTokenResult> {
@@ -66,6 +86,22 @@ export class AdminAccounts {
6686
);
6787
}
6888

89+
public async createReconnectionSession(
90+
params: TCreateReconnectionSessionParams,
91+
): Promise<TCreateReconnectionSessionResult> {
92+
const response = await this.httpClient.post<TCreateReconnectionSessionResult>(
93+
'/admin/accounts.createReconnectionSession',
94+
params,
95+
);
96+
if (response.success && response.result) {
97+
return response.result;
98+
}
99+
throw new LinkedApiError(
100+
(response.error?.type ?? 'httpError') as TLinkedApiErrorType,
101+
response.error?.message ?? 'Failed to create reconnection session',
102+
);
103+
}
104+
69105
public async getConnectionSession(
70106
params: TGetConnectionSessionParams,
71107
): Promise<TConnectionSessionResult> {

src/types/admin/accounts.type.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
export interface TAdminAccount {
22
id: string;
33
name: string;
4+
url: string;
5+
avatarUrl: string | null;
6+
headline: string | null;
47
countryCode: string;
58
identificationToken: string;
69
status: 'active' | 'frozen' | 'reconnection_required';
710
connectedAt: string;
11+
reconnectionSessionId?: string;
12+
reconnectionLink?: string;
813
}
914

1015
export interface TPendingConnectionSession {
@@ -21,6 +26,14 @@ export interface TDisconnectParams {
2126
accountId: string;
2227
}
2328

29+
export interface TReparseAccountInfoParams {
30+
accountId: string;
31+
}
32+
33+
export interface TReparseAccountInfoResult {
34+
workflowId: string;
35+
}
36+
2437
export interface TRegenerateTokenParams {
2538
accountId: string;
2639
}
@@ -34,6 +47,15 @@ export interface TCreateConnectionSessionResult {
3447
connectionLink: string;
3548
}
3649

50+
export interface TCreateReconnectionSessionParams {
51+
accountId: string;
52+
}
53+
54+
export interface TCreateReconnectionSessionResult {
55+
reconnectionSessionId: string;
56+
reconnectionLink: string;
57+
}
58+
3759
export interface TGetConnectionSessionParams {
3860
sessionId: string;
3961
}

src/types/errors.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import { TOperationName } from '../core';
1111
* - alreadyPending (sendConnectionRequest)
1212
* - alreadyConnected (sendConnectionRequest)
1313
* - emailRequired (sendConnectionRequest)
14+
* - noteTooLong (sendConnectionRequest)
15+
* - noteLimitExceeded (sendConnectionRequest)
1416
* - requestNotAllowed (sendConnectionRequest)
1517
* - notPending (withdrawConnectionRequest))
1618
* - retrievingNotAllowed (retrieveConnections, fetchCompany, nvFetchCompany)
@@ -30,6 +32,8 @@ export const LINKED_API_ACTION_ERROR = {
3032
alreadyPending: 'alreadyPending',
3133
alreadyConnected: 'alreadyConnected',
3234
emailRequired: 'emailRequired',
35+
noteTooLong: 'noteTooLong',
36+
noteLimitExceeded: 'noteLimitExceeded',
3337
requestNotAllowed: 'requestNotAllowed',
3438
notPending: 'notPending',
3539
retrievingNotAllowed: 'retrievingNotAllowed',

src/types/workflows.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,8 @@ export interface TWorkflowStatusResponse {
4444
message?: string;
4545
}
4646

47-
export interface TWorkflowResponse<
48-
TResult extends TWorkflowData = TWorkflowData,
49-
> extends TWorkflowStatusResponse {
47+
export interface TWorkflowResponse<TResult extends TWorkflowData = TWorkflowData>
48+
extends TWorkflowStatusResponse {
5049
completion?: TWorkflowCompletion<TResult>;
5150
failure?: TWorkflowFailure;
5251
}

0 commit comments

Comments
 (0)