Class: WhopSDK::Resources::Products

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

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: , business_type: nil, 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, industry_type: nil, member_affiliate_percentage: nil, member_affiliate_status: nil, plan_options: nil, product_highlights: nil, product_tax_code_id: nil, redirect_purchase_url: nil, route: nil, visibility: nil, request_options: {}) ⇒ WhopSDK::Models::Product

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

Creates a new Product

Required permissions:

  • ‘access_pass:create`

  • ‘access_pass:basic:read`

betwee

Parameters:

  • company_id (String)

    The ID of the company to create the product for.

  • title (String)

    The title of the product.

  • business_type (Symbol, WhopSDK::Models::BusinessTypes, nil)

    The different business types a company can be.

  • collect_shipping_address (Boolean, nil)

    Whether or not to collect shipping information at checkout 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)

    The custom call to action URL for the product.

  • custom_statement_descriptor (String, nil)

    The custom statement descriptor for the product i.e. WHOP*SPORTS, must be

  • description (String, nil)

    A written description of the product.

  • experience_ids (Array<String>, nil)

    An array of experience IDs that this pass has

  • global_affiliate_percentage (Float, nil)

    The percentage of the revenue that goes to the global affiliate program.

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

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

  • headline (String, nil)

    The headline of the product.

  • industry_type (Symbol, WhopSDK::Models::IndustryTypes, nil)

    The different industry types a company can be in.

  • member_affiliate_percentage (Float, nil)

    The percentage of the revenue that goes to the member affiliate program.

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

    The details to assign an autogenerated plan.

  • product_highlights (Array<WhopSDK::Models::ProductCreateParams::ProductHighlight>, nil)

    The product highlights for the product.

  • product_tax_code_id (String, nil)

    The ID of the product tax code to apply to this product.

  • redirect_purchase_url (String, nil)

    The URL to redirect the customer to after a purchase.

  • route (String, nil)

    The route of the product.

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

    Visibility of a resource

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

Returns:

See Also:



66
67
68
69
70
71
72
73
74
75
# File 'lib/whop_sdk/resources/products.rb', line 66

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 an existing Product

Required permissions:

  • ‘access_pass:delete`

Parameters:

  • id (String)

    The internal ID (tag) 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, direction: nil, first: nil, last: nil, order: nil, product_types: nil, visibilities: nil, request_options: {}) ⇒ WhopSDK::Internal::CursorPage<WhopSDK::Models::ProductListItem>

Lists products for a company

Required permissions:

  • ‘access_pass:basic:read`

Parameters:

  • company_id (String)

    The ID of the company to filter products by

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

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

    The ways a relation of AccessPasses can be ordered

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

    The type of products to filter by

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

    The visibility of the products to filter by

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

Returns:

See Also:



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

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

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

Retrieves a product by ID or route

Required permissions:

  • ‘access_pass:basic:read`

Parameters:

  • id (String)

    The ID or route of the product

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

Returns:

See Also:



92
93
94
95
96
97
98
99
# File 'lib/whop_sdk/resources/products.rb', line 92

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

#update(id, banner_image: nil, business_type: nil, collect_shipping_address: nil, custom_cta: nil, custom_cta_url: nil, custom_statement_descriptor: nil, description: nil, global_affiliate_percentage: nil, global_affiliate_status: nil, headline: nil, industry_type: nil, member_affiliate_percentage: nil, member_affiliate_status: nil, product_tax_code_id: nil, redirect_purchase_url: nil, route: 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.

Updates an existing Product

Required permissions:

  • ‘access_pass:update`

  • ‘access_pass:basic:read`

betwee

Parameters:

  • id (String)

    The ID (tag) of the product

  • banner_image (WhopSDK::Models::ProductUpdateParams::BannerImage::AttachmentInputWithDirectUploadID, WhopSDK::Models::ProductUpdateParams::BannerImage::AttachmentInputWithID, nil)

    A banner image for the product in png, jpeg format

  • business_type (Symbol, WhopSDK::Models::BusinessTypes, nil)

    The different business types a company can be.

  • collect_shipping_address (Boolean, nil)

    Whether or not to collect shipping information at checkout 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)

    The custom call to action URL for the product.

  • custom_statement_descriptor (String, nil)

    The custom statement descriptor for the product i.e. WHOP*SPORTS, must be

  • description (String, nil)

    A written description of the product.

  • global_affiliate_percentage (Float, nil)

    The percentage of the revenue that goes to the global affiliate program.

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

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

  • headline (String, nil)

    The headline of the product.

  • industry_type (Symbol, WhopSDK::Models::IndustryTypes, nil)

    The different industry types a company can be in.

  • member_affiliate_percentage (Float, nil)

    The percentage of the revenue that goes to the member affiliate program.

  • 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 ID of the product tax code to apply to this product.

  • redirect_purchase_url (String, nil)

    The URL to redirect the customer to after a purchase.

  • route (String, nil)

    The route of the product.

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

    Configuration for a product on the company’s store page.

  • title (String, nil)

    The title of the product.

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

    Visibility of a resource

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

Returns:

See Also:



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

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