Module: LinkedIn::API::Profiles
- Included in:
- Client
- Defined in:
- lib/linkedin/api/profiles.rb
Instance Method Summary collapse
- #connect_with(selector, subject, message, type = :friend, auth_name = nil, auth_value = nil) ⇒ Object
- #connections(selector = '~') ⇒ Object
- #message(subject, message, recipients) ⇒ Object
- #profile(selector = '~', fields = nil, token = nil) ⇒ Object
- #profile_api(selector) ⇒ Object
- #search(options = {}, token = nil) ⇒ Object
- #shared_connections(selector, offset = 0, limit = 10, token = nil) ⇒ Object
Instance Method Details
#connect_with(selector, subject, message, type = :friend, auth_name = nil, auth_value = nil) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/linkedin/api/profiles.rb', line 34 def connect_with(selector, subject, , type = :friend, auth_name = nil, auth_value = nil) if auth_name.blank? || auth_value.blank? profile = profile_api selector token = profile.apiStandardProfileRequest_.headers_.values_.first.value auth_name, auth_value = *token.split(':') end connection_request = { recipients: { values: [ { person: { _path: "/people/#{selector.to_param}" } } ] }, subject: subject, body: , 'item-content' => { 'invitation-request' => { 'connect-type' => type, authorization: { name: auth_name, value: auth_value } } } } post 'v1/people/~/mailbox' do |req| req.headers['Content-Type'] = 'application/json' req.headers['x-li-format'] = 'json' req.body = connection_request.to_json end end |
#connections(selector = '~') ⇒ Object
16 17 18 |
# File 'lib/linkedin/api/profiles.rb', line 16 def connections(selector = '~') profile [selector, 'connections'].join '/' end |
#message(subject, message, recipients) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/linkedin/api/profiles.rb', line 56 def (subject, , recipients) recipients = [recipients].flatten recipients = recipients.map { |recipient| { person: { _path: "/people/#{recipient.to_param}" } } } = { recipients: { values: recipients }, subject: subject, body: } post 'v1/people/~/mailbox' do |req| req.headers['Content-Type'] = 'application/json' req.headers['x-li-format'] = 'json' req.body = .to_json end end |
#profile(selector = '~', fields = nil, token = nil) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/linkedin/api/profiles.rb', line 8 def profile(selector = '~', fields = nil, token = nil) fields ||= profile_fields query = "#{selector.to_param}:(#{Permissions. fields})" get "v1/people/#{query}" do |req| req.headers.merge! 'x-li-auth-token' => token unless token.blank? end end |
#profile_api(selector) ⇒ Object
4 5 6 |
# File 'lib/linkedin/api/profiles.rb', line 4 def profile_api(selector) profile selector, Permissions::PROFILE_REQ end |
#search(options = {}, token = nil) ⇒ Object
28 29 30 31 32 |
# File 'lib/linkedin/api/profiles.rb', line 28 def search( = {}, token = nil) get "v1/people-search?#{.to_param}" do |req| req.headers.merge! 'x-li-auth-token' => token unless token.blank? end end |
#shared_connections(selector, offset = 0, limit = 10, token = nil) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/linkedin/api/profiles.rb', line 20 def shared_connections(selector, offset = 0, limit = 10, token = nil) query = "#{selector.to_param}:(#{Permissions. Permissions::RELATION})" get "v1/people/#{query}" do |req| req.params.merge! start: offset, count: limit req.headers.merge! 'x-li-auth-token' => token unless token.blank? end end |