Class: WhopSDK::Resources::CourseLessons

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

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:



173
174
175
# File 'lib/whop_sdk/resources/course_lessons.rb', line 173

def initialize(client:)
  @client = client
end

Instance Method Details

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

Creates a new course lesson

Required permissions:

  • ‘courses:update`

Parameters:

  • chapter_id (String)

    The ID of the chapter to create the lesson in

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

    The type of the lesson

  • content (String, nil)

    The content of the lesson

  • days_from_course_start_until_unlock (Integer, nil)

    Days from course start until unlock

  • title (String, nil)

    The title of the lesson

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

Returns:

See Also:



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

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

Deletes a course lesson

Required permissions:

  • ‘courses:update`

Parameters:

Returns:

  • (Boolean)

See Also:



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

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>

Lists lessons for a course or chapter

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 ID of the chapter (returns lessons only for this chapter)

  • course_id (String, nil)

    The ID of the course (returns 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:



135
136
137
138
139
140
141
142
143
144
145
# File 'lib/whop_sdk/resources/course_lessons.rb', line 135

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

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

Retrieves a course lesson by ID

Required permissions:

  • ‘courses:read`

Parameters:

Returns:

See Also:



54
55
56
57
58
59
60
61
# File 'lib/whop_sdk/resources/course_lessons.rb', line 54

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

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

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

Updates a course lesson

Required permissions:

  • ‘courses:update`

Parameters:

Returns:

See Also:



99
100
101
102
103
104
105
106
107
108
# File 'lib/whop_sdk/resources/course_lessons.rb', line 99

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