Class: WhopSDK::Resources::Products

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

Overview

A Product is a digital good or service sold on Whop. Products may contain plans for pricing and/or experiences for content delivery.

Use the Products API to create products, list products visible to your credentials, retrieve product details, update product metadata or merchandising fields, and delete products that should no longer be sold.

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Products

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

Parameters:



195
196
197
# File 'lib/whop_sdk/resources/products.rb', line 195

def initialize(client:)
  @client = client
end

Instance Method Details

#create(title:, collect_shipping_address: nil, company_id: nil, custom_cta: nil, custom_cta_url: nil, custom_statement_descriptor: nil, description: nil, global_affiliate_percentage: nil, global_affiliate_status: nil, headline: nil, member_affiliate_percentage: nil, member_affiliate_status: nil, metadata: nil, product_tax_code_id: nil, redirect_purchase_url: nil, route: nil, send_welcome_message: nil, visibility: nil, request_options: {}) ⇒ WhopSDK::Models::Product

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

Creates a new product for a company.

Parameters:

  • title (String)

    The display name of the product. Maximum 80 characters.

  • collect_shipping_address (Boolean, nil)

    Whether to collect a shipping address at checkout.

  • company_id (String)

    The unique identifier of the company to create this product for.

  • custom_cta (String, nil)

    The call-to-action button label.

  • custom_cta_url (String, nil)

    A URL the call-to-action button links to.

  • custom_statement_descriptor (String, nil)

    Custom bank statement descriptor. Must start with WHOP*.

  • description (String, nil)

    A written description displayed on the product page.

  • global_affiliate_percentage (Float, nil)

    The commission rate affiliates earn.

  • global_affiliate_status (String)

    The enrollment status in the global affiliate program.

  • headline (String, nil)

    A short marketing headline for the product page.

  • member_affiliate_percentage (Float, nil)

    The commission rate members earn.

  • member_affiliate_status (String)

    The enrollment status in the member affiliate program.

  • metadata (Object, nil)

    Custom key-value pairs to store on the product.

  • product_tax_code_id (String, nil)

    The unique identifier of the tax classification code. See the available [product

  • redirect_purchase_url (String, nil)

    A URL to redirect the customer to after purchase.

  • route (String, nil)

    The URL slug for the product's public link.

  • send_welcome_message (Boolean, nil)

    Whether to send an automated welcome message via support chat when a user joins

  • visibility (String)

    Whether the product is visible to customers.

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

Returns:

See Also:



60
61
62
63
64
65
66
67
68
69
# File 'lib/whop_sdk/resources/products.rb', line 60

def create(params)
  parsed, options = WhopSDK::ProductCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "products",
    body: parsed,
    model: WhopSDK::Product,
    options: options
  )
end

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

Deletes a product. Only products with no memberships, entries, reviews, or invoices can be deleted.

Parameters:

  • id (String)

    The unique identifier of the product.

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

Returns:

  • (Boolean)

See Also:



183
184
185
186
187
188
189
190
# File 'lib/whop_sdk/resources/products.rb', line 183

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

#list(company_id:, access_pass_types: nil, after: nil, before: nil, direction: nil, first: nil, last: nil, order: nil, visibilities: nil, request_options: {}) ⇒ WhopSDK::Internal::CursorPage<WhopSDK::Models::ProductListItem>

Returns a paginated list of products belonging to a company.

Parameters:

  • company_id (String)

    The unique identifier of the company to list products for.

  • access_pass_types (Array<String>)

    Filter to only products matching these types.

  • after (String)

    A cursor; returns products after this position.

  • before (String)

    A cursor; returns products before this position.

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

    The sort direction for results. Defaults to descending.

  • first (Integer)

    The number of products to return (default and max 100).

  • last (Integer)

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

  • order (String)

    The field to sort results by. Defaults to created_at.

  • visibilities (Array<String>)

    Filter to only products matching these visibility states.

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

Returns:

See Also:



158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/whop_sdk/resources/products.rb', line 158

def list(params)
  parsed, options = WhopSDK::ProductListParams.dump_request(params)
  query = WhopSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "products",
    query: query,
    page: WhopSDK::Internal::CursorPage,
    model: WhopSDK::ProductListItem,
    options: options
  )
end

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

Retrieves the details of an existing product. This endpoint is publicly accessible.

Parameters:

  • id (String)

    The unique identifier of the product.

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

Returns:

See Also:



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

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

#update(id, description: nil, headline: nil, metadata: nil, product_tax_code_id: nil, send_welcome_message: nil, title: nil, visibility: nil, request_options: {}) ⇒ WhopSDK::Models::Product

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

Updates an existing product.

Parameters:

  • id (String)

    The unique identifier of the product.

  • description (String, nil)

    A written description displayed on the product page.

  • headline (String, nil)

    A short marketing headline for the product page.

  • metadata (Object, nil)

    Custom key-value pairs to store on the product.

  • product_tax_code_id (String, nil)

    The unique identifier of the tax classification code. See the available [product

  • send_welcome_message (Boolean, nil)

    Whether to send an automated welcome message via support chat when a user joins

  • title (String)

    The display name of the product.

  • visibility (String)

    Whether the product is visible to customers.

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

Returns:

See Also:



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

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