Class: Whop_sdk::FinancialReports::Breakdown::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/whop_sdk/financial_reports/breakdown/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ void



10
11
12
# File 'lib/whop_sdk/financial_reports/breakdown/client.rb', line 10

def initialize(client:)
  @client = client
end

Instance Method Details

#retrieve(request_options: {}, **params) ⇒ Whop_sdk::FinancialReports::Breakdown::Types::RetrieveBreakdownResponse

Returns the top entities behind one high-level financial report bucket and an aggregate remainder.

Examples:

client.financial_reports.breakdown.retrieve(
  account_id: "account_id",
  bucket: "transfers",
  direction: "money_in",
  currency: "currency",
  from: "2024-01-15T09:30:00Z",
  to: "2024-01-15T09:30:00Z"
)

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):

Returns:



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
# File 'lib/whop_sdk/financial_reports/breakdown/client.rb', line 43

def retrieve(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["bucket"] = params[:bucket] if params.key?(:bucket)
  query_params["direction"] = params[:direction] if params.key?(:direction)
  query_params["currency"] = params[:currency] if params.key?(:currency)
  query_params["from"] = params[:from] if params.key?(:from)
  query_params["to"] = params[:to] if params.key?(:to)
  query_params["group_by"] = params[:group_by] if params.key?(:group_by)
  query_params["timezone"] = params[:timezone] if params.key?(:timezone)

  request = Whop_sdk::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "financial_reports/breakdown",
    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)
    Whop_sdk::FinancialReports::Breakdown::Types::RetrieveBreakdownResponse.load(response.body)
  else
    error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end