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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 72da0485d3741083f4f16250d750ecbae919d67a54a5aca51d8a00d73d8a0719
4
- data.tar.gz: 88b8658762763e70dd9a3bec29d040ec025b5ff6d6ad31f1ce89f30bd58ac95b
3
+ metadata.gz: 0d153344cbc2b2e493076481c82338b674c983304e812dfde4ea8b401e1ac17c
4
+ data.tar.gz: 01deb03d1642d62655ff4f63f5bbaafc8c0902396ff034b50c0c60bf83e613b8
5
5
  SHA512:
6
- metadata.gz: 05ddc9104e36e1a798640ec2ec275c68aed856108f17ad200aed418610fb6b7b2b72ac394fca1fc54b4b317aae3d6892bf63c10b7a8ef4e263dd1116ead8ab39
7
- data.tar.gz: ab9e3c2911639813bc048005b02998f3f5102c17a1a7675c3f701fd192c0bc78c1477ad85f527004bd137afe3c88346750c0696be0d77809fe04b8fb7801808c
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.1.4)
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.0)
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.1.1)
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.3)
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.2)
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
- url = URI("https://api.linkedin.com/v2/shares?q=owners&owners=#{@linkedin_organization}")
61
- https = Net::HTTP.new(url.host, url.port)
62
- https.use_ssl = true
60
+ page = 0
61
+ count = 100
62
+ looped_at_least_once = false
63
63
 
64
- request = Net::HTTP::Get.new(url)
65
- request["Accept"] = "application/json"
66
- request["Content-Type"] = "application/json"
67
- request["Authorization"] = "Bearer #{@linkedin_token}"
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
- response = https.request(request)
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
- response = JSON.parse(response.body)
74
+ response = https.request(request)
72
75
 
73
- return response["message"] if response["serviceErrorCode"]
76
+ response = JSON.parse(response.body)
74
77
 
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
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
- response["elements"].each do |element|
83
- posts << {
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LinkedinOrbit
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  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.2.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-06 00:00:00.000000000 Z
12
+ date: 2021-07-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: http