linkedin-ruby 0.1.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 +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE +21 -0
- data/README.md +148 -0
- data/Rakefile +6 -0
- data/lib/linked_in/access_token.rb +24 -0
- data/lib/linked_in/api.rb +60 -0
- data/lib/linked_in/api_resource.rb +180 -0
- data/lib/linked_in/configuration.rb +41 -0
- data/lib/linked_in/connection.rb +32 -0
- data/lib/linked_in/errors.rb +48 -0
- data/lib/linked_in/mash.rb +68 -0
- data/lib/linked_in/oauth2.rb +223 -0
- data/lib/linked_in/organizations.rb +52 -0
- data/lib/linked_in/people.rb +62 -0
- data/lib/linked_in/raise_error.rb +16 -0
- data/lib/linked_in/share_and_social_stream.rb +47 -0
- data/lib/linked_in/version.rb +3 -0
- data/lib/linkedin-ruby.rb +47 -0
- data/linkedin-ruby.gemspec +50 -0
- metadata +178 -0
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'time'
|
2
|
+
module LinkedIn
|
3
|
+
# People APIs
|
4
|
+
#
|
5
|
+
# @see http://developer.linkedin.com/documents/people People API
|
6
|
+
# @see http://developer.linkedin.com/documents/profile-fields Profile Fields
|
7
|
+
# @see http://developer.linkedin.com/documents/field-selectors Field Selectors
|
8
|
+
# @see http://developer.linkedin.com/documents/accessing-out-network-profiles Accessing Out of Network Profiles
|
9
|
+
class People < APIResource
|
10
|
+
|
11
|
+
# @!macro multi_profile_options
|
12
|
+
# @options opts [Array] :urls A list of profile urls
|
13
|
+
# @options opts [Array] :ids List of LinkedIn IDs
|
14
|
+
#
|
15
|
+
# @!macro new profile_args
|
16
|
+
# @overload profile()
|
17
|
+
# Fetches your own profile
|
18
|
+
# @overload profile(id_or_url, opts)
|
19
|
+
# Fetches the profile of another user
|
20
|
+
# @param [String] id_or_url a LinkedIn id or a profile URL
|
21
|
+
# @param [Hash] opts more profile options
|
22
|
+
# @macro profile_options
|
23
|
+
# @overload profile(opts)
|
24
|
+
# Fetches the profile of another user
|
25
|
+
# @param [Hash] opts profile options
|
26
|
+
# @macro profile_options
|
27
|
+
# @return [LinkedIn::Mash]
|
28
|
+
|
29
|
+
# Retrieve a member's LinkedIn profile.
|
30
|
+
#
|
31
|
+
# Required permissions: r_basicprofile, r_fullprofile
|
32
|
+
#
|
33
|
+
# @see http://developer.linkedin.com/documents/profile-api
|
34
|
+
# @macro profile_args
|
35
|
+
# @macro multi_profile_options
|
36
|
+
def profile(id = {}, options = {})
|
37
|
+
options = parse_id(id, options)
|
38
|
+
path = profile_path(options)
|
39
|
+
get(path, options)
|
40
|
+
end
|
41
|
+
|
42
|
+
private ##############################################################
|
43
|
+
|
44
|
+
|
45
|
+
def parse_id(id, options)
|
46
|
+
if id.is_a? String
|
47
|
+
if id.downcase =~ /linkedin\.com/
|
48
|
+
options[:url] = id
|
49
|
+
else
|
50
|
+
options[:id] = id
|
51
|
+
end
|
52
|
+
elsif id.is_a? Hash
|
53
|
+
options = id
|
54
|
+
# else
|
55
|
+
# options = {}
|
56
|
+
end
|
57
|
+
|
58
|
+
return options
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
|
3
|
+
module LinkedIn
|
4
|
+
class RaiseError < Faraday::Response::RaiseError
|
5
|
+
def on_complete(response)
|
6
|
+
status_code = response.status.to_i
|
7
|
+
if status_code == 403 && response.body =~ /throttle/i
|
8
|
+
raise LinkedIn::ThrottleError
|
9
|
+
else
|
10
|
+
super
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
Faraday::Response.register_middleware :linkedin_raise_error => LinkedIn::RaiseError
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module LinkedIn
|
2
|
+
# Share and Social Stream APIs
|
3
|
+
#
|
4
|
+
# @see https://developer.linkedin.com/docs/guide/v2/shares
|
5
|
+
# @see https://developer.linkedin.com/docs/guide/v2/shares/share-api
|
6
|
+
# @see https://developer.linkedin.com/docs/guide/v2/shares/network-update-social-actions
|
7
|
+
#
|
8
|
+
# LinkedIn's v2 API adherence to the documentation is shaky at best. Several of
|
9
|
+
# the calls simply don't work if you, e.g., pass the URN in as a path element
|
10
|
+
# for a resource - you have to use the ids=[URN] format w/ a single URN. Or
|
11
|
+
# sometimes passing in an "actor" parameter in the request body simply doesn't
|
12
|
+
# work, and you have to pass it in as a URL parameter. What you see in this
|
13
|
+
# file is the result of trial-and-error getting these endpoints to work, and the
|
14
|
+
# inconsistency is usually a result of either misunderstanding the docs or the
|
15
|
+
# API not working as advertised. It's also a bit unclear when the API wants
|
16
|
+
# an activity URN vs, e.g., an article URN. Caveat emptor.
|
17
|
+
#
|
18
|
+
# [(contribute here)](https://github.com/mallowtechdev/linkedin-ruby)
|
19
|
+
class ShareAndSocialStream < APIResource
|
20
|
+
|
21
|
+
# Create one share from a person, organization, or organizationBrand.
|
22
|
+
#
|
23
|
+
# Permissions:
|
24
|
+
# 1.) For personal shares, you may only post shares as the authorized member.
|
25
|
+
# 2.) For organization shares, you may only post shares as an organization for which the
|
26
|
+
# authorized member is an administrator.
|
27
|
+
#
|
28
|
+
# @see https://developer.linkedin.com/docs/guide/v2/shares/share-api#post
|
29
|
+
#
|
30
|
+
# @option options [String] :owner, the URN of the entity posting the share.
|
31
|
+
# @return [LinkedIn::Mash]
|
32
|
+
#
|
33
|
+
def share(options = {})
|
34
|
+
path = '/shares'
|
35
|
+
defaults = {distribution:
|
36
|
+
{
|
37
|
+
linkedInDistributionTarget:
|
38
|
+
{
|
39
|
+
visibleToGuest: true
|
40
|
+
}
|
41
|
+
}
|
42
|
+
}
|
43
|
+
post(path, MultiJson.dump(defaults.merge(options)), 'Content-Type' => 'application/json')
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'oauth2'
|
2
|
+
|
3
|
+
require 'linked_in/errors'
|
4
|
+
require 'linked_in/raise_error'
|
5
|
+
require 'linked_in/version'
|
6
|
+
require 'linked_in/configuration'
|
7
|
+
|
8
|
+
# Responsible for all authentication
|
9
|
+
# LinkedIn::OAuth2 inherits from OAuth2::Client
|
10
|
+
require 'linked_in/oauth2'
|
11
|
+
|
12
|
+
# Wraps a LinkedIn-specifc API connection
|
13
|
+
# LinkedIn::Connection inherits from Faraday::Connection
|
14
|
+
require 'faraday'
|
15
|
+
require 'linked_in/connection'
|
16
|
+
|
17
|
+
# Data object to wrap API access token
|
18
|
+
require 'linked_in/access_token'
|
19
|
+
|
20
|
+
# Coerces LinkedIn JSON to a nice Ruby hash
|
21
|
+
# LinkedIn::Mash inherits from Hashie::Mash
|
22
|
+
require 'hashie'
|
23
|
+
require 'linked_in/mash'
|
24
|
+
|
25
|
+
# Endpoints inherit from APIResource
|
26
|
+
require 'linked_in/api_resource'
|
27
|
+
|
28
|
+
# All of the endpoints
|
29
|
+
require 'linked_in/people'
|
30
|
+
require 'linked_in/organizations'
|
31
|
+
require 'linked_in/share_and_social_stream'
|
32
|
+
|
33
|
+
# The primary API object that makes requests.
|
34
|
+
# It composes in all of the endpoints
|
35
|
+
require 'linked_in/api'
|
36
|
+
|
37
|
+
module LinkedIn
|
38
|
+
@config = Configuration.new
|
39
|
+
|
40
|
+
class << self
|
41
|
+
attr_accessor :config
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.configure
|
45
|
+
yield self.config
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'linked_in/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'linkedin-ruby'
|
7
|
+
spec.version = LinkedIn::VERSION
|
8
|
+
spec.authors = ['MallowTech Developers']
|
9
|
+
spec.email = ['developers@mallow-tech.com']
|
10
|
+
|
11
|
+
spec.summary = 'Ruby wrapper for the LinkedIn 2.0 API'
|
12
|
+
spec.description = spec.summary
|
13
|
+
spec.homepage = 'https://github.com/mallowtechdev/linkedin-ruby'
|
14
|
+
|
15
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
16
|
+
# # to allow pushing to a single host or delete this section to allow pushing to any host.
|
17
|
+
# if spec.respond_to?(:metadata)
|
18
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
19
|
+
#
|
20
|
+
# spec.metadata["homepage_uri"] = spec.homepage
|
21
|
+
# spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
|
22
|
+
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
23
|
+
# else
|
24
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
25
|
+
# "public gem pushes."
|
26
|
+
# end
|
27
|
+
|
28
|
+
# Specify which files should be added to the gem when it is released.
|
29
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
30
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
31
|
+
`git ls-files -z`.split("\x0").reject {|f| f.match(%r{^(test|spec|features)/})}
|
32
|
+
end
|
33
|
+
spec.bindir = 'exe'
|
34
|
+
spec.executables = spec.files.grep(%r{^exe/}) {|f| File.basename(f)}
|
35
|
+
spec.require_paths = ['lib']
|
36
|
+
|
37
|
+
spec.required_ruby_version = '>= 1.9.3'
|
38
|
+
|
39
|
+
spec.add_dependency 'faraday', '~> 0.15'
|
40
|
+
spec.add_dependency 'hashie', '~> 3.2'
|
41
|
+
spec.add_dependency 'oauth2', '~> 1.4'
|
42
|
+
|
43
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
44
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
45
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
46
|
+
|
47
|
+
# We use VCR to mock LinkedIn API calls
|
48
|
+
spec.add_development_dependency 'vcr'
|
49
|
+
spec.add_development_dependency 'webmock'
|
50
|
+
end
|
metadata
ADDED
@@ -0,0 +1,178 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: linkedin-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- MallowTech Developers
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-05-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.15'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.15'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: hashie
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.2'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.2'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: oauth2
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.4'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.4'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.16'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.16'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: vcr
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: webmock
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: Ruby wrapper for the LinkedIn 2.0 API
|
126
|
+
email:
|
127
|
+
- developers@mallow-tech.com
|
128
|
+
executables: []
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files: []
|
131
|
+
files:
|
132
|
+
- ".gitignore"
|
133
|
+
- ".rspec"
|
134
|
+
- ".travis.yml"
|
135
|
+
- CODE_OF_CONDUCT.md
|
136
|
+
- Gemfile
|
137
|
+
- LICENSE
|
138
|
+
- README.md
|
139
|
+
- Rakefile
|
140
|
+
- lib/linked_in/access_token.rb
|
141
|
+
- lib/linked_in/api.rb
|
142
|
+
- lib/linked_in/api_resource.rb
|
143
|
+
- lib/linked_in/configuration.rb
|
144
|
+
- lib/linked_in/connection.rb
|
145
|
+
- lib/linked_in/errors.rb
|
146
|
+
- lib/linked_in/mash.rb
|
147
|
+
- lib/linked_in/oauth2.rb
|
148
|
+
- lib/linked_in/organizations.rb
|
149
|
+
- lib/linked_in/people.rb
|
150
|
+
- lib/linked_in/raise_error.rb
|
151
|
+
- lib/linked_in/share_and_social_stream.rb
|
152
|
+
- lib/linked_in/version.rb
|
153
|
+
- lib/linkedin-ruby.rb
|
154
|
+
- linkedin-ruby.gemspec
|
155
|
+
homepage: https://github.com/mallowtechdev/linkedin-ruby
|
156
|
+
licenses: []
|
157
|
+
metadata: {}
|
158
|
+
post_install_message:
|
159
|
+
rdoc_options: []
|
160
|
+
require_paths:
|
161
|
+
- lib
|
162
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 1.9.3
|
167
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
168
|
+
requirements:
|
169
|
+
- - ">="
|
170
|
+
- !ruby/object:Gem::Version
|
171
|
+
version: '0'
|
172
|
+
requirements: []
|
173
|
+
rubyforge_project:
|
174
|
+
rubygems_version: 2.7.8
|
175
|
+
signing_key:
|
176
|
+
specification_version: 4
|
177
|
+
summary: Ruby wrapper for the LinkedIn 2.0 API
|
178
|
+
test_files: []
|