Class: WhopSDK::Resources::Reactions

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

Overview

Reactions

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Reactions

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 Reactions.

Parameters:



138
139
140
# File 'lib/whop_sdk/resources/reactions.rb', line 138

def initialize(client:)
  @client = client
end

Instance Method Details

#create(resource_id:, emoji: nil, poll_option_id: nil, request_options: {}) ⇒ WhopSDK::Models::Reaction

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

Add an emoji reaction or poll vote to a message or forum post. In forums, the reaction is always a like.

Required permissions:

  • ‘chat:read`

Parameters:

  • resource_id (String)

    The unique identifier of the message or forum post to react to.

  • emoji (String, nil)

    The emoji to react with, in shortcode or unicode format. For example, ‘:heart:’

  • poll_option_id (String, nil)

    The unique identifier of a poll option to vote for. Only valid when the target m

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

Returns:

See Also:



30
31
32
33
34
35
36
37
38
39
# File 'lib/whop_sdk/resources/reactions.rb', line 30

def create(params)
  parsed, options = WhopSDK::ReactionCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "reactions",
    body: parsed,
    model: WhopSDK::Reaction,
    options: options
  )
end

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

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

Remove an emoji reaction from a message or forum post. Only the reaction author or a channel admin can remove a reaction.

Required permissions:

  • ‘chat:read`

Parameters:

  • id (String)

    The unique identifier of the reaction to remove, or the identifier of the messag

  • emoji (String, nil)

    The emoji to remove, in shortcode or unicode format. For example, ‘:heart:’ or a

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

Returns:

  • (Boolean)

See Also:



123
124
125
126
127
128
129
130
131
132
133
# File 'lib/whop_sdk/resources/reactions.rb', line 123

def delete(id, params = {})
  parsed, options = WhopSDK::ReactionDeleteParams.dump_request(params)
  query = WhopSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :delete,
    path: ["reactions/%1$s", id],
    query: query,
    model: WhopSDK::Internal::Type::Boolean,
    options: options
  )
end

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

Returns a paginated list of emoji reactions on a specific message or forum post, sorted by most recent.

Required permissions:

  • ‘chat:read`

Parameters:

  • resource_id (String)

    The unique identifier of the message or forum post to list reactions 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.

  • 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:



89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/whop_sdk/resources/reactions.rb', line 89

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

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

Retrieves the details of an existing reaction.

Required permissions:

  • ‘chat:read`

Parameters:

  • id (String)

    The unique identifier of the reaction to retrieve.

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

Returns:

See Also:



56
57
58
59
60
61
62
63
# File 'lib/whop_sdk/resources/reactions.rb', line 56

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