Class: WhopSDK::Resources::Products

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

Overview

Products

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:



240
241
242
# File 'lib/whop_sdk/resources/products.rb', line 240

def initialize(client:)
  @client = client
end

Instance Method Details

#create(company_id:, title:, collect_shipping_address: nil, custom_cta: nil, custom_cta_url: nil, custom_statement_descriptor: nil, description: nil, experience_ids: nil, global_affiliate_percentage: nil, global_affiliate_status: nil, headline: nil, member_affiliate_percentage: nil, member_affiliate_status: nil, plan_options: 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.

Create a new product for a company. The product serves as the top-level container for plans and experiences.

Required permissions:

  • ‘access_pass:create`

  • ‘access_pass:basic:read`

Parameters:

  • company_id (String)

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

  • title (String)

    The display name of the product. Maximum 80 characters.

  • collect_shipping_address (Boolean, nil)

    Whether the checkout flow collects a shipping address from the customer.

  • custom_cta (Symbol, WhopSDK::Models::CustomCta, nil)

    The different types of custom CTAs that can be selected.

  • custom_cta_url (String, nil)

    A URL that the call-to-action button links to instead of the default checkout fl

  • custom_statement_descriptor (String, nil)

    A custom text label that appears on the customer’s bank statement. Must be 5-22

  • description (String, nil)

    A written description of the product displayed on its product page.

  • experience_ids (Array<String>, nil)

    The unique identifiers of experiences to connect to this product.

  • global_affiliate_percentage (Float, nil)

    The commission rate as a percentage that affiliates earn through the global affi

  • global_affiliate_status (Symbol, WhopSDK::Models::GlobalAffiliateStatus, nil)

    The different statuses of the global affiliate program for a product.

  • headline (String, nil)

    A short marketing headline displayed prominently on the product page.

  • member_affiliate_percentage (Float, nil)

    The commission rate as a percentage that members earn through the member affilia

  • member_affiliate_status (Symbol, WhopSDK::Models::GlobalAffiliateStatus, nil)

    The different statuses of the global affiliate program for a product.

  • plan_options (WhopSDK::Models::ProductCreateParams::PlanOptions, nil)

    Configuration for an automatically generated plan to attach to this product.

  • product_tax_code_id (String, nil)

    The unique identifier of the tax classification code to apply to this product.

  • redirect_purchase_url (String, nil)

    A URL to redirect the customer to after completing a 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 (Symbol, WhopSDK::Models::Visibility, nil)

    Visibility of a resource

  • 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/products.rb', line 63

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

Permanently delete a product and remove it from the company’s catalog.

Required permissions:

  • ‘access_pass:delete`

Parameters:

  • id (String)

    The unique identifier of the product to delete.

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

Returns:

  • (Boolean)

See Also:



228
229
230
231
232
233
234
235
# File 'lib/whop_sdk/resources/products.rb', line 228

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:, after: nil, before: nil, created_after: nil, created_before: nil, direction: nil, first: nil, last: nil, order: nil, product_types: nil, visibilities: nil, request_options: {}) ⇒ WhopSDK::Internal::CursorPage<WhopSDK::Models::ProductListItem>

Returns a paginated list of products belonging to a company, with optional filtering by type, visibility, and creation date.

Required permissions:

  • ‘access_pass:basic:read`

Parameters:

  • company_id (String)

    The unique identifier of the company to list products 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.

  • created_after (Time, nil)

    Only return products created after this timestamp.

  • created_before (Time, nil)

    Only return products created before this timestamp.

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

  • order (Symbol, WhopSDK::Models::ProductListParams::Order, nil)

    The ways a relation of AccessPasses can be ordered

  • product_types (Array<Symbol, WhopSDK::Models::AccessPassType>, nil)

    Filter to only products matching these type classifications.

  • visibilities (Array<Symbol, WhopSDK::Models::VisibilityFilter>, nil)

    Filter to only products matching these visibility states.

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

Returns:

See Also:



200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/whop_sdk/resources/products.rb', line 200

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.

Required permissions:

  • ‘access_pass:basic:read`

Parameters:

  • id (String)

    The unique identifier or route slug of the product.

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

Returns:

See Also:



89
90
91
92
93
94
95
96
# File 'lib/whop_sdk/resources/products.rb', line 89

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

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

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

Update a product’s title, description, visibility, and other settings.

Required permissions:

  • ‘access_pass:update`

  • ‘access_pass:basic:read`

Parameters:

  • id (String)

    The unique identifier of the product to update.

  • collect_shipping_address (Boolean, nil)

    Whether the checkout flow collects a shipping address from the customer.

  • custom_cta (Symbol, WhopSDK::Models::CustomCta, nil)

    The different types of custom CTAs that can be selected.

  • custom_cta_url (String, nil)

    A URL that the call-to-action button links to instead of the default checkout fl

  • custom_statement_descriptor (String, nil)

    A custom text label that appears on the customer’s bank statement. Must be 5-22

  • description (String, nil)

    A written description of the product displayed on its product page.

  • gallery_images (Array<WhopSDK::Models::ProductUpdateParams::GalleryImage>, nil)

    The gallery images for the product.

  • global_affiliate_percentage (Float, nil)

    The commission rate as a percentage that affiliates earn through the global affi

  • global_affiliate_status (Symbol, WhopSDK::Models::GlobalAffiliateStatus, nil)

    The different statuses of the global affiliate program for a product.

  • headline (String, nil)

    A short marketing headline displayed prominently on the product page.

  • member_affiliate_percentage (Float, nil)

    The commission rate as a percentage that members earn through the member affilia

  • member_affiliate_status (Symbol, WhopSDK::Models::GlobalAffiliateStatus, nil)

    The different statuses of the global affiliate program for a product.

  • product_tax_code_id (String, nil)

    The unique identifier of the tax classification code to apply to this product.

  • redirect_purchase_url (String, nil)

    A URL to redirect the customer to after completing a 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

  • store_page_config (WhopSDK::Models::ProductUpdateParams::StorePageConfig, nil)

    Layout and display configuration for this product on the company’s store page.

  • title (String, nil)

    The display name of the product. Maximum 80 characters.

  • visibility (Symbol, WhopSDK::Models::Visibility, nil)

    Visibility of a resource

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

Returns:

See Also:



153
154
155
156
157
158
159
160
161
162
# File 'lib/whop_sdk/resources/products.rb', line 153

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