linkedin 0.2.2 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. data/{spec/fixtures/blank.xml → .gemtest} +0 -0
  2. data/.gitignore +36 -21
  3. data/.rspec +3 -0
  4. data/.travis.yml +6 -0
  5. data/Gemfile +6 -2
  6. data/Rakefile +9 -31
  7. data/changelog.markdown +1 -1
  8. data/lib/linked_in/api/query_methods.rb +49 -0
  9. data/lib/linked_in/api/update_methods.rb +54 -0
  10. data/lib/linked_in/client.rb +44 -147
  11. data/lib/linked_in/errors.rb +20 -0
  12. data/lib/linked_in/helpers/authorization.rb +67 -0
  13. data/lib/linked_in/helpers/request.rb +77 -0
  14. data/lib/linked_in/mash.rb +68 -0
  15. data/lib/linked_in/search.rb +34 -0
  16. data/lib/linked_in/version.rb +11 -0
  17. data/lib/linkedin.rb +4 -55
  18. data/linkedin.gemspec +26 -47
  19. data/spec/cases/client_spec.rb +260 -276
  20. data/spec/cases/linkedin_spec.rb +6 -6
  21. data/spec/cases/mash_spec.rb +85 -0
  22. data/spec/cases/oauth_spec.rb +146 -92
  23. data/spec/fixtures/cassette_library/LinkedIn_Client/_authorize_from_request.yml +28 -0
  24. data/spec/fixtures/cassette_library/LinkedIn_Client/_request_token.yml +28 -0
  25. data/spec/fixtures/cassette_library/LinkedIn_Client/_request_token/with_a_callback_url.yml +28 -0
  26. data/spec/fixtures/cassette_library/LinkedIn_Client/_request_token/with_default_options.yml +28 -0
  27. data/spec/helper.rb +30 -0
  28. metadata +139 -169
  29. data/VERSION +0 -1
  30. data/lib/linked_in/api_standard_profile_request.rb +0 -17
  31. data/lib/linked_in/authorization_helpers.rb +0 -48
  32. data/lib/linked_in/base.rb +0 -13
  33. data/lib/linked_in/birthdate.rb +0 -21
  34. data/lib/linked_in/company.rb +0 -11
  35. data/lib/linked_in/connections.rb +0 -16
  36. data/lib/linked_in/country.rb +0 -9
  37. data/lib/linked_in/current_share.rb +0 -56
  38. data/lib/linked_in/education.rb +0 -41
  39. data/lib/linked_in/error.rb +0 -21
  40. data/lib/linked_in/group.rb +0 -32
  41. data/lib/linked_in/languages.rb +0 -28
  42. data/lib/linked_in/likes.rb +0 -23
  43. data/lib/linked_in/location.rb +0 -13
  44. data/lib/linked_in/message.rb +0 -20
  45. data/lib/linked_in/network.rb +0 -12
  46. data/lib/linked_in/patents.rb +0 -42
  47. data/lib/linked_in/people.rb +0 -18
  48. data/lib/linked_in/person.rb +0 -7
  49. data/lib/linked_in/phone_number.rb +0 -29
  50. data/lib/linked_in/position.rb +0 -46
  51. data/lib/linked_in/profile.rb +0 -85
  52. data/lib/linked_in/publications.rb +0 -40
  53. data/lib/linked_in/recipient.rb +0 -7
  54. data/lib/linked_in/recipients.rb +0 -18
  55. data/lib/linked_in/recommendations.rb +0 -30
  56. data/lib/linked_in/short_profile.rb +0 -13
  57. data/lib/linked_in/skill.rb +0 -33
  58. data/lib/linked_in/to_xml_helpers.rb +0 -53
  59. data/lib/linked_in/update.rb +0 -23
  60. data/lib/linked_in/url_resource.rb +0 -26
  61. data/spec/fixtures/connections.xml +0 -3733
  62. data/spec/fixtures/error.xml +0 -7
  63. data/spec/fixtures/likes.xml +0 -18
  64. data/spec/fixtures/mailbox_items.xml +0 -16
  65. data/spec/fixtures/network_status_with_group.xml +0 -44
  66. data/spec/fixtures/network_statuses.xml +0 -317
  67. data/spec/fixtures/picture_updates.xml +0 -117
  68. data/spec/fixtures/profile.xml +0 -9
  69. data/spec/fixtures/profile_full.xml +0 -3906
  70. data/spec/fixtures/profile_with_positions.xml +0 -79
  71. data/spec/fixtures/search.xml +0 -538
  72. data/spec/fixtures/shares.xml +0 -12
  73. data/spec/fixtures/status.xml +0 -2
  74. data/spec/spec_helper.rb +0 -49
@@ -1,48 +0,0 @@
1
- module LinkedIn
2
-
3
- module AuthorizationHelpers
4
-
5
- def consumer
6
- @consumer ||= begin
7
- options = { :site => 'https://api.linkedin.com' }.merge(@consumer_options)
8
- ::OAuth::Consumer.new(@ctoken, @csecret, options)
9
- end
10
- end
11
-
12
- def set_callback_url(url)
13
- clear_request_token
14
- request_token(:oauth_callback => url)
15
- end
16
-
17
- # Note: If using oauth with a web app, be sure to provide :oauth_callback.
18
- # Options:
19
- # :oauth_callback => String, url that LinkedIn should redirect to
20
- def request_token(options={})
21
- @request_token ||= consumer.get_request_token(options)
22
- end
23
-
24
- # For web apps use params[:oauth_verifier], for desktop apps,
25
- # use the verifier is the pin that LinkedIn gives users.
26
- def authorize_from_request(rtoken, rsecret, verifier_or_pin)
27
- request_token = ::OAuth::RequestToken.new(consumer, rtoken, rsecret)
28
- access_token = request_token.get_access_token(:oauth_verifier => verifier_or_pin)
29
- @atoken, @asecret = access_token.token, access_token.secret
30
- end
31
-
32
- def access_token
33
- @access_token ||= ::OAuth::AccessToken.new(consumer, @atoken, @asecret)
34
- end
35
-
36
- def authorize_from_access(atoken, asecret)
37
- @atoken, @asecret = atoken, asecret
38
- end
39
-
40
- private
41
-
42
- def clear_request_token
43
- @request_token = nil
44
- end
45
-
46
- end
47
-
48
- end
@@ -1,13 +0,0 @@
1
- module LinkedIn
2
- class Base
3
-
4
- def self.from_xml(doc)
5
- new(Nokogiri::XML(doc))
6
- end
7
-
8
- def initialize(doc)
9
- @doc = doc
10
- end
11
-
12
- end
13
- end
@@ -1,21 +0,0 @@
1
- module LinkedIn
2
- class Birthdate < LinkedIn::Base
3
-
4
- def year
5
- @year ||= @doc.xpath("/person/date-of-birth/year").text.to_i
6
- end
7
-
8
- def day
9
- @day ||= @doc.xpath("/person/date-of-birth/day").text.to_i
10
- end
11
-
12
- def month
13
- @month ||= @doc.xpath("/person/date-of-birth/month").text.to_i
14
- end
15
-
16
- def to_date
17
- Date.civil(y=year,m=month,d=day)
18
- end
19
-
20
- end
21
- end
@@ -1,11 +0,0 @@
1
- module LinkedIn
2
- class Company < LinkedIn::Base
3
-
4
- %w[type name industry].each do |f|
5
- define_method(f.to_sym) do
6
- @doc.xpath("./#{f.gsub(/_/,'-')}").text
7
- end
8
- end
9
-
10
- end
11
- end
@@ -1,16 +0,0 @@
1
- module LinkedIn
2
- class Connections < LinkedIn::Base
3
-
4
- def connections
5
- @connections ||= @doc.xpath('//connections').children.inject([]) do |list, profile|
6
- list << Profile.new(Nokogiri::XML(profile.to_xml)) unless profile.blank?
7
- list
8
- end
9
- end
10
-
11
- def profiles
12
- connections
13
- end
14
-
15
- end
16
- end
@@ -1,9 +0,0 @@
1
- module LinkedIn
2
- class Country < LinkedIn::Base
3
-
4
- def code
5
- @doc.xpath("/person/location/country/code").text
6
- end
7
-
8
- end
9
- end
@@ -1,56 +0,0 @@
1
- module LinkedIn
2
-
3
- class CurrentShare < LinkedIn::Base
4
- %w[id comment].each do |f|
5
- define_method(f.to_sym) do
6
- @doc.xpath("./#{f.gsub(/_/,'-')}").text
7
- end
8
- end
9
-
10
- def submitted_url
11
- @doc.xpath('./content/submitted-url').text
12
- end
13
-
14
- def resolved_url
15
- @doc.xpath('./content/resolved-url').text
16
- end
17
-
18
- def shortened_url
19
- @doc.xpath('./content/shortened-url').text
20
- end
21
-
22
- def title
23
- @doc.xpath('./content/title').text
24
- end
25
-
26
- def description
27
- @doc.xpath('./content/description').text
28
- end
29
-
30
- def submitted_image_url
31
- @doc.xpath('./content/submitted-image-url').text
32
- end
33
-
34
- def thumbnail_url
35
- @doc.xpath('./content/thumbnail-url').text
36
- end
37
-
38
- def timestamp
39
- time = @doc.xpath('./timestamp').text.to_i
40
- Time.at(time / 1000)
41
- end
42
-
43
- def visibility
44
- @doc.xpath('./visibility/code').text
45
- end
46
-
47
- def application
48
- @doc.xpath('./source/application/name').text
49
- end
50
-
51
- def author
52
- @author ||= ShortProfile.new(@doc.xpath('./author'))
53
- end
54
- end
55
-
56
- end
@@ -1,41 +0,0 @@
1
- module LinkedIn
2
- class Education < LinkedIn::Base
3
-
4
- def educations
5
- @educations ||= @doc.children.inject([]) do |list, edu|
6
- list << Resource.new(edu) unless edu.blank?
7
- list
8
- end
9
- end
10
-
11
- class Resource
12
-
13
- def initialize(education)
14
- @education = education
15
- end
16
-
17
- %w[id school_name degree field_of_study activities notes].each do |f|
18
- define_method(f.to_sym) do
19
- @education.xpath("./#{f.gsub(/_/,'-')}").text
20
- end
21
- end
22
-
23
- def start_month
24
- @education.xpath('./start-date/month').text.to_i
25
- end
26
-
27
- def start_year
28
- @education.xpath('./start-date/year').text.to_i
29
- end
30
-
31
- def end_month
32
- @education.xpath('./end-date/month').text.to_i
33
- end
34
-
35
- def end_year
36
- @education.xpath('./end-date/year').text.to_i
37
- end
38
- end # resource class
39
-
40
- end # education class
41
- end
@@ -1,21 +0,0 @@
1
- module LinkedIn
2
- class Error < LinkedIn::Base
3
-
4
- def status
5
- @doc.xpath('//status').text.to_i
6
- end
7
-
8
- def timestamp
9
- @doc.xpath('//timestamp').text.to_i
10
- end
11
-
12
- def code
13
- @doc.xpath('//error-coce').text.to_i
14
- end
15
-
16
- def message
17
- @doc.xpath('//message').text
18
- end
19
-
20
- end
21
- end
@@ -1,32 +0,0 @@
1
- module LinkedIn
2
- class Group < LinkedIn::Base
3
-
4
- def groups
5
- @groups ||= @doc.children.inject([]) do |list, group|
6
- list << Resource.new(group) unless group.blank?
7
- list
8
- end
9
- end
10
-
11
- class Resource
12
-
13
- def initialize(group)
14
- @group = group
15
- end
16
-
17
- def id
18
- @group.xpath('//member-group/id').text.to_i
19
- end
20
-
21
- def name
22
- @group.xpath('//member-group/name').text
23
- end
24
-
25
- def url
26
- @group.xpath('//member-group/site-group-request/url').text
27
- end
28
-
29
- end
30
-
31
- end
32
- end
@@ -1,28 +0,0 @@
1
- module LinkedIn
2
- class Languages < LinkedIn::Base
3
-
4
- def languages
5
- @languages ||= @doc.children.inject([]) do |list, lang|
6
- list << Resource.new(lang) unless lang.blank?
7
- list
8
- end
9
- end
10
-
11
- class Resource
12
- # proficiency level not implemented yet
13
- # http://developer.linkedin.com/community/apis/blog/2011/01/04/new-profile-fields-are-here
14
- def initialize(language)
15
- @language = language
16
- end
17
-
18
- def id
19
- @language.xpath("./id").text
20
- end
21
-
22
- def name
23
- @language.xpath("./language/name").text
24
- end
25
- end
26
-
27
- end
28
- end
@@ -1,23 +0,0 @@
1
- module LinkedIn
2
- class Likes < LinkedIn::Base
3
-
4
- def likes
5
- @likes ||= @doc.xpath('//likes').children.inject([]) do |list, like|
6
- list << Resource.new(like) unless like.blank?
7
- list
8
- end
9
- end
10
-
11
- class Resource
12
- def initialize(like)
13
- @like = like
14
- end
15
-
16
- def profile
17
- Profile.new(Nokogiri::XML(@like.xpath('./person').to_xml))
18
- end
19
-
20
- end
21
-
22
- end
23
- end
@@ -1,13 +0,0 @@
1
- module LinkedIn
2
- class Location < LinkedIn::Base
3
-
4
- def name
5
- @doc.xpath("/person/location/name").text
6
- end
7
-
8
- def country
9
- @doc.xpath("/person/location/country/code").text
10
- end
11
-
12
- end
13
- end
@@ -1,20 +0,0 @@
1
- module LinkedIn
2
- class Message
3
-
4
- attr_accessor :subject, :body, :recipients
5
-
6
- def to_xml
7
- self.to_xml_node(Nokogiri.XML('<root/>', nil, 'UTF-8')).to_xml
8
- end
9
-
10
- def to_xml_node(doc)
11
- node = Nokogiri::XML::DocumentFragment.new(doc, '<mailbox-item><recipients/><subject/><body/></mailbox-item>')
12
- node.at_css('recipients').add_child(self.recipients.to_xml_nodes(doc))
13
- node.at_css('subject').content = self.subject
14
- node.at_css('body').content = self.body
15
- node
16
- end
17
-
18
- end
19
-
20
- end
@@ -1,12 +0,0 @@
1
- module LinkedIn
2
- class Network < LinkedIn::Base
3
-
4
- def updates
5
- @updates ||= @doc.xpath('//updates').children.inject([]) do |list, update|
6
- list << Update.new(Nokogiri::XML(update.to_xml)) unless update.blank?
7
- list
8
- end
9
- end
10
-
11
- end
12
- end
@@ -1,42 +0,0 @@
1
- module LinkedIn
2
- class Patents < LinkedIn::Base
3
-
4
- def patents
5
- @patents ||= @doc.children.inject([]) do |list, patent|
6
- list << Resource.new(patent) unless patent.blank?
7
- list
8
- end
9
- end
10
-
11
- class Resource
12
-
13
- def initialize(patent)
14
- @patent = patent
15
- end
16
-
17
- %w[id title].each do |f|
18
- define_method(f.to_sym) do
19
- @patent.xpath("./#{f.gsub(/_/,'-')}").text
20
- end
21
- end
22
-
23
- def year
24
- @year ||= @patent.xpath("./date/year").text.to_i
25
- end
26
-
27
- def day
28
- @day ||= @patent.xpath("./date/day").text.to_i
29
- end
30
-
31
- def month
32
- @month ||= @patent.xpath("./date/month").text.to_i
33
- end
34
-
35
- def date
36
- Date.civil(y=year,m=month,d=day)
37
- end
38
-
39
- end # resource class
40
-
41
- end # patent class
42
- end
@@ -1,18 +0,0 @@
1
- module LinkedIn
2
- class People < LinkedIn::Base
3
-
4
- %w[total start count].each do |f|
5
- define_method(f.to_sym) do
6
- @doc.xpath('.//people').first["#{f.gsub(/_/,'-')}"].to_i
7
- end
8
- end
9
-
10
- def profiles
11
- @profiles ||= @doc.xpath('//people').children.inject([]) do |list, profile|
12
- list << Profile.new(Nokogiri::XML(profile.to_xml)) unless profile.blank?
13
- list
14
- end
15
- end
16
-
17
- end
18
- end