Class: WhopSDK::Resources::Memberships

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Memberships

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

Parameters:



202
203
204
# File 'lib/whop_sdk/resources/memberships.rb', line 202

def initialize(client:)
  @client = client
end

Instance Method Details

#cancel(id, cancellation_mode: nil, request_options: {}) ⇒ WhopSDK::Models::Membership

Cancels a membership either immediately or at the end of the current billing period

Required permissions:

  • ‘member:manage`

  • ‘member:basic:read`

Parameters:

Returns:

See Also:



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

def cancel(id, params = {})
  parsed, options = WhopSDK::MembershipCancelParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["memberships/%1$s/cancel", id],
    body: parsed,
    model: WhopSDK::Membership,
    options: options
  )
end

#list(access_pass_ids: nil, after: nil, before: nil, cancel_options: nil, company_id: nil, created_after: nil, created_before: nil, direction: nil, first: nil, last: nil, order: nil, plan_ids: nil, promo_code_ids: nil, statuses: nil, user_ids: nil, request_options: {}) ⇒ WhopSDK::Internal::CursorPage<WhopSDK::Models::MembershipListResponse>

Lists memberships

Required permissions:

  • ‘member:basic:read`

Parameters:

  • access_pass_ids (Array<String>, nil)

    The access pass IDs to filter the memberships by

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

  • cancel_options (Array<Symbol, WhopSDK::Models::MembershipListParams::CancelOption>, nil)

    The cancel options to filter the memberships by

  • company_id (String, nil)

    The ID of the company to list memberships for

  • created_after (Time, nil)

    The minimum creation date to filter by

  • created_before (Time, nil)

    The maximum creation date to filter by

  • direction (Symbol, WhopSDK::Models::Direction, nil)

    The direction of the sort.

  • first (Integer, nil)

    Returns the first n elements from the list.

  • last (Integer, nil)

    Returns the last n elements from the list.

  • order (Symbol, WhopSDK::Models::MembershipListParams::Order, nil)

    Which columns can be used to sort.

  • plan_ids (Array<String>, nil)

    The plan IDs to filter the memberships by

  • promo_code_ids (Array<String>, nil)

    The promo code IDs to filter the memberships by

  • statuses (Array<Symbol, WhopSDK::Models::MembershipStatus>, nil)

    The membership status to filter the memberships by

  • user_ids (Array<String>, nil)

    Only return memberships from these whop user ids

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

Returns:

See Also:



101
102
103
104
105
106
107
108
109
110
111
# File 'lib/whop_sdk/resources/memberships.rb', line 101

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

#pause(id, void_payments: nil, request_options: {}) ⇒ WhopSDK::Models::Membership

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

Pauses a membership’s payments

Required permissions:

  • ‘member:manage`

  • ‘member:basic:read`

Parameters:

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

    Whether to void past_due payments associated with the membership to prevent futu

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

Returns:

See Also:



164
165
166
167
168
169
170
171
172
173
# File 'lib/whop_sdk/resources/memberships.rb', line 164

def pause(id, params = {})
  parsed, options = WhopSDK::MembershipPauseParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["memberships/%1$s/pause", id],
    body: parsed,
    model: WhopSDK::Membership,
    options: options
  )
end

#resume(id, request_options: {}) ⇒ WhopSDK::Models::Membership

Resumes a membership’s payments

Required permissions:

  • ‘member:manage`

  • ‘member:basic:read`

Parameters:

Returns:

See Also:



190
191
192
193
194
195
196
197
# File 'lib/whop_sdk/resources/memberships.rb', line 190

def resume(id, params = {})
  @client.request(
    method: :post,
    path: ["memberships/%1$s/resume", id],
    model: WhopSDK::Membership,
    options: params[:request_options]
  )
end

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

Retrieves a membership by ID or license key

Required permissions:

  • ‘member:basic:read`

Parameters:

Returns:

See Also:



20
21
22
23
24
25
26
27
# File 'lib/whop_sdk/resources/memberships.rb', line 20

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

#update(id, metadata: nil, request_options: {}) ⇒ WhopSDK::Models::Membership

Update a membership

Required permissions:

  • ‘member:manage`

  • ‘member:basic:read`

Parameters:

  • id (String)
  • metadata (Hash{Symbol=>Object}, nil)

    The metadata to update the membership with.

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

Returns:

See Also:



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

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