Class: WhopSDK::Resources::DmMembers

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

Overview

Dm members

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ DmMembers

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

Parameters:



159
160
161
# File 'lib/whop_sdk/resources/dm_members.rb', line 159

def initialize(client:)
  @client = client
end

Instance Method Details

#create(channel_id:, user_id:, request_options: {}) ⇒ WhopSDK::Models::DmMember

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

Add a new user to an existing DM channel. Only an admin of the channel can add members.

Required permissions:

  • ‘dms:channel:manage`

Parameters:

  • channel_id (String)

    The unique identifier of the DM channel to add the new member to.

  • user_id (String)

    The unique identifier of the user to add to the DM channel. For example, ‘user_x

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

Returns:

See Also:



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

def create(params)
  parsed, options = WhopSDK::DmMemberCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "dm_members",
    body: parsed,
    model: WhopSDK::DmMember,
    options: options
  )
end

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

Remove a user from a DM channel. An admin can remove any member, and a member can remove themselves.

Required permissions:

  • ‘dms:channel:manage`

Parameters:

  • id (String)

    The unique identifier of the DM channel member to remove.

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

Returns:

  • (Boolean)

See Also:



147
148
149
150
151
152
153
154
# File 'lib/whop_sdk/resources/dm_members.rb', line 147

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

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

Returns a paginated list of members in a specific DM channel, sorted by the date they were added.

Required permissions:

  • ‘dms:read`

Parameters:

  • channel_id (String)

    The unique identifier of the DM channel to list members 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:



118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/whop_sdk/resources/dm_members.rb', line 118

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

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

Retrieves the details of an existing DM member.

Required permissions:

  • ‘dms:read`

Parameters:

  • id (String)

    The unique identifier of the DM channel member to retrieve.

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

Returns:

See Also:



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

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

#update(id, notification_preference: nil, status: nil, request_options: {}) ⇒ WhopSDK::Models::DmMember

Update a DM channel member’s settings, such as their notification preferences or membership status.

Required permissions:

  • ‘dms:channel:manage`

Parameters:

Returns:

See Also:



83
84
85
86
87
88
89
90
91
92
# File 'lib/whop_sdk/resources/dm_members.rb', line 83

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