Class: WhopSDK::Resources::Affiliates

Inherits:
Object
  • Object
show all
Defined in:
lib/whop_sdk/resources/affiliates.rb,
lib/whop_sdk/resources/affiliates/overrides.rb

Overview

Affiliates

Defined Under Namespace

Classes: Overrides

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Affiliates

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

Parameters:



159
160
161
162
# File 'lib/whop_sdk/resources/affiliates.rb', line 159

def initialize(client:)
  @client = client
  @overrides = WhopSDK::Resources::Affiliates::Overrides.new(client: client)
end

Instance Attribute Details

#overridesWhopSDK::Resources::Affiliates::Overrides (readonly)

Affiliates



9
10
11
# File 'lib/whop_sdk/resources/affiliates.rb', line 9

def overrides
  @overrides
end

Instance Method Details

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

Archives an existing Affiliate

Required permissions:

  • ‘affiliate:update`

Parameters:

  • id (String)

    The internal ID of the affiliate to archive.

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

Returns:

  • (Boolean)

See Also:



123
124
125
126
127
128
129
130
# File 'lib/whop_sdk/resources/affiliates.rb', line 123

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

#create(company_id:, user_identifier:, request_options: {}) ⇒ WhopSDK::Models::Affiliate

Creates or finds an affiliate for a company and user.

Required permissions:

  • ‘affiliate:create`

Parameters:

  • company_id (String)

    The ID of the company to create the affiliate for.

  • user_identifier (String)

    The user identifier (username, email, user ID, or Discord ID).

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

Returns:

See Also:



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

def create(params)
  parsed, options = WhopSDK::AffiliateCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "affiliates",
    body: parsed,
    model: WhopSDK::Affiliate,
    options: options
  )
end

#list(company_id:, after: nil, before: nil, direction: nil, first: nil, last: nil, order: nil, query: nil, status: nil, request_options: {}) ⇒ WhopSDK::Internal::CursorPage<WhopSDK::Models::AffiliateListResponse>

Returns a paginated list of affiliates for the actor in context, with optional filtering by status, search, and sorting.

Required permissions:

  • ‘affiliate:basic:read`

Parameters:

  • company_id (String)

    The unique identifier of the company to list affiliates 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.

  • 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::AffiliateListParams::Order, nil)

    Which columns can be used to sort.

  • query (String, nil)

    Search affiliates by username.

  • status (Symbol, WhopSDK::Models::Status, nil)

    Statuses for resources

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

Returns:

See Also:



95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/whop_sdk/resources/affiliates.rb', line 95

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

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

Retrieves the details of an existing affiliate.

Required permissions:

  • ‘affiliate:basic:read`

Parameters:

  • id (String)

    The unique identifier of the affiliate.

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

Returns:

See Also:



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

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

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

Unarchives an existing Affiliate

Required permissions:

  • ‘affiliate:update`

Parameters:

  • id (String)

    The internal ID of the affiliate to archive.

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

Returns:

  • (Boolean)

See Also:



147
148
149
150
151
152
153
154
# File 'lib/whop_sdk/resources/affiliates.rb', line 147

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