Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added 'invite by email' API call #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/linked_in/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ def initialize(access_token=nil)
:company_updates_likes,
:company_updates_comments

def_delegators :@communications, :send_message
def_delegators :@communications, :send_message,
:invite_by_email

def_delegators :@share_and_social_stream, :shares,
:add_share,
Expand Down
25 changes: 25 additions & 0 deletions lib/linked_in/communications.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,30 @@ def send_message(subject, body, recipient_paths)

post(path, message)
end

def invite_by_email(email, first_name, last_name, **options)
path = "/people/~/mailbox"

message = {
"subject" => options[:subject] || "Invitation to connect",
"body" => options[:body] || "Please join my professional network on LinkedIn.",
"recipients" => {
"values" => [{
"person" => {
"_path" => "/people/email=#{email}",
"first-name" => first_name,
"last-name" => last_name
}
}]
},
"item-content" => {
"invitation-request" => {
"connect-type" => "friend"
}
}
}

post(path, message.to_json, "Content-Type" => "application/json")
end
end
end