Class: WhopSDK::Resources::DmChannels

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

Overview

Dm channels

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ DmChannels

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

Parameters:



161
162
163
# File 'lib/whop_sdk/resources/dm_channels.rb', line 161

def initialize(client:)
  @client = client
end

Instance Method Details

#create(with_user_ids:, company_id: nil, custom_name: nil, request_options: {}) ⇒ WhopSDK::Models::DmChannel

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

Create a new DM channel between two or more users, optionally scoped to a specific company. Returns the existing channel if one already exists.

Parameters:

  • with_user_ids (Array<String>)

    The list of user identifiers to include in the DM channel. Each entry can be an

  • company_id (String, nil)

    The unique identifier of the company to scope this DM channel to. When set, the

  • custom_name (String, nil)

    A custom display name for the DM channel. For example, ‘Project Discussion’.

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

Returns:

See Also:



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

def create(params)
  parsed, options = WhopSDK::DmChannelCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "dm_channels",
    body: parsed,
    model: WhopSDK::DmChannel,
    options: options
  )
end

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

Permanently delete a DM channel and all of its messages. Only an admin of the channel can perform this action.

Required permissions:

  • ‘dms:channel:manage`

Parameters:

  • id (String)

    The unique identifier of the DM channel to delete.

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

Returns:

  • (Boolean)

See Also:



149
150
151
152
153
154
155
156
# File 'lib/whop_sdk/resources/dm_channels.rb', line 149

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

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

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

Returns a paginated list of DM channels for the currently authenticated user, sorted by most recently active.

Required permissions:

  • ‘dms:read`

Parameters:

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

  • company_id (String, nil)

    The unique identifier of a company to filter DM channels by. Only returns channe

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



120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/whop_sdk/resources/dm_channels.rb', line 120

def list(params = {})
  parsed, options = WhopSDK::DmChannelListParams.dump_request(params)
  query = WhopSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "dm_channels",
    query: query,
    page: WhopSDK::Internal::CursorPage,
    model: WhopSDK::Models::DmChannelListResponse,
    options: options
  )
end

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

Retrieves the details of an existing DM channel.

Required permissions:

  • ‘dms:read`

Parameters:

  • id (String)

    The unique identifier of the DM channel to retrieve.

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

Returns:

See Also:



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

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

#update(id, custom_name: nil, request_options: {}) ⇒ WhopSDK::Models::DmChannel

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

Update the settings of an existing DM channel, such as its display name. Only an admin of the channel can perform this action.

Required permissions:

  • ‘dms:channel:manage`

Parameters:

  • id (String)

    The unique identifier of the DM channel to update.

  • custom_name (String, nil)

    A new custom display name for the DM channel. For example, ‘Project Discussion’.

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

Returns:

See Also:



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

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