Module: LinkedIn::Api::UpdateMethods
Constant Summary
Constants included from Helpers::Request
Helpers::Request::API_PATH, Helpers::Request::DEFAULT_HEADERS
Instance Method Summary collapse
- #add_share(share) ⇒ Object
- #message_to_xml(member_id, subject, message) ⇒ Object
- #post(path, body = '', options = {}) ⇒ Object
-
#send_message(member_id, subject, message) ⇒ Object
def share(options={}) path = “/people/~/shares” defaults = { :visability => ‘anyone’ } post(path, share_to_xml(defaults.merge(options))) end.
Instance Method Details
#add_share(share) ⇒ Object
8 9 10 11 12 |
# File 'lib/linked_in/api/update_methods.rb', line 8 def add_share(share) path = "/people/~/shares" defaults = {:visibility => {:code => "anyone"}} post(path, defaults.merge(share).to_json, "Content-Type" => "application/json") end |
#message_to_xml(member_id, subject, message) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/linked_in/api/update_methods.rb', line 60 def (member_id, subject, ) %Q{<?xml version="1.0" encoding="UTF-8"?> <mailbox-item> <recipients> <recipient> <person path="/people/#{member_id}" /> </recipient> </recipients> <subject>#{subject}</subject> <body>#{.strip}</body> </mailbox-item>} end |
#post(path, body = '', options = {}) ⇒ Object
73 74 75 76 77 |
# File 'lib/linked_in/api/update_methods.rb', line 73 def post(path, body='', ={}) response = access_token.post("#{API_PATH}#{path}", body, ) raise_errors(response) response end |
#send_message(member_id, subject, message) ⇒ Object
def share(options={})
path = "/people/~/shares"
defaults = { :visability => 'anyone' }
post(path, share_to_xml(defaults.merge()))
end
def update_comment(network_key, comment)
path = "/people/~/network/updates/key=#{network_key}/update-comments"
post(path, comment_to_xml(comment))
end
def update_network(message)
path = "/people/~/person-activities"
post(path, network_update_to_xml())
end
def send_message(subject, body, recipient_paths)
path = "/people/~/mailbox"
= LinkedIn::Message.new
.subject = subject
.body = body
recipients = LinkedIn::Recipients.new
recipients.recipients = recipient_paths.map do |profile_path|
recipient = LinkedIn::Recipient.new
recipient.person = LinkedIn::Person.new
recipient.person.path = "/people/#{profile_path}"
recipient
end
.recipients = recipients
post(path, ()).code
end
def clear_status
path = "/people/~/current-status"
delete(path).code
end
54 55 56 57 58 |
# File 'lib/linked_in/api/update_methods.rb', line 54 def (member_id, subject, ) path = "/people/~/mailbox" resp = post(path, (member_id, subject, ), {'Content-Type' => 'application/xml'}) (resp. == "Created" || resp.code.to_s == '201') ? true : false end |