Class: WhopSDK::Resources::Messages

Inherits:
Object
  • Object
show all
Defined in:
lib/whop_sdk/resources/messages.rb

Overview

Messages

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Messages

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Messages.

Parameters:



171
172
173
# File 'lib/whop_sdk/resources/messages.rb', line 171

def initialize(client:)
  @client = client
end

Instance Method Details

#create(channel_id:, content:, attachments: nil, auto_detect_links: nil, poll: nil, replying_to_message_id: nil, request_options: {}) ⇒ WhopSDK::Models::Message

Some parameter documentations has been truncated, see Models::MessageCreateParams for more details.

Send a new message in an experience chat, DM, or group chat channel. Supports text content, attachments, polls, and replies.

Required permissions:

  • ‘chat:message:create`

Parameters:

  • channel_id (String)

    The unique identifier of the channel or experience to send the message in. For e

  • content (String)

    The body of the message in Markdown format. For example, ‘Hello world’.

  • attachments (Array<WhopSDK::Models::MessageCreateParams::Attachment>, nil)

    A list of file attachments to include with the message, such as images or videos

  • auto_detect_links (Boolean, nil)

    Automatically detect URLs in the message and generate link previews.

  • poll (WhopSDK::Models::MessageCreateParams::Poll, nil)

    A poll to attach to this message, allowing recipients to vote on options.

  • replying_to_message_id (String, nil)

    The unique identifier of the message this is replying to, creating a threaded re

  • request_options (WhopSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



36
37
38
39
40
41
42
43
44
45
# File 'lib/whop_sdk/resources/messages.rb', line 36

def create(params)
  parsed, options = WhopSDK::MessageCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "messages",
    body: parsed,
    model: WhopSDK::Message,
    options: options
  )
end

#delete(id, request_options: {}) ⇒ Boolean

Permanently delete a message from an experience chat, DM, or group chat channel. Only the message author or a channel admin can delete a message.

Required permissions:

  • ‘chat:message:create`

Parameters:

  • id (String)

    The unique identifier of the message to delete.

  • request_options (WhopSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (Boolean)

See Also:



159
160
161
162
163
164
165
166
# File 'lib/whop_sdk/resources/messages.rb', line 159

def delete(id, params = {})
  @client.request(
    method: :delete,
    path: ["messages/%1$s", id],
    model: WhopSDK::Internal::Type::Boolean,
    options: params[:request_options]
  )
end

#list(channel_id:, after: nil, before: nil, direction: nil, first: nil, last: nil, request_options: {}) ⇒ WhopSDK::Internal::CursorPage<WhopSDK::Models::MessageListResponse>

Returns a paginated list of messages within a specific experience chat, DM, or group chat channel, sorted by creation time.

Required permissions:

  • ‘chat:read`

Parameters:

  • channel_id (String)

    The unique identifier of the channel or experience to list messages for.

  • after (String, nil)

    Returns the elements in the list that come after the specified cursor.

  • before (String, nil)

    Returns the elements in the list that come before the specified cursor.

  • direction (Symbol, WhopSDK::Models::Direction, nil)

    The direction of the sort.

  • first (Integer, nil)

    Returns the first n elements from the list.

  • last (Integer, nil)

    Returns the last n elements from the list.

  • request_options (WhopSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/whop_sdk/resources/messages.rb', line 130

def list(params)
  parsed, options = WhopSDK::MessageListParams.dump_request(params)
  query = WhopSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "messages",
    query: query,
    page: WhopSDK::Internal::CursorPage,
    model: WhopSDK::Models::MessageListResponse,
    options: options
  )
end

#retrieve(id, request_options: {}) ⇒ WhopSDK::Models::Message

Retrieves the details of an existing message.

Required permissions:

  • ‘chat:read`

Parameters:

  • id (String)

    The unique identifier of the message to retrieve.

  • request_options (WhopSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



62
63
64
65
66
67
68
69
# File 'lib/whop_sdk/resources/messages.rb', line 62

def retrieve(id, params = {})
  @client.request(
    method: :get,
    path: ["messages/%1$s", id],
    model: WhopSDK::Message,
    options: params[:request_options]
  )
end

#update(id, attachments: nil, content: nil, is_pinned: nil, request_options: {}) ⇒ WhopSDK::Models::Message

Some parameter documentations has been truncated, see Models::MessageUpdateParams for more details.

Edit the content, attachments, or pinned status of an existing message in an experience chat, DM, or group chat channel.

‘Hello *world

Parameters:

  • id (String)

    The unique identifier of the message to update.

  • attachments (Array<WhopSDK::Models::MessageUpdateParams::Attachment>, nil)

    A replacement list of file attachments for this message, such as images or video

  • content (String, nil)

    The updated body of the message in Markdown format. For example,

  • is_pinned (Boolean, nil)

    Whether this message should be pinned to the top of the channel.

  • request_options (WhopSDK::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



93
94
95
96
97
98
99
100
101
102
# File 'lib/whop_sdk/resources/messages.rb', line 93

def update(id, params = {})
  parsed, options = WhopSDK::MessageUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["messages/%1$s", id],
    body: parsed,
    model: WhopSDK::Message,
    options: options
  )
end