Class: WhopSDK::Resources::Companies

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Companies

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

Parameters:



103
104
105
# File 'lib/whop_sdk/resources/companies.rb', line 103

def initialize(client:)
  @client = client
end

Instance Method Details

#create(email: , parent_company_id: , title: , metadata: nil, request_options: {}) ⇒ WhopSDK::Models::Company

Create a new sub company for your platform

Required permissions:

  • ‘company:create_child`

  • ‘company:basic:read`

Parameters:

  • email (String)

    The email of the user who the company will belong to.

  • parent_company_id (String)

    The company ID of the platform creating this company.

  • title (String)

    The name of the company being created.

  • metadata (Hash{Symbol=>Object}, nil)

    Additional metadata for the account

  • 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/companies.rb', line 28

def create(params)
  parsed, options = WhopSDK::CompanyCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "companies",
    body: parsed,
    model: WhopSDK::Company,
    options: options
  )
end

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

Lists companies the current user has access to

Required permissions:

  • ‘company:basic:read`

Parameters:

  • parent_company_id (String)

    The ID of the parent company to list sub companies 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.

  • direction (Symbol, WhopSDK::Models::Direction, nil)

    The direction of the sort.

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



88
89
90
91
92
93
94
95
96
97
98
# File 'lib/whop_sdk/resources/companies.rb', line 88

def list(params)
  parsed, options = WhopSDK::CompanyListParams.dump_request(params)
  @client.request(
    method: :get,
    path: "companies",
    query: parsed,
    page: WhopSDK::Internal::CursorPage,
    model: WhopSDK::Models::CompanyListResponse,
    options: options
  )
end

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

Retrieves an company by ID or its url route

Required permissions:

  • ‘company:basic:read`

Parameters:

  • id (String)

    The ID or route of the company

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

Returns:

See Also:



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

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