Class: WhopSDK::Resources::Messages

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

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:



130
131
132
# File 'lib/whop_sdk/resources/messages.rb', line 130

def initialize(client:)
  @client = client
end

Instance Method Details

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

Creates a new message

Required permissions:

  • ‘chat:message:create`

Parameters:

Returns:

See Also:



27
28
29
30
31
32
33
34
35
36
# File 'lib/whop_sdk/resources/messages.rb', line 27

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

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

Lists messages inside a channel

Required permissions:

  • ‘chat:read`

Parameters:

  • channel_id (String)

    The ID of the channel or the experience ID 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:



115
116
117
118
119
120
121
122
123
124
125
# File 'lib/whop_sdk/resources/messages.rb', line 115

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

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

Retrieves a message

Required permissions:

  • ‘chat:read`

Parameters:

Returns:

See Also:



53
54
55
56
57
58
59
60
# File 'lib/whop_sdk/resources/messages.rb', line 53

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

Updates an existing message

Parameters:

Returns:

See Also:



79
80
81
82
83
84
85
86
87
88
# File 'lib/whop_sdk/resources/messages.rb', line 79

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