linkedin_orbit 0.1.0 → 0.2.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.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/Gemfile.lock +24 -9
- data/README.md +18 -2
- data/bin/linkedin_orbit +5 -0
- data/docs/FIRST_TIME_INSTRUCTIONS.md +30 -9
- data/lib/linkedin_orbit.rb +2 -0
- data/lib/linkedin_orbit/client.rb +9 -2
- data/lib/linkedin_orbit/interactions/comment.rb +8 -16
- data/lib/linkedin_orbit/linkedin.rb +44 -1
- data/lib/linkedin_orbit/version.rb +1 -1
- data/linkedin_orbit.gemspec +1 -0
- data/readme_images/linkedin-flow.png +0 -0
- data/readme_images/new-comment-screenshot.png +0 -0
- data/scripts/check_comments.rb +3 -3
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72da0485d3741083f4f16250d750ecbae919d67a54a5aca51d8a00d73d8a0719
|
4
|
+
data.tar.gz: 88b8658762763e70dd9a3bec29d040ec025b5ff6d6ad31f1ce89f30bd58ac95b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05ddc9104e36e1a798640ec2ec275c68aed856108f17ad200aed418610fb6b7b2b72ac394fca1fc54b4b317aae3d6892bf63c10b7a8ef4e263dd1116ead8ab39
|
7
|
+
data.tar.gz: ab9e3c2911639813bc048005b02998f3f5102c17a1a7675c3f701fd192c0bc78c1477ad85f527004bd137afe3c88346750c0696be0d77809fe04b8fb7801808c
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,18 +1,19 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
linkedin_orbit (0.
|
4
|
+
linkedin_orbit (0.1.4)
|
5
5
|
dotenv (~> 2.7)
|
6
6
|
http (~> 4.4)
|
7
7
|
json (~> 2.5)
|
8
8
|
linkedin (~> 1.1)
|
9
|
+
orbit_activities (~> 0.2)
|
9
10
|
thor (~> 1.1)
|
10
11
|
zeitwerk (~> 2.4)
|
11
12
|
|
12
13
|
GEM
|
13
14
|
remote: https://rubygems.org/
|
14
15
|
specs:
|
15
|
-
addressable (2.
|
16
|
+
addressable (2.8.0)
|
16
17
|
public_suffix (>= 2.0.2, < 5.0)
|
17
18
|
ast (2.4.2)
|
18
19
|
byebug (11.1.3)
|
@@ -22,16 +23,24 @@ GEM
|
|
22
23
|
domain_name (0.5.20190701)
|
23
24
|
unf (>= 0.0.5, < 1.0.0)
|
24
25
|
dotenv (2.7.6)
|
25
|
-
faraday (1.
|
26
|
+
faraday (1.5.0)
|
27
|
+
faraday-em_http (~> 1.0)
|
28
|
+
faraday-em_synchrony (~> 1.0)
|
26
29
|
faraday-excon (~> 1.1)
|
30
|
+
faraday-httpclient (~> 1.0.1)
|
27
31
|
faraday-net_http (~> 1.0)
|
28
32
|
faraday-net_http_persistent (~> 1.1)
|
33
|
+
faraday-patron (~> 1.0)
|
29
34
|
multipart-post (>= 1.2, < 3)
|
30
35
|
ruby2_keywords (>= 0.0.4)
|
36
|
+
faraday-em_http (1.0.0)
|
37
|
+
faraday-em_synchrony (1.0.0)
|
31
38
|
faraday-excon (1.1.0)
|
39
|
+
faraday-httpclient (1.0.1)
|
32
40
|
faraday-net_http (1.0.1)
|
33
41
|
faraday-net_http_persistent (1.1.0)
|
34
|
-
|
42
|
+
faraday-patron (1.0.0)
|
43
|
+
ffi (1.15.3)
|
35
44
|
ffi-compiler (1.0.1)
|
36
45
|
ffi (>= 1.0.0)
|
37
46
|
rake
|
@@ -42,7 +51,7 @@ GEM
|
|
42
51
|
http-cookie (~> 1.0)
|
43
52
|
http-form_data (~> 2.2)
|
44
53
|
http-parser (~> 1.2.0)
|
45
|
-
http-cookie (1.0.
|
54
|
+
http-cookie (1.0.4)
|
46
55
|
domain_name (~> 0.5)
|
47
56
|
http-form_data (2.3.0)
|
48
57
|
http-parser (1.2.3)
|
@@ -62,6 +71,11 @@ GEM
|
|
62
71
|
multi_json (~> 1.3)
|
63
72
|
multi_xml (~> 0.5)
|
64
73
|
rack (>= 1.2, < 3)
|
74
|
+
orbit_activities (0.2.2)
|
75
|
+
http (~> 4.4)
|
76
|
+
json (~> 2.5)
|
77
|
+
rake (~> 13.0)
|
78
|
+
zeitwerk (~> 2.4)
|
65
79
|
parallel (1.20.1)
|
66
80
|
parser (3.0.1.1)
|
67
81
|
ast (~> 2.4.1)
|
@@ -84,16 +98,16 @@ GEM
|
|
84
98
|
diff-lcs (>= 1.2.0, < 2.0)
|
85
99
|
rspec-support (~> 3.10.0)
|
86
100
|
rspec-support (3.10.2)
|
87
|
-
rubocop (1.
|
101
|
+
rubocop (1.18.2)
|
88
102
|
parallel (~> 1.10)
|
89
103
|
parser (>= 3.0.0.0)
|
90
104
|
rainbow (>= 2.2.2, < 4.0)
|
91
105
|
regexp_parser (>= 1.8, < 3.0)
|
92
106
|
rexml
|
93
|
-
rubocop-ast (>= 1.
|
107
|
+
rubocop-ast (>= 1.7.0, < 2.0)
|
94
108
|
ruby-progressbar (~> 1.7)
|
95
109
|
unicode-display_width (>= 1.4.0, < 3.0)
|
96
|
-
rubocop-ast (1.
|
110
|
+
rubocop-ast (1.7.0)
|
97
111
|
parser (>= 3.0.1.1)
|
98
112
|
ruby-progressbar (1.11.0)
|
99
113
|
ruby2_keywords (0.0.4)
|
@@ -102,7 +116,7 @@ GEM
|
|
102
116
|
unf_ext
|
103
117
|
unf_ext (0.0.7.7)
|
104
118
|
unicode-display_width (2.0.0)
|
105
|
-
webmock (3.
|
119
|
+
webmock (3.13.0)
|
106
120
|
addressable (>= 2.3.6)
|
107
121
|
crack (>= 0.3.2)
|
108
122
|
hashdiff (>= 0.4.0, < 2.0.0)
|
@@ -115,6 +129,7 @@ PLATFORMS
|
|
115
129
|
DEPENDENCIES
|
116
130
|
byebug
|
117
131
|
linkedin_orbit!
|
132
|
+
orbit_activities
|
118
133
|
rake (~> 13.0)
|
119
134
|
rspec (~> 3.4)
|
120
135
|
rubocop (~> 1.7)
|
data/README.md
CHANGED
@@ -4,7 +4,9 @@
|
|
4
4
|
[](https://badge.fury.io/rb/dev_orbit)
|
5
5
|
[](code_of_conduct.md)
|
6
6
|
|
7
|
-
|
7
|
+
Add your LinkedIn interactions into your Orbit workspace with this community-built integration.
|
8
|
+
|
9
|
+

|
8
10
|
|
9
11
|
|<p align="left">:sparkles:</p> This is a *community project*. The Orbit team does its best to maintain it and keep it up to date with any recent API changes.<br/><br/>We welcome community contributions to make sure that it stays current. <p align="right">:sparkles:</p>|
|
10
12
|
|-----------------------------------------|
|
@@ -21,7 +23,7 @@ The application requires the following environment variables:
|
|
21
23
|
| Variable | Description | More Info
|
22
24
|
|---|---|--|
|
23
25
|
| `LINKEDIN_TOKEN` | LinkedIn Token | Follow the [First Time Setup guide](docs/FIRST_TIME_INSTRUCTIONS.md) to obtain the token
|
24
|
-
| `LINKEDIN_ORGANIZATION` | LinkedIn Organization Page ID | Format: `urn:li:organization:#{id}
|
26
|
+
| `LINKEDIN_ORGANIZATION` | LinkedIn Organization Page ID | Format: `urn:li:organization:#{id}`, where `id` is the set of numbers in the LinkedIn page URL, i.e. `https://www.linkedin.com/company/28866695`, the `id` is `28866695`.
|
25
27
|
| `ORBIT_API_KEY` | API key for Orbit | Found in `Account Settings` in your Orbit workspace
|
26
28
|
| `ORBIT_WORKSPACE_ID` | ID for your Orbit workspace | Last part of the Orbit workspace URL, i.e. `https://app.orbit.love/my-workspace`, the ID is `my-workspace`
|
27
29
|
|
@@ -54,8 +56,20 @@ client = LinkedinOrbit::Client.new(
|
|
54
56
|
client = LinkedinOrbit::Client.new
|
55
57
|
```
|
56
58
|
|
59
|
+
### Performing a Historical Import
|
60
|
+
|
61
|
+
You may want to perform a one-time historical import to fetch all your previous LinkedIn interactions and bring them into your Orbit workspace. To do so, instantiate your `client` with the `historical_import` flag:
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
client = LinkedinOrbit::Client.new(
|
65
|
+
historical_import: true
|
66
|
+
)
|
67
|
+
```
|
68
|
+
|
57
69
|
### Fetching LinkedIn Comments
|
58
70
|
|
71
|
+
**The API token owner must be an admin on the LinkedIn organization's page in order to fetch comments. Please ask the manager of your LinkedIn page to grant admin status to your account before attempting to fetch comments.**
|
72
|
+
|
59
73
|
Once, you have an instantiated client, you can fetch LinkedIn comments on your organization's posts and send them to Orbit by invoking the `#comments` instance method:
|
60
74
|
|
61
75
|
```ruby
|
@@ -68,6 +82,8 @@ You can also use this package with the included CLI. To use the CLI pass in the
|
|
68
82
|
```bash
|
69
83
|
$ ORBIT_API_KEY=... ORBIT_WORKSPACE_ID=... LINKEDIN_TOKEN=... LINKEDIN_ORGANIZATION=... bundle exec linkedin_orbit --check_comments
|
70
84
|
```
|
85
|
+
|
86
|
+
**Add the `--historical-import` flag to your CLI command to perform a historical import of all your LinkedIn interactions using the CLI.**
|
71
87
|
## GitHub Actions Automation Setup
|
72
88
|
|
73
89
|
⚡ You can set up this integration in a matter of minutes using our GitHub Actions template. It will run regularly to add new activities to your Orbit workspace. All you need is a GitHub account.
|
data/bin/linkedin_orbit
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
require 'optparse'
|
3
3
|
|
4
4
|
check_comments = false
|
5
|
+
historical_import = false
|
5
6
|
|
6
7
|
options = {}
|
7
8
|
choices = OptionParser.new do |opts|
|
@@ -13,6 +14,9 @@ choices = OptionParser.new do |opts|
|
|
13
14
|
opts.on("--check-comments", "Check for new LinkedIn comments") do
|
14
15
|
check_comments = true
|
15
16
|
end
|
17
|
+
opts.on("--historical-import", "Performa historical import of all LinkedIn interactions") do
|
18
|
+
historical_import = true
|
19
|
+
end
|
16
20
|
end.parse!
|
17
21
|
|
18
22
|
$LOAD_PATH.unshift(File.expand_path('../lib/dev_orbit', __dir__))
|
@@ -23,5 +27,6 @@ require_relative '../scripts/check_comments'
|
|
23
27
|
if check_comments
|
24
28
|
puts "Checking for new LinkedIn comments and posting them to your Orbit workspace..."
|
25
29
|
ARGV[0] = 'render'
|
30
|
+
ARGV[1] = historical_import
|
26
31
|
LinkedinOrbit::Scripts::CheckComments.start(ARGV)
|
27
32
|
end
|
@@ -1,8 +1,17 @@
|
|
1
1
|
# Instructions for First Time Set Up
|
2
2
|
|
3
|
-
These instructions will walk you through authenticating to LinkedIn, and receiving your LinkedIn token, which is needed to use this integration. You will only need to do this once every two months
|
3
|
+
|These instructions will walk you through authenticating to LinkedIn, and receiving your LinkedIn token, which is needed to use this integration. You will only need to do this once every two months.|
|
4
|
+
|-----------------------------------------|
|
4
5
|
|
5
|
-
|
6
|
+

|
7
|
+
|
8
|
+
## 1. Before You Start
|
9
|
+
|
10
|
+
LinkedIn requires that the personal account (your LinkedIn account) requesting API access for an organization or company on LinkedIn be an admin of the organization or company's LinkedIn page.
|
11
|
+
|
12
|
+
Please verify that you have administrative privileges for the organization LinkedIn page. If you do not, your organization's administrator can grant your account the correct access level.
|
13
|
+
## 2. LinkedIn Setup
|
14
|
+
### Creating a LinkedIn Developers App
|
6
15
|
|
7
16
|
The first thing you must do is create a LinkedIn Developers app.
|
8
17
|
|
@@ -21,7 +30,7 @@ Once you submit the form, it usually takes 3-4 days for LinkedIn to confirm the
|
|
21
30
|
|
22
31
|
While you wait for verification, you can do the next step, which is to request the right API scope from LinkedIn.
|
23
32
|
|
24
|
-
|
33
|
+
### Requesting the LinkedIn Marketing Developer Platform API Access
|
25
34
|
|
26
35
|
LinkedIn has many different types of APIs and many different types of access levels to those APIs. The API your app needs access to is the **Marketing Developer Platform**.
|
27
36
|
|
@@ -33,7 +42,17 @@ This will take another few days for LinkedIn to verify and confirm this request.
|
|
33
42
|
|
34
43
|

|
35
44
|
|
36
|
-
##
|
45
|
+
## 3. Wait for LinkedIn
|
46
|
+
|
47
|
+
At this point, you need to wait for LinkedIn to approve both your new developer application, and access to the Marketing Developer Platform API. This generally takes several days. LinkedIn will both email you with an update, and post an update inside the [LinkedIn Developers](https://www.linkedin.com/developers) page.
|
48
|
+
|
49
|
+
If your request is denied access, you can submit an appeal to LinkedIn. The appeal process can take several days again. Pay close attention to the specified reason LinkedIn provided for the initial rejection, and work to remedy it before submitting an appeal.
|
50
|
+
|
51
|
+
The Orbit Developer Relations team unfortunately cannot assist or address LinkedIn API approval processes.
|
52
|
+
|
53
|
+
## 4. Integration Setup
|
54
|
+
|
55
|
+
### LinkedIn API Credentials
|
37
56
|
|
38
57
|
You will need your LinkedIn API credentials to move forward. You can copy your LinkedIn credentials, which are your Client ID and Client Secret from the "Auth" section in the LinkedIn Developers dashboard.
|
39
58
|
|
@@ -45,7 +64,9 @@ You will also see on the "Auth" page a section called "OAuth 2.0 Settings". We w
|
|
45
64
|
|
46
65
|
After you have finished all of the above steps, you are ready to move on to the last step in this first time setup instructions.
|
47
66
|
|
48
|
-
|
67
|
+
### LinkedIn Token
|
68
|
+
|
69
|
+
**Do not proceed to this step until you have received approval from LinkedIn for your API access request. This next step will not work until that has happened.**
|
49
70
|
|
50
71
|
LinkedIn uses OAuth 2.0 as its authentication format, and as such, you need to authenticate *one time every two months* to obtain a token that will be used for the integration from then on.
|
51
72
|
|
@@ -73,14 +94,14 @@ Now, return back to your browser window with your Heroku app running. Click on t
|
|
73
94
|
|
74
95
|
The last step you need to complete in this first time setup is to add the LinkedIn token you created into the LinkedIn Orbit community integration credentials, either in the context of a standalone app or in the context of running it as a GitHub Action.
|
75
96
|
|
76
|
-
|
77
|
-
|
97
|
+
### Add the LinkedIn Token to the LinkedIn Orbit Community Integration
|
98
|
+
#### Within GitHub Actions
|
78
99
|
|
79
100
|
*(This step assumes you have a GitHub repository created already to run the LinkedIn Orbit community integration. If you do not, please follow [this guide](https://docs.github.com/en/github/getting-started-with-github/create-a-repo) first.)*
|
80
101
|
|
81
102
|
The LinkedIn token you created in the last step needs to be added to the GitHub repository that you are running the LinkedIn Orbit community integration from. To do so, follow the step-by-step guide in the [README](https://github.com/orbit-love/github-actions-templates/blob/main/README.md#adding-your-credentials-to-github) in the GitHub Actions instructions. The name for this secret **must** be: `LINKEDIN_TOKEN`.
|
82
103
|
|
83
|
-
|
104
|
+
#### Within a Standalone App
|
84
105
|
|
85
106
|
If you are running the community integration as a standalone app, you can add the LinkedIn token as an environment variable inside the `.env` file in the root directory of the codebase.
|
86
107
|
|
@@ -89,6 +110,6 @@ Open up the `.env` file and add a new line starting with `LINKEDIN_TOKEN=` and a
|
|
89
110
|
|
90
111
|
You have now successfully finished the setup for your LinkedIn Orbit community integration. This steps needs to occur once every 60 days.
|
91
112
|
|
92
|
-
In between, you
|
113
|
+
In between, you should delete the Heroku app you created and recreate a new one when you need to do this again as keeping it alive potentially exposes your LinkedIn token to those who may come across it.
|
93
114
|
|
94
115
|
From within the Heroku dashboard, navigate to the "Settings" for the app and at the very bottom of the page is a button called "Delete app". Once you click on that button, Heroku will confirm you wish to delete the app. Upon confirmation, the app will be deleted and the deployment on the web will be removed.
|
data/lib/linkedin_orbit.rb
CHANGED
@@ -29,13 +29,18 @@ require "json"
|
|
29
29
|
# The LinkedIn organization would use the last component of that web address and would be:
|
30
30
|
# urn:li:organization:28866695
|
31
31
|
#
|
32
|
+
# @option params [Boolean] :historical_import
|
33
|
+
# Whether to do an import of all LinkedIn interactions ignoring latest
|
34
|
+
# activity already in the Orbit workspace.
|
35
|
+
# Default is false.
|
36
|
+
#
|
32
37
|
# @param [Hash] params
|
33
38
|
#
|
34
39
|
# @return [DevOrbit::Client]
|
35
40
|
#
|
36
41
|
module LinkedinOrbit
|
37
42
|
class Client
|
38
|
-
attr_accessor :orbit_api_key, :orbit_workspace, :linkedin_organization
|
43
|
+
attr_accessor :orbit_api_key, :orbit_workspace, :linkedin_organization, :historical_import
|
39
44
|
attr_reader :linkedin_token
|
40
45
|
|
41
46
|
def initialize(params = {})
|
@@ -43,6 +48,7 @@ module LinkedinOrbit
|
|
43
48
|
@orbit_workspace = params.fetch(:orbit_workspace, ENV["ORBIT_WORKSPACE_ID"])
|
44
49
|
@linkedin_token = token
|
45
50
|
@linkedin_organization = params.fetch(:linkedin_organization, ENV["LINKEDIN_ORGANIZATION"])
|
51
|
+
@historical_import = params.fetch(:historical_import, false)
|
46
52
|
end
|
47
53
|
|
48
54
|
def token
|
@@ -54,7 +60,8 @@ module LinkedinOrbit
|
|
54
60
|
linkedin_token: @linkedin_token,
|
55
61
|
linkedin_organization: @linkedin_organization,
|
56
62
|
orbit_api_key: @orbit_api_key,
|
57
|
-
orbit_workspace: @orbit_workspace
|
63
|
+
orbit_workspace: @orbit_workspace,
|
64
|
+
historical_import: @historical_import
|
58
65
|
).process_comments
|
59
66
|
end
|
60
67
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "net/http"
|
4
3
|
require "json"
|
5
4
|
|
6
5
|
module LinkedinOrbit
|
@@ -16,27 +15,20 @@ module LinkedinOrbit
|
|
16
15
|
end
|
17
16
|
|
18
17
|
def after_initialize!
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
request["Content-Type"] = "application/json"
|
27
|
-
request["Authorization"] = "Bearer #{@orbit_api_key}"
|
28
|
-
|
29
|
-
request.body = construct_body.to_json
|
30
|
-
|
31
|
-
response = http.request(request)
|
32
|
-
|
33
|
-
JSON.parse(response.body)
|
18
|
+
OrbitActivities::Request.new(
|
19
|
+
api_key: @orbit_api_key,
|
20
|
+
workspace_id: @orbit_workspace,
|
21
|
+
user_agent: "community-ruby-linkedin-orbit/#{LinkedinOrbit::VERSION}",
|
22
|
+
action: "new_activity",
|
23
|
+
body: construct_body.to_json
|
24
|
+
)
|
34
25
|
end
|
35
26
|
|
36
27
|
def construct_body
|
37
28
|
{
|
38
29
|
activity: {
|
39
30
|
activity_type: "linkedin:comment",
|
31
|
+
tags: ["channel:linkedin"],
|
40
32
|
title: "Commented on LinkedIn Post",
|
41
33
|
description: construct_description,
|
42
34
|
occurred_at: Time.at(@comment["created"]["time"] / 1000).utc,
|
@@ -7,12 +7,19 @@ module LinkedinOrbit
|
|
7
7
|
@linkedin_token = params.fetch(:linkedin_token)
|
8
8
|
@orbit_api_key = params.fetch(:orbit_api_key)
|
9
9
|
@orbit_workspace = params.fetch(:orbit_workspace)
|
10
|
+
@historical_import = params.fetch(:historical_import, false)
|
10
11
|
end
|
11
12
|
|
12
13
|
def process_comments
|
13
14
|
posts = get_posts
|
14
15
|
|
16
|
+
return posts unless posts.is_a?(Array)
|
17
|
+
|
18
|
+
orbit_timestamp = last_orbit_activity_timestamp
|
19
|
+
|
15
20
|
posts.each do |post|
|
21
|
+
times = 0
|
22
|
+
|
16
23
|
comments = get_post_comments(post["id"])
|
17
24
|
|
18
25
|
comments.reject! { |comment| comment["actor~"]["id"] == "private" }
|
@@ -20,6 +27,16 @@ module LinkedinOrbit
|
|
20
27
|
next if comments.nil? || comments.empty?
|
21
28
|
|
22
29
|
comments.each do |comment|
|
30
|
+
unless @historical_import && orbit_timestamp
|
31
|
+
next if Time.at(comment["created"]["time"] / 1000).utc.to_s < orbit_timestamp unless orbit_timestamp.nil?
|
32
|
+
end
|
33
|
+
|
34
|
+
if orbit_timestamp && @historical_import == false
|
35
|
+
next if Time.at(comment["created"]["time"] / 1000).utc.to_s < orbit_timestamp
|
36
|
+
end
|
37
|
+
|
38
|
+
times += 1
|
39
|
+
|
23
40
|
LinkedinOrbit::Orbit.call(
|
24
41
|
type: "comments",
|
25
42
|
data: {
|
@@ -30,6 +47,11 @@ module LinkedinOrbit
|
|
30
47
|
orbit_api_key: @orbit_api_key
|
31
48
|
)
|
32
49
|
end
|
50
|
+
|
51
|
+
output = "Sent #{times} new comments to your Orbit workspace"
|
52
|
+
|
53
|
+
puts output
|
54
|
+
return output
|
33
55
|
end
|
34
56
|
end
|
35
57
|
|
@@ -47,7 +69,16 @@ module LinkedinOrbit
|
|
47
69
|
response = https.request(request)
|
48
70
|
|
49
71
|
response = JSON.parse(response.body)
|
50
|
-
|
72
|
+
|
73
|
+
return response["message"] if response["serviceErrorCode"]
|
74
|
+
|
75
|
+
if response["elements"].nil? || response["elements"].empty?
|
76
|
+
return <<~HEREDOC
|
77
|
+
No new posts to process from your LinkedIn organization.
|
78
|
+
If you suspect this is incorrect, verify your LinkedIn organization schema is correct in your credentials.
|
79
|
+
HEREDOC
|
80
|
+
end
|
81
|
+
|
51
82
|
response["elements"].each do |element|
|
52
83
|
posts << {
|
53
84
|
"id" => element["activity"],
|
@@ -74,5 +105,17 @@ module LinkedinOrbit
|
|
74
105
|
|
75
106
|
response["elements"]
|
76
107
|
end
|
108
|
+
|
109
|
+
def last_orbit_activity_timestamp
|
110
|
+
@last_orbit_activity_timestamp ||= begin
|
111
|
+
OrbitActivities::Request.new(
|
112
|
+
api_key: @orbit_api_key,
|
113
|
+
workspace_id: @orbit_workspace,
|
114
|
+
user_agent: "community-ruby-linkedin-orbit/#{LinkedinOrbit::VERSION}",
|
115
|
+
action: "latest_activity_timestamp",
|
116
|
+
filters: { activity_type: "custom:linkedin:comment" }
|
117
|
+
).response
|
118
|
+
end
|
119
|
+
end
|
77
120
|
end
|
78
121
|
end
|
data/linkedin_orbit.gemspec
CHANGED
@@ -32,6 +32,7 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.add_dependency "thor", "~> 1.1"
|
33
33
|
spec.add_dependency "linkedin", "~> 1.1"
|
34
34
|
spec.add_dependency "dotenv", "~> 2.7"
|
35
|
+
spec.add_dependency "orbit_activities", "~> 0.2"
|
35
36
|
spec.add_development_dependency "rspec", "~> 3.4"
|
36
37
|
spec.add_development_dependency "webmock", "~> 3.12"
|
37
38
|
end
|
Binary file
|
Binary file
|
data/scripts/check_comments.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require "
|
4
|
+
require "linkedin_orbit"
|
5
5
|
require "thor"
|
6
6
|
|
7
7
|
module LinkedinOrbit
|
8
8
|
module Scripts
|
9
9
|
class CheckComments < Thor
|
10
10
|
desc "render", "check for new LinkedIn post comments and push them to Orbit"
|
11
|
-
def render
|
12
|
-
client = LinkedinOrbit::Client.new
|
11
|
+
def render(*params)
|
12
|
+
client = LinkedinOrbit::Client.new(historical_import: params[0])
|
13
13
|
client.comments
|
14
14
|
end
|
15
15
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: linkedin_orbit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Orbit DevRel
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-07-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: http
|
@@ -95,6 +95,20 @@ dependencies:
|
|
95
95
|
- - "~>"
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: '2.7'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: orbit_activities
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - "~>"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0.2'
|
105
|
+
type: :runtime
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0.2'
|
98
112
|
- !ruby/object:Gem::Dependency
|
99
113
|
name: rspec
|
100
114
|
requirement: !ruby/object:Gem::Requirement
|
@@ -154,9 +168,11 @@ files:
|
|
154
168
|
- readme_images/client_credentials.png
|
155
169
|
- readme_images/create_app_button.png
|
156
170
|
- readme_images/heroku_view_app_button.png
|
171
|
+
- readme_images/linkedin-flow.png
|
157
172
|
- readme_images/linkedin_oauth_redirects.png
|
158
173
|
- readme_images/logo.png
|
159
174
|
- readme_images/marketing_platform_request_access.png
|
175
|
+
- readme_images/new-comment-screenshot.png
|
160
176
|
- readme_images/products_list.png
|
161
177
|
- readme_images/ways-to-use.png
|
162
178
|
- scripts/check_comments.rb
|