@pipedream/linkedin 0.1.1 → 1.0.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/actions/create-comment/create-comment.mjs +1 -1
- package/actions/create-image-post-organization/create-image-post-organization.mjs +13 -9
- package/actions/create-image-post-user/create-image-post-user.mjs +13 -9
- package/actions/create-like-on-share/create-like-on-share.mjs +1 -1
- package/actions/create-text-post-organization/create-text-post-organization.mjs +1 -1
- package/actions/create-text-post-user/create-text-post-user.mjs +1 -1
- package/actions/delete-post/delete-post.mjs +1 -1
- package/actions/fetch-ad-account/fetch-ad-account.mjs +1 -1
- package/actions/get-current-member-profile/get-current-member-profile.mjs +1 -1
- package/actions/get-member-organization-access-control/get-member-organization-access-control.mjs +1 -1
- package/actions/get-member-profile/get-member-profile.mjs +1 -1
- package/actions/get-multiple-member-profiles/get-multiple-member-profiles.mjs +1 -1
- package/actions/get-organization-access-control/get-organization-access-control.mjs +1 -1
- package/actions/get-organization-administrators/get-organization-administrators.mjs +1 -1
- package/actions/retrieve-comments-on-comments/retrieve-comments-on-comments.mjs +1 -1
- package/actions/retrieve-comments-shares/retrieve-comments-shares.mjs +1 -1
- package/actions/search-organization/search-organization.mjs +1 -1
- package/common/constants.mjs +13 -0
- package/common/utils.mjs +38 -0
- package/linkedin.app.mjs +61 -0
- package/package.json +2 -2
- package/sources/common/polling.mjs +122 -0
- package/sources/new-organization-post-created/new-organization-post-created.mjs +82 -0
- package/sources/new-organization-post-created/test-event.mjs +18 -0
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "linkedin-create-comment",
|
|
5
5
|
name: "Create Comment",
|
|
6
6
|
description: "Create a comment on a share or user generated content post. [See the docs here](https://docs.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/network-update-social-actions#create-comment)",
|
|
7
|
-
version: "0.1.
|
|
7
|
+
version: "0.1.6",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
linkedin,
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import linkedin from "../../linkedin.app.mjs";
|
|
2
|
-
import
|
|
2
|
+
import { getFileStreamAndMetadata } from "@pipedream/platform";
|
|
3
3
|
import FormData from "form-data";
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
6
|
key: "linkedin-create-image-post-organization",
|
|
7
7
|
name: "Create Image Post (Organization)",
|
|
8
8
|
description: "Create an image post on LinkedIn. [See the docs here](https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/images-api?view=li-lms-2023-09&tabs=http#uploading-an-image)",
|
|
9
|
-
version: "0.0
|
|
9
|
+
version: "1.0.0",
|
|
10
10
|
type: "action",
|
|
11
11
|
props: {
|
|
12
12
|
linkedin,
|
|
@@ -16,10 +16,10 @@ export default {
|
|
|
16
16
|
"organizationId",
|
|
17
17
|
],
|
|
18
18
|
},
|
|
19
|
-
|
|
19
|
+
file: {
|
|
20
20
|
type: "string",
|
|
21
|
-
label: "File Path",
|
|
22
|
-
description: "The path
|
|
21
|
+
label: "File Path or URL",
|
|
22
|
+
description: "The path or URL to the image file.",
|
|
23
23
|
},
|
|
24
24
|
text: {
|
|
25
25
|
propDefinition: [
|
|
@@ -66,11 +66,15 @@ export default {
|
|
|
66
66
|
$,
|
|
67
67
|
});
|
|
68
68
|
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
const {
|
|
70
|
+
stream, metadata,
|
|
71
|
+
} = await getFileStreamAndMetadata(this.file);
|
|
72
72
|
const formData = new FormData();
|
|
73
|
-
formData.append("file",
|
|
73
|
+
formData.append("file", stream, {
|
|
74
|
+
filename: metadata.name,
|
|
75
|
+
contentType: metadata.contentType,
|
|
76
|
+
knownLength: metadata.size,
|
|
77
|
+
});
|
|
74
78
|
|
|
75
79
|
await this.uploadImage(uploadUrl, formData);
|
|
76
80
|
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import linkedin from "../../linkedin.app.mjs";
|
|
2
|
-
import
|
|
2
|
+
import { getFileStreamAndMetadata } from "@pipedream/platform";
|
|
3
3
|
import FormData from "form-data";
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
6
|
key: "linkedin-create-image-post-user",
|
|
7
7
|
name: "Create Image Post (User)",
|
|
8
8
|
description: "Create an image post on LinkedIn. [See the docs here](https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/images-api?view=li-lms-2023-09&tabs=http#uploading-an-image)",
|
|
9
|
-
version: "0.0
|
|
9
|
+
version: "1.0.0",
|
|
10
10
|
type: "action",
|
|
11
11
|
props: {
|
|
12
12
|
linkedin,
|
|
13
|
-
|
|
13
|
+
file: {
|
|
14
14
|
type: "string",
|
|
15
|
-
label: "File Path",
|
|
16
|
-
description: "The path
|
|
15
|
+
label: "File Path or URL",
|
|
16
|
+
description: "The path or URL of the image file to post.",
|
|
17
17
|
},
|
|
18
18
|
text: {
|
|
19
19
|
propDefinition: [
|
|
@@ -66,11 +66,15 @@ export default {
|
|
|
66
66
|
$,
|
|
67
67
|
});
|
|
68
68
|
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
const {
|
|
70
|
+
stream, metadata,
|
|
71
|
+
} = await getFileStreamAndMetadata(this.file);
|
|
72
72
|
const formData = new FormData();
|
|
73
|
-
formData.append("file",
|
|
73
|
+
formData.append("file", stream, {
|
|
74
|
+
filename: metadata.name,
|
|
75
|
+
contentType: metadata.contentType,
|
|
76
|
+
knownLength: metadata.size,
|
|
77
|
+
});
|
|
74
78
|
|
|
75
79
|
await this.uploadImage(uploadUrl, formData);
|
|
76
80
|
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "linkedin-create-like-on-share",
|
|
5
5
|
name: "Create Like On Share",
|
|
6
6
|
description: "Creates a like on a share. [See the docs here](https://docs.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/network-update-social-actions#create-a-like-on-a-share)",
|
|
7
|
-
version: "0.1.
|
|
7
|
+
version: "0.1.6",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
linkedin,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "linkedin-create-text-post-organization",
|
|
5
5
|
name: "Create a Simple Post (Organization)",
|
|
6
6
|
description: "Create post on LinkedIn using text, URL or article. [See the docs](https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/posts-api?view=li-lms-2022-11&tabs=http#create-organic-posts) for more information",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.6",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
linkedin,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "linkedin-create-text-post-user",
|
|
5
5
|
name: "Create a Simple Post (User)",
|
|
6
6
|
description: "Create post on LinkedIn using text, URL or article. [See the docs](https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/posts-api?view=li-lms-2022-11&tabs=http#create-organic-posts) for more information",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.6",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
linkedin,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "linkedin-delete-post",
|
|
5
5
|
name: "Delete Post",
|
|
6
6
|
description: "Removes a post from user's wall. [See the docs](https://docs.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/share-api?tabs=http#delete-shares) for more information",
|
|
7
|
-
version: "0.0.
|
|
7
|
+
version: "0.0.6",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
linkedin,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "linkedin-fetch-ad-account",
|
|
5
5
|
name: "Fetch Ad Account",
|
|
6
6
|
description: "Fetches an individual adAccount given its id. [See the docs here](https://docs.microsoft.com/en-us/linkedin/marketing/integrations/ads/account-structure/create-and-manage-accounts#fetch-ad-account)",
|
|
7
|
-
version: "0.1.
|
|
7
|
+
version: "0.1.6",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
linkedin,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "linkedin-get-current-member-profile",
|
|
5
5
|
name: "Get Current Member Profile",
|
|
6
6
|
description: "Gets the profile of the current authenticated member. [See the docs here](https://docs.microsoft.com/en-us/linkedin/shared/integrations/people/profile-api#retrieve-current-members-profile)",
|
|
7
|
-
version: "0.1.
|
|
7
|
+
version: "0.1.6",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
linkedin,
|
package/actions/get-member-organization-access-control/get-member-organization-access-control.mjs
CHANGED
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "linkedin-get-member-organization-access-control",
|
|
5
5
|
name: "Get Member's Organization Access Control Information",
|
|
6
6
|
description: "Gets the organization access control information of the current authenticated member. [See the docs here](https://docs.microsoft.com/en-us/linkedin/marketing/integrations/community-management/organizations/organization-access-control?context=linkedin/compliance/context#find-a-members-organization-access-control-information)",
|
|
7
|
-
version: "0.1.
|
|
7
|
+
version: "0.1.6",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
linkedin,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "linkedin-get-member-profile",
|
|
5
5
|
name: "Get Member Profile",
|
|
6
6
|
description: "Gets another member's profile, given its person id. [See the docs here](https://docs.microsoft.com/en-us/linkedin/shared/integrations/people/profile-api#retrieve-other-members-profile)",
|
|
7
|
-
version: "0.1.
|
|
7
|
+
version: "0.1.6",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
linkedin,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "linkedin-get-multiple-member-profiles",
|
|
5
5
|
name: "Get Multiple Member Profiles",
|
|
6
6
|
description: "Gets multiple member profiles at once. [See the docs here](https://docs.microsoft.com/en-us/linkedin/shared/integrations/people/profile-api#retrieve-other-members-profile)",
|
|
7
|
-
version: "0.1.
|
|
7
|
+
version: "0.1.6",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
linkedin,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "linkedin-get-organization-access-control",
|
|
5
5
|
name: "Gets Organization Access Control",
|
|
6
6
|
description: "Gets an organization's access control information, given the organization urn. [See the docs here](https://docs.microsoft.com/en-us/linkedin/marketing/integrations/community-management/organizations/organization-access-control?context=linkedin/compliance/context#find-access-control-information)",
|
|
7
|
-
version: "0.1.
|
|
7
|
+
version: "0.1.6",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
linkedin,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "linkedin-get-organization-administrators",
|
|
5
5
|
name: "Get Organization Administrators",
|
|
6
6
|
description: "Gets the administator members of an organization, given the organization urn. [See the docs here](https://docs.microsoft.com/en-us/linkedin/marketing/integrations/community-management/organizations/organization-access-control?context=linkedin/compliance/context#find-organization-administrators)",
|
|
7
|
-
version: "0.2.
|
|
7
|
+
version: "0.2.6",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
linkedin,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "linkedin-retrieve-comments-on-comments",
|
|
5
5
|
name: "Retrieves Comments on Comments",
|
|
6
6
|
description: "Retrieves comments on comments, given the parent comment urn. [See the docs here](https://docs.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/network-update-social-actions#retrieve-comments-on-comments)",
|
|
7
|
-
version: "0.1.
|
|
7
|
+
version: "0.1.6",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
linkedin,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "linkedin-retrieve-comments-shares",
|
|
5
5
|
name: "Retrieve Comments On Shares",
|
|
6
6
|
description: "Retrieve comments on shares given the share urn. [See the docs here](https://docs.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/network-update-social-actions#retrieve-comments-on-shares)",
|
|
7
|
-
version: "0.1.
|
|
7
|
+
version: "0.1.6",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
linkedin,
|
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
key: "linkedin-search-organization",
|
|
5
5
|
name: "Search Organization",
|
|
6
6
|
description: "Searches for an organization by vanity name or email domain. [See the docs here](https://docs.microsoft.com/en-us/linkedin/marketing/integrations/community-management/organizations/organization-lookup-api)",
|
|
7
|
-
version: "0.1.
|
|
7
|
+
version: "0.1.6",
|
|
8
8
|
type: "action",
|
|
9
9
|
props: {
|
|
10
10
|
linkedin,
|
package/common/constants.mjs
CHANGED
|
@@ -75,6 +75,13 @@ const ROLE_STATES = [
|
|
|
75
75
|
"REVOKED",
|
|
76
76
|
];
|
|
77
77
|
|
|
78
|
+
const DEFAULT_LIMIT = 20;
|
|
79
|
+
const DEFAULT_MAX = 100;
|
|
80
|
+
const IS_FIRST_RUN = "isFirstRun";
|
|
81
|
+
const LAST_DATE_AT = "lastDateAt";
|
|
82
|
+
const ORG_ID = "orgId";
|
|
83
|
+
const PERSON_ID = "personId";
|
|
84
|
+
|
|
78
85
|
export default {
|
|
79
86
|
VERSION_PATH,
|
|
80
87
|
BASE_URL,
|
|
@@ -85,4 +92,10 @@ export default {
|
|
|
85
92
|
PIVOT_OPTIONS,
|
|
86
93
|
ORGANIZATION_ROLES,
|
|
87
94
|
ROLE_STATES,
|
|
95
|
+
DEFAULT_LIMIT,
|
|
96
|
+
DEFAULT_MAX,
|
|
97
|
+
IS_FIRST_RUN,
|
|
98
|
+
LAST_DATE_AT,
|
|
99
|
+
ORG_ID,
|
|
100
|
+
PERSON_ID,
|
|
88
101
|
};
|
package/common/utils.mjs
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
async function iterate(iterations) {
|
|
2
|
+
const items = [];
|
|
3
|
+
for await (const item of iterations) {
|
|
4
|
+
items.push(item);
|
|
5
|
+
}
|
|
6
|
+
return items;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function getNestedProperty(obj, propertyString) {
|
|
10
|
+
const properties = propertyString.split(".");
|
|
11
|
+
return properties.reduce((prev, curr) => prev?.[curr], obj);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function defaultEncodeFn(key, value) {
|
|
15
|
+
return `${key}=${value}`;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function encodeFn(key, value) {
|
|
19
|
+
return `${key}=${encodeURIComponent(value)}`;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function getParamsSerializer(encodeFn = defaultEncodeFn) {
|
|
23
|
+
return (params) => {
|
|
24
|
+
return Object.entries(params)
|
|
25
|
+
.map(([
|
|
26
|
+
key,
|
|
27
|
+
value,
|
|
28
|
+
]) => encodeFn(key, value))
|
|
29
|
+
.join("&");
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default {
|
|
34
|
+
iterate,
|
|
35
|
+
getNestedProperty,
|
|
36
|
+
encodeFn,
|
|
37
|
+
getParamsSerializer,
|
|
38
|
+
};
|
package/linkedin.app.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { axios as axiosPD } from "@pipedream/platform";
|
|
2
2
|
import axios from "axios";
|
|
3
3
|
import constants from "./common/constants.mjs";
|
|
4
|
+
import utils from "./common/utils.mjs";
|
|
4
5
|
|
|
5
6
|
export default {
|
|
6
7
|
type: "app",
|
|
@@ -268,5 +269,65 @@ export default {
|
|
|
268
269
|
...args,
|
|
269
270
|
});
|
|
270
271
|
},
|
|
272
|
+
listPosts(args = {}) {
|
|
273
|
+
return this._makeRequest({
|
|
274
|
+
path: "/posts",
|
|
275
|
+
paramsSerializer: utils.getParamsSerializer(utils.encodeFn),
|
|
276
|
+
...args,
|
|
277
|
+
});
|
|
278
|
+
},
|
|
279
|
+
async *getIterations({
|
|
280
|
+
resourcesFn, resourcesFnArgs, resourceName,
|
|
281
|
+
lastDateAt, dateField,
|
|
282
|
+
max = constants.DEFAULT_MAX,
|
|
283
|
+
}) {
|
|
284
|
+
let page = 0;
|
|
285
|
+
let resourcesCount = 0;
|
|
286
|
+
|
|
287
|
+
while (true) {
|
|
288
|
+
const response =
|
|
289
|
+
await resourcesFn({
|
|
290
|
+
...resourcesFnArgs,
|
|
291
|
+
params: {
|
|
292
|
+
...resourcesFnArgs?.params,
|
|
293
|
+
count: constants.DEFAULT_LIMIT,
|
|
294
|
+
start: page * constants.DEFAULT_LIMIT,
|
|
295
|
+
},
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
const nextResources = utils.getNestedProperty(response, resourceName);
|
|
299
|
+
|
|
300
|
+
if (!nextResources?.length) {
|
|
301
|
+
console.log("No more resources found");
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
for (const resource of nextResources) {
|
|
306
|
+
const isDateGreater =
|
|
307
|
+
lastDateAt
|
|
308
|
+
&& resource[dateField] > lastDateAt;
|
|
309
|
+
|
|
310
|
+
if (!lastDateAt || isDateGreater) {
|
|
311
|
+
yield resource;
|
|
312
|
+
resourcesCount += 1;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
if (resourcesCount >= max) {
|
|
316
|
+
console.log("Reached max resources");
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
if (nextResources.length < constants.DEFAULT_LIMIT) {
|
|
322
|
+
console.log("No next page found");
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
page += 1;
|
|
327
|
+
}
|
|
328
|
+
},
|
|
329
|
+
paginate(args = {}) {
|
|
330
|
+
return utils.iterate(this.getIterations(args));
|
|
331
|
+
},
|
|
271
332
|
},
|
|
272
333
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pipedream/linkedin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Pipedream Linkedin Components",
|
|
5
5
|
"main": "linkedin.app.mjs",
|
|
6
6
|
"keywords": [
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"access": "public"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@pipedream/platform": "^1.
|
|
16
|
+
"@pipedream/platform": "^3.1.0",
|
|
17
17
|
"axios": "^1.2.3",
|
|
18
18
|
"form-data": "^4.0.0"
|
|
19
19
|
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConfigurationError,
|
|
3
|
+
DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
|
|
4
|
+
} from "@pipedream/platform";
|
|
5
|
+
import app from "../../linkedin.app.mjs";
|
|
6
|
+
import constants from "../../common/constants.mjs";
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
props: {
|
|
10
|
+
app,
|
|
11
|
+
db: "$.service.db",
|
|
12
|
+
timer: {
|
|
13
|
+
type: "$.interface.timer",
|
|
14
|
+
label: "Polling Schedule",
|
|
15
|
+
description: "How often to poll the API",
|
|
16
|
+
default: {
|
|
17
|
+
intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
hooks: {
|
|
22
|
+
deploy() {
|
|
23
|
+
this.setIsFirstRun(true);
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
methods: {
|
|
27
|
+
generateMeta() {
|
|
28
|
+
throw new ConfigurationError("generateMeta is not implemented");
|
|
29
|
+
},
|
|
30
|
+
setPersonId(value) {
|
|
31
|
+
this.db.set(constants.PERSON_ID, value);
|
|
32
|
+
},
|
|
33
|
+
getPersonId() {
|
|
34
|
+
return this.db.get(constants.PERSON_ID);
|
|
35
|
+
},
|
|
36
|
+
setOrganizationId(value) {
|
|
37
|
+
this.db.set(constants.ORG_ID, value);
|
|
38
|
+
},
|
|
39
|
+
getOrganizationId() {
|
|
40
|
+
return this.db.get(constants.ORG_ID);
|
|
41
|
+
},
|
|
42
|
+
setIsFirstRun(value) {
|
|
43
|
+
this.db.set(constants.IS_FIRST_RUN, value);
|
|
44
|
+
},
|
|
45
|
+
getIsFirstRun() {
|
|
46
|
+
return this.db.get(constants.IS_FIRST_RUN);
|
|
47
|
+
},
|
|
48
|
+
setLastDateAt(value) {
|
|
49
|
+
this.db.set(constants.LAST_DATE_AT, value);
|
|
50
|
+
},
|
|
51
|
+
getLastDateAt() {
|
|
52
|
+
return this.db.get(constants.LAST_DATE_AT);
|
|
53
|
+
},
|
|
54
|
+
getDateField() {
|
|
55
|
+
throw new ConfigurationError("getDateField is not implemented");
|
|
56
|
+
},
|
|
57
|
+
getResourceName() {
|
|
58
|
+
throw new ConfigurationError("getResourceName is not implemented");
|
|
59
|
+
},
|
|
60
|
+
getResourcesFn() {
|
|
61
|
+
throw new ConfigurationError("getResourcesFn is not implemented");
|
|
62
|
+
},
|
|
63
|
+
getResourcesFnArgs() {
|
|
64
|
+
throw new ConfigurationError("getResourcesFnArgs is not implemented");
|
|
65
|
+
},
|
|
66
|
+
processResource(resource) {
|
|
67
|
+
const meta = this.generateMeta(resource);
|
|
68
|
+
this.$emit(resource, meta);
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
async run() {
|
|
72
|
+
const {
|
|
73
|
+
app,
|
|
74
|
+
getDateField,
|
|
75
|
+
getLastDateAt,
|
|
76
|
+
getResourcesFn,
|
|
77
|
+
getResourcesFnArgs,
|
|
78
|
+
getResourceName,
|
|
79
|
+
getIsFirstRun,
|
|
80
|
+
setIsFirstRun,
|
|
81
|
+
setLastDateAt,
|
|
82
|
+
processResource,
|
|
83
|
+
} = this;
|
|
84
|
+
|
|
85
|
+
const isFirstRun = getIsFirstRun();
|
|
86
|
+
const dateField = getDateField();
|
|
87
|
+
const lastDateAt = getLastDateAt();
|
|
88
|
+
|
|
89
|
+
const otherArgs = isFirstRun
|
|
90
|
+
? {
|
|
91
|
+
max: constants.DEFAULT_LIMIT,
|
|
92
|
+
}
|
|
93
|
+
: {
|
|
94
|
+
dateField,
|
|
95
|
+
lastDateAt,
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const resources = await app.paginate({
|
|
99
|
+
resourcesFn: getResourcesFn(),
|
|
100
|
+
resourcesFnArgs: getResourcesFnArgs(),
|
|
101
|
+
resourceName: getResourceName(),
|
|
102
|
+
...otherArgs,
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
if (resources.length) {
|
|
106
|
+
const [
|
|
107
|
+
firstResource,
|
|
108
|
+
] = Array.from(resources);
|
|
109
|
+
if (firstResource) {
|
|
110
|
+
setLastDateAt(firstResource[dateField]);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
Array.from(resources)
|
|
115
|
+
.reverse()
|
|
116
|
+
.forEach(processResource);
|
|
117
|
+
|
|
118
|
+
if (isFirstRun) {
|
|
119
|
+
setIsFirstRun(false);
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { ConfigurationError } from "@pipedream/platform";
|
|
2
|
+
import common from "../common/polling.mjs";
|
|
3
|
+
import utils from "../../common/utils.mjs";
|
|
4
|
+
import sampleEmit from "./test-event.mjs";
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
...common,
|
|
8
|
+
key: "linkedin-new-organization-post-created",
|
|
9
|
+
name: "New Organization Post Created",
|
|
10
|
+
description: "Emit new event when a new post is created by the organization. [See the documentation](https://learn.microsoft.com/en-us/linkedin/marketing/community-management/shares/posts-api?view=li-lms-2024-09&tabs=curl#find-posts-by-authors).",
|
|
11
|
+
type: "source",
|
|
12
|
+
version: "0.0.1",
|
|
13
|
+
dedupe: "unique",
|
|
14
|
+
props: {
|
|
15
|
+
...common.props,
|
|
16
|
+
organizationVanityName: {
|
|
17
|
+
type: "string",
|
|
18
|
+
label: "Organization Vanity Name",
|
|
19
|
+
description: "You can get the Orgainization Vanity Name from the company LinkedIN URL, for example, if the company LinkedIn URL is `https://www.linkedin.com/company/confluent`, then the Organization Vanity Name is `confluent`.",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
hooks: {
|
|
23
|
+
...common.hooks,
|
|
24
|
+
async deploy() {
|
|
25
|
+
const {
|
|
26
|
+
app,
|
|
27
|
+
organizationVanityName,
|
|
28
|
+
setOrganizationId,
|
|
29
|
+
setIsFirstRun,
|
|
30
|
+
} = this;
|
|
31
|
+
|
|
32
|
+
const { elements } = await app.searchOrganizations("vanityName", {
|
|
33
|
+
debug: true,
|
|
34
|
+
params: {
|
|
35
|
+
vanityName: organizationVanityName,
|
|
36
|
+
},
|
|
37
|
+
paramsSerializer: utils.getParamsSerializer(utils.encodeFn),
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const organizationFound =
|
|
41
|
+
elements?.find(({ vanityName }) => vanityName === organizationVanityName);
|
|
42
|
+
|
|
43
|
+
if (!organizationFound) {
|
|
44
|
+
throw new ConfigurationError(`There's no Organization matched for Organization Vanity Name \`${organizationVanityName}\`.`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
setOrganizationId(organizationFound.id);
|
|
48
|
+
setIsFirstRun(true);
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
methods: {
|
|
52
|
+
...common.methods,
|
|
53
|
+
getDateField() {
|
|
54
|
+
return "createdAt";
|
|
55
|
+
},
|
|
56
|
+
getResourceName() {
|
|
57
|
+
return "elements";
|
|
58
|
+
},
|
|
59
|
+
getResourcesFn() {
|
|
60
|
+
return this.app.listPosts;
|
|
61
|
+
},
|
|
62
|
+
getResourcesFnArgs() {
|
|
63
|
+
const author = `urn:li:organization:${this.getOrganizationId()}`;
|
|
64
|
+
return {
|
|
65
|
+
debug: true,
|
|
66
|
+
params: {
|
|
67
|
+
author,
|
|
68
|
+
q: "author",
|
|
69
|
+
sortBy: "CREATED",
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
},
|
|
73
|
+
generateMeta(resource) {
|
|
74
|
+
return {
|
|
75
|
+
id: resource.id,
|
|
76
|
+
summary: `New Org Post: ${resource.id}`,
|
|
77
|
+
ts: resource.createdAt,
|
|
78
|
+
};
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
sampleEmit,
|
|
82
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
"isReshareDisabledByAuthor": false,
|
|
3
|
+
"lifecycleState": "PUBLISHED",
|
|
4
|
+
"createdAt": 1741038207195,
|
|
5
|
+
"lastModifiedAt": 1741038237226,
|
|
6
|
+
"visibility": "PUBLIC",
|
|
7
|
+
"publishedAt": 1741038207195,
|
|
8
|
+
"author": "urn:li:organization:100680185",
|
|
9
|
+
"id": "urn:li:share:7302443516318699520",
|
|
10
|
+
"distribution": {
|
|
11
|
+
"feedDistribution": "MAIN_FEED",
|
|
12
|
+
"thirdPartyDistributionChannels": []
|
|
13
|
+
},
|
|
14
|
+
"commentary": "test 1",
|
|
15
|
+
"lifecycleStateInfo": {
|
|
16
|
+
"isEditedByAuthor": false
|
|
17
|
+
}
|
|
18
|
+
};
|