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.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +86 -51
- data/lib/square/api/apple_pay_api.rb +12 -9
- data/lib/square/api/bank_accounts_api.rb +21 -24
- data/lib/square/api/base_api.rb +20 -9
- data/lib/square/api/bookings_api.rb +391 -0
- data/lib/square/api/cards_api.rb +170 -0
- data/lib/square/api/cash_drawers_api.rb +13 -6
- data/lib/square/api/catalog_api.rb +195 -85
- data/lib/square/api/checkout_api.rb +7 -5
- data/lib/square/api/customer_groups_api.rb +34 -16
- data/lib/square/api/customer_segments_api.rb +21 -9
- data/lib/square/api/customers_api.rb +102 -55
- data/lib/square/api/devices_api.rb +20 -8
- data/lib/square/api/disputes_api.rb +156 -144
- data/lib/square/api/employees_api.rb +7 -3
- data/lib/square/api/gift_card_activities_api.rb +133 -0
- data/lib/square/api/gift_cards_api.rb +297 -0
- data/lib/square/api/inventory_api.rb +290 -37
- data/lib/square/api/invoices_api.rb +61 -57
- data/lib/square/api/labor_api.rb +127 -93
- data/lib/square/api/locations_api.rb +36 -25
- data/lib/square/api/loyalty_api.rb +134 -87
- data/lib/square/api/merchants_api.rb +8 -4
- data/lib/square/api/mobile_authorization_api.rb +9 -7
- data/lib/square/api/o_auth_api.rb +41 -32
- data/lib/square/api/orders_api.rb +132 -54
- data/lib/square/api/payments_api.rb +133 -75
- data/lib/square/api/refunds_api.rb +51 -30
- data/lib/square/api/sites_api.rb +43 -0
- data/lib/square/api/snippets_api.rb +146 -0
- data/lib/square/api/subscriptions_api.rb +216 -26
- data/lib/square/api/team_api.rb +81 -65
- data/lib/square/api/terminal_api.rb +166 -16
- data/lib/square/api/transactions_api.rb +32 -194
- data/lib/square/api/v1_transactions_api.rb +53 -103
- data/lib/square/api_helper.rb +38 -43
- data/lib/square/client.rb +54 -24
- data/lib/square/configuration.rb +61 -21
- data/lib/square/http/api_response.rb +3 -1
- data/lib/square/http/faraday_client.rb +34 -5
- data/lib/square/utilities/date_time_helper.rb +151 -0
- data/lib/square/utilities/file_wrapper.rb +1 -2
- data/lib/square.rb +65 -61
- data/spec/user_journey_spec.rb +2 -5
- data/test/api/api_test_base.rb +1 -6
- data/test/api/test_catalog_api.rb +1 -4
- data/test/api/test_customers_api.rb +1 -4
- data/test/api/test_employees_api.rb +1 -4
- data/test/api/test_labor_api.rb +2 -6
- data/test/api/test_locations_api.rb +21 -35
- data/test/api/test_merchants_api.rb +1 -4
- data/test/api/test_payments_api.rb +3 -6
- data/test/api/test_refunds_api.rb +3 -6
- data/test/http_response_catcher.rb +0 -5
- data/test/test_helper.rb +1 -6
- metadata +40 -18
- data/lib/square/api/v1_employees_api.rb +0 -723
- data/lib/square/api/v1_items_api.rb +0 -1686
- data/lib/square/api/v1_locations_api.rb +0 -65
data/lib/square/api/team_api.rb
CHANGED
@@ -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`
|
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
|
-
# - `
|
12
|
-
# - `
|
13
|
-
# Learn about [Troubleshooting the
|
14
|
-
# API](https://developer.squareup.com/docs/
|
15
|
-
#
|
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
|
-
'
|
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(
|
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
|
-
#
|
49
|
-
# This process is non-transactional and
|
50
|
-
#
|
51
|
-
# the request cannot be successfully processed, the request
|
52
|
-
#
|
53
|
-
#
|
54
|
-
# Learn about [Troubleshooting the
|
55
|
-
# API](https://developer.squareup.com/docs/
|
56
|
-
#
|
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
|
-
'
|
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(
|
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
|
-
#
|
90
|
-
# This process is non-transactional and
|
91
|
-
#
|
92
|
-
# the request cannot be successfully processed, the request
|
93
|
-
#
|
94
|
-
#
|
95
|
-
# Learn about [Troubleshooting the
|
96
|
-
# API](https://developer.squareup.com/docs/
|
97
|
-
#
|
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
|
-
'
|
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(
|
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
|
131
|
-
# - location IDs
|
132
|
-
# - `
|
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
|
-
'
|
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(
|
167
|
+
ApiResponse.new(
|
168
|
+
_response, data: decoded, errors: _errors
|
169
|
+
)
|
162
170
|
end
|
163
171
|
|
164
|
-
#
|
165
|
-
# Learn about [Troubleshooting the
|
166
|
-
# API](https://developer.squareup.com/docs/
|
167
|
-
#
|
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(
|
205
|
+
ApiResponse.new(
|
206
|
+
_response, data: decoded, errors: _errors
|
207
|
+
)
|
198
208
|
end
|
199
209
|
|
200
|
-
# Updates a single `TeamMember` object. The `TeamMember`
|
201
|
-
# successful updates.
|
202
|
-
# Learn about [Troubleshooting the
|
203
|
-
# API](https://developer.squareup.com/docs/
|
204
|
-
#
|
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
|
-
'
|
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(
|
250
|
+
ApiResponse.new(
|
251
|
+
_response, data: decoded, errors: _errors
|
252
|
+
)
|
241
253
|
end
|
242
254
|
|
243
|
-
#
|
255
|
+
# Retrieves a `WageSetting` object for a team member specified
|
244
256
|
# by `TeamMember.id`.
|
245
|
-
# Learn about [Troubleshooting the
|
246
|
-
# API](https://developer.squareup.com/docs/
|
247
|
-
#
|
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
|
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(
|
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`
|
285
|
-
# Learn about [Troubleshooting the
|
286
|
-
# API](https://developer.squareup.com/docs/
|
287
|
-
#
|
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
|
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
|
-
'
|
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(
|
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
|
9
|
-
#
|
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
|
-
'
|
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(
|
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
|
-
'
|
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(
|
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:
|
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(
|
109
|
+
ApiResponse.new(
|
110
|
+
_response, data: decoded, errors: _errors
|
111
|
+
)
|
105
112
|
end
|
106
113
|
|
107
|
-
# Cancels a Terminal checkout request
|
114
|
+
# Cancels a Terminal checkout request if the status of the request permits
|
108
115
|
# it.
|
109
|
-
# @param [String] checkout_id Required parameter:
|
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(
|
286
|
+
ApiResponse.new(
|
287
|
+
_response, data: decoded, errors: _errors
|
288
|
+
)
|
139
289
|
end
|
140
290
|
end
|
141
291
|
end
|