square.rb 6.3.0.20200826 → 17.1.0.20220120

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/README.md +86 -51
  4. data/lib/square/api/apple_pay_api.rb +12 -9
  5. data/lib/square/api/bank_accounts_api.rb +21 -24
  6. data/lib/square/api/base_api.rb +20 -9
  7. data/lib/square/api/bookings_api.rb +391 -0
  8. data/lib/square/api/cards_api.rb +170 -0
  9. data/lib/square/api/cash_drawers_api.rb +13 -6
  10. data/lib/square/api/catalog_api.rb +195 -85
  11. data/lib/square/api/checkout_api.rb +7 -5
  12. data/lib/square/api/customer_groups_api.rb +34 -16
  13. data/lib/square/api/customer_segments_api.rb +21 -9
  14. data/lib/square/api/customers_api.rb +102 -55
  15. data/lib/square/api/devices_api.rb +20 -8
  16. data/lib/square/api/disputes_api.rb +156 -144
  17. data/lib/square/api/employees_api.rb +7 -3
  18. data/lib/square/api/gift_card_activities_api.rb +133 -0
  19. data/lib/square/api/gift_cards_api.rb +297 -0
  20. data/lib/square/api/inventory_api.rb +290 -37
  21. data/lib/square/api/invoices_api.rb +61 -57
  22. data/lib/square/api/labor_api.rb +127 -93
  23. data/lib/square/api/locations_api.rb +36 -25
  24. data/lib/square/api/loyalty_api.rb +134 -87
  25. data/lib/square/api/merchants_api.rb +8 -4
  26. data/lib/square/api/mobile_authorization_api.rb +9 -7
  27. data/lib/square/api/o_auth_api.rb +41 -32
  28. data/lib/square/api/orders_api.rb +132 -54
  29. data/lib/square/api/payments_api.rb +133 -75
  30. data/lib/square/api/refunds_api.rb +51 -30
  31. data/lib/square/api/sites_api.rb +43 -0
  32. data/lib/square/api/snippets_api.rb +146 -0
  33. data/lib/square/api/subscriptions_api.rb +216 -26
  34. data/lib/square/api/team_api.rb +81 -65
  35. data/lib/square/api/terminal_api.rb +166 -16
  36. data/lib/square/api/transactions_api.rb +32 -194
  37. data/lib/square/api/v1_transactions_api.rb +53 -103
  38. data/lib/square/api_helper.rb +38 -43
  39. data/lib/square/client.rb +54 -24
  40. data/lib/square/configuration.rb +61 -21
  41. data/lib/square/http/api_response.rb +3 -1
  42. data/lib/square/http/faraday_client.rb +34 -5
  43. data/lib/square/utilities/date_time_helper.rb +151 -0
  44. data/lib/square/utilities/file_wrapper.rb +1 -2
  45. data/lib/square.rb +65 -61
  46. data/spec/user_journey_spec.rb +2 -5
  47. data/test/api/api_test_base.rb +1 -6
  48. data/test/api/test_catalog_api.rb +1 -4
  49. data/test/api/test_customers_api.rb +1 -4
  50. data/test/api/test_employees_api.rb +1 -4
  51. data/test/api/test_labor_api.rb +2 -6
  52. data/test/api/test_locations_api.rb +21 -35
  53. data/test/api/test_merchants_api.rb +1 -4
  54. data/test/api/test_payments_api.rb +3 -6
  55. data/test/api/test_refunds_api.rb +3 -6
  56. data/test/http_response_catcher.rb +0 -5
  57. data/test/test_helper.rb +1 -6
  58. metadata +40 -18
  59. data/lib/square/api/v1_employees_api.rb +0 -723
  60. data/lib/square/api/v1_items_api.rb +0 -1686
  61. data/lib/square/api/v1_locations_api.rb +0 -65
@@ -5,20 +5,19 @@ module Square
5
5
  super(config, http_call_back: http_call_back)
6
6
  end
7
7
 
8
- # Returns a list of disputes associated
9
- # with a particular account.
8
+ # Returns a list of disputes associated with a particular account.
10
9
  # @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)
10
+ # a previous call to this endpoint. Provide this cursor to retrieve the next
11
+ # set of results for the original query. For more information, see
12
+ # [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
14
13
  # .
15
14
  # @param [DisputeState] states Optional parameter: The dispute states to
16
15
  # filter the result. If not specified, the endpoint returns all open
17
- # disputes (dispute status is not `INQUIRY_CLOSED`, `WON`, or `LOST`).
16
+ # disputes (the dispute status is not `INQUIRY_CLOSED`, `WON`, or `LOST`).
18
17
  # @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.
18
+ # which to return a list of disputes. If not specified, the endpoint returns
19
+ # all open disputes (the dispute status is not `INQUIRY_CLOSED`, `WON`, or
20
+ # `LOST`) associated with all locations.
22
21
  # @return [ListDisputesResponse Hash] response from the API call
23
22
  def list_disputes(cursor: nil,
24
23
  states: nil,
@@ -50,10 +49,12 @@ module Square
50
49
  # Return appropriate response type.
51
50
  decoded = APIHelper.json_deserialize(_response.raw_body)
52
51
  _errors = APIHelper.map_response(decoded, ['errors'])
53
- ApiResponse.new(_response, data: decoded, errors: _errors)
52
+ ApiResponse.new(
53
+ _response, data: decoded, errors: _errors
54
+ )
54
55
  end
55
56
 
56
- # Returns details of a specific dispute.
57
+ # Returns details about a specific dispute.
57
58
  # @param [String] dispute_id Required parameter: The ID of the dispute you
58
59
  # want more details about.
59
60
  # @return [RetrieveDisputeResponse Hash] response from the API call
@@ -63,7 +64,7 @@ module Square
63
64
  _query_builder << '/v2/disputes/{dispute_id}'
64
65
  _query_builder = APIHelper.append_url_with_template_parameters(
65
66
  _query_builder,
66
- 'dispute_id' => dispute_id
67
+ 'dispute_id' => { 'value' => dispute_id, 'encode' => true }
67
68
  )
68
69
  _query_url = APIHelper.clean_url _query_builder
69
70
 
@@ -83,20 +84,19 @@ module Square
83
84
  # Return appropriate response type.
84
85
  decoded = APIHelper.json_deserialize(_response.raw_body)
85
86
  _errors = APIHelper.map_response(decoded, ['errors'])
86
- ApiResponse.new(_response, data: decoded, errors: _errors)
87
+ ApiResponse.new(
88
+ _response, data: decoded, errors: _errors
89
+ )
87
90
  end
88
91
 
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.
92
+ # Accepts the loss on a dispute. Square returns the disputed amount to the
93
+ # cardholder and
94
+ # updates the dispute state to ACCEPTED.
95
+ # Square debits the disputed amount from the seller’s Square account. If the
96
+ # Square account
97
+ # does not have sufficient funds, Square debits the associated bank account.
98
+ # @param [String] dispute_id Required parameter: The ID of the dispute you
99
+ # want to accept.
100
100
  # @return [AcceptDisputeResponse Hash] response from the API call
101
101
  def accept_dispute(dispute_id:)
102
102
  # Prepare query url.
@@ -104,7 +104,7 @@ module Square
104
104
  _query_builder << '/v2/disputes/{dispute_id}/accept'
105
105
  _query_builder = APIHelper.append_url_with_template_parameters(
106
106
  _query_builder,
107
- 'dispute_id' => dispute_id
107
+ 'dispute_id' => { 'value' => dispute_id, 'encode' => true }
108
108
  )
109
109
  _query_url = APIHelper.clean_url _query_builder
110
110
 
@@ -124,19 +124,31 @@ module Square
124
124
  # Return appropriate response type.
125
125
  decoded = APIHelper.json_deserialize(_response.raw_body)
126
126
  _errors = APIHelper.map_response(decoded, ['errors'])
127
- ApiResponse.new(_response, data: decoded, errors: _errors)
127
+ ApiResponse.new(
128
+ _response, data: decoded, errors: _errors
129
+ )
128
130
  end
129
131
 
130
132
  # Returns a list of evidence associated with a dispute.
131
133
  # @param [String] dispute_id Required parameter: The ID of the dispute.
134
+ # @param [String] cursor Optional parameter: A pagination cursor returned by
135
+ # a previous call to this endpoint. Provide this cursor to retrieve the next
136
+ # set of results for the original query. For more information, see
137
+ # [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
138
+ # .
132
139
  # @return [ListDisputeEvidenceResponse Hash] response from the API call
133
- def list_dispute_evidence(dispute_id:)
140
+ def list_dispute_evidence(dispute_id:,
141
+ cursor: nil)
134
142
  # Prepare query url.
135
143
  _query_builder = config.get_base_uri
136
144
  _query_builder << '/v2/disputes/{dispute_id}/evidence'
137
145
  _query_builder = APIHelper.append_url_with_template_parameters(
138
146
  _query_builder,
139
- 'dispute_id' => dispute_id
147
+ 'dispute_id' => { 'value' => dispute_id, 'encode' => true }
148
+ )
149
+ _query_builder = APIHelper.append_url_with_query_parameters(
150
+ _query_builder,
151
+ 'cursor' => cursor
140
152
  )
141
153
  _query_url = APIHelper.clean_url _query_builder
142
154
 
@@ -156,41 +168,64 @@ module Square
156
168
  # Return appropriate response type.
157
169
  decoded = APIHelper.json_deserialize(_response.raw_body)
158
170
  _errors = APIHelper.map_response(decoded, ['errors'])
159
- ApiResponse.new(_response, data: decoded, errors: _errors)
171
+ ApiResponse.new(
172
+ _response, data: decoded, errors: _errors
173
+ )
160
174
  end
161
175
 
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).
176
+ # Uploads a file to use as evidence in a dispute challenge. The endpoint
177
+ # accepts HTTP
178
+ # multipart/form-data file uploads in HEIC, HEIF, JPEG, PDF, PNG, and TIFF
179
+ # formats.
168
180
  # @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:)
181
+ # want to upload evidence for.
182
+ # @param [CreateDisputeEvidenceFileRequest] request Optional parameter:
183
+ # Defines the parameters for a `CreateDisputeEvidenceFile` request.
184
+ # @param [File | UploadIO] image_file Optional parameter: Example:
185
+ # @return [CreateDisputeEvidenceFileResponse Hash] response from the API call
186
+ def create_dispute_evidence_file(dispute_id:,
187
+ request: nil,
188
+ image_file: nil)
175
189
  # Prepare query url.
176
190
  _query_builder = config.get_base_uri
177
- _query_builder << '/v2/disputes/{dispute_id}/evidence/{evidence_id}'
191
+ _query_builder << '/v2/disputes/{dispute_id}/evidence-files'
178
192
  _query_builder = APIHelper.append_url_with_template_parameters(
179
193
  _query_builder,
180
- 'dispute_id' => dispute_id,
181
- 'evidence_id' => evidence_id
194
+ 'dispute_id' => { 'value' => dispute_id, 'encode' => true }
182
195
  )
183
196
  _query_url = APIHelper.clean_url _query_builder
184
197
 
198
+ if image_file.is_a? FileWrapper
199
+ image_file_wrapper = image_file.file
200
+ image_file_content_type = image_file.content_type
201
+ else
202
+ image_file_wrapper = image_file
203
+ image_file_content_type = 'image/jpeg'
204
+ end
205
+
185
206
  # Prepare headers.
186
207
  _headers = {
187
208
  'accept' => 'application/json'
188
209
  }
189
210
 
211
+ # Prepare form parameters.
212
+ _parameters = {
213
+ 'request' => Faraday::UploadIO.new(
214
+ StringIO.new(request.to_json),
215
+ 'application/json'
216
+ ),
217
+ 'image_file' => Faraday::UploadIO.new(
218
+ image_file_wrapper,
219
+ image_file_content_type
220
+ )
221
+ }
222
+ _parameters = APIHelper.form_encode_parameters(_parameters)
223
+
190
224
  # Prepare and execute HttpRequest.
191
- _request = config.http_client.delete(
225
+ _request = config.http_client.post(
192
226
  _query_url,
193
- headers: _headers
227
+ headers: _headers,
228
+ parameters: _parameters
194
229
  )
195
230
  OAuth2.apply(config, _request)
196
231
  _response = execute_request(_request)
@@ -198,39 +233,40 @@ module Square
198
233
  # Return appropriate response type.
199
234
  decoded = APIHelper.json_deserialize(_response.raw_body)
200
235
  _errors = APIHelper.map_response(decoded, ['errors'])
201
- ApiResponse.new(_response, data: decoded, errors: _errors)
236
+ ApiResponse.new(
237
+ _response, data: decoded, errors: _errors
238
+ )
202
239
  end
203
240
 
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:)
241
+ # Uploads text to use as evidence for a dispute challenge.
242
+ # @param [String] dispute_id Required parameter: The ID of the dispute you
243
+ # want to upload evidence for.
244
+ # @param [CreateDisputeEvidenceTextRequest] body Required parameter: An
245
+ # object containing the fields to POST for the request. See the
246
+ # corresponding object definition for field details.
247
+ # @return [CreateDisputeEvidenceTextResponse Hash] response from the API call
248
+ def create_dispute_evidence_text(dispute_id:,
249
+ body:)
215
250
  # Prepare query url.
216
251
  _query_builder = config.get_base_uri
217
- _query_builder << '/v2/disputes/{dispute_id}/evidence/{evidence_id}'
252
+ _query_builder << '/v2/disputes/{dispute_id}/evidence-text'
218
253
  _query_builder = APIHelper.append_url_with_template_parameters(
219
254
  _query_builder,
220
- 'dispute_id' => dispute_id,
221
- 'evidence_id' => evidence_id
255
+ 'dispute_id' => { 'value' => dispute_id, 'encode' => true }
222
256
  )
223
257
  _query_url = APIHelper.clean_url _query_builder
224
258
 
225
259
  # Prepare headers.
226
260
  _headers = {
227
- 'accept' => 'application/json'
261
+ 'accept' => 'application/json',
262
+ 'Content-Type' => 'application/json'
228
263
  }
229
264
 
230
265
  # Prepare and execute HttpRequest.
231
- _request = config.http_client.get(
266
+ _request = config.http_client.post(
232
267
  _query_url,
233
- headers: _headers
268
+ headers: _headers,
269
+ parameters: body.to_json
234
270
  )
235
271
  OAuth2.apply(config, _request)
236
272
  _response = execute_request(_request)
@@ -238,65 +274,42 @@ module Square
238
274
  # Return appropriate response type.
239
275
  decoded = APIHelper.json_deserialize(_response.raw_body)
240
276
  _errors = APIHelper.map_response(decoded, ['errors'])
241
- ApiResponse.new(_response, data: decoded, errors: _errors)
277
+ ApiResponse.new(
278
+ _response, data: decoded, errors: _errors
279
+ )
242
280
  end
243
281
 
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)
282
+ # Removes specified evidence from a dispute.
283
+ # Square does not send the bank any evidence that is removed. Also, you
284
+ # cannot remove evidence after
285
+ # submitting it to the bank using
286
+ # [SubmitEvidence]($e/Disputes/SubmitEvidence).
287
+ # @param [String] dispute_id Required parameter: The ID of the dispute you
288
+ # want to remove evidence from.
289
+ # @param [String] evidence_id Required parameter: The ID of the evidence you
290
+ # want to remove.
291
+ # @return [DeleteDisputeEvidenceResponse Hash] response from the API call
292
+ def delete_dispute_evidence(dispute_id:,
293
+ evidence_id:)
260
294
  # Prepare query url.
261
295
  _query_builder = config.get_base_uri
262
- _query_builder << '/v2/disputes/{dispute_id}/evidence_file'
296
+ _query_builder << '/v2/disputes/{dispute_id}/evidence/{evidence_id}'
263
297
  _query_builder = APIHelper.append_url_with_template_parameters(
264
298
  _query_builder,
265
- 'dispute_id' => dispute_id
299
+ 'dispute_id' => { 'value' => dispute_id, 'encode' => true },
300
+ 'evidence_id' => { 'value' => evidence_id, 'encode' => true }
266
301
  )
267
302
  _query_url = APIHelper.clean_url _query_builder
268
303
 
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
304
  # Prepare headers.
278
305
  _headers = {
279
306
  'accept' => 'application/json'
280
307
  }
281
308
 
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
309
  # Prepare and execute HttpRequest.
296
- _request = config.http_client.post(
310
+ _request = config.http_client.delete(
297
311
  _query_url,
298
- headers: _headers,
299
- parameters: _parameters
312
+ headers: _headers
300
313
  )
301
314
  OAuth2.apply(config, _request)
302
315
  _response = execute_request(_request)
@@ -304,42 +317,42 @@ module Square
304
317
  # Return appropriate response type.
305
318
  decoded = APIHelper.json_deserialize(_response.raw_body)
306
319
  _errors = APIHelper.map_response(decoded, ['errors'])
307
- ApiResponse.new(_response, data: decoded, errors: _errors)
320
+ ApiResponse.new(
321
+ _response, data: decoded, errors: _errors
322
+ )
308
323
  end
309
324
 
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:)
325
+ # Returns the evidence metadata specified by the evidence ID in the request
326
+ # URL path
327
+ # You must maintain a copy of the evidence you upload if you want to
328
+ # reference it later. You cannot
329
+ # download the evidence after you upload it.
330
+ # @param [String] dispute_id Required parameter: The ID of the dispute that
331
+ # you want to retrieve evidence from.
332
+ # @param [String] evidence_id Required parameter: The ID of the evidence to
333
+ # retrieve.
334
+ # @return [RetrieveDisputeEvidenceResponse Hash] response from the API call
335
+ def retrieve_dispute_evidence(dispute_id:,
336
+ evidence_id:)
323
337
  # Prepare query url.
324
338
  _query_builder = config.get_base_uri
325
- _query_builder << '/v2/disputes/{dispute_id}/evidence_text'
339
+ _query_builder << '/v2/disputes/{dispute_id}/evidence/{evidence_id}'
326
340
  _query_builder = APIHelper.append_url_with_template_parameters(
327
341
  _query_builder,
328
- 'dispute_id' => dispute_id
342
+ 'dispute_id' => { 'value' => dispute_id, 'encode' => true },
343
+ 'evidence_id' => { 'value' => evidence_id, 'encode' => true }
329
344
  )
330
345
  _query_url = APIHelper.clean_url _query_builder
331
346
 
332
347
  # Prepare headers.
333
348
  _headers = {
334
- 'accept' => 'application/json',
335
- 'content-type' => 'application/json; charset=utf-8'
349
+ 'accept' => 'application/json'
336
350
  }
337
351
 
338
352
  # Prepare and execute HttpRequest.
339
- _request = config.http_client.post(
353
+ _request = config.http_client.get(
340
354
  _query_url,
341
- headers: _headers,
342
- parameters: body.to_json
355
+ headers: _headers
343
356
  )
344
357
  OAuth2.apply(config, _request)
345
358
  _response = execute_request(_request)
@@ -347,24 +360,21 @@ module Square
347
360
  # Return appropriate response type.
348
361
  decoded = APIHelper.json_deserialize(_response.raw_body)
349
362
  _errors = APIHelper.map_response(decoded, ['errors'])
350
- ApiResponse.new(_response, data: decoded, errors: _errors)
363
+ ApiResponse.new(
364
+ _response, data: decoded, errors: _errors
365
+ )
351
366
  end
352
367
 
353
368
  # Submits evidence to the cardholder's bank.
354
369
  # 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.
370
+ # includes evidence uploaded
371
+ # using the
372
+ # [CreateDisputeEvidenceFile]($e/Disputes/CreateDisputeEvidenceFile) and
373
+ # [CreateDisputeEvidenceText]($e/Disputes/CreateDisputeEvidenceText)
374
+ # endpoints and
375
+ # evidence automatically provided by Square, when available.
376
+ # @param [String] dispute_id Required parameter: The ID of the dispute that
377
+ # you want to submit evidence for.
368
378
  # @return [SubmitEvidenceResponse Hash] response from the API call
369
379
  def submit_evidence(dispute_id:)
370
380
  # Prepare query url.
@@ -372,7 +382,7 @@ module Square
372
382
  _query_builder << '/v2/disputes/{dispute_id}/submit-evidence'
373
383
  _query_builder = APIHelper.append_url_with_template_parameters(
374
384
  _query_builder,
375
- 'dispute_id' => dispute_id
385
+ 'dispute_id' => { 'value' => dispute_id, 'encode' => true }
376
386
  )
377
387
  _query_url = APIHelper.clean_url _query_builder
378
388
 
@@ -392,7 +402,9 @@ module Square
392
402
  # Return appropriate response type.
393
403
  decoded = APIHelper.json_deserialize(_response.raw_body)
394
404
  _errors = APIHelper.map_response(decoded, ['errors'])
395
- ApiResponse.new(_response, data: decoded, errors: _errors)
405
+ ApiResponse.new(
406
+ _response, data: decoded, errors: _errors
407
+ )
396
408
  end
397
409
  end
398
410
  end
@@ -47,7 +47,9 @@ module Square
47
47
  # Return appropriate response type.
48
48
  decoded = APIHelper.json_deserialize(_response.raw_body)
49
49
  _errors = APIHelper.map_response(decoded, ['errors'])
50
- ApiResponse.new(_response, data: decoded, errors: _errors)
50
+ ApiResponse.new(
51
+ _response, data: decoded, errors: _errors
52
+ )
51
53
  end
52
54
 
53
55
  # RetrieveEmployee
@@ -61,7 +63,7 @@ module Square
61
63
  _query_builder << '/v2/employees/{id}'
62
64
  _query_builder = APIHelper.append_url_with_template_parameters(
63
65
  _query_builder,
64
- 'id' => id
66
+ 'id' => { 'value' => id, 'encode' => true }
65
67
  )
66
68
  _query_url = APIHelper.clean_url _query_builder
67
69
 
@@ -81,7 +83,9 @@ module Square
81
83
  # Return appropriate response type.
82
84
  decoded = APIHelper.json_deserialize(_response.raw_body)
83
85
  _errors = APIHelper.map_response(decoded, ['errors'])
84
- ApiResponse.new(_response, data: decoded, errors: _errors)
86
+ ApiResponse.new(
87
+ _response, data: decoded, errors: _errors
88
+ )
85
89
  end
86
90
  end
87
91
  end
@@ -0,0 +1,133 @@
1
+ module Square
2
+ # GiftCardActivitiesApi
3
+ class GiftCardActivitiesApi < BaseApi
4
+ def initialize(config, http_call_back: nil)
5
+ super(config, http_call_back: http_call_back)
6
+ end
7
+
8
+ # Lists gift card activities. By default, you get gift card activities for
9
+ # all
10
+ # gift cards in the seller's account. You can optionally specify query
11
+ # parameters to
12
+ # filter the list. For example, you can get a list of gift card activities
13
+ # for a gift card,
14
+ # for all gift cards in a specific region, or for activities within a time
15
+ # window.
16
+ # @param [String] gift_card_id Optional parameter: If a gift card ID is
17
+ # provided, the endpoint returns activities related to the specified gift
18
+ # card. Otherwise, the endpoint returns all gift card activities for the
19
+ # seller.
20
+ # @param [String] type Optional parameter: If a
21
+ # [type]($m/GiftCardActivityType) is provided, the endpoint returns gift
22
+ # card activities of the specified type. Otherwise, the endpoint returns
23
+ # all types of gift card activities.
24
+ # @param [String] location_id Optional parameter: If a location ID is
25
+ # provided, the endpoint returns gift card activities for the specified
26
+ # location. Otherwise, the endpoint returns gift card activities for all
27
+ # locations.
28
+ # @param [String] begin_time Optional parameter: The timestamp for the
29
+ # beginning of the reporting period, in RFC 3339 format. This start time is
30
+ # inclusive. The default value is the current time minus one year.
31
+ # @param [String] end_time Optional parameter: The timestamp for the end of
32
+ # the reporting period, in RFC 3339 format. This end time is inclusive. The
33
+ # default value is the current time.
34
+ # @param [Integer] limit Optional parameter: If a limit is provided, the
35
+ # endpoint returns the specified number of results (or fewer) per page. The
36
+ # maximum value is 100. The default value is 50. For more information, see
37
+ # [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
38
+ # ion).
39
+ # @param [String] cursor Optional parameter: A pagination cursor returned by
40
+ # a previous call to this endpoint. Provide this cursor to retrieve the next
41
+ # set of results for the original query. If a cursor is not provided, the
42
+ # endpoint returns the first page of the results. For more information, see
43
+ # [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
44
+ # ion).
45
+ # @param [String] sort_order Optional parameter: The order in which the
46
+ # endpoint returns the activities, based on `created_at`. - `ASC` - Oldest
47
+ # to newest. - `DESC` - Newest to oldest (default).
48
+ # @return [ListGiftCardActivitiesResponse Hash] response from the API call
49
+ def list_gift_card_activities(gift_card_id: nil,
50
+ type: nil,
51
+ location_id: nil,
52
+ begin_time: nil,
53
+ end_time: nil,
54
+ limit: nil,
55
+ cursor: nil,
56
+ sort_order: nil)
57
+ # Prepare query url.
58
+ _query_builder = config.get_base_uri
59
+ _query_builder << '/v2/gift-cards/activities'
60
+ _query_builder = APIHelper.append_url_with_query_parameters(
61
+ _query_builder,
62
+ 'gift_card_id' => gift_card_id,
63
+ 'type' => type,
64
+ 'location_id' => location_id,
65
+ 'begin_time' => begin_time,
66
+ 'end_time' => end_time,
67
+ 'limit' => limit,
68
+ 'cursor' => cursor,
69
+ 'sort_order' => sort_order
70
+ )
71
+ _query_url = APIHelper.clean_url _query_builder
72
+
73
+ # Prepare headers.
74
+ _headers = {
75
+ 'accept' => 'application/json'
76
+ }
77
+
78
+ # Prepare and execute HttpRequest.
79
+ _request = config.http_client.get(
80
+ _query_url,
81
+ headers: _headers
82
+ )
83
+ OAuth2.apply(config, _request)
84
+ _response = execute_request(_request)
85
+
86
+ # Return appropriate response type.
87
+ decoded = APIHelper.json_deserialize(_response.raw_body)
88
+ _errors = APIHelper.map_response(decoded, ['errors'])
89
+ ApiResponse.new(
90
+ _response, data: decoded, errors: _errors
91
+ )
92
+ end
93
+
94
+ # Creates a gift card activity. For more information, see
95
+ # [GiftCardActivity](https://developer.squareup.com/docs/gift-cards/using-gi
96
+ # ft-cards-api#giftcardactivity) and
97
+ # [Using activated gift
98
+ # cards](https://developer.squareup.com/docs/gift-cards/using-gift-cards-api
99
+ # #using-activated-gift-cards).
100
+ # @param [CreateGiftCardActivityRequest] body Required parameter: An object
101
+ # containing the fields to POST for the request. See the corresponding
102
+ # object definition for field details.
103
+ # @return [CreateGiftCardActivityResponse Hash] response from the API call
104
+ def create_gift_card_activity(body:)
105
+ # Prepare query url.
106
+ _query_builder = config.get_base_uri
107
+ _query_builder << '/v2/gift-cards/activities'
108
+ _query_url = APIHelper.clean_url _query_builder
109
+
110
+ # Prepare headers.
111
+ _headers = {
112
+ 'accept' => 'application/json',
113
+ 'Content-Type' => 'application/json'
114
+ }
115
+
116
+ # Prepare and execute HttpRequest.
117
+ _request = config.http_client.post(
118
+ _query_url,
119
+ headers: _headers,
120
+ parameters: body.to_json
121
+ )
122
+ OAuth2.apply(config, _request)
123
+ _response = execute_request(_request)
124
+
125
+ # Return appropriate response type.
126
+ decoded = APIHelper.json_deserialize(_response.raw_body)
127
+ _errors = APIHelper.map_response(decoded, ['errors'])
128
+ ApiResponse.new(
129
+ _response, data: decoded, errors: _errors
130
+ )
131
+ end
132
+ end
133
+ end