Class: LinkedIn::Communications

Inherits:
APIResource show all
Defined in:
lib/linked_in/communications.rb

Overview

Communications APIs

Instance Method Summary collapse

Methods inherited from APIResource

#id_to_urn, #initialize, #urn_to_id

Constructor Details

This class inherits a constructor from LinkedIn::APIResource

Instance Method Details

#send_message(subject, body, recipient_paths) ⇒ void

This method returns an undefined value.

(Create) send a message from the authenticated user to a connection

Permissions: w_messages

Examples:

api.send_message("subject", "body", ["person_1_id", "person_2_id"])

Parameters:

  • subject (String)

    Subject of the message

  • body (String)

    Body of the message, plain text only

  • recipient_paths (Array<String>)

    a collection of profile paths that identify the users who will receive the message

See Also:



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/linked_in/communications.rb', line 24

def send_message(subject, body, recipient_paths)
  path = "/people/~/mailbox"

  message = {
    subject: subject,
    body: body,
    recipients: {
      values: recipient_paths.map do |profile_path|
        {person: {_path: "/people/#{profile_path}"} }
      end
    }
  }

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