Class: WhopSDK::Resources::AuthorizedUsers

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

Overview

Authorized users

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ AuthorizedUsers

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

Parameters:



152
153
154
# File 'lib/whop_sdk/resources/authorized_users.rb', line 152

def initialize(client:)
  @client = client
end

Instance Method Details

#create(company_id:, role:, user_id:, send_emails: nil, request_options: {}) ⇒ WhopSDK::Models::AuthorizedUser

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

Add a new authorized user to a company.

Required permissions:

  • ‘authorized_user:create`

  • ‘member:email:read`

Parameters:

  • company_id (String)

    The ID of the company to add the authorized user to.

  • role (Symbol, WhopSDK::Models::AuthorizedUserRoles)

    The role to assign to the authorized user within the company. Supported roles: ‘

  • user_id (String)

    The ID of the user to add as an authorized user.

  • send_emails (Boolean, nil)

    Whether to send notification emails to the user on creation.

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

Returns:

See Also:



32
33
34
35
36
37
38
39
40
41
# File 'lib/whop_sdk/resources/authorized_users.rb', line 32

def create(params)
  parsed, options = WhopSDK::AuthorizedUserCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "authorized_users",
    body: parsed,
    model: WhopSDK::AuthorizedUser,
    options: options
  )
end

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

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

Remove an authorized user from a company.

Required permissions:

  • ‘authorized_user:delete`

Parameters:

  • id (String)

    The ID of the authorized user or user to remove.

  • company_id (String, nil)

    The ID of the company the authorized user belongs to. Optional if the authorized

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

Returns:

  • (Boolean)

See Also:



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

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

#list(after: nil, before: nil, company_id: nil, created_after: nil, created_before: nil, first: nil, last: nil, role: nil, user_id: nil, request_options: {}) ⇒ WhopSDK::Internal::CursorPage<WhopSDK::Models::AuthorizedUserListResponse>

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

Returns a paginated list of authorized team members for a company, with optional filtering by user, role, and creation date.

Required permissions:

  • ‘company:authorized_user:read`

  • ‘member:email: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 the company to list authorized users for.

  • created_after (Time, nil)

    Only return authorized users created after this timestamp.

  • created_before (Time, nil)

    Only return authorized users created before this timestamp.

  • first (Integer, nil)

    Returns the first n elements from the list.

  • last (Integer, nil)

    Returns the last n elements from the list.

  • role (Symbol, WhopSDK::Models::AuthorizedUserRoles, nil)

    Possible roles an authorized user can have

  • user_id (String, nil)

    Filter results to a specific user to check if they are an authorized team member

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

Returns:

See Also:



104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/whop_sdk/resources/authorized_users.rb', line 104

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

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

Retrieves the details of an existing authorized user.

Required permissions:

  • ‘company:authorized_user:read`

  • ‘member:email:read`

Parameters:

  • id (String)

    The unique identifier of the authorized user to retrieve.

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

Returns:

See Also:



59
60
61
62
63
64
65
66
# File 'lib/whop_sdk/resources/authorized_users.rb', line 59

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