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,14 +5,14 @@ module Square
5
5
  super(config, http_call_back: http_call_back)
6
6
  end
7
7
 
8
- # Creates a single `TeamMember` object. The `TeamMember` will be returned on
9
- # successful creates.
8
+ # Creates a single `TeamMember` object. The `TeamMember` object is returned
9
+ # on successful creates.
10
10
  # You must provide the following values in your request to this endpoint:
11
- # - `first_name`
12
- # - `last_name`
13
- # Learn about [Troubleshooting the Teams
14
- # API](https://developer.squareup.com/docs/docs/team/troubleshooting#createt
15
- # eammember).
11
+ # - `given_name`
12
+ # - `family_name`
13
+ # Learn about [Troubleshooting the Team
14
+ # API](https://developer.squareup.com/docs/team/troubleshooting#createteamme
15
+ # mber).
16
16
  # @param [CreateTeamMemberRequest] body Required parameter: An object
17
17
  # containing the fields to POST for the request. See the corresponding
18
18
  # object definition for field details.
@@ -26,7 +26,7 @@ module Square
26
26
  # Prepare headers.
27
27
  _headers = {
28
28
  'accept' => 'application/json',
29
- 'content-type' => 'application/json; charset=utf-8'
29
+ 'Content-Type' => 'application/json'
30
30
  }
31
31
 
32
32
  # Prepare and execute HttpRequest.
@@ -41,19 +41,21 @@ module Square
41
41
  # Return appropriate response type.
42
42
  decoded = APIHelper.json_deserialize(_response.raw_body)
43
43
  _errors = APIHelper.map_response(decoded, ['errors'])
44
- ApiResponse.new(_response, data: decoded, errors: _errors)
44
+ ApiResponse.new(
45
+ _response, data: decoded, errors: _errors
46
+ )
45
47
  end
46
48
 
47
49
  # Creates multiple `TeamMember` objects. The created `TeamMember` objects
48
- # will be returned on successful creates.
49
- # This process is non-transactional and will process as much of the request
50
- # as is possible. If one of the creates in
51
- # the request cannot be successfully processed, the request will NOT be
52
- # marked as failed, but the body of the response
53
- # will contain explicit error information for this particular create.
54
- # Learn about [Troubleshooting the Teams
55
- # API](https://developer.squareup.com/docs/docs/team/troubleshooting#bulkcre
56
- # ateteammembers).
50
+ # are returned on successful creates.
51
+ # This process is non-transactional and processes as much of the request as
52
+ # possible. If one of the creates in
53
+ # the request cannot be successfully processed, the request is not marked as
54
+ # failed, but the body of the response
55
+ # contains explicit error information for the failed create.
56
+ # Learn about [Troubleshooting the Team
57
+ # API](https://developer.squareup.com/docs/team/troubleshooting#bulk-create-
58
+ # team-members).
57
59
  # @param [BulkCreateTeamMembersRequest] body Required parameter: An object
58
60
  # containing the fields to POST for the request. See the corresponding
59
61
  # object definition for field details.
@@ -67,7 +69,7 @@ module Square
67
69
  # Prepare headers.
68
70
  _headers = {
69
71
  'accept' => 'application/json',
70
- 'content-type' => 'application/json; charset=utf-8'
72
+ 'Content-Type' => 'application/json'
71
73
  }
72
74
 
73
75
  # Prepare and execute HttpRequest.
@@ -82,19 +84,21 @@ module Square
82
84
  # Return appropriate response type.
83
85
  decoded = APIHelper.json_deserialize(_response.raw_body)
84
86
  _errors = APIHelper.map_response(decoded, ['errors'])
85
- ApiResponse.new(_response, data: decoded, errors: _errors)
87
+ ApiResponse.new(
88
+ _response, data: decoded, errors: _errors
89
+ )
86
90
  end
87
91
 
88
92
  # Updates multiple `TeamMember` objects. The updated `TeamMember` objects
89
- # will be returned on successful updates.
90
- # This process is non-transactional and will process as much of the request
91
- # as is possible. If one of the updates in
92
- # the request cannot be successfully processed, the request will NOT be
93
- # marked as failed, but the body of the response
94
- # will contain explicit error information for this particular update.
95
- # Learn about [Troubleshooting the Teams
96
- # API](https://developer.squareup.com/docs/docs/team/troubleshooting#bulkupd
97
- # ateteammembers).
93
+ # are returned on successful updates.
94
+ # This process is non-transactional and processes as much of the request as
95
+ # possible. If one of the updates in
96
+ # the request cannot be successfully processed, the request is not marked as
97
+ # failed, but the body of the response
98
+ # contains explicit error information for the failed update.
99
+ # Learn about [Troubleshooting the Team
100
+ # API](https://developer.squareup.com/docs/team/troubleshooting#bulk-update-
101
+ # team-members).
98
102
  # @param [BulkUpdateTeamMembersRequest] body Required parameter: An object
99
103
  # containing the fields to POST for the request. See the corresponding
100
104
  # object definition for field details.
@@ -108,7 +112,7 @@ module Square
108
112
  # Prepare headers.
109
113
  _headers = {
110
114
  'accept' => 'application/json',
111
- 'content-type' => 'application/json; charset=utf-8'
115
+ 'Content-Type' => 'application/json'
112
116
  }
113
117
 
114
118
  # Prepare and execute HttpRequest.
@@ -123,13 +127,15 @@ module Square
123
127
  # Return appropriate response type.
124
128
  decoded = APIHelper.json_deserialize(_response.raw_body)
125
129
  _errors = APIHelper.map_response(decoded, ['errors'])
126
- ApiResponse.new(_response, data: decoded, errors: _errors)
130
+ ApiResponse.new(
131
+ _response, data: decoded, errors: _errors
132
+ )
127
133
  end
128
134
 
129
135
  # Returns a paginated list of `TeamMember` objects for a business.
130
- # The list to be returned can be filtered by:
131
- # - location IDs **and**
132
- # - `is_active`
136
+ # The list can be filtered by the following:
137
+ # - location IDs
138
+ # - `status`
133
139
  # @param [SearchTeamMembersRequest] body Required parameter: An object
134
140
  # containing the fields to POST for the request. See the corresponding
135
141
  # object definition for field details.
@@ -143,7 +149,7 @@ module Square
143
149
  # Prepare headers.
144
150
  _headers = {
145
151
  'accept' => 'application/json',
146
- 'content-type' => 'application/json; charset=utf-8'
152
+ 'Content-Type' => 'application/json'
147
153
  }
148
154
 
149
155
  # Prepare and execute HttpRequest.
@@ -158,13 +164,15 @@ module Square
158
164
  # Return appropriate response type.
159
165
  decoded = APIHelper.json_deserialize(_response.raw_body)
160
166
  _errors = APIHelper.map_response(decoded, ['errors'])
161
- ApiResponse.new(_response, data: decoded, errors: _errors)
167
+ ApiResponse.new(
168
+ _response, data: decoded, errors: _errors
169
+ )
162
170
  end
163
171
 
164
- # Retrieve a `TeamMember` object for the given `TeamMember.id`
165
- # Learn about [Troubleshooting the Teams
166
- # API](https://developer.squareup.com/docs/docs/team/troubleshooting#retriev
167
- # eteammember).
172
+ # Retrieves a `TeamMember` object for the given `TeamMember.id`.
173
+ # Learn about [Troubleshooting the Team
174
+ # API](https://developer.squareup.com/docs/team/troubleshooting#retrieve-a-t
175
+ # eam-member).
168
176
  # @param [String] team_member_id Required parameter: The ID of the team
169
177
  # member to retrieve.
170
178
  # @return [RetrieveTeamMemberResponse Hash] response from the API call
@@ -174,7 +182,7 @@ module Square
174
182
  _query_builder << '/v2/team-members/{team_member_id}'
175
183
  _query_builder = APIHelper.append_url_with_template_parameters(
176
184
  _query_builder,
177
- 'team_member_id' => team_member_id
185
+ 'team_member_id' => { 'value' => team_member_id, 'encode' => true }
178
186
  )
179
187
  _query_url = APIHelper.clean_url _query_builder
180
188
 
@@ -194,14 +202,16 @@ module Square
194
202
  # Return appropriate response type.
195
203
  decoded = APIHelper.json_deserialize(_response.raw_body)
196
204
  _errors = APIHelper.map_response(decoded, ['errors'])
197
- ApiResponse.new(_response, data: decoded, errors: _errors)
205
+ ApiResponse.new(
206
+ _response, data: decoded, errors: _errors
207
+ )
198
208
  end
199
209
 
200
- # Updates a single `TeamMember` object. The `TeamMember` will be returned on
201
- # successful updates.
202
- # Learn about [Troubleshooting the Teams
203
- # API](https://developer.squareup.com/docs/docs/team/troubleshooting#updatet
204
- # eammember).
210
+ # Updates a single `TeamMember` object. The `TeamMember` object is returned
211
+ # on successful updates.
212
+ # Learn about [Troubleshooting the Team
213
+ # API](https://developer.squareup.com/docs/team/troubleshooting#update-a-tea
214
+ # m-member).
205
215
  # @param [String] team_member_id Required parameter: The ID of the team
206
216
  # member to update.
207
217
  # @param [UpdateTeamMemberRequest] body Required parameter: An object
@@ -215,14 +225,14 @@ module Square
215
225
  _query_builder << '/v2/team-members/{team_member_id}'
216
226
  _query_builder = APIHelper.append_url_with_template_parameters(
217
227
  _query_builder,
218
- 'team_member_id' => team_member_id
228
+ 'team_member_id' => { 'value' => team_member_id, 'encode' => true }
219
229
  )
220
230
  _query_url = APIHelper.clean_url _query_builder
221
231
 
222
232
  # Prepare headers.
223
233
  _headers = {
224
234
  'accept' => 'application/json',
225
- 'content-type' => 'application/json; charset=utf-8'
235
+ 'Content-Type' => 'application/json'
226
236
  }
227
237
 
228
238
  # Prepare and execute HttpRequest.
@@ -237,16 +247,18 @@ module Square
237
247
  # Return appropriate response type.
238
248
  decoded = APIHelper.json_deserialize(_response.raw_body)
239
249
  _errors = APIHelper.map_response(decoded, ['errors'])
240
- ApiResponse.new(_response, data: decoded, errors: _errors)
250
+ ApiResponse.new(
251
+ _response, data: decoded, errors: _errors
252
+ )
241
253
  end
242
254
 
243
- # Retrieve a `WageSetting` object for a team member specified
255
+ # Retrieves a `WageSetting` object for a team member specified
244
256
  # by `TeamMember.id`.
245
- # Learn about [Troubleshooting the Teams
246
- # API](https://developer.squareup.com/docs/docs/team/troubleshooting#retriev
247
- # ewagesetting).
257
+ # Learn about [Troubleshooting the Team
258
+ # API](https://developer.squareup.com/docs/team/troubleshooting#retrievewage
259
+ # setting).
248
260
  # @param [String] team_member_id Required parameter: The ID of the team
249
- # member to retrieve wage setting for
261
+ # member for which to retrieve the wage setting.
250
262
  # @return [RetrieveWageSettingResponse Hash] response from the API call
251
263
  def retrieve_wage_setting(team_member_id:)
252
264
  # Prepare query url.
@@ -254,7 +266,7 @@ module Square
254
266
  _query_builder << '/v2/team-members/{team_member_id}/wage-setting'
255
267
  _query_builder = APIHelper.append_url_with_template_parameters(
256
268
  _query_builder,
257
- 'team_member_id' => team_member_id
269
+ 'team_member_id' => { 'value' => team_member_id, 'encode' => true }
258
270
  )
259
271
  _query_url = APIHelper.clean_url _query_builder
260
272
 
@@ -274,19 +286,21 @@ module Square
274
286
  # Return appropriate response type.
275
287
  decoded = APIHelper.json_deserialize(_response.raw_body)
276
288
  _errors = APIHelper.map_response(decoded, ['errors'])
277
- ApiResponse.new(_response, data: decoded, errors: _errors)
289
+ ApiResponse.new(
290
+ _response, data: decoded, errors: _errors
291
+ )
278
292
  end
279
293
 
280
294
  # Creates or updates a `WageSetting` object. The object is created if a
281
295
  # `WageSetting` with the specified `team_member_id` does not exist.
282
296
  # Otherwise,
283
297
  # it fully replaces the `WageSetting` object for the team member.
284
- # The `WageSetting` will be returned upon successful update.
285
- # Learn about [Troubleshooting the Teams
286
- # API](https://developer.squareup.com/docs/docs/team/troubleshooting#updatew
287
- # agesetting).
298
+ # The `WageSetting` is returned on a successful update.
299
+ # Learn about [Troubleshooting the Team
300
+ # API](https://developer.squareup.com/docs/team/troubleshooting#create-or-up
301
+ # date-a-wage-setting).
288
302
  # @param [String] team_member_id Required parameter: The ID of the team
289
- # member to update the `WageSetting` object for.
303
+ # member for which to update the `WageSetting` object.
290
304
  # @param [UpdateWageSettingRequest] body Required parameter: An object
291
305
  # containing the fields to POST for the request. See the corresponding
292
306
  # object definition for field details.
@@ -298,14 +312,14 @@ module Square
298
312
  _query_builder << '/v2/team-members/{team_member_id}/wage-setting'
299
313
  _query_builder = APIHelper.append_url_with_template_parameters(
300
314
  _query_builder,
301
- 'team_member_id' => team_member_id
315
+ 'team_member_id' => { 'value' => team_member_id, 'encode' => true }
302
316
  )
303
317
  _query_url = APIHelper.clean_url _query_builder
304
318
 
305
319
  # Prepare headers.
306
320
  _headers = {
307
321
  'accept' => 'application/json',
308
- 'content-type' => 'application/json; charset=utf-8'
322
+ 'Content-Type' => 'application/json'
309
323
  }
310
324
 
311
325
  # Prepare and execute HttpRequest.
@@ -320,7 +334,9 @@ module Square
320
334
  # Return appropriate response type.
321
335
  decoded = APIHelper.json_deserialize(_response.raw_body)
322
336
  _errors = APIHelper.map_response(decoded, ['errors'])
323
- ApiResponse.new(_response, data: decoded, errors: _errors)
337
+ ApiResponse.new(
338
+ _response, data: decoded, errors: _errors
339
+ )
324
340
  end
325
341
  end
326
342
  end
@@ -5,8 +5,9 @@ module Square
5
5
  super(config, http_call_back: http_call_back)
6
6
  end
7
7
 
8
- # Creates a new Terminal checkout request and sends it to the specified
9
- # device to take a payment for the requested amount.
8
+ # Creates a Terminal checkout request and sends it to the specified device
9
+ # to take a payment
10
+ # for the requested amount.
10
11
  # @param [CreateTerminalCheckoutRequest] body Required parameter: An object
11
12
  # containing the fields to POST for the request. See the corresponding
12
13
  # object definition for field details.
@@ -20,7 +21,7 @@ module Square
20
21
  # Prepare headers.
21
22
  _headers = {
22
23
  'accept' => 'application/json',
23
- 'content-type' => 'application/json; charset=utf-8'
24
+ 'Content-Type' => 'application/json'
24
25
  }
25
26
 
26
27
  # Prepare and execute HttpRequest.
@@ -35,7 +36,9 @@ module Square
35
36
  # Return appropriate response type.
36
37
  decoded = APIHelper.json_deserialize(_response.raw_body)
37
38
  _errors = APIHelper.map_response(decoded, ['errors'])
38
- ApiResponse.new(_response, data: decoded, errors: _errors)
39
+ ApiResponse.new(
40
+ _response, data: decoded, errors: _errors
41
+ )
39
42
  end
40
43
 
41
44
  # Retrieves a filtered list of Terminal checkout requests created by the
@@ -53,7 +56,7 @@ module Square
53
56
  # Prepare headers.
54
57
  _headers = {
55
58
  'accept' => 'application/json',
56
- 'content-type' => 'application/json; charset=utf-8'
59
+ 'Content-Type' => 'application/json'
57
60
  }
58
61
 
59
62
  # Prepare and execute HttpRequest.
@@ -68,12 +71,14 @@ module Square
68
71
  # Return appropriate response type.
69
72
  decoded = APIHelper.json_deserialize(_response.raw_body)
70
73
  _errors = APIHelper.map_response(decoded, ['errors'])
71
- ApiResponse.new(_response, data: decoded, errors: _errors)
74
+ ApiResponse.new(
75
+ _response, data: decoded, errors: _errors
76
+ )
72
77
  end
73
78
 
74
- # Retrieves a Terminal checkout request by checkout_id.
75
- # @param [String] checkout_id Required parameter: Unique ID for the desired
76
- # `TerminalCheckout`
79
+ # Retrieves a Terminal checkout request by `checkout_id`.
80
+ # @param [String] checkout_id Required parameter: The unique ID for the
81
+ # desired `TerminalCheckout`.
77
82
  # @return [GetTerminalCheckoutResponse Hash] response from the API call
78
83
  def get_terminal_checkout(checkout_id:)
79
84
  # Prepare query url.
@@ -81,7 +86,7 @@ module Square
81
86
  _query_builder << '/v2/terminals/checkouts/{checkout_id}'
82
87
  _query_builder = APIHelper.append_url_with_template_parameters(
83
88
  _query_builder,
84
- 'checkout_id' => checkout_id
89
+ 'checkout_id' => { 'value' => checkout_id, 'encode' => true }
85
90
  )
86
91
  _query_url = APIHelper.clean_url _query_builder
87
92
 
@@ -101,13 +106,15 @@ module Square
101
106
  # Return appropriate response type.
102
107
  decoded = APIHelper.json_deserialize(_response.raw_body)
103
108
  _errors = APIHelper.map_response(decoded, ['errors'])
104
- ApiResponse.new(_response, data: decoded, errors: _errors)
109
+ ApiResponse.new(
110
+ _response, data: decoded, errors: _errors
111
+ )
105
112
  end
106
113
 
107
- # Cancels a Terminal checkout request, if the status of the request permits
114
+ # Cancels a Terminal checkout request if the status of the request permits
108
115
  # it.
109
- # @param [String] checkout_id Required parameter: Unique ID for the desired
110
- # `TerminalCheckout`
116
+ # @param [String] checkout_id Required parameter: The unique ID for the
117
+ # desired `TerminalCheckout`.
111
118
  # @return [CancelTerminalCheckoutResponse Hash] response from the API call
112
119
  def cancel_terminal_checkout(checkout_id:)
113
120
  # Prepare query url.
@@ -115,7 +122,148 @@ module Square
115
122
  _query_builder << '/v2/terminals/checkouts/{checkout_id}/cancel'
116
123
  _query_builder = APIHelper.append_url_with_template_parameters(
117
124
  _query_builder,
118
- 'checkout_id' => checkout_id
125
+ 'checkout_id' => { 'value' => checkout_id, 'encode' => true }
126
+ )
127
+ _query_url = APIHelper.clean_url _query_builder
128
+
129
+ # Prepare headers.
130
+ _headers = {
131
+ 'accept' => 'application/json'
132
+ }
133
+
134
+ # Prepare and execute HttpRequest.
135
+ _request = config.http_client.post(
136
+ _query_url,
137
+ headers: _headers
138
+ )
139
+ OAuth2.apply(config, _request)
140
+ _response = execute_request(_request)
141
+
142
+ # Return appropriate response type.
143
+ decoded = APIHelper.json_deserialize(_response.raw_body)
144
+ _errors = APIHelper.map_response(decoded, ['errors'])
145
+ ApiResponse.new(
146
+ _response, data: decoded, errors: _errors
147
+ )
148
+ end
149
+
150
+ # Creates a request to refund an Interac payment completed on a Square
151
+ # Terminal.
152
+ # @param [CreateTerminalRefundRequest] body Required parameter: An object
153
+ # containing the fields to POST for the request. See the corresponding
154
+ # object definition for field details.
155
+ # @return [CreateTerminalRefundResponse Hash] response from the API call
156
+ def create_terminal_refund(body:)
157
+ # Prepare query url.
158
+ _query_builder = config.get_base_uri
159
+ _query_builder << '/v2/terminals/refunds'
160
+ _query_url = APIHelper.clean_url _query_builder
161
+
162
+ # Prepare headers.
163
+ _headers = {
164
+ 'accept' => 'application/json',
165
+ 'Content-Type' => 'application/json'
166
+ }
167
+
168
+ # Prepare and execute HttpRequest.
169
+ _request = config.http_client.post(
170
+ _query_url,
171
+ headers: _headers,
172
+ parameters: body.to_json
173
+ )
174
+ OAuth2.apply(config, _request)
175
+ _response = execute_request(_request)
176
+
177
+ # Return appropriate response type.
178
+ decoded = APIHelper.json_deserialize(_response.raw_body)
179
+ _errors = APIHelper.map_response(decoded, ['errors'])
180
+ ApiResponse.new(
181
+ _response, data: decoded, errors: _errors
182
+ )
183
+ end
184
+
185
+ # Retrieves a filtered list of Interac Terminal refund requests created by
186
+ # the seller making the request.
187
+ # @param [SearchTerminalRefundsRequest] body Required parameter: An object
188
+ # containing the fields to POST for the request. See the corresponding
189
+ # object definition for field details.
190
+ # @return [SearchTerminalRefundsResponse Hash] response from the API call
191
+ def search_terminal_refunds(body:)
192
+ # Prepare query url.
193
+ _query_builder = config.get_base_uri
194
+ _query_builder << '/v2/terminals/refunds/search'
195
+ _query_url = APIHelper.clean_url _query_builder
196
+
197
+ # Prepare headers.
198
+ _headers = {
199
+ 'accept' => 'application/json',
200
+ 'Content-Type' => 'application/json'
201
+ }
202
+
203
+ # Prepare and execute HttpRequest.
204
+ _request = config.http_client.post(
205
+ _query_url,
206
+ headers: _headers,
207
+ parameters: body.to_json
208
+ )
209
+ OAuth2.apply(config, _request)
210
+ _response = execute_request(_request)
211
+
212
+ # Return appropriate response type.
213
+ decoded = APIHelper.json_deserialize(_response.raw_body)
214
+ _errors = APIHelper.map_response(decoded, ['errors'])
215
+ ApiResponse.new(
216
+ _response, data: decoded, errors: _errors
217
+ )
218
+ end
219
+
220
+ # Retrieves an Interac Terminal refund object by ID.
221
+ # @param [String] terminal_refund_id Required parameter: The unique ID for
222
+ # the desired `TerminalRefund`.
223
+ # @return [GetTerminalRefundResponse Hash] response from the API call
224
+ def get_terminal_refund(terminal_refund_id:)
225
+ # Prepare query url.
226
+ _query_builder = config.get_base_uri
227
+ _query_builder << '/v2/terminals/refunds/{terminal_refund_id}'
228
+ _query_builder = APIHelper.append_url_with_template_parameters(
229
+ _query_builder,
230
+ 'terminal_refund_id' => { 'value' => terminal_refund_id, 'encode' => true }
231
+ )
232
+ _query_url = APIHelper.clean_url _query_builder
233
+
234
+ # Prepare headers.
235
+ _headers = {
236
+ 'accept' => 'application/json'
237
+ }
238
+
239
+ # Prepare and execute HttpRequest.
240
+ _request = config.http_client.get(
241
+ _query_url,
242
+ headers: _headers
243
+ )
244
+ OAuth2.apply(config, _request)
245
+ _response = execute_request(_request)
246
+
247
+ # Return appropriate response type.
248
+ decoded = APIHelper.json_deserialize(_response.raw_body)
249
+ _errors = APIHelper.map_response(decoded, ['errors'])
250
+ ApiResponse.new(
251
+ _response, data: decoded, errors: _errors
252
+ )
253
+ end
254
+
255
+ # Cancels an Interac Terminal refund request by refund request ID if the
256
+ # status of the request permits it.
257
+ # @param [String] terminal_refund_id Required parameter: The unique ID for
258
+ # the desired `TerminalRefund`.
259
+ # @return [CancelTerminalRefundResponse Hash] response from the API call
260
+ def cancel_terminal_refund(terminal_refund_id:)
261
+ # Prepare query url.
262
+ _query_builder = config.get_base_uri
263
+ _query_builder << '/v2/terminals/refunds/{terminal_refund_id}/cancel'
264
+ _query_builder = APIHelper.append_url_with_template_parameters(
265
+ _query_builder,
266
+ 'terminal_refund_id' => { 'value' => terminal_refund_id, 'encode' => true }
119
267
  )
120
268
  _query_url = APIHelper.clean_url _query_builder
121
269
 
@@ -135,7 +283,9 @@ module Square
135
283
  # Return appropriate response type.
136
284
  decoded = APIHelper.json_deserialize(_response.raw_body)
137
285
  _errors = APIHelper.map_response(decoded, ['errors'])
138
- ApiResponse.new(_response, data: decoded, errors: _errors)
286
+ ApiResponse.new(
287
+ _response, data: decoded, errors: _errors
288
+ )
139
289
  end
140
290
  end
141
291
  end