Module: X::Resources::DirectMessageConversations
- Included in:
- DirectMessage
- Defined in:
- x-resources/lib/x/resources/direct_message_conversations.rb
Overview
Group conversations of direct messages: starting one, sending to one, and reading one, extended by DirectMessage
Internal to x-resources: the methods it gives DirectMessage, such as X::DirectMessage.create_group, are public API, but the module is only how they are shared, and which classes extend or include it can change within 1.x.
Instance Method Summary collapse
-
#create_group(users, text = nil, client:, media_ids: nil, **params) ⇒ DirectMessage
Start a group conversation, sending its first message as the authenticated user.
-
#create_in(conversation, text = nil, client:, media_ids: nil, **params) ⇒ DirectMessage
Send a direct message to a conversation as the authenticated user.
-
#in(conversation, client:, **params) ⇒ Cursor
The direct message events of a conversation, one-to-one or group.
Instance Method Details
#create_group(users, text = nil, client:, media_ids: nil, **params) ⇒ DirectMessage
Start a group conversation, sending its first message as the authenticated user
40 41 42 43 |
# File 'x-resources/lib/x/resources/direct_message_conversations.rb', line 40 def create_group(users, text = nil, client:, media_ids: nil, **params) body = {conversation_type: "Group", participant_ids: users.map { |user| Utils.id_of(user, User) }, message: (text, params, media_ids)} sent(client.post("dm_conversations", body, **Utils::JSON_CLASSES), "dm_conversations", client:) end |
#create_in(conversation, text = nil, client:, media_ids: nil, **params) ⇒ DirectMessage
Send a direct message to a conversation as the authenticated user
63 64 65 66 |
# File 'x-resources/lib/x/resources/direct_message_conversations.rb', line 63 def create_in(conversation, text = nil, client:, media_ids: nil, **params) path = "dm_conversations/#{conversation_id_of(conversation)}/messages" sent(client.post(path, (text, params, media_ids), **Utils::JSON_CLASSES), path, client:) end |
#in(conversation, client:, **params) ⇒ Cursor
The direct message events of a conversation, one-to-one or group
78 79 80 81 |
# File 'x-resources/lib/x/resources/direct_message_conversations.rb', line 78 def in(conversation, client:, **params) path = "dm_conversations/#{conversation_id_of(conversation)}/dm_events" Cursor.__send__(:build, DirectMessage, path, client:, params: {max_results: MAX_RESULTS}.merge(params)) end |