Class: Whop_sdk::Accounts::Preferences::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/whop_sdk/accounts/preferences/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ void



10
11
12
# File 'lib/whop_sdk/accounts/preferences/client.rb', line 10

def initialize(client:)
  @client = client
end

Instance Method Details

#retrieve(request_options: {}, **params) ⇒ Whop_sdk::Accounts::Preferences::Types::RetrievePreferencesResponse

Retrieves the account's preferences: a singleton settings document keyed by preference name.

Examples:

client.accounts.preferences.retrieve(account_id: "account_id")

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :account_id (String)

Returns:



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/whop_sdk/accounts/preferences/client.rb', line 29

def retrieve(request_options: {}, **params)
  params = Whop_sdk::Internal::Types::Utils.normalize_keys(params)
  request = Whop_sdk::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "accounts/#{URI.encode_uri_component(params[:account_id].to_s)}/preferences",
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Whop_sdk::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Whop_sdk::Accounts::Preferences::Types::RetrievePreferencesResponse.load(response.body)
  else
    error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#update(request_options: {}, **params) ⇒ Whop_sdk::Accounts::Preferences::Types::UpdatePreferencesResponse

Updates the account's preferences. Each top-level key present in the body is replaced as a whole; omitted keys are left untouched. ads_triple_whale_integration takes the Data-In API key to connect with, or null to disconnect. ads_payment_methods always requires a primary entry. backup is optional and any pairing is allowed — two cards, card+platform_balance, or a single method — so a card-only advertiser can fund ads without a platform balance. The primary and backup must be different sources. A platform_balance entry may omit id to use the account's default Whop balance. Configuring a card requires a user token; account API keys can set up platform-balance billing only.

Examples:

client.accounts.preferences.update(account_id: "account_id")

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :account_id (String)

Returns:



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/whop_sdk/accounts/preferences/client.rb', line 72

def update(request_options: {}, **params)
  params = Whop_sdk::Internal::Types::Utils.normalize_keys(params)
  request_data = Whop_sdk::Accounts::Preferences::Types::UpdatePreferencesRequest.new(params).to_h
  non_body_param_names = %w[account_id]
  body = request_data.except(*non_body_param_names)

  request = Whop_sdk::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "PATCH",
    path: "accounts/#{URI.encode_uri_component(params[:account_id].to_s)}/preferences",
    body: body,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Whop_sdk::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Whop_sdk::Accounts::Preferences::Types::UpdatePreferencesResponse.load(response.body)
  else
    error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end