Class: WhopSDK::Resources::CourseChapters

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

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:



146
147
148
# File 'lib/whop_sdk/resources/course_chapters.rb', line 146

def initialize(client:)
  @client = client
end

Instance Method Details

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

Creates a new course chapter

Required permissions:

  • ‘courses:update`

Parameters:

  • course_id (String)

    The ID of the course to create the chapter in

  • title (String, nil)

    The title of the chapter

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

Returns:

See Also:



23
24
25
26
27
28
29
30
31
32
# File 'lib/whop_sdk/resources/course_chapters.rb', line 23

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

Deletes a course chapter

Required permissions:

  • ‘courses:update`

Parameters:

Returns:

  • (Boolean)

See Also:



134
135
136
137
138
139
140
141
# File 'lib/whop_sdk/resources/course_chapters.rb', line 134

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>

Lists chapters for a course

Required permissions:

  • ‘courses:read`

Parameters:

  • course_id (String)

    The ID of the course

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



108
109
110
111
112
113
114
115
116
117
118
# File 'lib/whop_sdk/resources/course_chapters.rb', line 108

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

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

Retrieves a course chapter by ID

Required permissions:

  • ‘courses:read`

Parameters:

Returns:

See Also:



48
49
50
51
52
53
54
55
# File 'lib/whop_sdk/resources/course_chapters.rb', line 48

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

Updates a course chapter

Required permissions:

  • ‘courses:update`

Parameters:

  • id (String)
  • title (String)

    The title of the chapter

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

Returns:

See Also:



74
75
76
77
78
79
80
81
82
83
# File 'lib/whop_sdk/resources/course_chapters.rb', line 74

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