Class: WhopSDK::Resources::Courses

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

Overview

Courses

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Courses

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

Parameters:



192
193
194
# File 'lib/whop_sdk/resources/courses.rb', line 192

def initialize(client:)
  @client = client
end

Instance Method Details

#create(experience_id:, title:, certificate_after_completion_enabled: nil, order: nil, require_completing_lessons_in_order: nil, tagline: nil, thumbnail: nil, visibility: nil, request_options: {}) ⇒ WhopSDK::Models::Course

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

Create a new course within an experience, with optional chapters, lessons, and a certificate.

Required permissions:

  • ‘courses:update`

Parameters:

  • experience_id (String)

    The unique identifier of the experience to create the course in (e.g., “exp_XXXX

  • title (String)

    The display title of the course (e.g., “Introduction to Web Development”).

  • certificate_after_completion_enabled (Boolean, nil)

    Whether the course awards students a PDF certificate after completing all lesson

  • order (String, nil)

    The decimal order position of the course within its experience. Use fractional v

  • require_completing_lessons_in_order (Boolean, nil)

    Whether students must complete each lesson sequentially before advancing to the

  • tagline (String, nil)

    A short tagline displayed beneath the course title (e.g., “Master the fundamenta

  • thumbnail (WhopSDK::Models::CourseCreateParams::Thumbnail, nil)

    The thumbnail image for the course in PNG, JPEG, or GIF format.

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

    The available visibilities for a course. Determines how / whether a course is vi

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

Returns:

See Also:



40
41
42
43
44
45
46
47
48
49
# File 'lib/whop_sdk/resources/courses.rb', line 40

def create(params)
  parsed, options = WhopSDK::CourseCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "courses",
    body: parsed,
    model: WhopSDK::Course,
    options: options
  )
end

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

Permanently delete a course and all of its chapters, lessons, and student progress.

Required permissions:

  • ‘courses:update`

Parameters:

  • id (String)

    The unique identifier of the course to delete (e.g., “course_XXXXX”).

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

Returns:

  • (Boolean)

See Also:



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

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

#list(after: nil, before: nil, company_id: nil, experience_id: nil, first: nil, last: nil, request_options: {}) ⇒ WhopSDK::Internal::CursorPage<WhopSDK::Models::CourseListResponse>

Returns a paginated list of courses, filtered by either an experience or a company.

Required permissions:

  • ‘courses:read`

Parameters:

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

  • company_id (String, nil)

    The unique identifier of the company to list courses for.

  • experience_id (String, nil)

    The unique identifier of the experience to list courses for.

  • first (Integer, nil)

    Returns the first n elements from the list.

  • last (Integer, nil)

    Returns the last n elements from the list.

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

Returns:

See Also:



151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/whop_sdk/resources/courses.rb', line 151

def list(params = {})
  parsed, options = WhopSDK::CourseListParams.dump_request(params)
  query = WhopSDK::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "courses",
    query: query,
    page: WhopSDK::Internal::CursorPage,
    model: WhopSDK::Models::CourseListResponse,
    options: options
  )
end

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

Retrieves the details of an existing course.

Required permissions:

  • ‘courses:read`

Parameters:

  • id (String)

    The unique identifier of the course to retrieve.

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

Returns:

See Also:



66
67
68
69
70
71
72
73
# File 'lib/whop_sdk/resources/courses.rb', line 66

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

#update(id, certificate_after_completion_enabled: nil, chapters: nil, description: nil, language: nil, order: nil, require_completing_lessons_in_order: nil, tagline: nil, thumbnail: nil, title: nil, visibility: nil, request_options: {}) ⇒ WhopSDK::Models::Course

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

Update a course’s title, description, visibility, thumbnail, or chapter ordering.

Required permissions:

  • ‘courses:update`

Parameters:

  • id (String)

    The unique identifier of the course to update (e.g., “course_XXXXX”).

  • certificate_after_completion_enabled (Boolean, nil)

    Whether the course awards students a PDF certificate after completing all lesson

  • chapters (Array<WhopSDK::Models::CourseUpdateParams::Chapter>, nil)

    A list of chapters with nested lessons to reorder or rename in bulk.

  • description (String, nil)

    A short description of the course displayed to students on the course page.

  • language (Symbol, WhopSDK::Models::Languages, nil)

    The available languages for a course

  • order (String, nil)

    The decimal order position of the course within its experience. Use fractional v

  • require_completing_lessons_in_order (Boolean, nil)

    Whether students must complete each lesson sequentially before advancing to the

  • tagline (String, nil)

    A short tagline displayed beneath the course title (e.g., “Master the fundamenta

  • thumbnail (WhopSDK::Models::CourseUpdateParams::Thumbnail, nil)

    The thumbnail image for the course in PNG, JPEG, or GIF format.

  • title (String, nil)

    The display title of the course (e.g., “Introduction to Web Development”).

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

    The available visibilities for a course. Determines how / whether a course is vi

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

Returns:

See Also:



114
115
116
117
118
119
120
121
122
123
# File 'lib/whop_sdk/resources/courses.rb', line 114

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