Module: Yammer::Api::Message

Included in:
Client
Defined in:
lib/yammer/api/message.rb

Instance Method Summary collapse

Instance Method Details

#all_messages(opts = {}) ⇒ Yammer::ApiResponse

Examples:

Fetch a list of messages from the company feed

msgs = Yammer.all_messages

Parameters:

  • opts (Hash) (defaults to: {})

    the options to fetch the messages with

Options Hash (opts):

  • :newer_than (Integer)

Returns:

Raises:

See Also:

Rest API path:

  • /api/v1/messages

Rate Limited?:

  • Yes

Authentication:

  • Requires user context



84
85
86
# File 'lib/yammer/api/message.rb', line 84

def all_messages(opts={})
  get("/api/v1/messages", opts)
end

#create_message(body, opts = {}) ⇒ Yammer::ApiResponse

Examples:

Create a new message

msg1 = Yammer.create_message('what are you workings on?')

msg2 = Yammer.create_message('building a yammer client', :replied_to_id => msg.id)

Attaching files

file1 = File.open('test1.txt')
file2 = File.open('test2.txt')
msg3 =  Yammer.create_message('building a yammer client', :attachment1 => file1, :attachment2 => file2 )

Parameters:

  • body (String)

    Message body

  • opts (Hash) (defaults to: {})

    the options to create a message with

Options Hash (opts):

  • :cc (Integer)
  • :replied_to_id (Integer)
  • :group_id (Integer)
  • :direct_to_user_ids (Array<Integer>)
  • :pending_attachment_ids (Array<Integer>)

Returns:

Raises:

See Also:

Rest API path:

  • /api/v1/messages

Rate Limited?:

  • Yes

Authentication:

  • Requires user context



42
43
44
45
# File 'lib/yammer/api/message.rb', line 42

def create_message(body, opts={})
  opts[:body] = body
  post("/api/v1/messages", opts)
end

#delete_message(id) ⇒ Yammer::ApiResponse

Examples:

Delete an existing message

result = Yammer.delete_message(1)

Parameters:

  • id (Integer)

    the thread ID

Returns:

Raises:

See Also:

Rest API path:

  • /api/v1/messages

Rate Limited?:

  • Yes

Authentication:

  • Requires user context



57
58
59
# File 'lib/yammer/api/message.rb', line 57

def delete_message(id)
  delete("/api/v1/messages/#{id}")
end

#followed_messages(opts = {}) ⇒ Yammer::ApiResponse

Examples:

Fetch a list of messages being followed by authenitcated user

msgs = Yammer.followed_messages

Parameters:

  • opts (Hash) (defaults to: {})

    the options to fetch the messages with

Options Hash (opts):

  • :newer_than (Integer)

Returns:

Raises:

See Also:

Rest API path:

  • /api/v1/messages

Rate Limited?:

  • Yes

Authentication:

  • Requires user context



140
141
142
# File 'lib/yammer/api/message.rb', line 140

def followed_messages(opts={})
  get("/api/v1/messages/following", opts)
end

#get_message(id) ⇒ Yammer::ApiResponse

Examples:

Fetch an existing message

msg = Yammer.get_message(3)

Parameters:

  • id (Integer)

    the ID of the message to be fetched

Returns:

Raises:

See Also:

Rest API path:

  • /api/v1/messages

Rate Limited?:

  • Yes

Authentication:

  • Requires user context



70
71
72
# File 'lib/yammer/api/message.rb', line 70

def get_message(id)
  get("/api/v1/messages/#{id}")
end

#like_message(id) ⇒ Yammer::ApiResponse

Examples:

Marks the specified message as liked by the current user

msgs = Yammer.like_message(10)

Parameters:

  • id (Integer)

    the ID of the message for which you want the current user to mark as liked

Returns:

Raises:

See Also:

Rest API path:

  • /api/v1/messages/liked_by/current.json?message_id=[:id]

Rate Limited?:

  • Yes

Authentication:

  • Requires user context



213
214
215
# File 'lib/yammer/api/message.rb', line 213

def like_message(id)
  post("/api/v1/messages/liked_by/current.json?message_id=#{id}", {})
end

#messages_about_topic(id, opts = {}) ⇒ Yammer::ApiResponse

Examples:

Fetch messages that have been tagged with a given topic

msgs = Yammer.messages_about_topic(1)

Parameters:

  • id (Integer)

    the topic ID

  • opts (Hash) (defaults to: {})

    the options to fetch the messages with

Options Hash (opts):

  • :newer_than (Integer)

Returns:

Raises:

See Also:

Rest API path:

  • /api/v1/messages

Rate Limited?:

  • Yes

Authentication:

  • Requires user context



170
171
172
# File 'lib/yammer/api/message.rb', line 170

def messages_about_topic(id, opts={})
  get("/api/v1/messages/about_topic/#{id}", opts)
end

#messages_for_open_graph_object(id) ⇒ Yammer::ApiResponse

Examples:

Fetch a list of messages in a given thread

msgs = Yammer.messages_for_open_graph_pbject(10)

Parameters:

  • id (Integer)

    the thread ID

Returns:

Raises:

See Also:

Rest API path:

  • /api/v1/messages/open_graph_objects

Rate Limited?:

  • Yes

Authentication:

  • Requires user context



254
255
256
# File 'lib/yammer/api/message.rb', line 254

def messages_for_open_graph_object(id)
  get("/api/v1/messages/open_graph_objects/#{id}")
end

#messages_from_user(id, opts = {}) ⇒ Yammer::ApiResponse

Examples:

Fetch a list of messages sent by a user in the authenticated user's network

msgs = Yammer.messages_from_user(8)

Parameters:

  • id (Integer)

    the ID of the user whose public messages we want to look at

  • opts (Hash) (defaults to: {})

    the options to fetch the messages with

Options Hash (opts):

  • :newer_than (Integer)

Returns:

Raises:

See Also:

Rest API path:

  • /api/v1/messages

Rate Limited?:

  • Yes

Authentication:

  • Requires user context



155
156
157
# File 'lib/yammer/api/message.rb', line 155

def messages_from_user(id, opts={})
  get("/api/v1/messages/from_user/#{id}", opts)
end

#messages_in_group(id, opts = {}) ⇒ Yammer::ApiResponse

Examples:

Fetch a list of messages in a given group

msgs = Yammer.messages_in_group(38)

Parameters:

  • id (Integer)

    the ID of the group whose messages you wish to fetch

  • opts (Hash) (defaults to: {})

    the options to fetch the messages with

Options Hash (opts):

  • :newer_than (Integer)

Returns:

Raises:

See Also:

Rest API path:

  • /api/v1/messages

Rate Limited?:

  • Yes

Authentication:

  • Requires user context



185
186
187
# File 'lib/yammer/api/message.rb', line 185

def messages_in_group(id, opts={})
  get("/api/v1/messages/in_group/#{id}", opts)
end

#messages_in_thread(id, opts = {}) ⇒ Yammer::ApiResponse

Examples:

Fetch a list of messages in a given thread

msgs = Yammer.messages_in_thread(10)

Parameters:

  • id (Integer)

    the thread ID

  • opts (Hash) (defaults to: {})

    the options to fetch the messages with

Options Hash (opts):

  • :newer_than (Integer)

Returns:

Raises:

See Also:

Rest API path:

  • /api/v1/messages

Rate Limited?:

  • Yes

Authentication:

  • Requires user context



241
242
243
# File 'lib/yammer/api/message.rb', line 241

def messages_in_thread(id, opts={})
  get("/api/v1/messages/in_thread/#{id}", opts)
end

#messages_liked_by(id, opts = {}) ⇒ Yammer::ApiResponse

Examples:

Fetch a list of messages liked by a given user

msgs = Yammer.messages_liked_by(4)

Parameters:

  • id (Integer)

    the ID of the user for whom you wish to get a list of messages they have liked

  • opts (Hash) (defaults to: {})

    the options to fetch the messages with

Options Hash (opts):

  • :newer_than (Integer)

Returns:

Raises:

See Also:

Rest API path:

  • /api/v1/messages

Rate Limited?:

  • Yes

Authentication:

  • Requires user context



200
201
202
# File 'lib/yammer/api/message.rb', line 200

def messages_liked_by(id, opts={})
  get("/api/v1/messages/liked_by/#{id}", opts)
end

#messages_received(opts = {}) ⇒ Yammer::ApiResponse

Examples:

Fetch list of messages sent to authenitcated user

msgs = Yammer.messages_received

Parameters:

  • opts (Hash) (defaults to: {})

    the options to fetch the messages with

Options Hash (opts):

  • :newer_than (Integer)

Returns:

Raises:

See Also:

Rest API path:

  • /api/v1/messages

Rate Limited?:

  • Yes

Authentication:

  • Requires user context



112
113
114
# File 'lib/yammer/api/message.rb', line 112

def messages_received(opts={})
  get("/api/v1/messages/received", opts)
end

#messages_sent(opts = {}) ⇒ Yammer::ApiResponse

Examples:

Fetch list messages sent by authenticated user

msgs = Yammer.messages_sent

Parameters:

  • opts (Hash) (defaults to: {})

    the options to fetch the messages with

Options Hash (opts):

  • :newer_than (Integer)

Returns:

Raises:

See Also:

Rest API path:

  • /api/v1/messages

Rate Limited?:

  • Yes

Authentication:

  • Requires user context



98
99
100
# File 'lib/yammer/api/message.rb', line 98

def messages_sent(opts={})
  get("/api/v1/messages/sent", opts)
end

#private_messages(opts = {}) ⇒ Yammer::ApiResponse

Examples:

Fetch a list of private messages sent to authenitcated user

msgs = Yammer.private_messages

Parameters:

  • opts (Hash) (defaults to: {})

    the options to fetch the messages with

Options Hash (opts):

  • :newer_than (Integer)

Returns:

Raises:

See Also:

Rest API path:

  • /api/v1/messages

Rate Limited?:

  • Yes

Authentication:

  • Requires user context



126
127
128
# File 'lib/yammer/api/message.rb', line 126

def private_messages(opts={})
  get("/api/v1/messages/private", opts)
end

#unlike_message(id) ⇒ Yammer::ApiResponse

Examples:

Removes the like mark on the specified message for the current user

msgs = Yammer.like_message(10)

Parameters:

  • id (Integer)

    the ID of the message for which you want the current user to remove the like mark

Returns:

Raises:

See Also:

Rest API path:

  • /api/v1/messages/liked_by/current.json?message_id=[:id]

Rate Limited?:

  • Yes

Authentication:

  • Requires user context



226
227
228
# File 'lib/yammer/api/message.rb', line 226

def unlike_message(id)
  delete("/api/v1/messages/liked_by/current.json?message_id=#{id}", {})
end