Class: Whop_sdk::Payouts::SupportedMethods::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/whop_sdk/payouts/supported_methods/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ void



10
11
12
# File 'lib/whop_sdk/payouts/supported_methods/client.rb', line 10

def initialize(client:)
  @client = client
end

Instance Method Details

#list(request_options: {}, **params) ⇒ Whop_sdk::Payouts::SupportedMethods::Types::ListSupportedMethodsResponse

Lists the payout methods an account or user is eligible to add.

Examples:

client.payouts.supported_methods.list

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, nil)
  • :user_id (String, nil)
  • :country (String, nil)
  • :amount (Integer, nil)
  • :currency (String, nil)
  • :supported_payout_method_id (String, nil)
  • :destination_currency (String, nil)
  • :first (Integer, nil)
  • :after (String, nil)
  • :last (Integer, nil)
  • :before (String, nil)

Returns:



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/whop_sdk/payouts/supported_methods/client.rb', line 39

def list(request_options: {}, **params)
  params = Whop_sdk::Internal::Types::Utils.normalize_keys(params)
  query_params = {}
  query_params["account_id"] = params[:account_id] if params.key?(:account_id)
  query_params["user_id"] = params[:user_id] if params.key?(:user_id)
  query_params["country"] = params[:country] if params.key?(:country)
  query_params["amount"] = params[:amount] if params.key?(:amount)
  query_params["currency"] = params[:currency] if params.key?(:currency)
  query_params["supported_payout_method_id"] = params[:supported_payout_method_id] if params.key?(:supported_payout_method_id)
  query_params["destination_currency"] = params[:destination_currency] if params.key?(:destination_currency)
  query_params["first"] = params[:first] if params.key?(:first)
  query_params["after"] = params[:after] if params.key?(:after)
  query_params["last"] = params[:last] if params.key?(:last)
  query_params["before"] = params[:before] if params.key?(:before)

  Whop_sdk::Internal::CursorItemIterator.new(
    cursor_field: :end_cursor,
    item_field: :data,
    initial_cursor: query_params["after"]
  ) do |next_cursor|
    query_params["after"] = next_cursor
    request = Whop_sdk::Internal::JSON::Request.new(
      base_url: request_options[:base_url],
      method: "GET",
      path: "payouts/supported_methods",
      query: query_params,
      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)
      parsed_response = Whop_sdk::Payouts::SupportedMethods::Types::ListSupportedMethodsResponse.load(response.body)
      [parsed_response, response]
    else
      error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code)
      raise error_class.new(response.body, code: code)
    end
  end
end