Class: WhopSDK::Resources::CourseLessons

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

Overview

Course lessons

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ CourseLessons

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

Parameters:



267
268
269
# File 'lib/whop_sdk/resources/course_lessons.rb', line 267

def initialize(client:)
  @client = client
end

Instance Method Details

#create(chapter_id:, lesson_type:, content: nil, days_from_course_start_until_unlock: nil, embed_id: nil, embed_type: nil, thumbnail: nil, title: nil, request_options: {}) ⇒ WhopSDK::Models::Lesson

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

Create a new lesson within a course chapter. Lessons can contain video, text, or assessment content.

Required permissions:

  • ‘courses:update`

Parameters:

  • chapter_id (String)

    The unique identifier of the chapter to create the lesson in (e.g., “chap_XXXXX”

  • lesson_type (Symbol, WhopSDK::Models::LessonTypes)

    The content type of the lesson, such as video, text, quiz, or knowledge check.

  • content (String, nil)

    The Markdown content body of the lesson.

  • days_from_course_start_until_unlock (Integer, nil)

    The number of days after a student starts the course before this lesson becomes

  • embed_id (String, nil)

    The external video identifier for embedded content (e.g., a YouTube video ID or

  • embed_type (Symbol, WhopSDK::Models::EmbedType, nil)

    The type of embed for a lesson

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

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

  • title (String, nil)

    The display title of the lesson (e.g., “Getting Started with APIs”).

  • 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/course_lessons.rb', line 40

def create(params)
  parsed, options = WhopSDK::CourseLessonCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "course_lessons",
    body: parsed,
    model: WhopSDK::Lesson,
    options: options
  )
end

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

Permanently delete a lesson and remove it from its chapter.

Required permissions:

  • ‘courses:update`

Parameters:

  • id (String)

    The unique identifier of the lesson to delete (e.g., “les_XXXXX”).

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

Returns:

  • (Boolean)

See Also:



187
188
189
190
191
192
193
194
# File 'lib/whop_sdk/resources/course_lessons.rb', line 187

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

#list(after: nil, before: nil, chapter_id: nil, course_id: nil, first: nil, last: nil, request_options: {}) ⇒ WhopSDK::Internal::CursorPage<WhopSDK::Models::CourseLessonListResponse>

Returns a paginated list of lessons within a course or chapter, ordered by position.

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.

  • chapter_id (String, nil)

    The unique identifier of a chapter to return only its lessons.

  • course_id (String, nil)

    The unique identifier of the course to return all lessons across all chapters.

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



159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/whop_sdk/resources/course_lessons.rb', line 159

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

#mark_as_completed(lesson_id, request_options: {}) ⇒ Boolean

Mark a lesson as completed for the current user after they finish the content.

Parameters:

  • lesson_id (String)

    The unique identifier of the lesson to mark as completed (e.g., “les_XXXXX”).

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

Returns:

  • (Boolean)

See Also:



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

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

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

Retrieves the details of an existing course lesson.

Required permissions:

  • ‘courses:read`

Parameters:

  • id (String)

    The unique identifier of the lesson 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/course_lessons.rb', line 66

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

#start(lesson_id, request_options: {}) ⇒ Boolean

Record that the current user has started viewing a lesson, creating progress tracking records.

Parameters:

  • lesson_id (String)

    The unique identifier of the lesson the user is starting (e.g., “les_XXXXX”).

  • 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/course_lessons.rb', line 228

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

#submit_assessment(lesson_id, answers:, request_options: {}) ⇒ WhopSDK::Models::CourseLessonSubmitAssessmentResponse

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

Submit answers for a quiz or knowledge check lesson and receive a graded result.

Parameters:

Returns:

See Also:



253
254
255
256
257
258
259
260
261
262
# File 'lib/whop_sdk/resources/course_lessons.rb', line 253

def submit_assessment(lesson_id, params)
  parsed, options = WhopSDK::CourseLessonSubmitAssessmentParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["course_lessons/%1$s/submit_assessment", lesson_id],
    body: parsed,
    model: WhopSDK::Models::CourseLessonSubmitAssessmentResponse,
    options: options
  )
end

#update(id, assessment_completion_requirement: nil, assessment_questions: nil, attachments: nil, content: nil, days_from_course_start_until_unlock: nil, embed_id: nil, embed_type: nil, lesson_type: nil, main_pdf: nil, max_attempts: nil, mux_asset_id: nil, thumbnail: nil, title: nil, visibility: nil, request_options: {}) ⇒ WhopSDK::Models::Lesson

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

Update a lesson’s content, type, visibility, assessment questions, or media attachments.

Required permissions:

  • ‘courses:update`

Parameters:

Returns:

See Also:



122
123
124
125
126
127
128
129
130
131
# File 'lib/whop_sdk/resources/course_lessons.rb', line 122

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