linkedin-oauth2 0.1.1 → 1.0.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 +9 -9
- data/.gitignore +24 -39
- data/.travis.yml +4 -4
- data/.yardopts +2 -0
- data/CHANGELOG.md +10 -0
- data/CONTRIBUTING.md +1 -0
- data/Gemfile +6 -5
- data/LICENSE +19 -17
- data/README.md +399 -0
- data/Rakefile +15 -22
- data/lib/linked_in/access_token.rb +24 -0
- data/lib/linked_in/api.rb +96 -3
- data/lib/linked_in/api_resource.rb +165 -0
- data/lib/linked_in/communications.rb +40 -0
- data/lib/linked_in/companies.rb +146 -0
- data/lib/linked_in/configuration.rb +41 -0
- data/lib/linked_in/connection.rb +31 -0
- data/lib/linked_in/errors.rb +33 -13
- data/lib/linked_in/groups.rb +116 -0
- data/lib/linked_in/jobs.rb +68 -0
- data/lib/linked_in/mash.rb +34 -34
- data/lib/linked_in/oauth2.rb +223 -0
- data/lib/linked_in/people.rb +141 -0
- data/lib/linked_in/search.rb +58 -43
- data/lib/linked_in/share_and_social_stream.rb +128 -0
- data/lib/linked_in/version.rb +1 -9
- data/lib/linkedin-oauth2.rb +43 -25
- data/linkedin-oauth2.gemspec +35 -21
- data/spec/linked_in/api/api_spec.rb +41 -0
- data/spec/linked_in/api/communications_spec.rb +13 -0
- data/spec/linked_in/api/companies_spec.rb +59 -0
- data/spec/linked_in/api/groups_spec.rb +55 -0
- data/spec/linked_in/api/jobs_spec.rb +33 -0
- data/spec/linked_in/api/people_spec.rb +181 -0
- data/spec/linked_in/api/search_spec.rb +71 -0
- data/spec/linked_in/api/share_and_social_stream_spec.rb +60 -0
- data/spec/linked_in/configuration_spec.rb +46 -0
- data/spec/linked_in/connection_spec.rb +10 -0
- data/spec/linked_in/module_loading_spec.rb +23 -0
- data/spec/linked_in/oauth/access_token_spec.rb +27 -0
- data/spec/linked_in/oauth/auth_code_spec.rb +86 -0
- data/spec/linked_in/oauth/credentials_spec.rb +96 -0
- data/spec/linked_in/oauth/get_access_token_spec.rb +108 -0
- data/spec/spec_helper.rb +15 -0
- data/spec/vcr_cassettes/access_token_success.yml +84 -0
- data/spec/vcr_cassettes/bad_code.yml +78 -0
- data/spec/vcr_cassettes/companies_data.yml +44 -0
- data/spec/vcr_cassettes/invalid_access_token.yml +60 -0
- data/spec/vcr_cassettes/not_found.yml +64 -0
- data/spec/vcr_cassettes/people_picture_urls.yml +54 -0
- data/spec/vcr_cassettes/people_profile_connections_fields.yml +73 -0
- data/spec/vcr_cassettes/people_profile_connections_other.yml +78 -0
- data/spec/vcr_cassettes/people_profile_connections_self.yml +78 -0
- data/spec/vcr_cassettes/people_profile_fields_complex.yml +70 -0
- data/spec/vcr_cassettes/people_profile_fields_simple.yml +57 -0
- data/spec/vcr_cassettes/people_profile_lang_spanish.yml +59 -0
- data/spec/vcr_cassettes/people_profile_multiple_fields.yml +68 -0
- data/spec/vcr_cassettes/people_profile_multiple_uids.yml +70 -0
- data/spec/vcr_cassettes/people_profile_multiple_uids_and_urls.yml +76 -0
- data/spec/vcr_cassettes/people_profile_multiple_urls.yml +70 -0
- data/spec/vcr_cassettes/people_profile_new_connections_fields.yml +69 -0
- data/spec/vcr_cassettes/people_profile_new_connections_other.yml +72 -0
- data/spec/vcr_cassettes/people_profile_new_connections_self.yml +72 -0
- data/spec/vcr_cassettes/people_profile_other_uid.yml +59 -0
- data/spec/vcr_cassettes/people_profile_other_url.yml +59 -0
- data/spec/vcr_cassettes/people_profile_own.yml +59 -0
- data/spec/vcr_cassettes/people_profile_own_secure.yml +59 -0
- data/spec/vcr_cassettes/unauthorized.yml +61 -0
- data/spec/vcr_cassettes/unavailable.yml +81 -0
- metadata +145 -88
- data/.autotest +0 -14
- data/.document +0 -5
- data/.gemtest +0 -0
- data/.rspec +0 -1
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
- data/README.markdown +0 -121
- data/changelog.markdown +0 -94
- data/examples/authenticate.rb +0 -16
- data/examples/network.rb +0 -12
- data/examples/profile.rb +0 -18
- data/examples/sinatra.rb +0 -69
- data/examples/status.rb +0 -6
- data/lib/linked_in/api/query_methods.rb +0 -123
- data/lib/linked_in/api/update_methods.rb +0 -76
- data/lib/linked_in/client.rb +0 -31
- data/lib/linked_in/helpers.rb +0 -6
- data/lib/linked_in/helpers/authorization.rb +0 -106
- data/lib/linked_in/helpers/request.rb +0 -93
- data/spec/cases/api_spec.rb +0 -192
- data/spec/cases/linkedin_spec.rb +0 -37
- data/spec/cases/mash_spec.rb +0 -85
- data/spec/cases/oauth_spec.rb +0 -130
- data/spec/cases/search_spec.rb +0 -190
- data/spec/helper.rb +0 -30
data/linkedin-oauth2.gemspec
CHANGED
@@ -1,25 +1,39 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
|
2
|
+
# Follow http://guides.rubygems.org/ best practices
|
3
|
+
|
4
|
+
require File.expand_path("../lib/linked_in/version", __FILE__)
|
3
5
|
|
4
6
|
Gem::Specification.new do |gem|
|
5
|
-
gem.
|
6
|
-
gem.
|
7
|
-
gem.
|
8
|
-
gem.
|
9
|
-
gem.
|
10
|
-
gem.
|
11
|
-
gem.
|
12
|
-
gem.
|
13
|
-
|
14
|
-
gem.
|
15
|
-
gem.
|
16
|
-
gem.
|
17
|
-
|
18
|
-
|
19
|
-
gem.
|
20
|
-
|
21
|
-
gem.
|
22
|
-
gem.
|
23
|
-
gem.
|
24
|
-
|
7
|
+
gem.name = "linkedin-oauth2"
|
8
|
+
gem.email = ["evan@evanmorikawa.com"]
|
9
|
+
gem.version = LinkedIn::VERSION
|
10
|
+
gem.authors = ["Evan Morikawa"]
|
11
|
+
gem.summary = "Ruby wrapper for the LinkedIn OAuth 2.0 API"
|
12
|
+
gem.license = "MIT"
|
13
|
+
gem.homepage = "http://github.com/emorikawa/linkedin-oauth2"
|
14
|
+
gem.description = gem.summary
|
15
|
+
|
16
|
+
gem.files = `git ls-files`.split("\n")
|
17
|
+
gem.test_files = `git ls-files -- spec/**/*`.split("\n")
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
# To support native JSON. Same requirements as Rails.
|
21
|
+
gem.required_ruby_version = '>= 1.9.3'
|
22
|
+
|
23
|
+
gem.add_dependency "oauth2", "~> 1.0"
|
24
|
+
gem.add_dependency "hashie", "~> 3.2"
|
25
|
+
gem.add_dependency "faraday", "~> 0.9"
|
26
|
+
|
27
|
+
gem.add_development_dependency "rake"
|
28
|
+
gem.add_development_dependency "rspec", "~> 3.0"
|
29
|
+
|
30
|
+
# We use YARD for documentation
|
31
|
+
# Extra gems for GitHub flavored MarkDown in YARD
|
32
|
+
gem.add_development_dependency "yard"
|
33
|
+
gem.add_development_dependency "redcarpet"
|
34
|
+
gem.add_development_dependency "github-markdown"
|
35
|
+
|
36
|
+
# We use VCR to mock LinkedIn API calls
|
37
|
+
gem.add_development_dependency "vcr"
|
38
|
+
gem.add_development_dependency "webmock"
|
25
39
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe LinkedIn::API do
|
4
|
+
context "With no access token" do
|
5
|
+
let(:err_msg) { LinkedIn::ErrorMessages.no_access_token }
|
6
|
+
|
7
|
+
it "Raises an error" do
|
8
|
+
expect{LinkedIn::API.new}.to raise_error(LinkedIn::InvalidRequest, err_msg)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
shared_examples "test access token" do
|
13
|
+
it "Build a LinkedIn::API instance" do
|
14
|
+
expect(subject).to be_kind_of LinkedIn::API
|
15
|
+
end
|
16
|
+
|
17
|
+
it "Sets the access_token object" do
|
18
|
+
expect(subject.access_token).to be_kind_of LinkedIn::AccessToken
|
19
|
+
end
|
20
|
+
|
21
|
+
it "Sets the access_token string" do
|
22
|
+
expect(subject.access_token.token).to eq access_token
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context "With a string access token" do
|
27
|
+
let(:access_token) { "dummy_access_token" }
|
28
|
+
subject {LinkedIn::API.new(access_token)}
|
29
|
+
|
30
|
+
include_examples "test access token"
|
31
|
+
end
|
32
|
+
|
33
|
+
context "With a LinkedIn::AccessToken object" do
|
34
|
+
let(:access_token) { "dummy_access_token" }
|
35
|
+
let(:access_token_obj) { LinkedIn::AccessToken.new(access_token) }
|
36
|
+
|
37
|
+
subject {LinkedIn::API.new(access_token_obj)}
|
38
|
+
|
39
|
+
include_examples "test access token"
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe LinkedIn::Communications do
|
4
|
+
let(:access_token) {"dummy_access_token"}
|
5
|
+
let(:api) {LinkedIn::API.new(access_token)}
|
6
|
+
|
7
|
+
it "should be able to send a message" do
|
8
|
+
stub_request(:post, "https://api.linkedin.com/v1/people/~/mailbox?oauth2_access_token=dummy_access_token").to_return(body: "", status: 201)
|
9
|
+
response = api.send_message("subject", "body", ["recip1", "recip2"])
|
10
|
+
expect(response.body).to eq ""
|
11
|
+
expect(response.status).to eq 201
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe LinkedIn::Companies do
|
4
|
+
let(:access_token) {"dummy_access_token"}
|
5
|
+
let(:api) {LinkedIn::API.new(access_token)}
|
6
|
+
|
7
|
+
def stub(url)
|
8
|
+
url += "oauth2_access_token=#{access_token}"
|
9
|
+
stub_request(:get, url).to_return(body: '{}')
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should be able to view a company profile" do
|
13
|
+
stub("https://api.linkedin.com/v1/companies/1586?")
|
14
|
+
expect(api.company(id: 1586)).to be_an_instance_of(LinkedIn::Mash)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should be able to view a company by universal name" do
|
18
|
+
stub("https://api.linkedin.com/v1/companies/universal-name=acme?")
|
19
|
+
expect(api.company(name: "acme")).to be_an_instance_of(LinkedIn::Mash)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should be able to view a company by e-mail domain" do
|
23
|
+
stub("https://api.linkedin.com/v1/companies?email-domain=acme.com&")
|
24
|
+
expect(api.company(domain: "acme.com")).to be_an_instance_of(LinkedIn::Mash)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should load correct company data" do
|
28
|
+
VCR.use_cassette("companies data") do
|
29
|
+
data = api.company(id: 1586, fields: %w{ id name industry locations:(address:(city state country-code) is-headquarters) employee-count-range })
|
30
|
+
expect(data.id).to eq 1586
|
31
|
+
expect(data.name).to eq "Amazon"
|
32
|
+
expect(data.industry).to eq "Internet"
|
33
|
+
expect(data.employee_count_range.name).to eq "10001+"
|
34
|
+
expect(data.locations.all[0].address.city).to eq "Seattle"
|
35
|
+
expect(data.locations.all[0].is_headquarters).to eq true
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should be able to share a new company status" do
|
40
|
+
stub_request(:post, "https://api.linkedin.com/v1/companies/123456/shares?oauth2_access_token=#{access_token}").to_return(body: "", status: 201)
|
41
|
+
response = api.add_company_share("123456", { comment: "Testing, 1, 2, 3" })
|
42
|
+
expect(response.body).to eq ""
|
43
|
+
expect(response.status).to eq 201
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should be able to follow a company" do
|
47
|
+
stub_request(:post, "https://api.linkedin.com/v1/people/~/following/companies?oauth2_access_token=#{access_token}").to_return(body: "", status: 201)
|
48
|
+
response = api.follow_company(1586)
|
49
|
+
expect(response.body).to eq ""
|
50
|
+
expect(response.status).to eq 201
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should be able to unfollow a company" do
|
54
|
+
stub_request(:delete, "https://api.linkedin.com/v1/people/~/following/companies/id=1586?oauth2_access_token=#{access_token}").to_return(body: "", status: 201)
|
55
|
+
response = api.unfollow_company(1586)
|
56
|
+
expect(response.body).to eq ""
|
57
|
+
expect(response.status).to eq 201
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe LinkedIn::Groups do
|
4
|
+
let(:access_token) {"dummy_access_token"}
|
5
|
+
let(:api) {LinkedIn::API.new(access_token)}
|
6
|
+
|
7
|
+
def stub(url)
|
8
|
+
url += "oauth2_access_token=#{access_token}"
|
9
|
+
stub_request(:get, url).to_return(body: '{}')
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should be able to list group memberships for a profile" do
|
13
|
+
stub("https://api.linkedin.com/v1/people/~/group-memberships?")
|
14
|
+
expect(api.group_memberships).to be_an_instance_of(LinkedIn::Mash)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should be able to list suggested groups for a profile" do
|
18
|
+
stub("https://api.linkedin.com/v1/people/~/suggestions/groups?")
|
19
|
+
expect(api.group_suggestions).to be_an_instance_of(LinkedIn::Mash)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should be able to parse nested fields" do
|
23
|
+
stub("https://api.linkedin.com/v1/people/~/group-memberships:(group:(id,name,small-logo-url,short-description))?")
|
24
|
+
expect(api.group_memberships(fields: [{group: ["id",
|
25
|
+
"name",
|
26
|
+
"small-logo-url",
|
27
|
+
"short-description"]}])
|
28
|
+
).to be_an_instance_of(LinkedIn::Mash)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should be able to join a group" do
|
32
|
+
stub_request(:put, "https://api.linkedin.com/v1/people/~/group-memberships/123?oauth2_access_token=#{access_token}").to_return(body: "", status: 201)
|
33
|
+
|
34
|
+
response = api.join_group(123)
|
35
|
+
expect(response.body).to eq ""
|
36
|
+
expect(response.status).to eq 201
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should be able to list a group profile" do
|
40
|
+
stub("https://api.linkedin.com/v1/groups/123?")
|
41
|
+
expect(api.group_profile(:id => 123)).to be_an_instance_of(LinkedIn::Mash)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should be able to list group posts" do
|
45
|
+
stub("https://api.linkedin.com/v1/groups/123/posts?")
|
46
|
+
expect(api.group_posts(:id => 123)).to be_an_instance_of(LinkedIn::Mash)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should be able to share a new group status" do
|
50
|
+
stub_request(:post, "https://api.linkedin.com/v1/groups/1/posts?oauth2_access_token=#{access_token}").to_return(body: "", status: 201)
|
51
|
+
response = api.add_group_share(1, comment: "Testing, 1, 2, 3")
|
52
|
+
expect(response.body).to eq ""
|
53
|
+
expect(response.status).to eq 201
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe LinkedIn::Jobs, helpers: :api do
|
4
|
+
let(:access_token) {"dummy_access_token"}
|
5
|
+
let(:api) {LinkedIn::API.new(access_token)}
|
6
|
+
|
7
|
+
def stub(url)
|
8
|
+
url += "oauth2_access_token=#{access_token}"
|
9
|
+
stub_request(:get, url).to_return(body: '{}')
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should be able to view a job listing" do
|
13
|
+
stub("https://api.linkedin.com/v1/jobs/id=1586?")
|
14
|
+
expect(api.job(:id => 1586)).to be_an_instance_of(LinkedIn::Mash)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should be able to view its job bookmarks" do
|
18
|
+
stub("https://api.linkedin.com/v1/people/~/job-bookmarks?")
|
19
|
+
expect(api.job_bookmarks).to be_an_instance_of(LinkedIn::Mash)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should be able to view its job suggestion" do
|
23
|
+
stub("https://api.linkedin.com/v1/people/~/suggestions/job-suggestions?")
|
24
|
+
expect(api.job_suggestions).to be_an_instance_of(LinkedIn::Mash)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should be able to add a bookmark" do
|
28
|
+
stub_request(:post, "https://api.linkedin.com/v1/people/~/job-bookmarks?oauth2_access_token=#{access_token}").to_return(body: "", status: 201)
|
29
|
+
response = api.add_job_bookmark(id: 1452577)
|
30
|
+
expect(response.body).to eq ""
|
31
|
+
expect(response.status).to eq 201
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,181 @@
|
|
1
|
+
describe LinkedIn::People do
|
2
|
+
let(:uid) {"SDmkCxL2ya"}
|
3
|
+
let(:url) {"http://www.linkedin.com/in/evanmorikawa"}
|
4
|
+
let(:access_token) {"dummy_access_token"}
|
5
|
+
|
6
|
+
let(:api) {LinkedIn::API.new(access_token)}
|
7
|
+
|
8
|
+
def verify(result)
|
9
|
+
expect(result).to be_kind_of LinkedIn::Mash
|
10
|
+
end
|
11
|
+
|
12
|
+
###### PROFILES
|
13
|
+
# Self
|
14
|
+
it "grabs your own profile" do
|
15
|
+
VCR.use_cassette("people profile own") do
|
16
|
+
result = api.profile
|
17
|
+
verify result
|
18
|
+
expect(result["firstName"]).to be_kind_of String
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# Secure
|
23
|
+
it "accepts secure-urls param via secure option" do
|
24
|
+
VCR.use_cassette("people profile own secure") do
|
25
|
+
verify api.profile(secure: true)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# Language
|
30
|
+
it "gets profiles in a different language" do
|
31
|
+
VCR.use_cassette("people profile lang spanish") do
|
32
|
+
verify api.profile(lang: "es")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# Others
|
37
|
+
it "gets another users profile by user id" do
|
38
|
+
VCR.use_cassette("people profile other uid") do
|
39
|
+
result = api.profile(id: uid)
|
40
|
+
verify result
|
41
|
+
expect(result["firstName"]).to be_kind_of String
|
42
|
+
end
|
43
|
+
end
|
44
|
+
it "gets another users profile by url" do
|
45
|
+
VCR.use_cassette("people profile other url") do
|
46
|
+
result = api.profile(url: url)
|
47
|
+
verify result
|
48
|
+
expect(result["firstName"]).to be_kind_of String
|
49
|
+
end
|
50
|
+
end
|
51
|
+
it "gets another users profile by user id" do
|
52
|
+
VCR.use_cassette("people profile other uid") do
|
53
|
+
verify api.profile(uid)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
it "gets another users profile by url" do
|
57
|
+
VCR.use_cassette("people profile other url") do
|
58
|
+
verify api.profile(url)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# Errors
|
63
|
+
it "errors on bad input" do
|
64
|
+
expect{api.profile("Bad input")}.to raise_error
|
65
|
+
end
|
66
|
+
it "errors on email deprecation" do
|
67
|
+
msg = LinkedIn::ErrorMessages.deprecated
|
68
|
+
expect{api.profile(email: "email@email.com")}.to raise_error(LinkedIn::Deprecated, msg)
|
69
|
+
end
|
70
|
+
|
71
|
+
# Fields
|
72
|
+
it "grabs certain profile fields" do
|
73
|
+
VCR.use_cassette("people profile fields simple") do
|
74
|
+
result = api.profile(fields: ["id","industry"])
|
75
|
+
verify result
|
76
|
+
expect(result["industry"]).to be_kind_of String
|
77
|
+
end
|
78
|
+
end
|
79
|
+
it "grabs more complex profile fields" do
|
80
|
+
VCR.use_cassette("people profile fields complex") do
|
81
|
+
result = api.profile(fields: ["id",{"positions" => ["title"]}])
|
82
|
+
verify result
|
83
|
+
expect(result["positions"]["values"][0]["title"]).to be_kind_of String
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# Multiple people
|
88
|
+
it "grabs multiple people by uids" do
|
89
|
+
VCR.use_cassette("people profile multiple uids") do
|
90
|
+
result = api.profile(ids: ["self", uid])
|
91
|
+
verify result
|
92
|
+
expect(result["values"].length).to eq 2
|
93
|
+
end
|
94
|
+
end
|
95
|
+
it "grabs multiple people by urls" do
|
96
|
+
VCR.use_cassette("people profile multiple urls") do
|
97
|
+
result = api.profile(urls: ["self", url])
|
98
|
+
verify result
|
99
|
+
expect(result["values"].length).to eq 2
|
100
|
+
end
|
101
|
+
end
|
102
|
+
it "grabs multiple people by uids and urls" do
|
103
|
+
VCR.use_cassette("people profile multiple uids and urls") do
|
104
|
+
result = api.profile(ids: ["self", uid], urls: [url])
|
105
|
+
verify result
|
106
|
+
expect(result["values"].length).to eq 3
|
107
|
+
end
|
108
|
+
end
|
109
|
+
it "grabs certain fields for multiple people" do
|
110
|
+
VCR.use_cassette("people profile multiple fields") do
|
111
|
+
result = api.profile(ids: ["self", uid], fields: ["id", "industry"])
|
112
|
+
verify result
|
113
|
+
expect(result["values"][0]["industry"]).to be_kind_of String
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
###### CONNECTIONS
|
118
|
+
it "grabs your own connections" do
|
119
|
+
VCR.use_cassette("people profile connections self") do
|
120
|
+
result = api.connections
|
121
|
+
verify result
|
122
|
+
expect(result["values"].length).to eq 3
|
123
|
+
end
|
124
|
+
end
|
125
|
+
it "grabs the connections of others" do
|
126
|
+
VCR.use_cassette("people profile connections other") do
|
127
|
+
result = api.connections(id: uid)
|
128
|
+
verify result
|
129
|
+
expect(result["values"].length).to eq 3
|
130
|
+
end
|
131
|
+
end
|
132
|
+
it "grabs certain fields for those connections" do
|
133
|
+
VCR.use_cassette("people profile connections fields") do
|
134
|
+
result = api.connections(fields: ["id", "industry"])
|
135
|
+
verify result
|
136
|
+
expect(result["values"].length).to eq 4
|
137
|
+
expect(result["values"][0]["industry"]).to be_kind_of String
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
it "grabs new connections since a string date" do
|
142
|
+
VCR.use_cassette("people profile new connections self") do
|
143
|
+
result = api.new_connections("2014-01-01")
|
144
|
+
verify result
|
145
|
+
expect(result["values"].length).to eq 2
|
146
|
+
end
|
147
|
+
end
|
148
|
+
it "grabs new connections since a numeric date" do
|
149
|
+
VCR.use_cassette("people profile new connections self") do
|
150
|
+
verify api.new_connections(1388534400000)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
it "grabs new connections since a Time.utc object" do
|
154
|
+
VCR.use_cassette("people profile new connections self") do
|
155
|
+
verify api.new_connections(Time.utc(2014,1,1))
|
156
|
+
end
|
157
|
+
end
|
158
|
+
it "grabs new connections for another user" do
|
159
|
+
VCR.use_cassette("people profile new connections other") do
|
160
|
+
result = api.new_connections("2014-01-01", id: uid)
|
161
|
+
verify result
|
162
|
+
expect(result["values"].length).to eq 2
|
163
|
+
end
|
164
|
+
end
|
165
|
+
it "grabs certain fields of new connections" do
|
166
|
+
VCR.use_cassette("people profile new connections fields") do
|
167
|
+
result = api.new_connections("2014-01-01", fields: ["id", "industry"])
|
168
|
+
verify result
|
169
|
+
expect(result["values"].length).to eq 3
|
170
|
+
expect(result["values"][0]["industry"]).to be_kind_of String
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
it "grabs picture urls" do
|
175
|
+
VCR.use_cassette("people picture urls") do
|
176
|
+
result = api.picture_urls
|
177
|
+
verify result
|
178
|
+
expect(result["values"][0] =~ URI::regexp).to_not be_nil
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|