Class: Square::DisputesApi

Inherits:
BaseApi
  • Object
show all
Defined in:
lib/square/api/disputes_api.rb

Overview

DisputesApi

Instance Attribute Summary

Attributes inherited from BaseApi

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseApi

#initialize, #new_api_call_builder, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters

Constructor Details

This class inherits a constructor from Square::BaseApi

Instance Method Details

#accept_dispute(dispute_id:) ⇒ AcceptDisputeResponse Hash

Accepts the loss on a dispute. Square returns the disputed amount to the cardholder and updates the dispute state to ACCEPTED. Square debits the disputed amount from the seller’s Square account. If the Square account does not have sufficient funds, Square debits the associated bank account. want to accept.

Parameters:

  • dispute_id (String)

    Required parameter: The ID of the dispute you

Returns:

  • (AcceptDisputeResponse Hash)

    response from the API call



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/square/api/disputes_api.rb', line 65

def accept_dispute(dispute_id:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v2/disputes/{dispute_id}/accept',
                                 'default')
               .template_param(new_parameter(dispute_id, key: 'dispute_id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#create_dispute_evidence_file(dispute_id:, request: nil, image_file: nil) ⇒ CreateDisputeEvidenceFileResponse Hash

Uploads a file to use as evidence in a dispute challenge. The endpoint accepts HTTP multipart/form-data file uploads in HEIC, HEIF, JPEG, PDF, PNG, and TIFF formats. which you want to upload evidence. Defines the parameters for a ‘CreateDisputeEvidenceFile` request.

Parameters:

  • dispute_id (String)

    Required parameter: The ID of the dispute for

  • request (CreateDisputeEvidenceFileRequest) (defaults to: nil)

    Optional parameter:

  • image_file (File | UploadIO) (defaults to: nil)

    Optional parameter: Example:

Returns:

  • (CreateDisputeEvidenceFileResponse Hash)

    response from the API call



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/square/api/disputes_api.rb', line 117

def create_dispute_evidence_file(dispute_id:,
                                 request: nil,
                                 image_file: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v2/disputes/{dispute_id}/evidence-files',
                                 'default')
               .template_param(new_parameter(dispute_id, key: 'dispute_id')
                                .should_encode(true))
               .multipart_param(new_parameter(StringIO.new(request.to_json), key: 'request')
                                 .default_content_type('application/json; charset=utf-8'))
               .multipart_param(new_parameter(image_file, key: 'image_file')
                                 .default_content_type('image/jpeg'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#create_dispute_evidence_text(dispute_id:, body:) ⇒ CreateDisputeEvidenceTextResponse Hash

Uploads text to use as evidence for a dispute challenge. which you want to upload evidence. object containing the fields to POST for the request. See the corresponding object definition for field details.

Parameters:

  • dispute_id (String)

    Required parameter: The ID of the dispute for

  • body (CreateDisputeEvidenceTextRequest)

    Required parameter: An

Returns:

  • (CreateDisputeEvidenceTextResponse Hash)

    response from the API call



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/square/api/disputes_api.rb', line 146

def create_dispute_evidence_text(dispute_id:,
                                 body:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v2/disputes/{dispute_id}/evidence-text',
                                 'default')
               .template_param(new_parameter(dispute_id, key: 'dispute_id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#delete_dispute_evidence(dispute_id:, evidence_id:) ⇒ DeleteDisputeEvidenceResponse Hash

Removes specified evidence from a dispute. Square does not send the bank any evidence that is removed. which you want to remove evidence. want to remove.

Parameters:

  • dispute_id (String)

    Required parameter: The ID of the dispute from

  • evidence_id (String)

    Required parameter: The ID of the evidence you

Returns:

  • (DeleteDisputeEvidenceResponse Hash)

    response from the API call



173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# File 'lib/square/api/disputes_api.rb', line 173

def delete_dispute_evidence(dispute_id:,
                            evidence_id:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::DELETE,
                                 '/v2/disputes/{dispute_id}/evidence/{evidence_id}',
                                 'default')
               .template_param(new_parameter(dispute_id, key: 'dispute_id')
                                .should_encode(true))
               .template_param(new_parameter(evidence_id, key: 'evidence_id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#list_dispute_evidence(dispute_id:, cursor: nil) ⇒ ListDisputeEvidenceResponse Hash

Returns a list of evidence associated with a dispute. a previous call to this endpoint. Provide this cursor to retrieve the next set of results for the original query. For more information, see [Pagination](developer.squareup.com/docs/build-basics/common-api-p atterns/pagination).

Parameters:

  • dispute_id (String)

    Required parameter: The ID of the dispute.

  • cursor (String) (defaults to: nil)

    Optional parameter: A pagination cursor returned by

Returns:

  • (ListDisputeEvidenceResponse Hash)

    response from the API call



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/square/api/disputes_api.rb', line 89

def list_dispute_evidence(dispute_id:,
                          cursor: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/disputes/{dispute_id}/evidence',
                                 'default')
               .template_param(new_parameter(dispute_id, key: 'dispute_id')
                                .should_encode(true))
               .query_param(new_parameter(cursor, key: 'cursor'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#list_disputes(cursor: nil, states: nil, location_id: nil) ⇒ ListDisputesResponse Hash

Returns a list of disputes associated with a particular account. a previous call to this endpoint. Provide this cursor to retrieve the next set of results for the original query. For more information, see [Pagination](developer.squareup.com/docs/build-basics/common-api-p atterns/pagination). to filter the result. If not specified, the endpoint returns all disputes. which to return a list of disputes. If not specified, the endpoint returns disputes associated with all locations.

Parameters:

  • cursor (String) (defaults to: nil)

    Optional parameter: A pagination cursor returned by

  • states (DisputeState) (defaults to: nil)

    Optional parameter: The dispute states used

  • location_id (String) (defaults to: nil)

    Optional parameter: The ID of the location for

Returns:

  • (ListDisputesResponse Hash)

    response from the API call



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/square/api/disputes_api.rb', line 17

def list_disputes(cursor: nil,
                  states: nil,
                  location_id: nil)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/disputes',
                                 'default')
               .query_param(new_parameter(cursor, key: 'cursor'))
               .query_param(new_parameter(states, key: 'states'))
               .query_param(new_parameter(location_id, key: 'location_id'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#retrieve_dispute(dispute_id:) ⇒ RetrieveDisputeResponse Hash

Returns details about a specific dispute. want more details about.

Parameters:

  • dispute_id (String)

    Required parameter: The ID of the dispute you

Returns:

  • (RetrieveDisputeResponse Hash)

    response from the API call



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/square/api/disputes_api.rb', line 40

def retrieve_dispute(dispute_id:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/disputes/{dispute_id}',
                                 'default')
               .template_param(new_parameter(dispute_id, key: 'dispute_id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#retrieve_dispute_evidence(dispute_id:, evidence_id:) ⇒ RetrieveDisputeEvidenceResponse Hash

Returns the metadata for the evidence specified in the request URL path. You must maintain a copy of any evidence uploaded if you want to reference it later. Evidence cannot be downloaded after you upload it. which you want to retrieve evidence metadata. retrieve.

Parameters:

  • dispute_id (String)

    Required parameter: The ID of the dispute from

  • evidence_id (String)

    Required parameter: The ID of the evidence to

Returns:

  • (RetrieveDisputeEvidenceResponse Hash)

    response from the API call



200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
# File 'lib/square/api/disputes_api.rb', line 200

def retrieve_dispute_evidence(dispute_id:,
                              evidence_id:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/disputes/{dispute_id}/evidence/{evidence_id}',
                                 'default')
               .template_param(new_parameter(dispute_id, key: 'dispute_id')
                                .should_encode(true))
               .template_param(new_parameter(evidence_id, key: 'evidence_id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end

#submit_evidence(dispute_id:) ⇒ SubmitEvidenceResponse Hash

Submits evidence to the cardholder’s bank. The evidence submitted by this endpoint includes evidence uploaded using the [CreateDisputeEvidenceFile]($e/Disputes/CreateDisputeEvidenceFile) and [CreateDisputeEvidenceText]($e/Disputes/CreateDisputeEvidenceText) endpoints and evidence automatically provided by Square, when available. Evidence cannot be removed from a dispute after submission. which you want to submit evidence.

Parameters:

  • dispute_id (String)

    Required parameter: The ID of the dispute for

Returns:

  • (SubmitEvidenceResponse Hash)

    response from the API call



231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
# File 'lib/square/api/disputes_api.rb', line 231

def submit_evidence(dispute_id:)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v2/disputes/{dispute_id}/submit-evidence',
                                 'default')
               .template_param(new_parameter(dispute_id, key: 'dispute_id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('global')))
    .response(new_response_handler
               .deserializer(APIHelper.method(:json_deserialize))
               .is_api_response(true)
               .convertor(ApiResponse.method(:create)))
    .execute
end