Class: WhopSDK::Resources::PromoCodes
- Inherits:
-
Object
- Object
- WhopSDK::Resources::PromoCodes
- Defined in:
- lib/whop_sdk/resources/promo_codes.rb
Overview
Promo codes
Instance Method Summary collapse
-
#create(amount_off:, base_currency:, code:, company_id:, new_users_only:, promo_duration_months:, promo_type:, churned_users_only: nil, existing_memberships_only: nil, expires_at: nil, one_per_customer: nil, plan_ids: nil, product_id: nil, stock: nil, unlimited_stock: nil, request_options: {}) ⇒ WhopSDK::Models::PromoCode
Some parameter documentations has been truncated, see Models::PromoCodeCreateParams for more details.
-
#delete(id, request_options: {}) ⇒ Boolean
Archive a promo code, preventing it from being used in future checkouts.
-
#initialize(client:) ⇒ PromoCodes
constructor
private
A new instance of PromoCodes.
-
#list(company_id:, after: nil, before: nil, created_after: nil, created_before: nil, first: nil, last: nil, plan_ids: nil, product_ids: nil, status: nil, request_options: {}) ⇒ WhopSDK::Internal::CursorPage<WhopSDK::Models::PromoCodeListResponse>
Returns a paginated list of promo codes belonging to a company, with optional filtering by product, plan, and status.
-
#retrieve(id, request_options: {}) ⇒ WhopSDK::Models::PromoCode
Retrieves the details of an existing promo code.
Constructor Details
#initialize(client:) ⇒ PromoCodes
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 PromoCodes.
168 169 170 |
# File 'lib/whop_sdk/resources/promo_codes.rb', line 168 def initialize(client:) @client = client end |
Instance Method Details
#create(amount_off:, base_currency:, code:, company_id:, new_users_only:, promo_duration_months:, promo_type:, churned_users_only: nil, existing_memberships_only: nil, expires_at: nil, one_per_customer: nil, plan_ids: nil, product_id: nil, stock: nil, unlimited_stock: nil, request_options: {}) ⇒ WhopSDK::Models::PromoCode
Some parameter documentations has been truncated, see Models::PromoCodeCreateParams for more details.
Create a new promo code that applies a discount at checkout. Can be scoped to specific products or plans.
Required permissions:
-
‘promo_code:create`
-
‘access_pass:basic:read`
unlimited_
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/whop_sdk/resources/promo_codes.rb', line 56 def create(params) parsed, = WhopSDK::PromoCodeCreateParams.dump_request(params) @client.request( method: :post, path: "promo_codes", body: parsed, model: WhopSDK::PromoCode, options: ) end |
#delete(id, request_options: {}) ⇒ Boolean
Archive a promo code, preventing it from being used in future checkouts. Existing memberships are not affected.
Required permissions:
-
‘promo_code:delete`
156 157 158 159 160 161 162 163 |
# File 'lib/whop_sdk/resources/promo_codes.rb', line 156 def delete(id, params = {}) @client.request( method: :delete, path: ["promo_codes/%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, first: nil, last: nil, plan_ids: nil, product_ids: nil, status: nil, request_options: {}) ⇒ WhopSDK::Internal::CursorPage<WhopSDK::Models::PromoCodeListResponse>
Returns a paginated list of promo codes belonging to a company, with optional filtering by product, plan, and status.
Required permissions:
-
‘promo_code:basic:read`
-
‘access_pass:basic:read`
127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/whop_sdk/resources/promo_codes.rb', line 127 def list(params) parsed, = WhopSDK::PromoCodeListParams.dump_request(params) query = WhopSDK::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "promo_codes", query: query, page: WhopSDK::Internal::CursorPage, model: WhopSDK::Models::PromoCodeListResponse, options: ) end |
#retrieve(id, request_options: {}) ⇒ WhopSDK::Models::PromoCode
Retrieves the details of an existing promo code.
Required permissions:
-
‘promo_code:basic:read`
-
‘access_pass:basic:read`
83 84 85 86 87 88 89 90 |
# File 'lib/whop_sdk/resources/promo_codes.rb', line 83 def retrieve(id, params = {}) @client.request( method: :get, path: ["promo_codes/%1$s", id], model: WhopSDK::PromoCode, options: params[:request_options] ) end |