Class: WhopSDK::Resources::Courses

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

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:



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

def initialize(client:)
  @client = client
end

Instance Method Details

#create(experience_id: , title: , cover_image: nil, tagline: nil, thumbnail: nil, request_options: {}) ⇒ WhopSDK::Models::Course

Creates a new course module in an experience

Required permissions:

  • ‘courses:update`

Parameters:

  • experience_id (String)

    The ID of the experience to create the course in

  • title (String)

    The title of the course

  • cover_image (String, nil)

    The cover image URL of the course

  • tagline (String, nil)

    The tagline of the course

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

    The thumbnail for the course in png, jpeg, or gif format

  • 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/courses.rb', line 29

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

Deletes a course

Required permissions:

  • ‘courses:update`

Parameters:

Returns:

  • (Boolean)

See Also:



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

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>

Lists courses for an experience or 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 ID of the company

  • experience_id (String, nil)

    The ID of the experience

  • 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/courses.rb', line 135

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

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

Retrieves a course by ID

Required permissions:

  • ‘courses:read`

Parameters:

Returns:

See Also:



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

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, cover_image: nil, description: nil, language: nil, require_completing_lessons_in_order: nil, tagline: nil, thumbnail: nil, title: nil, request_options: {}) ⇒ WhopSDK::Models::Course

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

Updates a course

Required permissions:

  • ‘courses:update`

Parameters:

  • id (String)
  • certificate_after_completion_enabled (Boolean, nil)

    Whether the course will award its students a PDF certificate after completing al

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

    The chapters and lessons to update

  • cover_image (String, nil)

    The cover image URL of the course

  • description (String, nil)

    A short description of the course

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

    The available languages for a course

  • require_completing_lessons_in_order (Boolean, nil)

    Whether the course requires students to complete the previous lesson before movi

  • tagline (String, nil)

    A short tagline for the course

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

    The thumbnail for the course in png, jpeg, or gif format

  • title (String, nil)

    The title of the course

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

Returns:

See Also:



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

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