square.rb 6.4.0.20200923 → 9.0.0.20210226

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/README.md +43 -31
  4. data/lib/square.rb +60 -61
  5. data/lib/square/api/apple_pay_api.rb +5 -3
  6. data/lib/square/api/bank_accounts_api.rb +16 -19
  7. data/lib/square/api/base_api.rb +1 -1
  8. data/lib/square/api/bookings_api.rb +308 -0
  9. data/lib/square/api/cash_drawers_api.rb +13 -6
  10. data/lib/square/api/catalog_api.rb +71 -35
  11. data/lib/square/api/checkout_api.rb +4 -2
  12. data/lib/square/api/customer_groups_api.rb +18 -8
  13. data/lib/square/api/customer_segments_api.rb +9 -5
  14. data/lib/square/api/customers_api.rb +47 -27
  15. data/lib/square/api/devices_api.rb +17 -6
  16. data/lib/square/api/disputes_api.rb +70 -54
  17. data/lib/square/api/employees_api.rb +7 -3
  18. data/lib/square/api/inventory_api.rb +27 -13
  19. data/lib/square/api/invoices_api.rb +44 -25
  20. data/lib/square/api/labor_api.rb +57 -25
  21. data/lib/square/api/locations_api.rb +16 -13
  22. data/lib/square/api/loyalty_api.rb +60 -66
  23. data/lib/square/api/merchants_api.rb +7 -3
  24. data/lib/square/api/mobile_authorization_api.rb +5 -3
  25. data/lib/square/api/o_auth_api.rb +11 -8
  26. data/lib/square/api/orders_api.rb +55 -8
  27. data/lib/square/api/payments_api.rb +68 -55
  28. data/lib/square/api/refunds_api.rb +32 -26
  29. data/lib/square/api/subscriptions_api.rb +26 -14
  30. data/lib/square/api/team_api.rb +46 -30
  31. data/lib/square/api/terminal_api.rb +156 -7
  32. data/lib/square/api/transactions_api.rb +32 -18
  33. data/lib/square/api/v1_employees_api.rb +27 -389
  34. data/lib/square/api/v1_transactions_api.rb +42 -101
  35. data/lib/square/api_helper.rb +14 -9
  36. data/lib/square/client.rb +10 -14
  37. data/lib/square/configuration.rb +21 -6
  38. data/lib/square/http/api_response.rb +2 -0
  39. data/lib/square/http/faraday_client.rb +9 -2
  40. data/spec/user_journey_spec.rb +2 -5
  41. data/test/api/test_locations_api.rb +1 -1
  42. metadata +5 -6
  43. data/lib/square/api/v1_items_api.rb +0 -1686
  44. data/lib/square/api/v1_locations_api.rb +0 -65
@@ -40,7 +40,9 @@ module Square
40
40
  # Return appropriate response type.
41
41
  decoded = APIHelper.json_deserialize(_response.raw_body)
42
42
  _errors = APIHelper.map_response(decoded, ['errors'])
43
- ApiResponse.new(_response, data: decoded, errors: _errors)
43
+ ApiResponse.new(
44
+ _response, data: decoded, errors: _errors
45
+ )
44
46
  end
45
47
 
46
48
  # Searches for subscriptions.
@@ -58,8 +60,8 @@ module Square
58
60
  # customer by subscription creation date.
59
61
  # For more information, see
60
62
  # [Retrieve
61
- # subscriptions](https://developer.squareup.com/docs/docs/subscriptions-api/
62
- # overview#retrieve-subscriptions).
63
+ # subscriptions](https://developer.squareup.com/docs/subscriptions-api/overv
64
+ # iew#retrieve-subscriptions).
63
65
  # @param [SearchSubscriptionsRequest] body Required parameter: An object
64
66
  # containing the fields to POST for the request. See the corresponding
65
67
  # object definition for field details.
@@ -88,7 +90,9 @@ module Square
88
90
  # Return appropriate response type.
89
91
  decoded = APIHelper.json_deserialize(_response.raw_body)
90
92
  _errors = APIHelper.map_response(decoded, ['errors'])
91
- ApiResponse.new(_response, data: decoded, errors: _errors)
93
+ ApiResponse.new(
94
+ _response, data: decoded, errors: _errors
95
+ )
92
96
  end
93
97
 
94
98
  # Retrieves a subscription.
@@ -101,7 +105,7 @@ module Square
101
105
  _query_builder << '/v2/subscriptions/{subscription_id}'
102
106
  _query_builder = APIHelper.append_url_with_template_parameters(
103
107
  _query_builder,
104
- 'subscription_id' => subscription_id
108
+ 'subscription_id' => { 'value' => subscription_id, 'encode' => true }
105
109
  )
106
110
  _query_url = APIHelper.clean_url _query_builder
107
111
 
@@ -121,7 +125,9 @@ module Square
121
125
  # Return appropriate response type.
122
126
  decoded = APIHelper.json_deserialize(_response.raw_body)
123
127
  _errors = APIHelper.map_response(decoded, ['errors'])
124
- ApiResponse.new(_response, data: decoded, errors: _errors)
128
+ ApiResponse.new(
129
+ _response, data: decoded, errors: _errors
130
+ )
125
131
  end
126
132
 
127
133
  # Updates a subscription. You can set, modify, and clear the
@@ -139,7 +145,7 @@ module Square
139
145
  _query_builder << '/v2/subscriptions/{subscription_id}'
140
146
  _query_builder = APIHelper.append_url_with_template_parameters(
141
147
  _query_builder,
142
- 'subscription_id' => subscription_id
148
+ 'subscription_id' => { 'value' => subscription_id, 'encode' => true }
143
149
  )
144
150
  _query_url = APIHelper.clean_url _query_builder
145
151
 
@@ -161,7 +167,9 @@ module Square
161
167
  # Return appropriate response type.
162
168
  decoded = APIHelper.json_deserialize(_response.raw_body)
163
169
  _errors = APIHelper.map_response(decoded, ['errors'])
164
- ApiResponse.new(_response, data: decoded, errors: _errors)
170
+ ApiResponse.new(
171
+ _response, data: decoded, errors: _errors
172
+ )
165
173
  end
166
174
 
167
175
  # Sets the `canceled_date` field to the end of the active billing period.
@@ -175,7 +183,7 @@ module Square
175
183
  _query_builder << '/v2/subscriptions/{subscription_id}/cancel'
176
184
  _query_builder = APIHelper.append_url_with_template_parameters(
177
185
  _query_builder,
178
- 'subscription_id' => subscription_id
186
+ 'subscription_id' => { 'value' => subscription_id, 'encode' => true }
179
187
  )
180
188
  _query_url = APIHelper.clean_url _query_builder
181
189
 
@@ -195,7 +203,9 @@ module Square
195
203
  # Return appropriate response type.
196
204
  decoded = APIHelper.json_deserialize(_response.raw_body)
197
205
  _errors = APIHelper.map_response(decoded, ['errors'])
198
- ApiResponse.new(_response, data: decoded, errors: _errors)
206
+ ApiResponse.new(
207
+ _response, data: decoded, errors: _errors
208
+ )
199
209
  end
200
210
 
201
211
  # Lists all events for a specific subscription.
@@ -207,8 +217,8 @@ module Square
207
217
  # @param [String] cursor Optional parameter: A pagination cursor returned by
208
218
  # a previous call to this endpoint. Provide this to retrieve the next set of
209
219
  # results for the original query. For more information, see
210
- # [Pagination](https://developer.squareup.com/docs/docs/working-with-apis/pa
211
- # gination).
220
+ # [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
221
+ # ion).
212
222
  # @param [Integer] limit Optional parameter: The upper limit on the number
213
223
  # of subscription events to return in the response. Default: `200`
214
224
  # @return [ListSubscriptionEventsResponse Hash] response from the API call
@@ -220,7 +230,7 @@ module Square
220
230
  _query_builder << '/v2/subscriptions/{subscription_id}/events'
221
231
  _query_builder = APIHelper.append_url_with_template_parameters(
222
232
  _query_builder,
223
- 'subscription_id' => subscription_id
233
+ 'subscription_id' => { 'value' => subscription_id, 'encode' => true }
224
234
  )
225
235
  _query_builder = APIHelper.append_url_with_query_parameters(
226
236
  _query_builder,
@@ -245,7 +255,9 @@ module Square
245
255
  # Return appropriate response type.
246
256
  decoded = APIHelper.json_deserialize(_response.raw_body)
247
257
  _errors = APIHelper.map_response(decoded, ['errors'])
248
- ApiResponse.new(_response, data: decoded, errors: _errors)
258
+ ApiResponse.new(
259
+ _response, data: decoded, errors: _errors
260
+ )
249
261
  end
250
262
  end
251
263
  end
@@ -8,11 +8,11 @@ module Square
8
8
  # Creates a single `TeamMember` object. The `TeamMember` will be returned on
9
9
  # successful creates.
10
10
  # You must provide the following values in your request to this endpoint:
11
- # - `first_name`
12
- # - `last_name`
11
+ # - `given_name`
12
+ # - `family_name`
13
13
  # Learn about [Troubleshooting the Teams
14
- # API](https://developer.squareup.com/docs/docs/team/troubleshooting#createt
15
- # eammember).
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.
@@ -41,7 +41,9 @@ 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
@@ -52,8 +54,8 @@ module Square
52
54
  # marked as failed, but the body of the response
53
55
  # will contain explicit error information for this particular create.
54
56
  # Learn about [Troubleshooting the Teams
55
- # API](https://developer.squareup.com/docs/docs/team/troubleshooting#bulkcre
56
- # ateteammembers).
57
+ # API](https://developer.squareup.com/docs/team/troubleshooting#bulkcreatete
58
+ # ammembers).
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.
@@ -82,7 +84,9 @@ 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
@@ -93,8 +97,8 @@ module Square
93
97
  # marked as failed, but the body of the response
94
98
  # will contain explicit error information for this particular update.
95
99
  # Learn about [Troubleshooting the Teams
96
- # API](https://developer.squareup.com/docs/docs/team/troubleshooting#bulkupd
97
- # ateteammembers).
100
+ # API](https://developer.squareup.com/docs/team/troubleshooting#bulkupdatete
101
+ # ammembers).
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.
@@ -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
136
  # The list to be returned can be filtered by:
131
137
  # - location IDs **and**
132
- # - `is_active`
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.
@@ -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`
172
+ # Retrieve a `TeamMember` object for the given `TeamMember.id`.
165
173
  # Learn about [Troubleshooting the Teams
166
- # API](https://developer.squareup.com/docs/docs/team/troubleshooting#retriev
167
- # eteammember).
174
+ # API](https://developer.squareup.com/docs/team/troubleshooting#retrieveteam
175
+ # 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
210
  # Updates a single `TeamMember` object. The `TeamMember` will be returned on
201
211
  # successful updates.
202
212
  # Learn about [Troubleshooting the Teams
203
- # API](https://developer.squareup.com/docs/docs/team/troubleshooting#updatet
204
- # eammember).
213
+ # API](https://developer.squareup.com/docs/team/troubleshooting#updateteamme
214
+ # mber).
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,7 +225,7 @@ 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
 
@@ -237,14 +247,16 @@ 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
255
  # Retrieve a `WageSetting` object for a team member specified
244
256
  # by `TeamMember.id`.
245
257
  # Learn about [Troubleshooting the Teams
246
- # API](https://developer.squareup.com/docs/docs/team/troubleshooting#retriev
247
- # ewagesetting).
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
261
  # member to retrieve wage setting for
250
262
  # @return [RetrieveWageSettingResponse Hash] response from the API call
@@ -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,7 +286,9 @@ 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
@@ -283,8 +297,8 @@ module Square
283
297
  # it fully replaces the `WageSetting` object for the team member.
284
298
  # The `WageSetting` will be returned upon successful update.
285
299
  # Learn about [Troubleshooting the Teams
286
- # API](https://developer.squareup.com/docs/docs/team/troubleshooting#updatew
287
- # agesetting).
300
+ # API](https://developer.squareup.com/docs/team/troubleshooting#updatewagese
301
+ # tting).
288
302
  # @param [String] team_member_id Required parameter: The ID of the team
289
303
  # member to update the `WageSetting` object for.
290
304
  # @param [UpdateWageSettingRequest] body Required parameter: An object
@@ -298,7 +312,7 @@ 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
 
@@ -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
@@ -35,7 +35,9 @@ module Square
35
35
  # Return appropriate response type.
36
36
  decoded = APIHelper.json_deserialize(_response.raw_body)
37
37
  _errors = APIHelper.map_response(decoded, ['errors'])
38
- ApiResponse.new(_response, data: decoded, errors: _errors)
38
+ ApiResponse.new(
39
+ _response, data: decoded, errors: _errors
40
+ )
39
41
  end
40
42
 
41
43
  # Retrieves a filtered list of Terminal checkout requests created by the
@@ -68,7 +70,9 @@ module Square
68
70
  # Return appropriate response type.
69
71
  decoded = APIHelper.json_deserialize(_response.raw_body)
70
72
  _errors = APIHelper.map_response(decoded, ['errors'])
71
- ApiResponse.new(_response, data: decoded, errors: _errors)
73
+ ApiResponse.new(
74
+ _response, data: decoded, errors: _errors
75
+ )
72
76
  end
73
77
 
74
78
  # Retrieves a Terminal checkout request by checkout_id.
@@ -81,7 +85,7 @@ module Square
81
85
  _query_builder << '/v2/terminals/checkouts/{checkout_id}'
82
86
  _query_builder = APIHelper.append_url_with_template_parameters(
83
87
  _query_builder,
84
- 'checkout_id' => checkout_id
88
+ 'checkout_id' => { 'value' => checkout_id, 'encode' => true }
85
89
  )
86
90
  _query_url = APIHelper.clean_url _query_builder
87
91
 
@@ -101,10 +105,12 @@ module Square
101
105
  # Return appropriate response type.
102
106
  decoded = APIHelper.json_deserialize(_response.raw_body)
103
107
  _errors = APIHelper.map_response(decoded, ['errors'])
104
- ApiResponse.new(_response, data: decoded, errors: _errors)
108
+ ApiResponse.new(
109
+ _response, data: decoded, errors: _errors
110
+ )
105
111
  end
106
112
 
107
- # Cancels a Terminal checkout request, if the status of the request permits
113
+ # Cancels a Terminal checkout request if the status of the request permits
108
114
  # it.
109
115
  # @param [String] checkout_id Required parameter: Unique ID for the desired
110
116
  # `TerminalCheckout`
@@ -115,7 +121,148 @@ module Square
115
121
  _query_builder << '/v2/terminals/checkouts/{checkout_id}/cancel'
116
122
  _query_builder = APIHelper.append_url_with_template_parameters(
117
123
  _query_builder,
118
- 'checkout_id' => checkout_id
124
+ 'checkout_id' => { 'value' => checkout_id, 'encode' => true }
125
+ )
126
+ _query_url = APIHelper.clean_url _query_builder
127
+
128
+ # Prepare headers.
129
+ _headers = {
130
+ 'accept' => 'application/json'
131
+ }
132
+
133
+ # Prepare and execute HttpRequest.
134
+ _request = config.http_client.post(
135
+ _query_url,
136
+ headers: _headers
137
+ )
138
+ OAuth2.apply(config, _request)
139
+ _response = execute_request(_request)
140
+
141
+ # Return appropriate response type.
142
+ decoded = APIHelper.json_deserialize(_response.raw_body)
143
+ _errors = APIHelper.map_response(decoded, ['errors'])
144
+ ApiResponse.new(
145
+ _response, data: decoded, errors: _errors
146
+ )
147
+ end
148
+
149
+ # Creates a request to refund an Interac payment completed on a Square
150
+ # Terminal.
151
+ # @param [CreateTerminalRefundRequest] body Required parameter: An object
152
+ # containing the fields to POST for the request. See the corresponding
153
+ # object definition for field details.
154
+ # @return [CreateTerminalRefundResponse Hash] response from the API call
155
+ def create_terminal_refund(body:)
156
+ # Prepare query url.
157
+ _query_builder = config.get_base_uri
158
+ _query_builder << '/v2/terminals/refunds'
159
+ _query_url = APIHelper.clean_url _query_builder
160
+
161
+ # Prepare headers.
162
+ _headers = {
163
+ 'accept' => 'application/json',
164
+ 'content-type' => 'application/json; charset=utf-8'
165
+ }
166
+
167
+ # Prepare and execute HttpRequest.
168
+ _request = config.http_client.post(
169
+ _query_url,
170
+ headers: _headers,
171
+ parameters: body.to_json
172
+ )
173
+ OAuth2.apply(config, _request)
174
+ _response = execute_request(_request)
175
+
176
+ # Return appropriate response type.
177
+ decoded = APIHelper.json_deserialize(_response.raw_body)
178
+ _errors = APIHelper.map_response(decoded, ['errors'])
179
+ ApiResponse.new(
180
+ _response, data: decoded, errors: _errors
181
+ )
182
+ end
183
+
184
+ # Retrieves a filtered list of Terminal Interac refund requests created by
185
+ # the seller making the request.
186
+ # @param [SearchTerminalRefundsRequest] body Required parameter: An object
187
+ # containing the fields to POST for the request. See the corresponding
188
+ # object definition for field details.
189
+ # @return [SearchTerminalRefundsResponse Hash] response from the API call
190
+ def search_terminal_refunds(body:)
191
+ # Prepare query url.
192
+ _query_builder = config.get_base_uri
193
+ _query_builder << '/v2/terminals/refunds/search'
194
+ _query_url = APIHelper.clean_url _query_builder
195
+
196
+ # Prepare headers.
197
+ _headers = {
198
+ 'accept' => 'application/json',
199
+ 'content-type' => 'application/json; charset=utf-8'
200
+ }
201
+
202
+ # Prepare and execute HttpRequest.
203
+ _request = config.http_client.post(
204
+ _query_url,
205
+ headers: _headers,
206
+ parameters: body.to_json
207
+ )
208
+ OAuth2.apply(config, _request)
209
+ _response = execute_request(_request)
210
+
211
+ # Return appropriate response type.
212
+ decoded = APIHelper.json_deserialize(_response.raw_body)
213
+ _errors = APIHelper.map_response(decoded, ['errors'])
214
+ ApiResponse.new(
215
+ _response, data: decoded, errors: _errors
216
+ )
217
+ end
218
+
219
+ # Retrieves an Interac terminal refund object by ID.
220
+ # @param [String] terminal_refund_id Required parameter: Unique ID for the
221
+ # desired `TerminalRefund`
222
+ # @return [GetTerminalRefundResponse Hash] response from the API call
223
+ def get_terminal_refund(terminal_refund_id:)
224
+ # Prepare query url.
225
+ _query_builder = config.get_base_uri
226
+ _query_builder << '/v2/terminals/refunds/{terminal_refund_id}'
227
+ _query_builder = APIHelper.append_url_with_template_parameters(
228
+ _query_builder,
229
+ 'terminal_refund_id' => { 'value' => terminal_refund_id, 'encode' => true }
230
+ )
231
+ _query_url = APIHelper.clean_url _query_builder
232
+
233
+ # Prepare headers.
234
+ _headers = {
235
+ 'accept' => 'application/json'
236
+ }
237
+
238
+ # Prepare and execute HttpRequest.
239
+ _request = config.http_client.get(
240
+ _query_url,
241
+ headers: _headers
242
+ )
243
+ OAuth2.apply(config, _request)
244
+ _response = execute_request(_request)
245
+
246
+ # Return appropriate response type.
247
+ decoded = APIHelper.json_deserialize(_response.raw_body)
248
+ _errors = APIHelper.map_response(decoded, ['errors'])
249
+ ApiResponse.new(
250
+ _response, data: decoded, errors: _errors
251
+ )
252
+ end
253
+
254
+ # Cancels an Interac terminal refund request by refund request ID if the
255
+ # status of the request permits it.
256
+ # @param [String] terminal_refund_id Required parameter: Unique ID for the
257
+ # desired `TerminalRefund`
258
+ # @return [CancelTerminalRefundResponse Hash] response from the API call
259
+ def cancel_terminal_refund(terminal_refund_id:)
260
+ # Prepare query url.
261
+ _query_builder = config.get_base_uri
262
+ _query_builder << '/v2/terminals/refunds/{terminal_refund_id}/cancel'
263
+ _query_builder = APIHelper.append_url_with_template_parameters(
264
+ _query_builder,
265
+ 'terminal_refund_id' => { 'value' => terminal_refund_id, 'encode' => true }
119
266
  )
120
267
  _query_url = APIHelper.clean_url _query_builder
121
268
 
@@ -135,7 +282,9 @@ module Square
135
282
  # Return appropriate response type.
136
283
  decoded = APIHelper.json_deserialize(_response.raw_body)
137
284
  _errors = APIHelper.map_response(decoded, ['errors'])
138
- ApiResponse.new(_response, data: decoded, errors: _errors)
285
+ ApiResponse.new(
286
+ _response, data: decoded, errors: _errors
287
+ )
139
288
  end
140
289
  end
141
290
  end