fangkuai.rb 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +10 -0
- data/README.md +1 -0
- data/lib/square.rb +61 -0
- data/lib/square/api/apple_pay_api.rb +50 -0
- data/lib/square/api/bank_accounts_api.rb +136 -0
- data/lib/square/api/base_api.rb +43 -0
- data/lib/square/api/cash_drawers_api.rb +150 -0
- data/lib/square/api/catalog_api.rb +572 -0
- data/lib/square/api/checkout_api.rb +49 -0
- data/lib/square/api/customer_groups_api.rb +182 -0
- data/lib/square/api/customer_segments_api.rb +78 -0
- data/lib/square/api/customers_api.rb +418 -0
- data/lib/square/api/devices_api.rb +120 -0
- data/lib/square/api/disputes_api.rb +398 -0
- data/lib/square/api/employees_api.rb +87 -0
- data/lib/square/api/inventory_api.rb +296 -0
- data/lib/square/api/invoices_api.rb +358 -0
- data/lib/square/api/labor_api.rb +630 -0
- data/lib/square/api/locations_api.rb +151 -0
- data/lib/square/api/loyalty_api.rb +543 -0
- data/lib/square/api/merchants_api.rb +83 -0
- data/lib/square/api/mobile_authorization_api.rb +52 -0
- data/lib/square/api/o_auth_api.rb +163 -0
- data/lib/square/api/orders_api.rb +280 -0
- data/lib/square/api/payments_api.rb +279 -0
- data/lib/square/api/refunds_api.rb +145 -0
- data/lib/square/api/subscriptions_api.rb +251 -0
- data/lib/square/api/team_api.rb +326 -0
- data/lib/square/api/terminal_api.rb +141 -0
- data/lib/square/api/transactions_api.rb +369 -0
- data/lib/square/api/v1_employees_api.rb +723 -0
- data/lib/square/api/v1_items_api.rb +1686 -0
- data/lib/square/api/v1_locations_api.rb +65 -0
- data/lib/square/api/v1_transactions_api.rb +572 -0
- data/lib/square/api_helper.rb +276 -0
- data/lib/square/client.rb +211 -0
- data/lib/square/configuration.rb +101 -0
- data/lib/square/exceptions/api_exception.rb +15 -0
- data/lib/square/http/api_response.rb +45 -0
- data/lib/square/http/auth/o_auth2.rb +12 -0
- data/lib/square/http/faraday_client.rb +55 -0
- data/lib/square/http/http_call_back.rb +19 -0
- data/lib/square/http/http_client.rb +99 -0
- data/lib/square/http/http_method_enum.rb +8 -0
- data/lib/square/http/http_request.rb +45 -0
- data/lib/square/http/http_response.rb +24 -0
- data/lib/square/utilities/file_wrapper.rb +12 -0
- data/spec/user_journey_spec.rb +148 -0
- data/test/api/api_test_base.rb +24 -0
- data/test/api/test_catalog_api.rb +59 -0
- data/test/api/test_customers_api.rb +45 -0
- data/test/api/test_employees_api.rb +36 -0
- data/test/api/test_labor_api.rb +74 -0
- data/test/api/test_locations_api.rb +35 -0
- data/test/api/test_merchants_api.rb +40 -0
- data/test/api/test_payments_api.rb +42 -0
- data/test/api/test_refunds_api.rb +41 -0
- data/test/http_response_catcher.rb +19 -0
- data/test/test_helper.rb +94 -0
- metadata +199 -0
@@ -0,0 +1,120 @@
|
|
1
|
+
module Square
|
2
|
+
# DevicesApi
|
3
|
+
class DevicesApi < BaseApi
|
4
|
+
def initialize(config, http_call_back: nil)
|
5
|
+
super(config, http_call_back: http_call_back)
|
6
|
+
end
|
7
|
+
|
8
|
+
# Lists all DeviceCodes associated with the merchant.
|
9
|
+
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
10
|
+
# a previous call to this endpoint. Provide this to retrieve the next set of
|
11
|
+
# results for your original query. See [Paginating
|
12
|
+
# results](#paginatingresults) for more information.
|
13
|
+
# @param [String] location_id Optional parameter: If specified, only returns
|
14
|
+
# DeviceCodes of the specified location. Returns DeviceCodes of all
|
15
|
+
# locations if empty.
|
16
|
+
# @param [ProductType] product_type Optional parameter: If specified, only
|
17
|
+
# returns DeviceCodes targeting the specified product type. Returns
|
18
|
+
# DeviceCodes of all product types if empty.
|
19
|
+
# @return [ListDeviceCodesResponse Hash] response from the API call
|
20
|
+
def list_device_codes(cursor: nil,
|
21
|
+
location_id: nil,
|
22
|
+
product_type: nil)
|
23
|
+
# Prepare query url.
|
24
|
+
_query_builder = config.get_base_uri
|
25
|
+
_query_builder << '/v2/devices/codes'
|
26
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
27
|
+
_query_builder,
|
28
|
+
'cursor' => cursor,
|
29
|
+
'location_id' => location_id,
|
30
|
+
'product_type' => product_type
|
31
|
+
)
|
32
|
+
_query_url = APIHelper.clean_url _query_builder
|
33
|
+
|
34
|
+
# Prepare headers.
|
35
|
+
_headers = {
|
36
|
+
'accept' => 'application/json'
|
37
|
+
}
|
38
|
+
|
39
|
+
# Prepare and execute HttpRequest.
|
40
|
+
_request = config.http_client.get(
|
41
|
+
_query_url,
|
42
|
+
headers: _headers
|
43
|
+
)
|
44
|
+
OAuth2.apply(config, _request)
|
45
|
+
_response = execute_request(_request)
|
46
|
+
|
47
|
+
# Return appropriate response type.
|
48
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
49
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
50
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Creates a DeviceCode that can be used to login to a Square Terminal device
|
54
|
+
# to enter the connected
|
55
|
+
# terminal mode.
|
56
|
+
# @param [CreateDeviceCodeRequest] body Required parameter: An object
|
57
|
+
# containing the fields to POST for the request. See the corresponding
|
58
|
+
# object definition for field details.
|
59
|
+
# @return [CreateDeviceCodeResponse Hash] response from the API call
|
60
|
+
def create_device_code(body:)
|
61
|
+
# Prepare query url.
|
62
|
+
_query_builder = config.get_base_uri
|
63
|
+
_query_builder << '/v2/devices/codes'
|
64
|
+
_query_url = APIHelper.clean_url _query_builder
|
65
|
+
|
66
|
+
# Prepare headers.
|
67
|
+
_headers = {
|
68
|
+
'accept' => 'application/json',
|
69
|
+
'content-type' => 'application/json; charset=utf-8'
|
70
|
+
}
|
71
|
+
|
72
|
+
# Prepare and execute HttpRequest.
|
73
|
+
_request = config.http_client.post(
|
74
|
+
_query_url,
|
75
|
+
headers: _headers,
|
76
|
+
parameters: body.to_json
|
77
|
+
)
|
78
|
+
OAuth2.apply(config, _request)
|
79
|
+
_response = execute_request(_request)
|
80
|
+
|
81
|
+
# Return appropriate response type.
|
82
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
83
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
84
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
85
|
+
end
|
86
|
+
|
87
|
+
# Retrieves DeviceCode with the associated ID.
|
88
|
+
# @param [String] id Required parameter: The unique identifier for the
|
89
|
+
# device code.
|
90
|
+
# @return [GetDeviceCodeResponse Hash] response from the API call
|
91
|
+
def get_device_code(id:)
|
92
|
+
# Prepare query url.
|
93
|
+
_query_builder = config.get_base_uri
|
94
|
+
_query_builder << '/v2/devices/codes/{id}'
|
95
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
96
|
+
_query_builder,
|
97
|
+
'id' => id
|
98
|
+
)
|
99
|
+
_query_url = APIHelper.clean_url _query_builder
|
100
|
+
|
101
|
+
# Prepare headers.
|
102
|
+
_headers = {
|
103
|
+
'accept' => 'application/json'
|
104
|
+
}
|
105
|
+
|
106
|
+
# Prepare and execute HttpRequest.
|
107
|
+
_request = config.http_client.get(
|
108
|
+
_query_url,
|
109
|
+
headers: _headers
|
110
|
+
)
|
111
|
+
OAuth2.apply(config, _request)
|
112
|
+
_response = execute_request(_request)
|
113
|
+
|
114
|
+
# Return appropriate response type.
|
115
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
116
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
117
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
@@ -0,0 +1,398 @@
|
|
1
|
+
module Square
|
2
|
+
# DisputesApi
|
3
|
+
class DisputesApi < BaseApi
|
4
|
+
def initialize(config, http_call_back: nil)
|
5
|
+
super(config, http_call_back: http_call_back)
|
6
|
+
end
|
7
|
+
|
8
|
+
# Returns a list of disputes associated
|
9
|
+
# with a particular account.
|
10
|
+
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
11
|
+
# a previous call to this endpoint. Provide this to retrieve the next set of
|
12
|
+
# results for the original query. For more information, see
|
13
|
+
# [Paginating](https://developer.squareup.com/docs/basics/api101/pagination)
|
14
|
+
# .
|
15
|
+
# @param [DisputeState] states Optional parameter: The dispute states to
|
16
|
+
# filter the result. If not specified, the endpoint returns all open
|
17
|
+
# disputes (dispute status is not `INQUIRY_CLOSED`, `WON`, or `LOST`).
|
18
|
+
# @param [String] location_id Optional parameter: The ID of the location for
|
19
|
+
# which to return a list of disputes. If not specified, the endpoint
|
20
|
+
# returns all open disputes (dispute status is not `INQUIRY_CLOSED`, `WON`,
|
21
|
+
# or `LOST`) associated with all locations.
|
22
|
+
# @return [ListDisputesResponse Hash] response from the API call
|
23
|
+
def list_disputes(cursor: nil,
|
24
|
+
states: nil,
|
25
|
+
location_id: nil)
|
26
|
+
# Prepare query url.
|
27
|
+
_query_builder = config.get_base_uri
|
28
|
+
_query_builder << '/v2/disputes'
|
29
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
30
|
+
_query_builder,
|
31
|
+
'cursor' => cursor,
|
32
|
+
'states' => states,
|
33
|
+
'location_id' => location_id
|
34
|
+
)
|
35
|
+
_query_url = APIHelper.clean_url _query_builder
|
36
|
+
|
37
|
+
# Prepare headers.
|
38
|
+
_headers = {
|
39
|
+
'accept' => 'application/json'
|
40
|
+
}
|
41
|
+
|
42
|
+
# Prepare and execute HttpRequest.
|
43
|
+
_request = config.http_client.get(
|
44
|
+
_query_url,
|
45
|
+
headers: _headers
|
46
|
+
)
|
47
|
+
OAuth2.apply(config, _request)
|
48
|
+
_response = execute_request(_request)
|
49
|
+
|
50
|
+
# Return appropriate response type.
|
51
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
52
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
53
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
54
|
+
end
|
55
|
+
|
56
|
+
# Returns details of a specific dispute.
|
57
|
+
# @param [String] dispute_id Required parameter: The ID of the dispute you
|
58
|
+
# want more details about.
|
59
|
+
# @return [RetrieveDisputeResponse Hash] response from the API call
|
60
|
+
def retrieve_dispute(dispute_id:)
|
61
|
+
# Prepare query url.
|
62
|
+
_query_builder = config.get_base_uri
|
63
|
+
_query_builder << '/v2/disputes/{dispute_id}'
|
64
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
65
|
+
_query_builder,
|
66
|
+
'dispute_id' => dispute_id
|
67
|
+
)
|
68
|
+
_query_url = APIHelper.clean_url _query_builder
|
69
|
+
|
70
|
+
# Prepare headers.
|
71
|
+
_headers = {
|
72
|
+
'accept' => 'application/json'
|
73
|
+
}
|
74
|
+
|
75
|
+
# Prepare and execute HttpRequest.
|
76
|
+
_request = config.http_client.get(
|
77
|
+
_query_url,
|
78
|
+
headers: _headers
|
79
|
+
)
|
80
|
+
OAuth2.apply(config, _request)
|
81
|
+
_response = execute_request(_request)
|
82
|
+
|
83
|
+
# Return appropriate response type.
|
84
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
85
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
86
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
87
|
+
end
|
88
|
+
|
89
|
+
# Accepts loss on a dispute. Square returns
|
90
|
+
# the disputed amount to the cardholder and updates the
|
91
|
+
# dispute state to ACCEPTED.
|
92
|
+
# Square debits the disputed amount from the seller’s Square
|
93
|
+
# account. If the Square account balance does not have
|
94
|
+
# sufficient funds, Square debits the associated bank account.
|
95
|
+
# For an overview of the Disputes API, see
|
96
|
+
# [Overview](https://developer.squareup.com/docs/docs/disputes-api/overview)
|
97
|
+
# .
|
98
|
+
# @param [String] dispute_id Required parameter: ID of the dispute you want
|
99
|
+
# to accept.
|
100
|
+
# @return [AcceptDisputeResponse Hash] response from the API call
|
101
|
+
def accept_dispute(dispute_id:)
|
102
|
+
# Prepare query url.
|
103
|
+
_query_builder = config.get_base_uri
|
104
|
+
_query_builder << '/v2/disputes/{dispute_id}/accept'
|
105
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
106
|
+
_query_builder,
|
107
|
+
'dispute_id' => dispute_id
|
108
|
+
)
|
109
|
+
_query_url = APIHelper.clean_url _query_builder
|
110
|
+
|
111
|
+
# Prepare headers.
|
112
|
+
_headers = {
|
113
|
+
'accept' => 'application/json'
|
114
|
+
}
|
115
|
+
|
116
|
+
# Prepare and execute HttpRequest.
|
117
|
+
_request = config.http_client.post(
|
118
|
+
_query_url,
|
119
|
+
headers: _headers
|
120
|
+
)
|
121
|
+
OAuth2.apply(config, _request)
|
122
|
+
_response = execute_request(_request)
|
123
|
+
|
124
|
+
# Return appropriate response type.
|
125
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
126
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
127
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
128
|
+
end
|
129
|
+
|
130
|
+
# Returns a list of evidence associated with a dispute.
|
131
|
+
# @param [String] dispute_id Required parameter: The ID of the dispute.
|
132
|
+
# @return [ListDisputeEvidenceResponse Hash] response from the API call
|
133
|
+
def list_dispute_evidence(dispute_id:)
|
134
|
+
# Prepare query url.
|
135
|
+
_query_builder = config.get_base_uri
|
136
|
+
_query_builder << '/v2/disputes/{dispute_id}/evidence'
|
137
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
138
|
+
_query_builder,
|
139
|
+
'dispute_id' => dispute_id
|
140
|
+
)
|
141
|
+
_query_url = APIHelper.clean_url _query_builder
|
142
|
+
|
143
|
+
# Prepare headers.
|
144
|
+
_headers = {
|
145
|
+
'accept' => 'application/json'
|
146
|
+
}
|
147
|
+
|
148
|
+
# Prepare and execute HttpRequest.
|
149
|
+
_request = config.http_client.get(
|
150
|
+
_query_url,
|
151
|
+
headers: _headers
|
152
|
+
)
|
153
|
+
OAuth2.apply(config, _request)
|
154
|
+
_response = execute_request(_request)
|
155
|
+
|
156
|
+
# Return appropriate response type.
|
157
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
158
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
159
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
160
|
+
end
|
161
|
+
|
162
|
+
# Removes specified evidence from a dispute.
|
163
|
+
# Square does not send the bank any evidence that
|
164
|
+
# is removed. Also, you cannot remove evidence after
|
165
|
+
# submitting it to the bank using
|
166
|
+
# [SubmitEvidence](https://developer.squareup.com/docs/reference/square/disp
|
167
|
+
# utes-api/submit-evidence).
|
168
|
+
# @param [String] dispute_id Required parameter: The ID of the dispute you
|
169
|
+
# want to remove evidence from.
|
170
|
+
# @param [String] evidence_id Required parameter: The ID of the evidence you
|
171
|
+
# want to remove.
|
172
|
+
# @return [RemoveDisputeEvidenceResponse Hash] response from the API call
|
173
|
+
def remove_dispute_evidence(dispute_id:,
|
174
|
+
evidence_id:)
|
175
|
+
# Prepare query url.
|
176
|
+
_query_builder = config.get_base_uri
|
177
|
+
_query_builder << '/v2/disputes/{dispute_id}/evidence/{evidence_id}'
|
178
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
179
|
+
_query_builder,
|
180
|
+
'dispute_id' => dispute_id,
|
181
|
+
'evidence_id' => evidence_id
|
182
|
+
)
|
183
|
+
_query_url = APIHelper.clean_url _query_builder
|
184
|
+
|
185
|
+
# Prepare headers.
|
186
|
+
_headers = {
|
187
|
+
'accept' => 'application/json'
|
188
|
+
}
|
189
|
+
|
190
|
+
# Prepare and execute HttpRequest.
|
191
|
+
_request = config.http_client.delete(
|
192
|
+
_query_url,
|
193
|
+
headers: _headers
|
194
|
+
)
|
195
|
+
OAuth2.apply(config, _request)
|
196
|
+
_response = execute_request(_request)
|
197
|
+
|
198
|
+
# Return appropriate response type.
|
199
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
200
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
201
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
202
|
+
end
|
203
|
+
|
204
|
+
# Returns the specific evidence metadata associated with a specific dispute.
|
205
|
+
# You must maintain a copy of the evidence you upload if you want to
|
206
|
+
# reference it later. You cannot download the evidence
|
207
|
+
# after you upload it.
|
208
|
+
# @param [String] dispute_id Required parameter: The ID of the dispute that
|
209
|
+
# you want to retrieve evidence from.
|
210
|
+
# @param [String] evidence_id Required parameter: The ID of the evidence to
|
211
|
+
# retrieve.
|
212
|
+
# @return [RetrieveDisputeEvidenceResponse Hash] response from the API call
|
213
|
+
def retrieve_dispute_evidence(dispute_id:,
|
214
|
+
evidence_id:)
|
215
|
+
# Prepare query url.
|
216
|
+
_query_builder = config.get_base_uri
|
217
|
+
_query_builder << '/v2/disputes/{dispute_id}/evidence/{evidence_id}'
|
218
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
219
|
+
_query_builder,
|
220
|
+
'dispute_id' => dispute_id,
|
221
|
+
'evidence_id' => evidence_id
|
222
|
+
)
|
223
|
+
_query_url = APIHelper.clean_url _query_builder
|
224
|
+
|
225
|
+
# Prepare headers.
|
226
|
+
_headers = {
|
227
|
+
'accept' => 'application/json'
|
228
|
+
}
|
229
|
+
|
230
|
+
# Prepare and execute HttpRequest.
|
231
|
+
_request = config.http_client.get(
|
232
|
+
_query_url,
|
233
|
+
headers: _headers
|
234
|
+
)
|
235
|
+
OAuth2.apply(config, _request)
|
236
|
+
_response = execute_request(_request)
|
237
|
+
|
238
|
+
# Return appropriate response type.
|
239
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
240
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
241
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
242
|
+
end
|
243
|
+
|
244
|
+
# Uploads a file to use as evidence in a dispute challenge. The endpoint
|
245
|
+
# accepts
|
246
|
+
# HTTP multipart/form-data file uploads in HEIC, HEIF, JPEG, PDF, PNG,
|
247
|
+
# and TIFF formats.
|
248
|
+
# For more information, see [Challenge a
|
249
|
+
# Dispute](https://developer.squareup.com/docs/docs/disputes-api/process-dis
|
250
|
+
# putes#challenge-a-dispute).
|
251
|
+
# @param [String] dispute_id Required parameter: ID of the dispute you want
|
252
|
+
# to upload evidence for.
|
253
|
+
# @param [CreateDisputeEvidenceFileRequest] request Optional parameter:
|
254
|
+
# Defines parameters for a CreateDisputeEvidenceFile request.
|
255
|
+
# @param [File | UploadIO] image_file Optional parameter: Example:
|
256
|
+
# @return [CreateDisputeEvidenceFileResponse Hash] response from the API call
|
257
|
+
def create_dispute_evidence_file(dispute_id:,
|
258
|
+
request: nil,
|
259
|
+
image_file: nil)
|
260
|
+
# Prepare query url.
|
261
|
+
_query_builder = config.get_base_uri
|
262
|
+
_query_builder << '/v2/disputes/{dispute_id}/evidence_file'
|
263
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
264
|
+
_query_builder,
|
265
|
+
'dispute_id' => dispute_id
|
266
|
+
)
|
267
|
+
_query_url = APIHelper.clean_url _query_builder
|
268
|
+
|
269
|
+
if image_file.is_a? FileWrapper
|
270
|
+
image_file_wrapper = image_file.file
|
271
|
+
image_file_content_type = image_file.content_type
|
272
|
+
else
|
273
|
+
image_file_wrapper = image_file
|
274
|
+
image_file_content_type = 'image/jpeg'
|
275
|
+
end
|
276
|
+
|
277
|
+
# Prepare headers.
|
278
|
+
_headers = {
|
279
|
+
'accept' => 'application/json'
|
280
|
+
}
|
281
|
+
|
282
|
+
# Prepare form parameters.
|
283
|
+
_parameters = {
|
284
|
+
'request' => Faraday::UploadIO.new(
|
285
|
+
StringIO.new(request.to_json),
|
286
|
+
'application/json'
|
287
|
+
),
|
288
|
+
'image_file' => Faraday::UploadIO.new(
|
289
|
+
image_file_wrapper,
|
290
|
+
image_file_content_type
|
291
|
+
)
|
292
|
+
}
|
293
|
+
_parameters = APIHelper.form_encode_parameters(_parameters)
|
294
|
+
|
295
|
+
# Prepare and execute HttpRequest.
|
296
|
+
_request = config.http_client.post(
|
297
|
+
_query_url,
|
298
|
+
headers: _headers,
|
299
|
+
parameters: _parameters
|
300
|
+
)
|
301
|
+
OAuth2.apply(config, _request)
|
302
|
+
_response = execute_request(_request)
|
303
|
+
|
304
|
+
# Return appropriate response type.
|
305
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
306
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
307
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
308
|
+
end
|
309
|
+
|
310
|
+
# Uploads text to use as evidence for a dispute challenge. For more
|
311
|
+
# information, see
|
312
|
+
# [Challenge a
|
313
|
+
# Dispute](https://developer.squareup.com/docs/docs/disputes-api/process-dis
|
314
|
+
# putes#challenge-a-dispute).
|
315
|
+
# @param [String] dispute_id Required parameter: The ID of the dispute you
|
316
|
+
# want to upload evidence for.
|
317
|
+
# @param [CreateDisputeEvidenceTextRequest] body Required parameter: An
|
318
|
+
# object containing the fields to POST for the request. See the
|
319
|
+
# corresponding object definition for field details.
|
320
|
+
# @return [CreateDisputeEvidenceTextResponse Hash] response from the API call
|
321
|
+
def create_dispute_evidence_text(dispute_id:,
|
322
|
+
body:)
|
323
|
+
# Prepare query url.
|
324
|
+
_query_builder = config.get_base_uri
|
325
|
+
_query_builder << '/v2/disputes/{dispute_id}/evidence_text'
|
326
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
327
|
+
_query_builder,
|
328
|
+
'dispute_id' => dispute_id
|
329
|
+
)
|
330
|
+
_query_url = APIHelper.clean_url _query_builder
|
331
|
+
|
332
|
+
# Prepare headers.
|
333
|
+
_headers = {
|
334
|
+
'accept' => 'application/json',
|
335
|
+
'content-type' => 'application/json; charset=utf-8'
|
336
|
+
}
|
337
|
+
|
338
|
+
# Prepare and execute HttpRequest.
|
339
|
+
_request = config.http_client.post(
|
340
|
+
_query_url,
|
341
|
+
headers: _headers,
|
342
|
+
parameters: body.to_json
|
343
|
+
)
|
344
|
+
OAuth2.apply(config, _request)
|
345
|
+
_response = execute_request(_request)
|
346
|
+
|
347
|
+
# Return appropriate response type.
|
348
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
349
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
350
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
351
|
+
end
|
352
|
+
|
353
|
+
# Submits evidence to the cardholder's bank.
|
354
|
+
# Before submitting evidence, Square compiles all available evidence. This
|
355
|
+
# includes
|
356
|
+
# evidence uploaded using the
|
357
|
+
# [CreateDisputeEvidenceFile](https://developer.squareup.com/docs/reference/
|
358
|
+
# square/disputes-api/create-dispute-evidence-file) and
|
359
|
+
# [CreateDisputeEvidenceText](https://developer.squareup.com/docs/reference/
|
360
|
+
# square/disputes-api/create-dispute-evidence-text) endpoints,
|
361
|
+
# and evidence automatically provided by Square, when
|
362
|
+
# available. For more information, see
|
363
|
+
# [Challenge a
|
364
|
+
# Dispute](https://developer.squareup.com/docs/docs/disputes-api/process-dis
|
365
|
+
# putes#challenge-a-dispute).
|
366
|
+
# @param [String] dispute_id Required parameter: The ID of the dispute you
|
367
|
+
# want to submit evidence for.
|
368
|
+
# @return [SubmitEvidenceResponse Hash] response from the API call
|
369
|
+
def submit_evidence(dispute_id:)
|
370
|
+
# Prepare query url.
|
371
|
+
_query_builder = config.get_base_uri
|
372
|
+
_query_builder << '/v2/disputes/{dispute_id}/submit-evidence'
|
373
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
374
|
+
_query_builder,
|
375
|
+
'dispute_id' => dispute_id
|
376
|
+
)
|
377
|
+
_query_url = APIHelper.clean_url _query_builder
|
378
|
+
|
379
|
+
# Prepare headers.
|
380
|
+
_headers = {
|
381
|
+
'accept' => 'application/json'
|
382
|
+
}
|
383
|
+
|
384
|
+
# Prepare and execute HttpRequest.
|
385
|
+
_request = config.http_client.post(
|
386
|
+
_query_url,
|
387
|
+
headers: _headers
|
388
|
+
)
|
389
|
+
OAuth2.apply(config, _request)
|
390
|
+
_response = execute_request(_request)
|
391
|
+
|
392
|
+
# Return appropriate response type.
|
393
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
394
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
395
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
396
|
+
end
|
397
|
+
end
|
398
|
+
end
|