Class: WhopSDK::Resources::Users

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

Overview

Users

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Users

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

Parameters:



141
142
143
# File 'lib/whop_sdk/resources/users.rb', line 141

def initialize(client:)
  @client = client
end

Instance Method Details

#check_access(resource_id, id:, request_options: {}) ⇒ WhopSDK::Models::UserCheckAccessResponse

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

Check whether a user has access to a specific resource, and return their access level.

Parameters:

  • resource_id (String)

    The unique identifier of the resource to check access for. Accepts a company, pr

  • id (String)

    The unique identifier or username of the user.

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

Returns:

See Also:



124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/whop_sdk/resources/users.rb', line 124

def check_access(resource_id, params)
  parsed, options = WhopSDK::UserCheckAccessParams.dump_request(params)
  id =
    parsed.delete(:id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["users/%1$s/access/%2$s", id, resource_id],
    model: WhopSDK::Models::UserCheckAccessResponse,
    options: options
  )
end

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

Search for users by name or username, ranked by social proximity to the authenticated user.

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.

  • first (Integer, nil)

    Returns the first n elements from the list.

  • last (Integer, nil)

    Returns the last n elements from the list.

  • query (String, nil)

    Search term to filter by name or username.

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

Returns:

See Also:



94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/whop_sdk/resources/users.rb', line 94

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

#retrieve(id, company_id: nil, request_options: {}) ⇒ WhopSDK::Models::User

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

Retrieves the details of an existing user.

Parameters:

  • id (String)

    The unique identifier or username of the user.

  • company_id (String, nil)

    When provided, returns the user’s company-specific profile overrides (name, prof

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

Returns:

See Also:



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/whop_sdk/resources/users.rb', line 23

def retrieve(id, params = {})
  parsed, options = WhopSDK::UserRetrieveParams.dump_request(params)
  query = WhopSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["users/%1$s", id],
    query: query,
    model: WhopSDK::User,
    options: options
  )
end

#update(id, bio: nil, company_id: nil, name: nil, profile_picture: nil, username: nil, request_options: {}) ⇒ WhopSDK::Models::User

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

Update a user’s profile by their ID.

Required permissions:

  • ‘user:profile:update`

Parameters:

  • id (String)

    The unique identifier of the user to update. Accepts ‘me’, a user tag, or a user

  • bio (String, nil)

    A short biography displayed on the user’s public profile.

  • company_id (String, nil)

    When provided, updates the user’s profile overrides for this company instead of

  • name (String, nil)

    The user’s display name shown on their public profile. Maximum 100 characters.

  • profile_picture (WhopSDK::Models::UserUpdateParams::ProfilePicture, nil)

    The user’s profile picture image attachment.

  • username (String, nil)

    The user’s unique username. Alphanumeric characters and hyphens only. Maximum 42

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

Returns:

See Also:



63
64
65
66
67
68
69
70
71
72
# File 'lib/whop_sdk/resources/users.rb', line 63

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