Class: WhopSDK::Resources::Products
- Inherits:
-
Object
- Object
- WhopSDK::Resources::Products
- 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
-
#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.
-
#delete(id, request_options: {}) ⇒ Boolean
Deletes a product.
-
#initialize(client:) ⇒ Products
constructor
private
A new instance of Products.
-
#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.
-
#retrieve(id, request_options: {}) ⇒ WhopSDK::Models::Product
Retrieves the details of an existing product.
-
#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.
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.
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.
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/whop_sdk/resources/products.rb', line 60 def create(params) parsed, = WhopSDK::ProductCreateParams.dump_request(params) @client.request( method: :post, path: "products", body: parsed, model: WhopSDK::Product, options: ) end |
#delete(id, request_options: {}) ⇒ Boolean
Deletes a product. Only products with no memberships, entries, reviews, or invoices can be deleted.
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.
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, = 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: ) end |
#retrieve(id, request_options: {}) ⇒ WhopSDK::Models::Product
Retrieves the details of an existing product. This endpoint is publicly accessible.
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.
120 121 122 123 124 125 126 127 128 129 |
# File 'lib/whop_sdk/resources/products.rb', line 120 def update(id, params = {}) parsed, = WhopSDK::ProductUpdateParams.dump_request(params) @client.request( method: :patch, path: ["products/%1$s", id], body: parsed, model: WhopSDK::Product, options: ) end |