Class: WhopSDK::Resources::PromoCodes
- Inherits:
-
Object
- Object
- WhopSDK::Resources::PromoCodes
- Defined in:
- lib/whop_sdk/resources/promo_codes.rb
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 further use.
-
#initialize(client:) ⇒ PromoCodes
constructor
private
A new instance of PromoCodes.
-
#list(company_id: , after: nil, before: nil, first: nil, last: nil, plan_ids: nil, product_ids: nil, status: nil, request_options: {}) ⇒ WhopSDK::Internal::CursorPage<WhopSDK::Models::PromoCodeListResponse>
Lists promo codes for a company.
-
#retrieve(id, request_options: {}) ⇒ WhopSDK::Models::PromoCode
Retrieves a promo code by ID.
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.
158 159 160 |
# File 'lib/whop_sdk/resources/promo_codes.rb', line 158 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 for a product or plan
Required permissions:
-
‘promo_code:create`
-
‘access_pass:basic:read`
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/whop_sdk/resources/promo_codes.rb', line 53 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 further use
Required permissions:
-
‘promo_code:delete`
146 147 148 149 150 151 152 153 |
# File 'lib/whop_sdk/resources/promo_codes.rb', line 146 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, first: nil, last: nil, plan_ids: nil, product_ids: nil, status: nil, request_options: {}) ⇒ WhopSDK::Internal::CursorPage<WhopSDK::Models::PromoCodeListResponse>
Lists promo codes for a company
Required permissions:
-
‘promo_code:basic:read`
-
‘access_pass:basic:read`
119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/whop_sdk/resources/promo_codes.rb', line 119 def list(params) parsed, = WhopSDK::PromoCodeListParams.dump_request(params) @client.request( method: :get, path: "promo_codes", query: parsed, page: WhopSDK::Internal::CursorPage, model: WhopSDK::Models::PromoCodeListResponse, options: ) end |
#retrieve(id, request_options: {}) ⇒ WhopSDK::Models::PromoCode
Retrieves a promo code by ID
Required permissions:
-
‘promo_code:basic:read`
-
‘access_pass:basic:read`
80 81 82 83 84 85 86 87 |
# File 'lib/whop_sdk/resources/promo_codes.rb', line 80 def retrieve(id, params = {}) @client.request( method: :get, path: ["promo_codes/%1$s", id], model: WhopSDK::PromoCode, options: params[:request_options] ) end |