linkedin_orbit 0.2.0 → 0.3.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.lock +5 -6
- data/lib/linkedin_orbit/linkedin.rb +32 -21
- data/lib/linkedin_orbit/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d153344cbc2b2e493076481c82338b674c983304e812dfde4ea8b401e1ac17c
|
4
|
+
data.tar.gz: 01deb03d1642d62655ff4f63f5bbaafc8c0902396ff034b50c0c60bf83e613b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 982b06fd0771e316f10777898a0e7002af7a6d53dc6e790cc2c2e0720423813484362cdc954ed4136484fb238e1f728d4786d42024ff70c0ecf17a9683d0455a
|
7
|
+
data.tar.gz: 960f1217736db479c1088cfa9fa3ef317db1396e0142981af13aaf8b09b7ee1b4b7e196bbfa2fdb1d8653833ccb934d6cc69bbcbc3c5fcf02de7a97406cfc0de
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
linkedin_orbit (0.
|
4
|
+
linkedin_orbit (0.2.0)
|
5
5
|
dotenv (~> 2.7)
|
6
6
|
http (~> 4.4)
|
7
7
|
json (~> 2.5)
|
@@ -23,7 +23,7 @@ GEM
|
|
23
23
|
domain_name (0.5.20190701)
|
24
24
|
unf (>= 0.0.5, < 1.0.0)
|
25
25
|
dotenv (2.7.6)
|
26
|
-
faraday (1.5.
|
26
|
+
faraday (1.5.1)
|
27
27
|
faraday-em_http (~> 1.0)
|
28
28
|
faraday-em_synchrony (~> 1.0)
|
29
29
|
faraday-excon (~> 1.1)
|
@@ -77,12 +77,12 @@ GEM
|
|
77
77
|
rake (~> 13.0)
|
78
78
|
zeitwerk (~> 2.4)
|
79
79
|
parallel (1.20.1)
|
80
|
-
parser (3.0.
|
80
|
+
parser (3.0.2.0)
|
81
81
|
ast (~> 2.4.1)
|
82
82
|
public_suffix (4.0.6)
|
83
83
|
rack (2.2.3)
|
84
84
|
rainbow (3.0.0)
|
85
|
-
rake (13.0.
|
85
|
+
rake (13.0.6)
|
86
86
|
regexp_parser (2.1.1)
|
87
87
|
rexml (3.2.5)
|
88
88
|
rspec (3.10.0)
|
@@ -98,7 +98,7 @@ GEM
|
|
98
98
|
diff-lcs (>= 1.2.0, < 2.0)
|
99
99
|
rspec-support (~> 3.10.0)
|
100
100
|
rspec-support (3.10.2)
|
101
|
-
rubocop (1.18.
|
101
|
+
rubocop (1.18.3)
|
102
102
|
parallel (~> 1.10)
|
103
103
|
parser (>= 3.0.0.0)
|
104
104
|
rainbow (>= 2.2.2, < 4.0)
|
@@ -124,7 +124,6 @@ GEM
|
|
124
124
|
|
125
125
|
PLATFORMS
|
126
126
|
arm64-darwin-20
|
127
|
-
x86_64-linux
|
128
127
|
|
129
128
|
DEPENDENCIES
|
130
129
|
byebug
|
@@ -57,33 +57,44 @@ module LinkedinOrbit
|
|
57
57
|
|
58
58
|
def get_posts
|
59
59
|
posts = []
|
60
|
-
|
61
|
-
|
62
|
-
|
60
|
+
page = 0
|
61
|
+
count = 100
|
62
|
+
looped_at_least_once = false
|
63
63
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
64
|
+
while page >= 0
|
65
|
+
url = URI("https://api.linkedin.com/v2/shares?q=owners&owners=#{@linkedin_organization}&start=#{page}&count=#{count}")
|
66
|
+
https = Net::HTTP.new(url.host, url.port)
|
67
|
+
https.use_ssl = true
|
68
68
|
|
69
|
-
|
69
|
+
request = Net::HTTP::Get.new(url)
|
70
|
+
request["Accept"] = "application/json"
|
71
|
+
request["Content-Type"] = "application/json"
|
72
|
+
request["Authorization"] = "Bearer #{@linkedin_token}"
|
70
73
|
|
71
|
-
|
74
|
+
response = https.request(request)
|
72
75
|
|
73
|
-
|
76
|
+
response = JSON.parse(response.body)
|
74
77
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
78
|
+
return response["message"] if response["serviceErrorCode"]
|
79
|
+
|
80
|
+
if response["elements"].nil? || response["elements"].empty?
|
81
|
+
return <<~HEREDOC
|
82
|
+
No new posts to process from your LinkedIn organization.
|
83
|
+
If you suspect this is incorrect, verify your LinkedIn organization schema is correct in your credentials.
|
84
|
+
HEREDOC
|
85
|
+
end
|
86
|
+
|
87
|
+
response["elements"].each do |element|
|
88
|
+
posts << {
|
89
|
+
"id" => element["activity"],
|
90
|
+
"message_highlight" => element["text"]["text"][0, 40]
|
91
|
+
}
|
92
|
+
end
|
93
|
+
|
94
|
+
break if response["elements"].count < count
|
81
95
|
|
82
|
-
|
83
|
-
|
84
|
-
"id" => element["activity"],
|
85
|
-
"message_highlight" => element["text"]["text"][0, 40]
|
86
|
-
}
|
96
|
+
looped_at_least_once = true
|
97
|
+
page += 1 if looped_at_least_once
|
87
98
|
end
|
88
99
|
|
89
100
|
posts
|
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.3.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-07-
|
12
|
+
date: 2021-07-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: http
|