Class: WhopSDK::Resources::Experiences

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

Overview

Experiences

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Experiences

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

Parameters:



257
258
259
# File 'lib/whop_sdk/resources/experiences.rb', line 257

def initialize(client:)
  @client = client
end

Instance Method Details

#attach(id, product_id:, request_options: {}) ⇒ WhopSDK::Models::Experience

Attach an experience to a product, making it accessible to the product’s customers.

Required permissions:

  • ‘experience:attach`

Parameters:

  • id (String)

    The unique identifier of the experience to attach.

  • product_id (String)

    The unique identifier of the product to attach the experience to.

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

Returns:

See Also:



178
179
180
181
182
183
184
185
186
187
# File 'lib/whop_sdk/resources/experiences.rb', line 178

def attach(id, params)
  parsed, options = WhopSDK::ExperienceAttachParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["experiences/%1$s/attach", id],
    body: parsed,
    model: WhopSDK::Experience,
    options: options
  )
end

#create(app_id:, company_id:, is_public: nil, logo: nil, name: nil, section_id: nil, request_options: {}) ⇒ WhopSDK::Models::Experience

Required permissions:

  • ‘experience:create`

Parameters:

  • app_id (String)

    The unique identifier of the app that powers this experience.

  • company_id (String)

    The unique identifier of the company to create this experience for.

  • is_public (Boolean, nil)

    Whether the experience is publicly accessible without a membership.

  • logo (WhopSDK::Models::ExperienceCreateParams::Logo, nil)

    A logo image displayed alongside the experience name.

  • name (String, nil)

    The display name of the experience. Defaults to the app’s name if not provided.

  • section_id (String, nil)

    The unique identifier of the section to place the experience in.

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

Returns:

See Also:



30
31
32
33
34
35
36
37
38
39
# File 'lib/whop_sdk/resources/experiences.rb', line 30

def create(params)
  parsed, options = WhopSDK::ExperienceCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "experiences",
    body: parsed,
    model: WhopSDK::Experience,
    options: options
  )
end

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

Required permissions:

  • ‘experience:delete`

Parameters:

  • id (String)

    The unique identifier of the experience to delete.

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

Returns:

  • (Boolean)

See Also:



151
152
153
154
155
156
157
158
# File 'lib/whop_sdk/resources/experiences.rb', line 151

def delete(id, params = {})
  @client.request(
    method: :delete,
    path: ["experiences/%1$s", id],
    model: WhopSDK::Internal::Type::Boolean,
    options: params[:request_options]
  )
end

#detach(id, product_id:, request_options: {}) ⇒ WhopSDK::Models::Experience

Detach an experience from a product, removing customer access to it through that product.

Required permissions:

  • ‘experience:detach`

Parameters:

  • id (String)

    The unique identifier of the experience to detach.

  • product_id (String)

    The unique identifier of the product to detach the experience from.

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

Returns:

See Also:



207
208
209
210
211
212
213
214
215
216
# File 'lib/whop_sdk/resources/experiences.rb', line 207

def detach(id, params)
  parsed, options = WhopSDK::ExperienceDetachParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["experiences/%1$s/detach", id],
    body: parsed,
    model: WhopSDK::Experience,
    options: options
  )
end

#duplicate(id, name: nil, request_options: {}) ⇒ WhopSDK::Models::Experience

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

Duplicates an existing experience. The name will be copied, unless provided. The new experience will be attached to the same products as the original experience. If duplicating a Forum or Chat experience, the new experience will have the same settings as the original experience, e.g. who can post, who can comment, etc. No content, e.g. posts, messages, lessons from within the original experience will be copied.

Required permissions:

  • ‘experience:create`

Parameters:

  • id (String)

    The unique identifier of the experience to duplicate.

  • name (String, nil)

    The display name for the duplicated experience. Defaults to the original experie

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

Returns:

See Also:



243
244
245
246
247
248
249
250
251
252
# File 'lib/whop_sdk/resources/experiences.rb', line 243

def duplicate(id, params = {})
  parsed, options = WhopSDK::ExperienceDuplicateParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["experiences/%1$s/duplicate", id],
    body: parsed,
    model: WhopSDK::Experience,
    options: options
  )
end

#list(company_id:, after: nil, app_id: nil, before: nil, created_after: nil, created_before: nil, first: nil, last: nil, product_id: nil, request_options: {}) ⇒ WhopSDK::Internal::CursorPage<WhopSDK::Models::ExperienceListResponse>

Returns a paginated list of experiences belonging to a company, with optional filtering by product and app.

Parameters:

  • company_id (String)

    The unique identifier of the company to list experiences for.

  • after (String, nil)

    Returns the elements in the list that come after the specified cursor.

  • app_id (String, nil)

    Filter to only experiences powered by this app identifier.

  • before (String, nil)

    Returns the elements in the list that come before the specified cursor.

  • created_after (Time, nil)

    Only return experiences created after this timestamp.

  • created_before (Time, nil)

    Only return experiences created before this timestamp.

  • first (Integer, nil)

    Returns the first n elements from the list.

  • last (Integer, nil)

    Returns the last n elements from the list.

  • product_id (String, nil)

    Filter to only experiences attached to this product identifier.

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

Returns:

See Also:



125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/whop_sdk/resources/experiences.rb', line 125

def list(params)
  parsed, options = WhopSDK::ExperienceListParams.dump_request(params)
  query = WhopSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "experiences",
    query: query,
    page: WhopSDK::Internal::CursorPage,
    model: WhopSDK::Models::ExperienceListResponse,
    options: options
  )
end

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

Retrieves the details of an existing experience.

Parameters:

  • id (String)

    The unique identifier of the experience.

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

Returns:

See Also:



52
53
54
55
56
57
58
59
# File 'lib/whop_sdk/resources/experiences.rb', line 52

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

#update(id, access_level: nil, is_public: nil, logo: nil, name: nil, order: nil, section_id: nil, request_options: {}) ⇒ WhopSDK::Models::Experience

Required permissions:

  • ‘experience:update`

Parameters:

  • id (String)

    The unique identifier of the experience to update.

  • access_level (Symbol, WhopSDK::Models::ExperienceUpdateParams::AccessLevel, nil)

    The different access levels for experiences (PUBLIC IS NEVER USED ANYMORE).

  • is_public (Boolean, nil)

    Whether the experience is publicly accessible without a membership.

  • logo (WhopSDK::Models::ExperienceUpdateParams::Logo, nil)

    A logo image displayed alongside the experience name.

  • name (String, nil)

    The display name of the experience.

  • order (String, nil)

    The position of the experience within its section for display ordering.

  • section_id (String, nil)

    The unique identifier of the section to move the experience into.

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

Returns:

See Also:



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

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