Module: LinkedIn::Api::Communications

Included in:
Client
Defined in:
lib/linked_in/api/communications.rb

Overview

Communications APIs

Instance Method Summary collapse

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:

client.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:



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

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