Class: WhopSDK::Resources::Users

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

Overview

A User represents a person on Whop. Users have a public profile and can buy products, join accounts, and access experiences.

Use the Users API to search for users, retrieve or update profiles, and check whether a user has access to an account, product, or experience.

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:



190
191
192
# File 'lib/whop_sdk/resources/users.rb', line 190

def initialize(client:)
  @client = client
end

Instance Method Details

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

Checks whether a user has access to an account, product, or experience the caller can reach.

Parameters:

  • resource_id (String)

    An account (biz*), product (prod*), or experience (exp_) ID.

  • id (String)

    The user_ tag or username to check access for.

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

Returns:

See Also:



136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/whop_sdk/resources/users.rb', line 136

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

Search for users by name or username, ranked by social proximity to the authenticated user. Returns the user's most recently followed users when no query is given.

Parameters:

  • after (String)

    A cursor; returns users after this position.

  • before (String)

    A cursor; returns users before this position.

  • first (Integer)

    The number of users to return (max 50).

  • last (Integer)

    The number of users to return from the end of the range.

  • query (String)

    A search term to filter users by name or username.

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

Returns:

See Also:



109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/whop_sdk/resources/users.rb', line 109

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::User,
    options: options
  )
end

#retrieve(id, account_id: nil, from: nil, include_balance_history: nil, interval: nil, time_zone: nil, to: nil, request_options: {}) ⇒ WhopSDK::Models::User

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

Retrieves a user's public profile by user_ tag, username, or 'me'.

Parameters:

  • id (String)

    User ID (prefixed user_), username, or me.

  • account_id (String)

    When set, returns the user's account-specific profile overrides for this account

  • from (String)

    Balance-history window start, ISO 8601 date or datetime. Defaults to 30 days ago

  • include_balance_history (Boolean)

    On GET /users/me, also compute the caller's balance history (opt-in; runs a he

  • interval (Symbol, WhopSDK::Models::UserRetrieveParams::Interval)

    Balance-history point granularity. Defaults to day. Only used with `include_ba

  • time_zone (String)

    IANA time zone the balance-history points are bucketed in. Defaults to UTC. On

  • to (String)

    Balance-history window end, ISO 8601 date or datetime. Defaults to now. Only use

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

Returns:

See Also:



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/whop_sdk/resources/users.rb', line 37

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, account_id: nil, bio: 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.

Updates a user. A user token updates their own global profile; an API key updates the user's account-specific profile override (account_id required).

Parameters:

  • id (String)

    Path param: User ID (prefixed user_), username, or me.

  • account_id (String)

    Query param: The account whose profile override to update. Required for API key

  • bio (String)

    Body param

  • name (String)

    Body param

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

    Body param

  • username (String)

    Body param

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

Returns:

See Also:



74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/whop_sdk/resources/users.rb', line 74

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

#update_me(account_id: nil, bio: nil, name: nil, profile_picture: nil, username: nil, request_options: {}) ⇒ WhopSDK::Models::User

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

Updates the authenticated user's global profile, or their profile override for an account when account_id is given. Not available to API keys.

Parameters:

Returns:

See Also:



173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/whop_sdk/resources/users.rb', line 173

def update_me(params = {})
  query_params = [:account_id]
  parsed, options = WhopSDK::UserUpdateMeParams.dump_request(params)
  query = WhopSDK::Internal::Util.encode_query_params(parsed.slice(*query_params))
  @client.request(
    method: :patch,
    path: "users/me",
    query: query,
    body: parsed.except(*query_params),
    model: WhopSDK::User,
    options: options
  )
end