Class: WhopSDK::Resources::CourseChapters

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

Overview

Course chapters

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ CourseChapters

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

Parameters:



153
154
155
# File 'lib/whop_sdk/resources/course_chapters.rb', line 153

def initialize(client:)
  @client = client
end

Instance Method Details

#create(course_id:, title: nil, request_options: {}) ⇒ WhopSDK::Models::CourseChapter

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

Create a new chapter within a course to organize lessons into sections.

Required permissions:

  • ‘courses:update`

Parameters:

  • course_id (String)

    The unique identifier of the course to create the chapter in (e.g., “course_XXXX

  • title (String, nil)

    The display title of the chapter (e.g., “Module 1: Introduction”).

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

Returns:

See Also:



27
28
29
30
31
32
33
34
35
36
# File 'lib/whop_sdk/resources/course_chapters.rb', line 27

def create(params)
  parsed, options = WhopSDK::CourseChapterCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "course_chapters",
    body: parsed,
    model: WhopSDK::CourseChapter,
    options: options
  )
end

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

Permanently delete a chapter and all of its lessons from a course.

Required permissions:

  • ‘courses:update`

Parameters:

  • id (String)

    The unique identifier of the chapter to delete (e.g., “chap_XXXXX”).

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

Returns:

  • (Boolean)

See Also:



141
142
143
144
145
146
147
148
# File 'lib/whop_sdk/resources/course_chapters.rb', line 141

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

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

Returns a paginated list of chapters within a course, ordered by position.

Required permissions:

  • ‘courses:read`

Parameters:

  • course_id (String)

    The unique identifier of the course to list chapters for.

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

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



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

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

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

Retrieves the details of an existing course chapter.

Required permissions:

  • ‘courses:read`

Parameters:

  • id (String)

    The unique identifier of the chapter to retrieve.

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

Returns:

See Also:



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

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

#update(id, title:, request_options: {}) ⇒ WhopSDK::Models::CourseChapter

Update a chapter’s title within a course.

Required permissions:

  • ‘courses:update`

Parameters:

  • id (String)

    The unique identifier of the chapter to update (e.g., “chap_XXXXX”).

  • title (String)

    The new display title of the chapter (e.g., “Module 1: Introduction”).

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

Returns:

See Also:



79
80
81
82
83
84
85
86
87
88
# File 'lib/whop_sdk/resources/course_chapters.rb', line 79

def update(id, params)
  parsed, options = WhopSDK::CourseChapterUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["course_chapters/%1$s", id],
    body: parsed,
    model: WhopSDK::CourseChapter,
    options: options
  )
end