linkedin_orbit 0.0.2 → 0.1.4
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/.env.sample +0 -1
- data/Gemfile +2 -0
- data/Gemfile.lock +16 -3
- data/README.md +6 -4
- data/docs/FIRST_TIME_INSTRUCTIONS.md +12 -10
- data/lib/linkedin_orbit.rb +2 -0
- data/lib/linkedin_orbit/client.rb +6 -9
- data/lib/linkedin_orbit/interactions/comment.rb +9 -16
- data/lib/linkedin_orbit/linkedin.rb +11 -0
- data/lib/linkedin_orbit/version.rb +1 -1
- data/linkedin_orbit.gemspec +2 -0
- data/readme_images/new-comment-screenshot.png +0 -0
- data/scripts/check_comments.rb +1 -1
- metadata +31 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8796a2d61f0d7a8b454eb036291eef66e0b7f04ab5c9ffe36c7e4a6662dff34e
|
4
|
+
data.tar.gz: e083b2dc30609e1ee1d5cbf9f6c8e1d5b277e06cbf6f30580385aa64a900230b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2ee0f8697cd95f02737396538669b2cfae02851df3da05d44f63d9572c552e7c015ba258bfe57b94668d59d1d1459f42f20526b2b1c44524867d73b7cb3fbee
|
7
|
+
data.tar.gz: acf4c02bcacabc318df46775bb86e61aef4c93e8aacc1ca3eb3965853fbd2bf52eab142b6fb6a823fc632d8177afefdf1c267880fb6f824fe1dbab8a629b303e
|
data/.env.sample
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
linkedin_orbit (0.
|
4
|
+
linkedin_orbit (0.1.3)
|
5
|
+
dotenv (~> 2.7)
|
5
6
|
http (~> 4.4)
|
6
7
|
json (~> 2.5)
|
7
8
|
linkedin (~> 1.1)
|
9
|
+
orbit_activities (~> 0.1)
|
8
10
|
thor (~> 1.1)
|
9
11
|
zeitwerk (~> 2.4)
|
10
12
|
|
@@ -20,16 +22,21 @@ GEM
|
|
20
22
|
diff-lcs (1.4.4)
|
21
23
|
domain_name (0.5.20190701)
|
22
24
|
unf (>= 0.0.5, < 1.0.0)
|
23
|
-
|
25
|
+
dotenv (2.7.6)
|
26
|
+
faraday (1.4.2)
|
27
|
+
faraday-em_http (~> 1.0)
|
28
|
+
faraday-em_synchrony (~> 1.0)
|
24
29
|
faraday-excon (~> 1.1)
|
25
30
|
faraday-net_http (~> 1.0)
|
26
31
|
faraday-net_http_persistent (~> 1.1)
|
27
32
|
multipart-post (>= 1.2, < 3)
|
28
33
|
ruby2_keywords (>= 0.0.4)
|
34
|
+
faraday-em_http (1.0.0)
|
35
|
+
faraday-em_synchrony (1.0.0)
|
29
36
|
faraday-excon (1.1.0)
|
30
37
|
faraday-net_http (1.0.1)
|
31
38
|
faraday-net_http_persistent (1.1.0)
|
32
|
-
ffi (1.15.
|
39
|
+
ffi (1.15.1)
|
33
40
|
ffi-compiler (1.0.1)
|
34
41
|
ffi (>= 1.0.0)
|
35
42
|
rake
|
@@ -60,6 +67,11 @@ GEM
|
|
60
67
|
multi_json (~> 1.3)
|
61
68
|
multi_xml (~> 0.5)
|
62
69
|
rack (>= 1.2, < 3)
|
70
|
+
orbit_activities (0.1.0)
|
71
|
+
http (~> 4.4)
|
72
|
+
json (~> 2.5)
|
73
|
+
rake (~> 13.0)
|
74
|
+
zeitwerk (~> 2.4)
|
63
75
|
parallel (1.20.1)
|
64
76
|
parser (3.0.1.1)
|
65
77
|
ast (~> 2.4.1)
|
@@ -113,6 +125,7 @@ PLATFORMS
|
|
113
125
|
DEPENDENCIES
|
114
126
|
byebug
|
115
127
|
linkedin_orbit!
|
128
|
+
orbit_activities
|
116
129
|
rake (~> 13.0)
|
117
130
|
rspec (~> 3.4)
|
118
131
|
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
|
|-----------------------------------------|
|
@@ -20,7 +22,7 @@ The application requires the following environment variables:
|
|
20
22
|
|
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
26
|
| `LINKEDIN_ORGANIZATION` | LinkedIn Organization Page ID | Format: `urn:li:organization:#{id}`. ID is the set of numbers in 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`
|
@@ -43,7 +45,7 @@ You can instantiate a client by either passing in the required credentials durin
|
|
43
45
|
client = LinkedinOrbit::Client.new(
|
44
46
|
orbit_api_key: YOUR_API_KEY,
|
45
47
|
orbit_workspace_id: YOUR_ORBIT_WORKSPACE_ID,
|
46
|
-
|
48
|
+
linkedin_token: YOUR_LINKEDIN_TOKEN,
|
47
49
|
linkedin_organization: YOUR_LINKEDIN_ORGANIZATION_ID
|
48
50
|
)
|
49
51
|
```
|
@@ -66,7 +68,7 @@ client.comments
|
|
66
68
|
You can also use this package with the included CLI. To use the CLI pass in the required environment variables on the command line before invoking the CLI:
|
67
69
|
|
68
70
|
```bash
|
69
|
-
$ ORBIT_API_KEY=... ORBIT_WORKSPACE_ID=...
|
71
|
+
$ ORBIT_API_KEY=... ORBIT_WORKSPACE_ID=... LINKEDIN_TOKEN=... LINKEDIN_ORGANIZATION=... bundle exec linkedin_orbit --check_comments
|
70
72
|
```
|
71
73
|
## GitHub Actions Automation Setup
|
72
74
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# Instructions for First Time Set Up
|
2
2
|
|
3
|
-
These instructions will walk you through authenticating to LinkedIn, and receiving your LinkedIn
|
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
|
## Creating a LinkedIn Developers App
|
6
6
|
|
@@ -45,9 +45,9 @@ You will also see on the "Auth" page a section called "OAuth 2.0 Settings". We w
|
|
45
45
|
|
46
46
|
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
47
|
|
48
|
-
## LinkedIn
|
48
|
+
## LinkedIn Token
|
49
49
|
|
50
|
-
LinkedIn uses OAuth 2.0 as its authentication format, and as such, you need to authenticate *one
|
50
|
+
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
51
|
|
52
52
|
The `linkedin_orbit` integration includes an authentication application to facilitate this process for you. It requires that you have a [Heroku](https://www.heroku.com/) account. It is free to set up a Heroku account, and the one-time authentication app, is fine to run inside the free tier of the platform.
|
53
53
|
|
@@ -69,24 +69,26 @@ Copy the URL of the Heroku app in your browser address bar and return to the Lin
|
|
69
69
|
|
70
70
|
You will see a link appear called "+ Add redirect URL". Click on that link. In the text box that appears above it enter your Heroku app URL with "/auth/linkedin/callback" appended at the end. For example, if your Heroku URL was "https://example-heroku-app-url.herokuapp.com" then the full address you need to enter would be: "https://example-heroku-app-url.herokuapp.com/auth/linkedin/callback". When you are finished, click on the "Update" button.
|
71
71
|
|
72
|
-
Now, return back to your browser window with your Heroku app running. Click on the "LinkedIn" link on the app. Follow the prompts by LinkedIn to authorize your LinkedIn Developer application. When you are finished, you will be redirected back to your Heroku app and you will see a LinkedIn
|
72
|
+
Now, return back to your browser window with your Heroku app running. Click on the "LinkedIn" link on the app. Follow the prompts by LinkedIn to authorize your LinkedIn Developer application. When you are finished, you will be redirected back to your Heroku app and you will see a LinkedIn token. This token is very important. The token you see will be the credential used to authenticate to LinkedIn.
|
73
73
|
|
74
|
-
The last step you need to complete in this first time setup is to add the LinkedIn
|
74
|
+
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
75
|
|
76
|
-
## Add the LinkedIn
|
76
|
+
## Add the LinkedIn Token to the LinkedIn Orbit Community Integration
|
77
77
|
### Within GitHub Actions
|
78
78
|
|
79
79
|
*(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
80
|
|
81
|
-
The LinkedIn
|
81
|
+
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
82
|
|
83
83
|
### Within a Standalone App
|
84
84
|
|
85
|
-
If you are running the community integration as a standalone app, you can add the LinkedIn
|
85
|
+
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
86
|
|
87
|
-
Open up the `.env` file and add a new line starting with `
|
87
|
+
Open up the `.env` file and add a new line starting with `LINKEDIN_TOKEN=` and add the LinkedIn Code after the equal sign.
|
88
88
|
## Wrapping Up
|
89
89
|
|
90
|
-
You have now successfully finished the
|
90
|
+
You have now successfully finished the setup for your LinkedIn Orbit community integration. This steps needs to occur once every 60 days.
|
91
|
+
|
92
|
+
In between, you can safely delete the Heroku app you created and recreate a new one when you need to do this again.
|
91
93
|
|
92
94
|
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
@@ -1,6 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "linkedin"
|
4
|
+
require "dotenv/load"
|
5
|
+
require "net/http"
|
6
|
+
require "json"
|
4
7
|
|
5
8
|
# Create a client to log LinkedIn interactions in your Orbit workspace
|
6
9
|
# Credentials can either be passed in to the instance or be loaded
|
@@ -15,8 +18,8 @@ require "linkedin"
|
|
15
18
|
# @option params [String] :orbit_workspace
|
16
19
|
# The workspace ID for the Orbit workspace
|
17
20
|
#
|
18
|
-
# @option params [String] :
|
19
|
-
# The
|
21
|
+
# @option params [String] :linkedin_token
|
22
|
+
# The token obtained after authenticating with LinkedIn
|
20
23
|
# Required if value not provided for LINKEDIN_TOKEN environment variable
|
21
24
|
#
|
22
25
|
# @option params [String] :linkedin_organization
|
@@ -38,18 +41,12 @@ module LinkedinOrbit
|
|
38
41
|
def initialize(params = {})
|
39
42
|
@orbit_api_key = params.fetch(:orbit_api_key, ENV["ORBIT_API_KEY"])
|
40
43
|
@orbit_workspace = params.fetch(:orbit_workspace, ENV["ORBIT_WORKSPACE_ID"])
|
41
|
-
@linkedin_code = params[:linkedin_code] || ENV['LINKEDIN_CODE'] || nil
|
42
44
|
@linkedin_token = token
|
43
45
|
@linkedin_organization = params.fetch(:linkedin_organization, ENV["LINKEDIN_ORGANIZATION"])
|
44
46
|
end
|
45
47
|
|
46
48
|
def token
|
47
|
-
@token ||=
|
48
|
-
return ENV["LINKEDIN_TOKEN"] if ENV["LINKEDIN_TOKEN"]
|
49
|
-
|
50
|
-
linkedin = LinkedIn::Client.new(@linkedin_client_id, @linkedin_client_secret)
|
51
|
-
linkedin.authorize_from_access(ENV["LINKEDIN_CODE"])
|
52
|
-
end
|
49
|
+
@token ||= ENV["LINKEDIN_TOKEN"]
|
53
50
|
end
|
54
51
|
|
55
52
|
def comments
|
@@ -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,31 +15,25 @@ 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,
|
43
35
|
key: @comment["id"],
|
36
|
+
link: "https://www.linkedin.com/feed/update/#{@comment["object"]}",
|
44
37
|
member: {
|
45
38
|
name: name
|
46
39
|
}
|
@@ -12,6 +12,8 @@ module LinkedinOrbit
|
|
12
12
|
def process_comments
|
13
13
|
posts = get_posts
|
14
14
|
|
15
|
+
return posts unless posts.is_a?(Array)
|
16
|
+
|
15
17
|
posts.each do |post|
|
16
18
|
comments = get_post_comments(post["id"])
|
17
19
|
|
@@ -48,6 +50,15 @@ module LinkedinOrbit
|
|
48
50
|
|
49
51
|
response = JSON.parse(response.body)
|
50
52
|
|
53
|
+
return response["message"] if response["serviceErrorCode"]
|
54
|
+
|
55
|
+
if response["elements"].nil? || response["elements"].empty?
|
56
|
+
return <<~HEREDOC
|
57
|
+
No new posts to process from your LinkedIn organization.
|
58
|
+
If you suspect this is incorrect, verify your LinkedIn organization schema is correct in your credentials.
|
59
|
+
HEREDOC
|
60
|
+
end
|
61
|
+
|
51
62
|
response["elements"].each do |element|
|
52
63
|
posts << {
|
53
64
|
"id" => element["activity"],
|
data/linkedin_orbit.gemspec
CHANGED
@@ -31,6 +31,8 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.add_dependency "zeitwerk", "~> 2.4"
|
32
32
|
spec.add_dependency "thor", "~> 1.1"
|
33
33
|
spec.add_dependency "linkedin", "~> 1.1"
|
34
|
+
spec.add_dependency "dotenv", "~> 2.7"
|
35
|
+
spec.add_dependency "orbit_activities", "~> 0.1"
|
34
36
|
spec.add_development_dependency "rspec", "~> 3.4"
|
35
37
|
spec.add_development_dependency "webmock", "~> 3.12"
|
36
38
|
end
|
Binary file
|
data/scripts/check_comments.rb
CHANGED
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.1.4
|
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-06-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: http
|
@@ -81,6 +81,34 @@ dependencies:
|
|
81
81
|
- - "~>"
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '1.1'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: dotenv
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '2.7'
|
91
|
+
type: :runtime
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
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.1'
|
105
|
+
type: :runtime
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0.1'
|
84
112
|
- !ruby/object:Gem::Dependency
|
85
113
|
name: rspec
|
86
114
|
requirement: !ruby/object:Gem::Requirement
|
@@ -143,6 +171,7 @@ files:
|
|
143
171
|
- readme_images/linkedin_oauth_redirects.png
|
144
172
|
- readme_images/logo.png
|
145
173
|
- readme_images/marketing_platform_request_access.png
|
174
|
+
- readme_images/new-comment-screenshot.png
|
146
175
|
- readme_images/products_list.png
|
147
176
|
- readme_images/ways-to-use.png
|
148
177
|
- scripts/check_comments.rb
|