diff --git a/lib/linked_in/api/update_methods.rb b/lib/linked_in/api/update_methods.rb index 0a70273e..22cca0ec 100644 --- a/lib/linked_in/api/update_methods.rb +++ b/lib/linked_in/api/update_methods.rb @@ -69,6 +69,27 @@ def send_message(subject, body, recipient_paths) post(path, message.to_json, "Content-Type" => "application/json") end + def invite_by_email(email) + require 'uri' + path = "/people/~/mailbox" + safe_email = URI.escape(email) + message = { + 'subject' => "Join my network on LinkedIn", + 'body' => "I'd like to add you to my professional network on LinkedIn.", + 'recipients' => { + 'values' => [{ + 'person' => { '_path' => "/people/email=#{safe_email}" } + }] + }, + 'item-content' => { + 'invitation-request' => { + 'connect-type' => 'friend' + } + } + } + post(path, message.to_json, "Content-Type" => "application/json") + end + def post_group_discussion(group_id, discussion) path = "/groups/#{group_id}/posts" post(path, discussion.to_json, "Content-Type" => "application/json")