Class: Whop_sdk::Disputes::Client

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ void



9
10
11
# File 'lib/whop_sdk/disputes/client.rb', line 9

def initialize(client:)
  @client = client
end

Instance Method Details

#list(request_options: {}, **params) ⇒ Whop_sdk::Disputes::Types::ListDisputesResponse

Lists the disputes across the accounts you can read.

Examples:

client.disputes.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):

Returns:



38
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
# File 'lib/whop_sdk/disputes/client.rb', line 38

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["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)
  query_params["order"] = params[:order] if params.key?(:order)
  query_params["direction"] = params[:direction] if params.key?(:direction)
  query_params["status"] = params[:status] if params.key?(:status)
  query_params["currency"] = params[:currency] if params.key?(:currency)
  query_params["created_before"] = params[:created_before] if params.key?(:created_before)
  query_params["created_after"] = params[:created_after] if params.key?(:created_after)

  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: "disputes",
      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::Disputes::Types::ListDisputesResponse.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

#retrieve(request_options: {}, **params) ⇒ Whop_sdk::Types::Dispute

Retrieves a single dispute.

Examples:

client.disputes.retrieve(id: "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):

  • :id (String)

Returns:



149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/whop_sdk/disputes/client.rb', line 149

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: "disputes/#{URI.encode_uri_component(params[:id].to_s)}",
    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::Types::Dispute.load(response.body)
  else
    error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#submit(request_options: {}, **params) ⇒ Whop_sdk::Types::Dispute

Sends a dispute's evidence to the payment processor. This is final — it cannot be edited or sent again.

Examples:

client.disputes.submit(id: "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):

  • :id (String)

Returns:



228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
# File 'lib/whop_sdk/disputes/client.rb', line 228

def submit(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: "POST",
    path: "disputes/#{URI.encode_uri_component(params[:id].to_s)}/submit",
    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::Types::Dispute.load(response.body)
  else
    error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#submit_evidence_dispute(request_options: {}, **params) ⇒ Whop_sdk::Types::Dispute

Submit a payment dispute to the payment processor for review. Once submitted, no further edits can be made.

Required permissions:

  • payment:dispute
  • plan:basic:read
  • access_pass:basic:read
  • company:basic:read
  • payment:basic:read
  • member:email:read
  • member:basic:read
  • member:phone:read

Examples:

client.disputes.submit_evidence_dispute(id: "dspt_xxxxxxxxxxxxx")

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

  • :id (String)

Returns:



275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
# File 'lib/whop_sdk/disputes/client.rb', line 275

def submit_evidence_dispute(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: "POST",
    path: "disputes/#{URI.encode_uri_component(params[:id].to_s)}/submit_evidence",
    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::Types::Dispute.load(response.body)
  else
    error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#summary(request_options: {}, **params) ⇒ Whop_sdk::Disputes::Types::SummaryDisputesResponse

Totals up the same disputes the list returns, so you can build status tabs and totals without paging through them.

Examples:

client.disputes.summary

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:



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/whop_sdk/disputes/client.rb', line 103

def summary(request_options: {}, **params)
  params = Whop_sdk::Internal::Types::Utils.normalize_keys(params)
  query_params = {}
  query_params["groups"] = params[:groups] if params.key?(:groups)
  query_params["account_id"] = params[:account_id] if params.key?(:account_id)
  query_params["status"] = params[:status] if params.key?(:status)
  query_params["currency"] = params[:currency] if params.key?(:currency)
  query_params["created_before"] = params[:created_before] if params.key?(:created_before)
  query_params["created_after"] = params[:created_after] if params.key?(:created_after)

  request = Whop_sdk::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "disputes/summary",
    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::Disputes::Types::SummaryDisputesResponse.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::Types::Dispute

Edits a dispute's evidence, while it is still editable. Sending it is a separate call.

Examples:

client.disputes.update(id: "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):

  • :id (String)

Returns:



186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/whop_sdk/disputes/client.rb', line 186

def update(request_options: {}, **params)
  params = Whop_sdk::Internal::Types::Utils.normalize_keys(params)
  request_data = Whop_sdk::Disputes::Types::UpdateDisputesRequest.new(params).to_h
  non_body_param_names = %w[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: "disputes/#{URI.encode_uri_component(params[:id].to_s)}",
    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::Types::Dispute.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_evidence_dispute(request_options: {}, **params) ⇒ Whop_sdk::Types::Dispute

Update a dispute with evidence data to attempt to win the dispute.

Required permissions:

  • payment:dispute
  • plan:basic:read
  • access_pass:basic:read
  • company:basic:read
  • payment:basic:read
  • member:email:read
  • member:basic:read
  • member:phone:read

Examples:

client.disputes.update_evidence_dispute(id: "dspt_xxxxxxxxxxxxx")

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

  • :id (String)

Returns:



322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
# File 'lib/whop_sdk/disputes/client.rb', line 322

def update_evidence_dispute(request_options: {}, **params)
  params = Whop_sdk::Internal::Types::Utils.normalize_keys(params)
  request_data = Whop_sdk::Disputes::Types::UpdateEvidenceDisputeRequest.new(params).to_h
  non_body_param_names = %w[id]
  body = request_data.except(*non_body_param_names)

  request = Whop_sdk::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "disputes/#{URI.encode_uri_component(params[:id].to_s)}/update_evidence",
    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::Types::Dispute.load(response.body)
  else
    error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#upload_evidence(request_options: {}, **params) ⇒ Whop_sdk::Types::Dispute

Replaces the full set of uploaded evidence documents on a dispute, beyond the four fixed evidence slots. Upload files through POST /files and reference them by id, or send the files as multipart file parts to upload and attach in one call. Send every document the packet should carry — up to 10, 10MB each and 25MB in total; an empty list removes them all. Accepted content types: application/pdf, application/json, image/jpeg, image/png, image/webp — any other type is rejected.

Examples:

client.disputes.upload_evidence(
  id: "id",
  documents: [{
    document_type: "return_policy"
  }]
)

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

  • :id (String)

Returns:



373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
# File 'lib/whop_sdk/disputes/client.rb', line 373

def upload_evidence(request_options: {}, **params)
  params = Whop_sdk::Internal::Types::Utils.normalize_keys(params)
  request_data = Whop_sdk::Disputes::Types::UploadEvidenceDisputesRequest.new(params).to_h
  non_body_param_names = %w[id]
  body = request_data.except(*non_body_param_names)

  request = Whop_sdk::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "disputes/#{URI.encode_uri_component(params[:id].to_s)}/upload_evidence",
    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::Types::Dispute.load(response.body)
  else
    error_class = Whop_sdk::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end