Class: WhopSDK::Resources::Plans

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Plans

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

Parameters:



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

def initialize(client:)
  @client = client
end

Instance Method Details

#create(company_id: , product_id: , billing_period: nil, currency: nil, custom_fields: nil, description: nil, expiration_days: nil, image: nil, initial_price: nil, internal_notes: nil, override_tax_type: nil, payment_method_configuration: nil, plan_type: nil, release_method: nil, renewal_price: nil, stock: nil, strike_through_initial_price: nil, strike_through_renewal_price: nil, title: nil, trial_period_days: nil, unlimited_stock: nil, visibility: nil, request_options: {}) ⇒ WhopSDK::Models::Plan

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

Create a new Plan

Required permissions:

  • ‘plan:create`

  • ‘access_pass:basic:read`

  • ‘plan:basic:read`

Parameters:

  • company_id (String)

    The company the plan should be created for.

  • product_id (String)

    The product the plan is related to.

  • billing_period (Integer, nil)

    The interval in days at which the plan charges (renewal plans).

  • currency (Symbol, WhopSDK::Models::Currency, nil)

    The available currencies on the platform

  • custom_fields (Array<WhopSDK::Models::PlanCreateParams::CustomField>, nil)

    An array of custom field objects.

  • description (String, nil)

    The description of the plan.

  • expiration_days (Integer, nil)

    The interval at which the plan charges (expiration plans).

  • image (WhopSDK::Models::PlanCreateParams::Image::AttachmentInputWithDirectUploadID, WhopSDK::Models::PlanCreateParams::Image::AttachmentInputWithID, nil)

    An image for the plan. This will be visible on the product page to customers.

  • initial_price (Float, nil)

    An additional amount charged upon first purchase. Use only if a one time payment

  • internal_notes (String, nil)

    A personal description or notes section for the business.

  • override_tax_type (Symbol, WhopSDK::Models::TaxType, nil)

    Whether or not the tax is included in a plan’s price (or if it hasn’t been set u

  • payment_method_configuration (WhopSDK::Models::PlanCreateParams::PaymentMethodConfiguration, nil)

    The explicit payment method configuration for the plan. If not provided, the pla

  • plan_type (Symbol, WhopSDK::Models::PlanType, nil)

    The type of plan that can be attached to a product

  • release_method (Symbol, WhopSDK::Models::ReleaseMethod, nil)

    The methods of how a plan can be released.

  • renewal_price (Float, nil)

    The amount the customer is charged every billing period. Use only if a recurring

  • stock (Integer, nil)

    The number of units available for purchase.

  • strike_through_initial_price (Float, nil)

    The price to display with a strikethrough for the initial price. Provided as a n

  • strike_through_renewal_price (Float, nil)

    The price to display with a strikethrough for the renewal price. Provided as a n

  • title (String, nil)

    The title of the plan. This will be visible on the product page to customers.

  • trial_period_days (Integer, nil)

    The number of free trial days added before a renewal plan.

  • unlimited_stock (Boolean, nil)

    Limits/doesn’t limit the number of units available for purchase.

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

    Visibility of a resource

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

Returns:

See Also:



68
69
70
71
# File 'lib/whop_sdk/resources/plans.rb', line 68

def create(params)
  parsed, options = WhopSDK::PlanCreateParams.dump_request(params)
  @client.request(method: :post, path: "plans", body: parsed, model: WhopSDK::Plan, options: options)
end

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

Delete an existing Plan

Required permissions:

  • ‘plan:delete`

Parameters:

  • id (String)

    The ID of the plan 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/plans.rb', line 228

def delete(id, params = {})
  @client.request(
    method: :delete,
    path: ["plans/%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, plan_types: nil, product_ids: nil, release_methods: nil, visibilities: nil, request_options: {}) ⇒ WhopSDK::Internal::CursorPage<WhopSDK::Models::PlanListResponse>

Lists plans for a company

Required permissions:

  • ‘plan:basic:read`

Parameters:

  • company_id (String)

    The ID of the company

  • 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::PlanListParams::Order, nil)

    The ways a relation of Plans can be ordered

  • plan_types (Array<Symbol, WhopSDK::Models::PlanType>, nil)

    The plan type to filter the plans by

  • product_ids (Array<String>, nil)

    The product IDs to filter the plans by

  • release_methods (Array<Symbol, WhopSDK::Models::ReleaseMethod>, nil)

    The release method to filter the plans by

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

    The visibility to filter the plans 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/plans.rb', line 201

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

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

Retrieves a plan by ID

Required permissions:

  • ‘plan:basic:read`

Parameters:

Returns:

See Also:



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

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

#update(id, billing_period: nil, currency: nil, custom_fields: nil, description: nil, expiration_days: nil, image: nil, initial_price: nil, internal_notes: nil, offer_cancel_discount: nil, override_tax_type: nil, payment_method_configuration: nil, renewal_price: nil, stock: nil, strike_through_initial_price: nil, strike_through_renewal_price: nil, title: nil, trial_period_days: nil, unlimited_stock: nil, visibility: nil, request_options: {}) ⇒ WhopSDK::Models::Plan

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

Update an existing Plan

Required permissions:

  • ‘plan:update`

  • ‘access_pass:basic:read`

  • ‘plan:basic:read`

Parameters:

  • id (String)

    The ID

  • billing_period (Integer, nil)

    The interval at which the plan charges (renewal plans).

  • currency (Symbol, WhopSDK::Models::Currency, nil)

    The available currencies on the platform

  • custom_fields (Array<WhopSDK::Models::PlanUpdateParams::CustomField>, nil)

    An array of custom field objects.

  • description (String, nil)

    The description of the plan.

  • expiration_days (Integer, nil)

    The interval at which the plan charges (expiration plans).

  • image (WhopSDK::Models::PlanUpdateParams::Image::AttachmentInputWithDirectUploadID, WhopSDK::Models::PlanUpdateParams::Image::AttachmentInputWithID, nil)

    An image for the plan. This will be visible on the product page to customers.

  • initial_price (Float, nil)

    An additional amount charged upon first purchase.

  • internal_notes (String, nil)

    A personal description or notes section for the business.

  • offer_cancel_discount (Boolean, nil)

    Whether or not to offer a discount to cancel a subscription.

  • override_tax_type (Symbol, WhopSDK::Models::TaxType, nil)

    Whether or not the tax is included in a plan’s price (or if it hasn’t been set u

  • payment_method_configuration (WhopSDK::Models::PlanUpdateParams::PaymentMethodConfiguration, nil)

    The explicit payment method configuration for the plan. If sent as null, the cus

  • renewal_price (Float, nil)

    The amount the customer is charged every billing period.

  • stock (Integer, nil)

    The number of units available for purchase.

  • strike_through_initial_price (Float, nil)

    The price to display with a strikethrough for the initial price. Provided as a n

  • strike_through_renewal_price (Float, nil)

    The price to display with a strikethrough for the renewal price. Provided as a n

  • title (String, nil)

    The title of the plan. This will be visible on the product page to customers.

  • trial_period_days (Integer, nil)

    The number of free trial days added before a renewal plan.

  • unlimited_stock (Boolean, nil)

    Limits/doesn’t limit the number of units available for purchase.

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

    Visibility of a resource

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

Returns:

See Also:



155
156
157
158
159
160
161
162
163
164
# File 'lib/whop_sdk/resources/plans.rb', line 155

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