xing_api 0.2 → 0.3

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a6694210d744441f7872f84c1e2f6587dd689fc9
4
+ data.tar.gz: 6f63ab052a256e12be4a4c0bc121a67e29cd5ffb
5
+ SHA512:
6
+ metadata.gz: ba557942b95e3d2ccc43b477daa0ce44ac93ac97271c4e7a65ed8966e01bee56ea512cb22d19c600f58ac297c0eb12eec704203be539972b30988cdab82b8e82
7
+ data.tar.gz: 38212eb4d27b98c42e91b61edb19f890aa00cb18f028b277ac581f502b79407e832221e4a3a8ad6e8739e81bca7defdbe7ca20a96072a487a8e8b5e7f03b2daa
@@ -1,17 +1,17 @@
1
1
  module XingApi
2
- class Activity::Comment < XingApi::Base
2
+ class Activity
3
+ class Comment < XingApi::Base
4
+ def self.list(activity_id, options = {})
5
+ request(:get, "/v1/activities/#{activity_id}/comments", options)
6
+ end
3
7
 
4
- def self.list(activity_id, options={})
5
- request(:get, "/v1/activities/#{activity_id}/comments", options)
6
- end
7
-
8
- def self.create(activity_id, comment, options={})
9
- request(:post, "/v1/activities/#{activity_id}/comments", {:text => comment}.merge(options))
10
- end
8
+ def self.create(activity_id, comment, options = {})
9
+ request(:post, "/v1/activities/#{activity_id}/comments", { text: comment }.merge(options))
10
+ end
11
11
 
12
- def self.delete(activity_id, comment_id, options={})
13
- request(:delete, "/v1/activities/#{activity_id}/comments/#{comment_id}", options)
12
+ def self.delete(activity_id, comment_id, options = {})
13
+ request(:delete, "/v1/activities/#{activity_id}/comments/#{comment_id}", options)
14
+ end
14
15
  end
15
-
16
16
  end
17
17
  end
@@ -1,17 +1,17 @@
1
1
  module XingApi
2
- class Activity::Like < XingApi::Base
2
+ class Activity
3
+ class Like < XingApi::Base
4
+ def self.list(activity_id, options = {})
5
+ request(:get, "/v1/activities/#{activity_id}/likes", options)
6
+ end
3
7
 
4
- def self.list(activity_id, options={})
5
- request(:get, "/v1/activities/#{activity_id}/likes", options)
6
- end
7
-
8
- def self.create(activity_id, options={})
9
- request(:put, "/v1/activities/#{activity_id}/likes", options)
10
- end
8
+ def self.create(activity_id, options = {})
9
+ request(:put, "/v1/activities/#{activity_id}/likes", options)
10
+ end
11
11
 
12
- def self.delete(activity_id, options={})
13
- request(:delete, "/v1/activities/#{activity_id}/likes", options)
12
+ def self.delete(activity_id, options = {})
13
+ request(:delete, "/v1/activities/#{activity_id}/likes", options)
14
+ end
14
15
  end
15
-
16
16
  end
17
17
  end
@@ -1,17 +1,15 @@
1
1
  module XingApi
2
2
  class Activity < XingApi::Base
3
-
4
- def self.find(activity_id, options={})
3
+ def self.find(activity_id, options = {})
5
4
  request(:get, "/v1/activities/#{activity_id}", options)
6
5
  end
7
6
 
8
- def self.delete(activity_id, options={})
7
+ def self.delete(activity_id, options = {})
9
8
  request(:delete, "/v1/activities/#{activity_id}", options)
10
9
  end
11
10
 
12
- def self.share(activity_id, options={})
11
+ def self.share(activity_id, options = {})
13
12
  request(:post, "/v1/activities/#{activity_id}/share", options)
14
13
  end
15
-
16
14
  end
17
15
  end
data/lib/xing_api/base.rb CHANGED
@@ -1,13 +1,12 @@
1
1
  module XingApi
2
2
  class Base
3
3
  class << self
4
-
5
- def request(http_verb, url, options={})
4
+ def request(http_verb, url, options = {})
6
5
  client = options.delete(:client) || default_client
7
6
  client.request(http_verb, url, options)
8
7
  end
9
8
 
10
- def request_with_body(http_verb, url, body_hash, options={})
9
+ def request_with_body(http_verb, url, body_hash, options = {})
11
10
  client = options.delete(:client) || default_client
12
11
  client.request_with_body(http_verb, url, body_hash)
13
12
  end
@@ -17,7 +16,6 @@ module XingApi
17
16
  def default_client
18
17
  XingApi::Client.new
19
18
  end
20
-
21
19
  end
22
20
  end
23
21
  end
@@ -1,17 +1,15 @@
1
1
  module XingApi
2
2
  class Bookmark < XingApi::Base
3
-
4
- def self.list(options={})
5
- request(:get, "/v1/users/me/bookmarks", options)
3
+ def self.list(options = {})
4
+ request(:get, '/v1/users/me/bookmarks', options)
6
5
  end
7
6
 
8
- def self.create(user_id, options={})
7
+ def self.create(user_id, options = {})
9
8
  request(:put, "/v1/users/me/bookmarks/#{user_id}", options)
10
9
  end
11
10
 
12
- def self.delete(user_id, options={})
11
+ def self.delete(user_id, options = {})
13
12
  request(:delete, "/v1/users/me/bookmarks/#{user_id}", options)
14
13
  end
15
-
16
14
  end
17
15
  end
@@ -3,36 +3,36 @@ module XingApi
3
3
  include XingApi::ResponseHandler
4
4
 
5
5
  OAUTH_ATTRIBUTES = [:consumer_key, :consumer_secret, :oauth_token, :oauth_token_secret]
6
- attr_writer *OAUTH_ATTRIBUTES
6
+ attr_writer(*OAUTH_ATTRIBUTES)
7
7
  attr_accessor :request_token_hash
8
8
 
9
9
  class << self
10
10
  attr_accessor :default_options
11
11
 
12
- def configure(&block)
13
- instance = self.new
12
+ def configure
13
+ instance = new
14
14
  yield instance
15
15
  self.default_options = instance.send(:to_hash)
16
16
  end
17
17
  end # class << self
18
18
 
19
- def initialize(options={})
19
+ def initialize(options = {})
20
20
  options = (self.class.default_options ||= {}).merge(options)
21
21
  OAUTH_ATTRIBUTES.each do |attribute|
22
22
  send "#{attribute}=", options[attribute]
23
23
  end
24
24
  end
25
25
 
26
- def request(http_verb, url, options={})
26
+ def request(http_verb, url, options = {})
27
27
  full_url = url + hash_to_params(options)
28
28
  handle(access_token.request(http_verb, full_url))
29
29
  end
30
30
 
31
- def request_with_body(http_verb, url, body_hash={})
32
- handle(access_token.request(http_verb, url, body_hash.to_json, { 'Content-Type' => 'application/json' }))
31
+ def request_with_body(http_verb, url, body_hash = {})
32
+ handle(access_token.request(http_verb, url, body_hash.to_json, 'Content-Type' => 'application/json'))
33
33
  end
34
34
 
35
- def get_request_token(oauth_callback='oob')
35
+ def get_request_token(oauth_callback = 'oob')
36
36
  ensure_attributes_are_set! %w(consumer_key consumer_secret)
37
37
 
38
38
  request_token = request_token(oauth_callback)
@@ -43,15 +43,11 @@ module XingApi
43
43
  }
44
44
  end
45
45
 
46
- def get_access_token(verifier, options={})
46
+ def get_access_token(verifier, options = {})
47
47
  ensure_attributes_are_set! %w(consumer_key consumer_secret)
48
-
49
48
  options = request_token_hash.merge(options) if request_token_hash
50
- request_token = options[:request_token] || raise('request_token missing')
51
- request_token_secret = options[:request_token_secret] || raise('request_token_secret missing')
52
49
 
53
- request_token = OAuth::RequestToken.new(consumer, request_token, request_token_secret)
54
- access_token = request_token.get_access_token(:oauth_verifier => verifier)
50
+ access_token = rebuild_request_token(options).get_access_token(oauth_verifier: verifier)
55
51
  self.oauth_token = access_token.token
56
52
  self.oauth_token_secret = access_token.secret
57
53
  {
@@ -68,17 +64,23 @@ module XingApi
68
64
 
69
65
  private
70
66
 
67
+ def rebuild_request_token(options)
68
+ request_token = options[:request_token] || fail('request_token missing')
69
+ request_token_secret = options[:request_token_secret] || fail('request_token_secret missing')
70
+ OAuth::RequestToken.new(consumer, request_token, request_token_secret)
71
+ end
72
+
71
73
  def to_hash
72
74
  {
73
- :consumer_key => consumer_key,
74
- :consumer_secret => consumer_secret,
75
- :oauth_token => oauth_token,
76
- :oauth_token_secret => oauth_token_secret
75
+ consumer_key: consumer_key,
76
+ consumer_secret: consumer_secret,
77
+ oauth_token: oauth_token,
78
+ oauth_token_secret: oauth_token_secret
77
79
  }
78
80
  end
79
81
 
80
82
  def request_token(oauth_callback)
81
- @request_token ||= consumer.get_request_token(:oauth_callback => oauth_callback)
83
+ @request_token ||= consumer.get_request_token(oauth_callback: oauth_callback)
82
84
  end
83
85
 
84
86
  def consumer
@@ -91,26 +93,25 @@ module XingApi
91
93
 
92
94
  def xing_oauth_options
93
95
  {
94
- :site => ENV['XING_API_SITE'] || 'https://api.xing.com',
95
- :request_token_path => '/v1/request_token',
96
- :authorize_path => '/v1/authorize',
97
- :access_token_path => '/v1/access_token',
98
- :signature_method => 'PLAINTEXT',
99
- :oauth_version => '1.0',
100
- :scheme => 'query_string'
96
+ site: ENV['XING_API_SITE'] || 'https://api.xing.com',
97
+ request_token_path: '/v1/request_token',
98
+ authorize_path: '/v1/authorize',
99
+ access_token_path: '/v1/access_token',
100
+ signature_method: 'PLAINTEXT',
101
+ oauth_version: '1.0',
102
+ scheme: 'query_string'
101
103
  }
102
104
  end
103
105
 
104
106
  def hash_to_params(hash)
105
107
  return '' if hash.empty?
106
- '?' + hash.map {|k,v| "#{k}=#{CGI.escape(v.to_s)}"}.join('&')
108
+ '?' + hash.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
107
109
  end
108
110
 
109
111
  def ensure_attributes_are_set!(attribute_names)
110
112
  Array(attribute_names).each do |attribute_name|
111
- raise "#{attribute_name} is missing" unless send(attribute_name)
113
+ fail "#{attribute_name} is missing" unless send(attribute_name)
112
114
  end
113
115
  end
114
-
115
116
  end
116
117
  end
@@ -1,9 +1,9 @@
1
1
  module XingApi
2
- class Contact::Tag < XingApi::Base
3
-
4
- def self.list(user_id, options={})
5
- request(:get, "/v1/users/me/contacts/#{user_id}/tags", options)
2
+ class Contact
3
+ class Tag < XingApi::Base
4
+ def self.list(user_id, options = {})
5
+ request(:get, "/v1/users/me/contacts/#{user_id}/tags", options)
6
+ end
6
7
  end
7
-
8
8
  end
9
9
  end
@@ -1,17 +1,15 @@
1
1
  module XingApi
2
2
  class Contact < XingApi::Base
3
-
4
- def self.list(user_id, options={})
3
+ def self.list(user_id, options = {})
5
4
  request(:get, "/v1/users/#{user_id}/contacts", options)
6
5
  end
7
6
 
8
- def self.list_ids(options={})
7
+ def self.list_ids(options = {})
9
8
  request(:get, '/v1/users/me/contact_ids', options)
10
9
  end
11
10
 
12
- def self.shared(user_id, options={})
11
+ def self.shared(user_id, options = {})
13
12
  request(:get, "/v1/users/#{user_id}/contacts/shared", options)
14
13
  end
15
-
16
14
  end
17
15
  end
@@ -1,25 +1,23 @@
1
1
  module XingApi
2
2
  class ContactRequest < XingApi::Base
3
-
4
- def self.list(options={})
3
+ def self.list(options = {})
5
4
  request(:get, '/v1/users/me/contact_requests', options)
6
5
  end
7
6
 
8
- def self.create(user_id, options={})
7
+ def self.create(user_id, options = {})
9
8
  request(:post, "/v1/users/#{user_id}/contact_requests", options)
10
9
  end
11
10
 
12
- def self.accept(user_id, options={})
11
+ def self.accept(user_id, options = {})
13
12
  request(:put, "/v1/users/#{user_id}/contact_requests/me/accept", options)
14
13
  end
15
14
 
16
- def self.deny(user_id, options={})
15
+ def self.deny(user_id, options = {})
17
16
  request(:delete, "/v1/users/me/contact_requests/#{user_id}", options)
18
17
  end
19
18
 
20
- def self.sent(options={})
19
+ def self.sent(options = {})
21
20
  request(:get, '/v1/users/me/contact_requests/sent', options)
22
21
  end
23
-
24
22
  end
25
23
  end
@@ -1,13 +1,13 @@
1
1
  module XingApi
2
- class Conversation::Attachment < XingApi::Base
2
+ class Conversation
3
+ class Attachment < XingApi::Base
4
+ def self.list(conversation_id, options = {})
5
+ request(:get, "/v1/users/me/conversations/#{conversation_id}/attachments", options)
6
+ end
3
7
 
4
- def self.list(conversation_id, options={})
5
- request(:get, "/v1/users/me/conversations/#{conversation_id}/attachments", options)
8
+ def self.download_url(conversation_id, attachment_id, options = {})
9
+ request(:post, "/v1/users/me/conversations/#{conversation_id}/attachments/#{attachment_id}/download", options)
10
+ end
6
11
  end
7
-
8
- def self.download_url(conversation_id, attachment_id, options={})
9
- request(:post, "/v1/users/me/conversations/#{conversation_id}/attachments/#{attachment_id}/download", options)
10
- end
11
-
12
12
  end
13
13
  end
@@ -1,25 +1,25 @@
1
1
  module XingApi
2
- class Conversation::Message < XingApi::Base
2
+ class Conversation
3
+ class Message < XingApi::Base
4
+ def self.list(conversation_id, options = {})
5
+ request(:get, "/v1/users/me/conversations/#{conversation_id}/messages", options)
6
+ end
3
7
 
4
- def self.list(conversation_id, options={})
5
- request(:get, "/v1/users/me/conversations/#{conversation_id}/messages", options)
6
- end
7
-
8
- def self.create(conversation_id, content, options={})
9
- request(:post, "/v1/users/me/conversations/#{conversation_id}/messages", {:content => content}.merge(options))
10
- end
8
+ def self.create(conversation_id, content, options = {})
9
+ request(:post, "/v1/users/me/conversations/#{conversation_id}/messages", { content: content }.merge(options))
10
+ end
11
11
 
12
- def self.find(conversation_id, message_id, options={})
13
- request(:get, "/v1/users/me/conversations/#{conversation_id}/messages/#{message_id}", options)
14
- end
12
+ def self.find(conversation_id, message_id, options = {})
13
+ request(:get, "/v1/users/me/conversations/#{conversation_id}/messages/#{message_id}", options)
14
+ end
15
15
 
16
- def self.read(conversation_id, message_id, options={})
17
- request(:put, "/v1/users/me/conversations/#{conversation_id}/messages/#{message_id}/read", options)
18
- end
16
+ def self.read(conversation_id, message_id, options = {})
17
+ request(:put, "/v1/users/me/conversations/#{conversation_id}/messages/#{message_id}/read", options)
18
+ end
19
19
 
20
- def self.unread(conversation_id, message_id, options={})
21
- request(:delete, "/v1/users/me/conversations/#{conversation_id}/messages/#{message_id}/read", options)
20
+ def self.unread(conversation_id, message_id, options = {})
21
+ request(:delete, "/v1/users/me/conversations/#{conversation_id}/messages/#{message_id}/read", options)
22
+ end
22
23
  end
23
-
24
24
  end
25
25
  end
@@ -1,33 +1,35 @@
1
1
  module XingApi
2
2
  class Conversation < XingApi::Base
3
-
4
- def self.list(options={})
3
+ def self.list(options = {})
5
4
  request(:get, '/v1/users/me/conversations', options)
6
5
  end
7
6
 
8
- def self.find(conversation_id, options={})
7
+ def self.find(conversation_id, options = {})
9
8
  request(:get, "/v1/users/me/conversations/#{conversation_id}", options)
10
9
  end
11
10
 
12
- def self.create(recipient_ids, subject, content, options={})
11
+ def self.create(recipient_ids, subject, content, options = {})
13
12
  request(:post, '/v1/users/me/conversations', {
14
- :recipient_ids => recipient_ids,
15
- :subject => subject,
16
- :content => content
13
+ recipient_ids: recipient_ids,
14
+ subject: subject,
15
+ content: content
17
16
  }.merge(options))
18
17
  end
19
18
 
20
- def self.delete(conversation_id, options={})
19
+ def self.delete(conversation_id, options = {})
21
20
  request(:delete, "/v1/users/me/conversations/#{conversation_id}", options)
22
21
  end
23
22
 
24
- def self.valid_recipient(recipient_id, options={})
23
+ def self.valid_recipient(recipient_id, options = {})
25
24
  request(:get, "/v1/users/me/conversations/valid_recipients/#{recipient_id}", options)
26
25
  end
27
26
 
28
- def self.read(conversation_id, options={})
27
+ def self.read(conversation_id, options = {})
29
28
  request(:put, "/v1/users/me/conversations/#{conversation_id}/read", options)
30
29
  end
31
30
 
31
+ def self.unread(conversation_id, options = {})
32
+ request(:delete, "/v1/users/me/conversations/#{conversation_id}/read", options)
33
+ end
32
34
  end
33
35
  end
@@ -12,13 +12,12 @@ module XingApi
12
12
  def to_s
13
13
  [status_code, name, text].join(' - ')
14
14
  end
15
-
16
15
  end
17
16
 
18
- class OauthError < XingApi::Error; end
19
- class ServerError < XingApi::Error; end
20
- class AccessDeniedError < XingApi::Error; end
21
- class InvalidParameterError < XingApi::Error; end
17
+ class OauthError < XingApi::Error; end
18
+ class ServerError < XingApi::Error; end
19
+ class AccessDeniedError < XingApi::Error; end
20
+ class InvalidParameterError < XingApi::Error; end
22
21
  class InvalidOauthTokenError < XingApi::Error; end
23
22
  class RateLimitExceededError < XingApi::Error; end
24
23
  end
@@ -0,0 +1,7 @@
1
+ module XingApi
2
+ class Group < XingApi::Base
3
+ def self.search(keywords, options = {})
4
+ request(:get, '/v1/groups/find', { keywords: keywords }.merge(options))
5
+ end
6
+ end
7
+ end
@@ -1,9 +1,7 @@
1
1
  module XingApi
2
2
  class Invite < XingApi::Base
3
-
4
- def self.create(emails, options={})
5
- request(:post, '/v1/users/invite', {:to_emails => emails}.merge(options))
3
+ def self.create(emails, options = {})
4
+ request(:post, '/v1/users/invite', { to_emails: emails }.merge(options))
6
5
  end
7
-
8
6
  end
9
7
  end
data/lib/xing_api/job.rb CHANGED
@@ -1,17 +1,15 @@
1
1
  module XingApi
2
2
  class Job < XingApi::Base
3
-
4
- def self.find(job_id, options={})
3
+ def self.find(job_id, options = {})
5
4
  request(:get, "/v1/jobs/#{job_id}", options)
6
5
  end
7
6
 
8
- def self.search(query, options={})
9
- request(:get, '/v1/jobs/find', {:query => query}.merge(options))
7
+ def self.search(query, options = {})
8
+ request(:get, '/v1/jobs/find', { query: query }.merge(options))
10
9
  end
11
10
 
12
- def self.recommendations(options={})
11
+ def self.recommendations(options = {})
13
12
  request(:get, '/v1/users/me/jobs/recommendations', options)
14
13
  end
15
-
16
14
  end
17
15
  end
@@ -1,17 +1,15 @@
1
1
  module XingApi
2
2
  class ProfileMessage < XingApi::Base
3
-
4
- def self.find(user_id, options={})
3
+ def self.find(user_id, options = {})
5
4
  request(:get, "/v1/users/#{user_id}/profile_message", options)
6
5
  end
7
6
 
8
- def self.update(message, options={})
9
- request(:put, '/v1/users/me/profile_message', {:message => message}.merge(options))
7
+ def self.update(message, options = {})
8
+ request(:put, '/v1/users/me/profile_message', { message: message }.merge(options))
10
9
  end
11
10
 
12
- def self.delete(options={})
13
- request(:put, '/v1/users/me/profile_message', {:message => ''}.merge(options))
11
+ def self.delete(options = {})
12
+ request(:put, '/v1/users/me/profile_message', { message: '' }.merge(options))
14
13
  end
15
-
16
14
  end
17
15
  end
@@ -1,13 +1,11 @@
1
1
  module XingApi
2
2
  class ProfileVisit < XingApi::Base
3
-
4
- def self.list(options={})
3
+ def self.list(options = {})
5
4
  request(:get, '/v1/users/me/visits', options)
6
5
  end
7
6
 
8
- def self.create(user_id, options={})
7
+ def self.create(user_id, options = {})
9
8
  request(:post, "/v1/users/#{user_id}/visits", options)
10
9
  end
11
-
12
10
  end
13
11
  end
@@ -1,6 +1,5 @@
1
1
  module XingApi
2
2
  module ResponseHandler
3
-
4
3
  OAUTH_ERROR_RESPONSES = %w(
5
4
  INVALID_OAUTH_CONSUMER
6
5
  CONSUMER_MISMATCH
@@ -21,7 +20,7 @@ module XingApi
21
20
  raise_failed_response!(response)
22
21
  end
23
22
 
24
- JSON.parse(response.body.to_s, :symbolize_names => true)
23
+ JSON.parse(response.body.to_s, symbolize_names: true)
25
24
  rescue JSON::ParserError
26
25
  {}
27
26
  end
@@ -33,37 +32,44 @@ module XingApi
33
32
  body = parse_json(response)
34
33
  error_class = failed_response_for(status_code, body[:error_name])
35
34
 
36
- raise error_class.new(status_code, body[:error_name], body[:message])
35
+ fail error_class.new(status_code, body[:error_name], body[:message])
37
36
  end
38
37
 
39
38
  def failed_response_for(status_code, error_name)
40
39
  case status_code
41
40
  when 401
42
- case error_name
43
- when *OAUTH_ERROR_RESPONSES
44
- XingApi::OauthError
45
- when 'INVALID_OAUTH_TOKEN'
46
- XingApi::InvalidOauthTokenError
47
- end
41
+ unauthorized_response_for(error_name)
48
42
  when 403
49
- case error_name
50
- when 'RATE_LIMIT_EXCEEDED'
51
- XingApi::RateLimitExceededError
52
- when 'ACCESS_DENIED'
53
- XingApi::AccessDeniedError
54
- when 'INVALID_PARAMETERS'
55
- XingApi::InvalidParameterError
56
- end
43
+ forbidden_response_for(error_name)
57
44
  when (500..504)
58
45
  XingApi::ServerError
59
46
  end || XingApi::Error
60
47
  end
61
48
 
49
+ def unauthorized_response_for(error_name)
50
+ case error_name
51
+ when *OAUTH_ERROR_RESPONSES
52
+ XingApi::OauthError
53
+ when 'INVALID_OAUTH_TOKEN'
54
+ XingApi::InvalidOauthTokenError
55
+ end
56
+ end
57
+
58
+ def forbidden_response_for(error_name)
59
+ case error_name
60
+ when 'RATE_LIMIT_EXCEEDED'
61
+ XingApi::RateLimitExceededError
62
+ when 'ACCESS_DENIED'
63
+ XingApi::AccessDeniedError
64
+ when 'INVALID_PARAMETERS'
65
+ XingApi::InvalidParameterError
66
+ end
67
+ end
68
+
62
69
  def parse_json(response)
63
- body = JSON.parse(response.body.to_s, :symbolize_names => true)
70
+ JSON.parse(response.body.to_s, symbolize_names: true)
64
71
  rescue JSON::ParserError
65
72
  { message: response.body.to_s }
66
73
  end
67
-
68
74
  end
69
75
  end
@@ -1,17 +1,17 @@
1
1
  module XingApi
2
- class User::BirthDate < XingApi::Base
3
-
4
- def self.update(day, month, year, options={})
5
- request(
6
- :put,
7
- '/v1/users/me/birth_date',
8
- {
9
- :day => day,
10
- :month => month,
11
- :year => year
12
- }.merge(options)
13
- )
2
+ class User
3
+ class BirthDate < XingApi::Base
4
+ def self.update(day, month, year, options = {})
5
+ request(
6
+ :put,
7
+ '/v1/users/me/birth_date',
8
+ {
9
+ day: day,
10
+ month: month,
11
+ year: year
12
+ }.merge(options)
13
+ )
14
+ end
14
15
  end
15
-
16
16
  end
17
17
  end
@@ -1,9 +1,9 @@
1
1
  module XingApi
2
- class User::BusinessAddress < XingApi::Base
3
-
4
- def self.update(options={})
5
- request(:put, '/v1/users/me/business_address', options)
2
+ class User
3
+ class BusinessAddress < XingApi::Base
4
+ def self.update(options = {})
5
+ request(:put, '/v1/users/me/business_address', options)
6
+ end
6
7
  end
7
-
8
8
  end
9
9
  end
@@ -1,30 +1,34 @@
1
1
  module XingApi
2
- class User::Company < XingApi::Base
2
+ class User
3
+ class Company < XingApi::Base
4
+ def self.create(name, title, industry, employment_type, options = {})
5
+ request(
6
+ :post,
7
+ '/v1/users/me/professional_experience/companies',
8
+ {
9
+ name: name,
10
+ title: title,
11
+ industry: industry,
12
+ employment_type: employment_type
13
+ }.merge(options)
14
+ )
15
+ end
3
16
 
4
- def self.create(name, title, industry, employment_type, options={})
5
- request(
6
- :post,
7
- '/v1/users/me/professional_experience/companies',
8
- {
9
- :name => name,
10
- :title => title,
11
- :industry => industry,
12
- :employment_type => employment_type
13
- }.merge(options)
14
- )
15
- end
17
+ def self.update(company_id, options = {})
18
+ request(:put, "/v1/users/me/professional_experience/companies/#{company_id}", options)
19
+ end
16
20
 
17
- def self.update(company_id, options={})
18
- request(:put, "/v1/users/me/professional_experience/companies/#{company_id}", options)
19
- end
21
+ def self.delete(company_id, options = {})
22
+ request(:delete, "/v1/users/me/professional_experience/companies/#{company_id}", options)
23
+ end
20
24
 
21
- def self.delete(company_id, options={})
22
- request(:delete, "/v1/users/me/professional_experience/companies/#{company_id}", options)
25
+ def self.primary_company(company_id, options = {})
26
+ request(
27
+ :put,
28
+ '/v1/users/me/professional_experience/primary_company',
29
+ { company_id: company_id }.merge(options)
30
+ )
31
+ end
23
32
  end
24
-
25
- def self.primary_company(company_id, options={})
26
- request(:put, '/v1/users/me/professional_experience/primary_company', { :company_id => company_id }.merge(options))
27
- end
28
-
29
33
  end
30
34
  end
@@ -1,13 +1,13 @@
1
1
  module XingApi
2
- class User::Language < XingApi::Base
2
+ class User
3
+ class Language < XingApi::Base
4
+ def self.update(language, options = {})
5
+ request(:put, "/v1/users/me/languages/#{language}", options)
6
+ end
3
7
 
4
- def self.update(language, options={})
5
- request(:put, "/v1/users/me/languages/#{language}", options)
8
+ def self.delete(language, options = {})
9
+ request(:delete, "/v1/users/me/languages/#{language}", options)
10
+ end
6
11
  end
7
-
8
- def self.delete(language, options={})
9
- request(:delete, "/v1/users/me/languages/#{language}", options)
10
- end
11
-
12
12
  end
13
13
  end
@@ -1,13 +1,13 @@
1
1
  module XingApi
2
- class User::Photo < XingApi::Base
2
+ class User
3
+ class Photo < XingApi::Base
4
+ def self.update(body_hash, options = {})
5
+ request_with_body(:put, '/v1/users/me/photo', body_hash, options)
6
+ end
3
7
 
4
- def self.update(body_hash, options={})
5
- request_with_body(:put, '/v1/users/me/photo', body_hash, options)
8
+ def self.delete(options = {})
9
+ request(:delete, '/v1/users/me/photo', options)
10
+ end
6
11
  end
7
-
8
- def self.delete(options={})
9
- request(:delete, '/v1/users/me/photo', options)
10
- end
11
-
12
12
  end
13
13
  end
@@ -1,9 +1,9 @@
1
1
  module XingApi
2
- class User::PrivateAddress < XingApi::Base
3
-
4
- def self.update(options={})
5
- request(:put, '/v1/users/me/private_address', options)
2
+ class User
3
+ class PrivateAddress < XingApi::Base
4
+ def self.update(options = {})
5
+ request(:put, '/v1/users/me/private_address', options)
6
+ end
6
7
  end
7
-
8
8
  end
9
9
  end
@@ -1,13 +1,13 @@
1
1
  module XingApi
2
- class User::Qualification < XingApi::Base
3
-
4
- def self.create(description, options={})
5
- request(
6
- :post,
7
- '/v1/users/me/educational_background/qualifications',
8
- { :description => description }.merge(options)
9
- )
2
+ class User
3
+ class Qualification < XingApi::Base
4
+ def self.create(description, options = {})
5
+ request(
6
+ :post,
7
+ '/v1/users/me/educational_background/qualifications',
8
+ { description: description }.merge(options)
9
+ )
10
+ end
10
11
  end
11
-
12
12
  end
13
13
  end
@@ -1,13 +1,13 @@
1
1
  module XingApi
2
- class User::Recommendation < XingApi::Base
2
+ class User
3
+ class Recommendation < XingApi::Base
4
+ def self.list(options = {})
5
+ request(:get, '/v1/users/me/network/recommendations', options)
6
+ end
3
7
 
4
- def self.list(options={})
5
- request(:get, '/v1/users/me/network/recommendations', options)
8
+ def self.delete(user_id, options = {})
9
+ request(:delete, "/v1/users/me/network/recommendations/user/#{user_id}", options)
10
+ end
6
11
  end
7
-
8
- def self.delete(user_id, options={})
9
- request(:delete, "/v1/users/me/network/recommendations/user/#{user_id}", options)
10
- end
11
-
12
12
  end
13
13
  end
@@ -1,21 +1,21 @@
1
1
  module XingApi
2
- class User::School < XingApi::Base
2
+ class User
3
+ class School < XingApi::Base
4
+ def self.create(name, options = {})
5
+ request(:post, '/v1/users/me/educational_background/schools', { name: name }.merge(options))
6
+ end
3
7
 
4
- def self.create(name, options={})
5
- request(:post, '/v1/users/me/educational_background/schools', { :name => name }.merge(options))
6
- end
8
+ def self.update(school_id, options = {})
9
+ request(:put, "/v1/users/me/educational_background/schools/#{school_id}", options)
10
+ end
7
11
 
8
- def self.update(school_id, options={})
9
- request(:put, "/v1/users/me/educational_background/schools/#{school_id}", options)
10
- end
12
+ def self.delete(school_id, options = {})
13
+ request(:delete, "/v1/users/me/educational_background/schools/#{school_id}", options)
14
+ end
11
15
 
12
- def self.delete(school_id, options={})
13
- request(:delete, "/v1/users/me/educational_background/schools/#{school_id}", options)
16
+ def self.primary_school(school_id, options = {})
17
+ request(:put, '/v1/users/me/educational_background/schools', { school_id: school_id }.merge(options))
18
+ end
14
19
  end
15
-
16
- def self.primary_school(school_id, options={})
17
- request(:put, '/v1/users/me/educational_background/schools', { :school_id => school_id }.merge(options))
18
- end
19
-
20
20
  end
21
21
  end
@@ -1,9 +1,9 @@
1
1
  module XingApi
2
- class User::WebProfile < XingApi::Base
3
-
4
- def self.delete(profile, options={})
5
- request(:delete, "/v1/users/me/web_profiles/#{profile}", options)
2
+ class User
3
+ class WebProfile < XingApi::Base
4
+ def self.delete(profile, options = {})
5
+ request(:delete, "/v1/users/me/web_profiles/#{profile}", options)
6
+ end
6
7
  end
7
-
8
8
  end
9
9
  end
data/lib/xing_api/user.rb CHANGED
@@ -1,49 +1,51 @@
1
1
  module XingApi
2
2
  class User < XingApi::Base
3
-
4
- def self.find(user_id, options={})
3
+ def self.find(user_id, options = {})
5
4
  request(:get, "/v1/users/#{user_id}", options)
6
5
  end
7
6
 
8
- def self.me(options={})
7
+ def self.me(options = {})
9
8
  find('me', options)
10
9
  end
11
10
 
12
- def self.id_card(options={})
11
+ def self.id_card(options = {})
13
12
  request(:get, '/v1/users/me/id_card', options)
14
13
  end
15
14
 
16
- def self.activities(user_id, options={})
15
+ def self.activities(user_id, options = {})
17
16
  request(:get, "/v1/users/#{user_id}/feed", options)
18
17
  end
19
18
 
20
- def self.network_activities(options={})
21
- request(:get, "/v1/users/me/network_feed", options)
19
+ def self.network_activities(options = {})
20
+ request(:get, '/v1/users/me/network_feed', options)
22
21
  end
23
22
 
24
- def self.shared(user_id, options={})
23
+ def self.shared(user_id, options = {})
25
24
  request(:get, "/v1/users/#{user_id}/contacts/shared", options)
26
25
  end
27
26
 
28
- def self.paths(user_id, options={})
27
+ def self.paths(user_id, options = {})
29
28
  request(:get, "/v1/users/me/network/#{user_id}/paths", options)
30
29
  end
31
30
 
32
- def self.find_by_emails(emails, options={})
33
- request(:get, '/v1/users/find_by_emails', {:emails => emails}.merge(options))
31
+ def self.find_by_emails(emails, options = {})
32
+ request(:get, '/v1/users/find_by_emails', { emails: emails }.merge(options))
34
33
  end
35
34
 
36
- def self.status_message(message, options={})
37
- request(:post, '/v1/users/me/status_message', {:message => message}.merge(options))
35
+ def self.groups(user_id, options = {})
36
+ request(:get, "/v1/users/#{user_id}/groups", options)
38
37
  end
39
38
 
40
- def self.share_link(uri, options={})
41
- request(:post, "/v1/users/me/share/link", options = {uri: uri}.merge(options))
39
+ def self.status_message(message, options = {})
40
+ request(:post, '/v1/users/me/status_message', { message: message }.merge(options))
42
41
  end
43
42
 
44
- def self.update(options={})
45
- request(:put, '/v1/users/me', options)
43
+ def self.share_link(uri, options = {})
44
+ request(:post, '/v1/users/me/share/link', { uri: uri }.merge(options))
46
45
  end
47
46
 
47
+ def self.update(options = {})
48
+ request(:put, '/v1/users/me', options)
49
+ end
48
50
  end
49
51
  end
@@ -1,4 +1,3 @@
1
- # encoding: UTF-8
2
1
  module XingApi
3
- VERSION = '0.2' unless defined?(XingApi::VERSION)
2
+ VERSION = '0.3' unless defined?(XingApi::VERSION)
4
3
  end
data/lib/xing_api.rb CHANGED
@@ -17,6 +17,7 @@ require 'xing_api/contact_request'
17
17
  require 'xing_api/conversation'
18
18
  require 'xing_api/conversation/attachment'
19
19
  require 'xing_api/conversation/message'
20
+ require 'xing_api/group'
20
21
  require 'xing_api/invite'
21
22
  require 'xing_api/job'
22
23
  require 'xing_api/profile_message'
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xing_api
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.2'
5
- prerelease:
4
+ version: '0.3'
6
5
  platform: ruby
7
6
  authors:
8
7
  - Mark Schmidt
@@ -10,135 +9,142 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2015-01-10 00:00:00.000000000 Z
12
+ date: 2015-05-31 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: oauth
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
- - - ~>
18
+ - - "~>"
21
19
  - !ruby/object:Gem::Version
22
20
  version: 0.4.7
23
21
  type: :runtime
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
- - - ~>
25
+ - - "~>"
29
26
  - !ruby/object:Gem::Version
30
27
  version: 0.4.7
31
28
  - !ruby/object:Gem::Dependency
32
29
  name: mocha
33
30
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
31
  requirements:
36
- - - ! '>='
32
+ - - ">="
37
33
  - !ruby/object:Gem::Version
38
34
  version: '0'
39
35
  type: :development
40
36
  prerelease: false
41
37
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
38
  requirements:
44
- - - ! '>='
39
+ - - ">="
45
40
  - !ruby/object:Gem::Version
46
41
  version: '0'
47
42
  - !ruby/object:Gem::Dependency
48
43
  name: rspec
49
44
  requirement: !ruby/object:Gem::Requirement
50
- none: false
51
45
  requirements:
52
- - - ! '>='
46
+ - - ">="
53
47
  - !ruby/object:Gem::Version
54
48
  version: '0'
55
49
  type: :development
56
50
  prerelease: false
57
51
  version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
52
  requirements:
60
- - - ! '>='
53
+ - - ">="
61
54
  - !ruby/object:Gem::Version
62
55
  version: '0'
63
56
  - !ruby/object:Gem::Dependency
64
57
  name: rake
65
58
  requirement: !ruby/object:Gem::Requirement
66
- none: false
67
59
  requirements:
68
- - - ! '>='
60
+ - - ">="
69
61
  - !ruby/object:Gem::Version
70
62
  version: '0'
71
63
  type: :development
72
64
  prerelease: false
73
65
  version_requirements: !ruby/object:Gem::Requirement
74
- none: false
75
66
  requirements:
76
- - - ! '>='
67
+ - - ">="
77
68
  - !ruby/object:Gem::Version
78
69
  version: '0'
79
- description: Provides access to every endpoint of the XING API. Takes care of oauth,
80
- reponse parsing and simplifies error handling. You can get the required consumer_key
81
- and consumer_secret at https://dev.xing.com
70
+ - !ruby/object:Gem::Dependency
71
+ name: rubocop
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ description: |2
85
+ Provides access to every endpoint of the XING API.
86
+ Takes care of oauth, reponse parsing and simplifies error handling.
87
+ You can get the required consumer_key and consumer_secret at https://dev.xing.com
82
88
  email:
83
89
  - api-support@xing.com
84
90
  executables: []
85
91
  extensions: []
86
92
  extra_rdoc_files: []
87
93
  files:
88
- - lib/xing_api/profile_visit.rb
94
+ - lib/xing_api.rb
95
+ - lib/xing_api/activity.rb
89
96
  - lib/xing_api/activity/comment.rb
90
97
  - lib/xing_api/activity/like.rb
98
+ - lib/xing_api/base.rb
99
+ - lib/xing_api/bookmark.rb
100
+ - lib/xing_api/client.rb
101
+ - lib/xing_api/contact.rb
102
+ - lib/xing_api/contact/tag.rb
103
+ - lib/xing_api/contact_request.rb
104
+ - lib/xing_api/conversation.rb
105
+ - lib/xing_api/conversation/attachment.rb
106
+ - lib/xing_api/conversation/message.rb
91
107
  - lib/xing_api/error.rb
92
- - lib/xing_api/user.rb
93
- - lib/xing_api/response_handler.rb
108
+ - lib/xing_api/group.rb
94
109
  - lib/xing_api/invite.rb
95
- - lib/xing_api/contact_request.rb
96
- - lib/xing_api/version.rb
97
- - lib/xing_api/user/school.rb
98
- - lib/xing_api/user/qualification.rb
99
- - lib/xing_api/user/photo.rb
100
- - lib/xing_api/user/recommendation.rb
101
- - lib/xing_api/user/language.rb
110
+ - lib/xing_api/job.rb
111
+ - lib/xing_api/profile_message.rb
112
+ - lib/xing_api/profile_visit.rb
113
+ - lib/xing_api/response_handler.rb
114
+ - lib/xing_api/user.rb
115
+ - lib/xing_api/user/birth_date.rb
116
+ - lib/xing_api/user/business_address.rb
102
117
  - lib/xing_api/user/company.rb
118
+ - lib/xing_api/user/language.rb
119
+ - lib/xing_api/user/photo.rb
103
120
  - lib/xing_api/user/private_address.rb
121
+ - lib/xing_api/user/qualification.rb
122
+ - lib/xing_api/user/recommendation.rb
123
+ - lib/xing_api/user/school.rb
104
124
  - lib/xing_api/user/web_profile.rb
105
- - lib/xing_api/user/birth_date.rb
106
- - lib/xing_api/user/business_address.rb
107
- - lib/xing_api/contact.rb
108
- - lib/xing_api/profile_message.rb
109
- - lib/xing_api/conversation.rb
110
- - lib/xing_api/conversation/message.rb
111
- - lib/xing_api/conversation/attachment.rb
112
- - lib/xing_api/activity.rb
113
- - lib/xing_api/base.rb
114
- - lib/xing_api/client.rb
115
- - lib/xing_api/bookmark.rb
116
- - lib/xing_api/contact/tag.rb
117
- - lib/xing_api/job.rb
118
- - lib/xing_api.rb
125
+ - lib/xing_api/version.rb
119
126
  homepage: https://github.com/xing/xing_api
120
127
  licenses:
121
128
  - MIT
129
+ metadata: {}
122
130
  post_install_message:
123
131
  rdoc_options: []
124
132
  require_paths:
125
133
  - lib
126
134
  required_ruby_version: !ruby/object:Gem::Requirement
127
- none: false
128
135
  requirements:
129
- - - ! '>='
136
+ - - ">="
130
137
  - !ruby/object:Gem::Version
131
138
  version: '0'
132
139
  required_rubygems_version: !ruby/object:Gem::Requirement
133
- none: false
134
140
  requirements:
135
- - - ! '>='
141
+ - - ">="
136
142
  - !ruby/object:Gem::Version
137
143
  version: 1.3.5
138
144
  requirements: []
139
145
  rubyforge_project:
140
- rubygems_version: 1.8.23
146
+ rubygems_version: 2.4.5
141
147
  signing_key:
142
- specification_version: 3
148
+ specification_version: 4
143
149
  summary: Official Ruby wrapper for the XING API
144
150
  test_files: []