Class: Teems::Api::Messages
Overview
API wrapper for messages endpoints Uses Teams ng.msg service for reading messages Requires skypeToken from authsvc exchange (not the JWT from localStorage)
Constant Summary collapse
- ENDPOINT =
:msgservice
Instance Method Summary collapse
-
#channel_messages(channel_id:, limit: 50) ⇒ Object
Get messages from a channel using ng.msg API.
-
#chat_messages(chat_id:, limit: 50) ⇒ Object
Get messages from a chat using ng.msg API.
-
#chat_messages_page(chat_id:, limit: 200, **pagination) ⇒ Object
Get a page of messages for sync, with pagination support.
-
#replies(thread_id:, message_id:, limit: 50) ⇒ Object
Get replies to a message.
Methods inherited from Client
Constructor Details
This class inherits a constructor from Teems::Api::Client
Instance Method Details
#channel_messages(channel_id:, limit: 50) ⇒ Object
Get messages from a channel using ng.msg API
12 13 14 15 16 17 |
# File 'lib/teems/api/messages.rb', line 12 def (channel_id:, limit: 50) # The ng.msg API uses /v1/users/ME/conversations/{threadId}/messages encoded_id = URI.encode_www_form_component(channel_id) get("/v1/users/ME/conversations/#{encoded_id}/messages", params: { pageSize: limit, view: 'msnp24Equivalent|supportsMessageProperties' }) end |
#chat_messages(chat_id:, limit: 50) ⇒ Object
Get messages from a chat using ng.msg API
20 21 22 23 24 |
# File 'lib/teems/api/messages.rb', line 20 def (chat_id:, limit: 50) encoded_id = URI.encode_www_form_component(chat_id) get("/v1/users/ME/conversations/#{encoded_id}/messages", params: { pageSize: limit, view: 'msnp24Equivalent|supportsMessageProperties' }) end |
#chat_messages_page(chat_id:, limit: 200, **pagination) ⇒ Object
Get a page of messages for sync, with pagination support. Returns the full response hash including _metadata for pagination.
When backward_link is provided, follows it directly to get older messages. Otherwise builds a request with startTime for time-range filtering.
The ng.msg API returns newest-first with _metadata.backwardLink for older pages.
33 34 35 36 37 38 39 40 |
# File 'lib/teems/api/messages.rb', line 33 def (chat_id:, limit: 200, **pagination) backward_link = pagination[:backward_link] return get(backward_link, params: {}) if backward_link encoded_id = URI.encode_www_form_component(chat_id) params = (limit, pagination[:start_time]) get("/v1/users/ME/conversations/#{encoded_id}/messages", params: params) end |
#replies(thread_id:, message_id:, limit: 50) ⇒ Object
Get replies to a message
43 44 45 46 47 |
# File 'lib/teems/api/messages.rb', line 43 def replies(thread_id:, message_id:, limit: 50) encoded_id = URI.encode_www_form_component(thread_id) get("/v1/users/ME/conversations/#{encoded_id}/messages/#{}/replies", params: { pageSize: limit }) end |