square.rb 26.1.0.20230119 → 27.0.0.20230419
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/README.md +4 -0
- data/lib/square/api/apple_pay_api.rb +14 -30
- data/lib/square/api/bank_accounts_api.rb +40 -90
- data/lib/square/api/base_api.rb +42 -42
- data/lib/square/api/booking_custom_attributes_api.rb +171 -336
- data/lib/square/api/bookings_api.rb +140 -263
- data/lib/square/api/cards_api.rb +58 -120
- data/lib/square/api/cash_drawers_api.rb +47 -103
- data/lib/square/api/catalog_api.rb +200 -426
- data/lib/square/api/checkout_api.rb +86 -176
- data/lib/square/api/customer_custom_attributes_api.rb +157 -310
- data/lib/square/api/customer_groups_api.rb +69 -145
- data/lib/square/api/customer_segments_api.rb +26 -61
- data/lib/square/api/customers_api.rb +147 -294
- data/lib/square/api/devices_api.rb +42 -89
- data/lib/square/api/disputes_api.rb +132 -290
- data/lib/square/api/employees_api.rb +28 -63
- data/lib/square/api/gift_card_activities_api.rb +34 -66
- data/lib/square/api/gift_cards_api.rb +109 -207
- data/lib/square/api/inventory_api.rb +204 -391
- data/lib/square/api/invoices_api.rb +121 -240
- data/lib/square/api/labor_api.rb +223 -459
- data/lib/square/api/location_custom_attributes_api.rb +173 -338
- data/lib/square/api/locations_api.rb +54 -112
- data/lib/square/api/loyalty_api.rb +283 -535
- data/lib/square/api/merchants_api.rb +25 -60
- data/lib/square/api/mobile_authorization_api.rb +14 -30
- data/lib/square/api/o_auth_api.rb +54 -109
- data/lib/square/api/order_custom_attributes_api.rb +174 -339
- data/lib/square/api/orders_api.rb +115 -222
- data/lib/square/api/payments_api.rb +118 -217
- data/lib/square/api/payouts_api.rb +54 -107
- data/lib/square/api/refunds_api.rb +59 -104
- data/lib/square/api/sites_api.rb +11 -28
- data/lib/square/api/snippets_api.rb +42 -90
- data/lib/square/api/subscriptions_api.rb +150 -299
- data/lib/square/api/team_api.rb +114 -224
- data/lib/square/api/terminal_api.rb +162 -328
- data/lib/square/api/transactions_api.rb +64 -128
- data/lib/square/api/v1_transactions_api.rb +155 -296
- data/lib/square/api/vendors_api.rb +100 -193
- data/lib/square/api/webhook_subscriptions_api.rb +124 -244
- data/lib/square/api_helper.rb +1 -437
- data/lib/square/client.rb +77 -47
- data/lib/square/configuration.rb +28 -53
- data/lib/square/exceptions/api_exception.rb +1 -11
- data/lib/square/http/api_response.rb +13 -19
- data/lib/square/http/auth/o_auth2.rb +14 -7
- data/lib/square/http/http_call_back.rb +1 -15
- data/lib/square/http/http_method_enum.rb +1 -4
- data/lib/square/http/http_request.rb +1 -45
- data/lib/square/http/http_response.rb +1 -20
- data/lib/square/utilities/date_time_helper.rb +1 -146
- data/lib/square/utilities/file_wrapper.rb +5 -5
- data/lib/square.rb +6 -6
- data/spec/user_journey_spec.rb +2 -2
- data/test/api/api_test_base.rb +13 -5
- data/test/api/test_catalog_api.rb +5 -4
- data/test/api/test_customers_api.rb +3 -2
- data/test/api/test_employees_api.rb +4 -3
- data/test/api/test_labor_api.rb +6 -5
- data/test/api/test_locations_api.rb +3 -2
- data/test/api/test_merchants_api.rb +4 -3
- data/test/api/test_payments_api.rb +4 -3
- data/test/api/test_refunds_api.rb +4 -3
- metadata +11 -111
- data/lib/square/exceptions/validation_exception.rb +0 -13
- data/lib/square/http/faraday_client.rb +0 -93
- data/lib/square/http/http_client.rb +0 -118
- data/test/test_helper.rb +0 -89
@@ -1,42 +1,26 @@
|
|
1
1
|
module Square
|
2
2
|
# TerminalApi
|
3
3
|
class TerminalApi < BaseApi
|
4
|
-
def initialize(config, http_call_back: nil)
|
5
|
-
super(config, http_call_back: http_call_back)
|
6
|
-
end
|
7
|
-
|
8
4
|
# Creates a Terminal action request and sends it to the specified device.
|
9
5
|
# @param [CreateTerminalActionRequest] body Required parameter: An object
|
10
6
|
# containing the fields to POST for the request. See the corresponding
|
11
7
|
# object definition for field details.
|
12
8
|
# @return [CreateTerminalActionResponse Hash] response from the API call
|
13
9
|
def create_terminal_action(body:)
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
headers: _headers,
|
29
|
-
parameters: body.to_json
|
30
|
-
)
|
31
|
-
OAuth2.apply(config, _request)
|
32
|
-
_response = execute_request(_request)
|
33
|
-
|
34
|
-
# Return appropriate response type.
|
35
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
36
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
37
|
-
ApiResponse.new(
|
38
|
-
_response, data: decoded, errors: _errors
|
39
|
-
)
|
10
|
+
new_api_call_builder
|
11
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
12
|
+
'/v2/terminals/actions',
|
13
|
+
'default')
|
14
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
15
|
+
.body_param(new_parameter(body))
|
16
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
17
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
18
|
+
.auth(Single.new('global')))
|
19
|
+
.response(new_response_handler
|
20
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
21
|
+
.is_api_response(true)
|
22
|
+
.convertor(ApiResponse.method(:create)))
|
23
|
+
.execute
|
40
24
|
end
|
41
25
|
|
42
26
|
# Retrieves a filtered list of Terminal action requests created by the
|
@@ -47,32 +31,20 @@ module Square
|
|
47
31
|
# object definition for field details.
|
48
32
|
# @return [SearchTerminalActionsResponse Hash] response from the API call
|
49
33
|
def search_terminal_actions(body:)
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
headers: _headers,
|
65
|
-
parameters: body.to_json
|
66
|
-
)
|
67
|
-
OAuth2.apply(config, _request)
|
68
|
-
_response = execute_request(_request)
|
69
|
-
|
70
|
-
# Return appropriate response type.
|
71
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
72
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
73
|
-
ApiResponse.new(
|
74
|
-
_response, data: decoded, errors: _errors
|
75
|
-
)
|
34
|
+
new_api_call_builder
|
35
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
36
|
+
'/v2/terminals/actions/search',
|
37
|
+
'default')
|
38
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
39
|
+
.body_param(new_parameter(body))
|
40
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
41
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
42
|
+
.auth(Single.new('global')))
|
43
|
+
.response(new_response_handler
|
44
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
45
|
+
.is_api_response(true)
|
46
|
+
.convertor(ApiResponse.method(:create)))
|
47
|
+
.execute
|
76
48
|
end
|
77
49
|
|
78
50
|
# Retrieves a Terminal action request by `action_id`. Terminal action
|
@@ -81,34 +53,19 @@ module Square
|
|
81
53
|
# `TerminalAction`
|
82
54
|
# @return [GetTerminalActionResponse Hash] response from the API call
|
83
55
|
def get_terminal_action(action_id:)
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
# Prepare and execute HttpRequest.
|
99
|
-
_request = config.http_client.get(
|
100
|
-
_query_url,
|
101
|
-
headers: _headers
|
102
|
-
)
|
103
|
-
OAuth2.apply(config, _request)
|
104
|
-
_response = execute_request(_request)
|
105
|
-
|
106
|
-
# Return appropriate response type.
|
107
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
108
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
109
|
-
ApiResponse.new(
|
110
|
-
_response, data: decoded, errors: _errors
|
111
|
-
)
|
56
|
+
new_api_call_builder
|
57
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
58
|
+
'/v2/terminals/actions/{action_id}',
|
59
|
+
'default')
|
60
|
+
.template_param(new_parameter(action_id, key: 'action_id')
|
61
|
+
.should_encode(true))
|
62
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
63
|
+
.auth(Single.new('global')))
|
64
|
+
.response(new_response_handler
|
65
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
66
|
+
.is_api_response(true)
|
67
|
+
.convertor(ApiResponse.method(:create)))
|
68
|
+
.execute
|
112
69
|
end
|
113
70
|
|
114
71
|
# Cancels a Terminal action request if the status of the request permits it.
|
@@ -116,34 +73,19 @@ module Square
|
|
116
73
|
# `TerminalAction`
|
117
74
|
# @return [CancelTerminalActionResponse Hash] response from the API call
|
118
75
|
def cancel_terminal_action(action_id:)
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
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
|
-
)
|
76
|
+
new_api_call_builder
|
77
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
78
|
+
'/v2/terminals/actions/{action_id}/cancel',
|
79
|
+
'default')
|
80
|
+
.template_param(new_parameter(action_id, key: 'action_id')
|
81
|
+
.should_encode(true))
|
82
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
83
|
+
.auth(Single.new('global')))
|
84
|
+
.response(new_response_handler
|
85
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
86
|
+
.is_api_response(true)
|
87
|
+
.convertor(ApiResponse.method(:create)))
|
88
|
+
.execute
|
147
89
|
end
|
148
90
|
|
149
91
|
# Creates a Terminal checkout request and sends it to the specified device
|
@@ -154,32 +96,20 @@ module Square
|
|
154
96
|
# object definition for field details.
|
155
97
|
# @return [CreateTerminalCheckoutResponse Hash] response from the API call
|
156
98
|
def create_terminal_checkout(body:)
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
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
|
-
)
|
99
|
+
new_api_call_builder
|
100
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
101
|
+
'/v2/terminals/checkouts',
|
102
|
+
'default')
|
103
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
104
|
+
.body_param(new_parameter(body))
|
105
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
106
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
107
|
+
.auth(Single.new('global')))
|
108
|
+
.response(new_response_handler
|
109
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
110
|
+
.is_api_response(true)
|
111
|
+
.convertor(ApiResponse.method(:create)))
|
112
|
+
.execute
|
183
113
|
end
|
184
114
|
|
185
115
|
# Returns a filtered list of Terminal checkout requests created by the
|
@@ -191,32 +121,20 @@ module Square
|
|
191
121
|
# object definition for field details.
|
192
122
|
# @return [SearchTerminalCheckoutsResponse Hash] response from the API call
|
193
123
|
def search_terminal_checkouts(body:)
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
headers: _headers,
|
209
|
-
parameters: body.to_json
|
210
|
-
)
|
211
|
-
OAuth2.apply(config, _request)
|
212
|
-
_response = execute_request(_request)
|
213
|
-
|
214
|
-
# Return appropriate response type.
|
215
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
216
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
217
|
-
ApiResponse.new(
|
218
|
-
_response, data: decoded, errors: _errors
|
219
|
-
)
|
124
|
+
new_api_call_builder
|
125
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
126
|
+
'/v2/terminals/checkouts/search',
|
127
|
+
'default')
|
128
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
129
|
+
.body_param(new_parameter(body))
|
130
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
131
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
132
|
+
.auth(Single.new('global')))
|
133
|
+
.response(new_response_handler
|
134
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
135
|
+
.is_api_response(true)
|
136
|
+
.convertor(ApiResponse.method(:create)))
|
137
|
+
.execute
|
220
138
|
end
|
221
139
|
|
222
140
|
# Retrieves a Terminal checkout request by `checkout_id`. Terminal checkout
|
@@ -225,34 +143,19 @@ module Square
|
|
225
143
|
# desired `TerminalCheckout`.
|
226
144
|
# @return [GetTerminalCheckoutResponse Hash] response from the API call
|
227
145
|
def get_terminal_checkout(checkout_id:)
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
# Prepare and execute HttpRequest.
|
243
|
-
_request = config.http_client.get(
|
244
|
-
_query_url,
|
245
|
-
headers: _headers
|
246
|
-
)
|
247
|
-
OAuth2.apply(config, _request)
|
248
|
-
_response = execute_request(_request)
|
249
|
-
|
250
|
-
# Return appropriate response type.
|
251
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
252
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
253
|
-
ApiResponse.new(
|
254
|
-
_response, data: decoded, errors: _errors
|
255
|
-
)
|
146
|
+
new_api_call_builder
|
147
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
148
|
+
'/v2/terminals/checkouts/{checkout_id}',
|
149
|
+
'default')
|
150
|
+
.template_param(new_parameter(checkout_id, key: 'checkout_id')
|
151
|
+
.should_encode(true))
|
152
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
153
|
+
.auth(Single.new('global')))
|
154
|
+
.response(new_response_handler
|
155
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
156
|
+
.is_api_response(true)
|
157
|
+
.convertor(ApiResponse.method(:create)))
|
158
|
+
.execute
|
256
159
|
end
|
257
160
|
|
258
161
|
# Cancels a Terminal checkout request if the status of the request permits
|
@@ -261,34 +164,19 @@ module Square
|
|
261
164
|
# desired `TerminalCheckout`.
|
262
165
|
# @return [CancelTerminalCheckoutResponse Hash] response from the API call
|
263
166
|
def cancel_terminal_checkout(checkout_id:)
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
# Prepare and execute HttpRequest.
|
279
|
-
_request = config.http_client.post(
|
280
|
-
_query_url,
|
281
|
-
headers: _headers
|
282
|
-
)
|
283
|
-
OAuth2.apply(config, _request)
|
284
|
-
_response = execute_request(_request)
|
285
|
-
|
286
|
-
# Return appropriate response type.
|
287
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
288
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
289
|
-
ApiResponse.new(
|
290
|
-
_response, data: decoded, errors: _errors
|
291
|
-
)
|
167
|
+
new_api_call_builder
|
168
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
169
|
+
'/v2/terminals/checkouts/{checkout_id}/cancel',
|
170
|
+
'default')
|
171
|
+
.template_param(new_parameter(checkout_id, key: 'checkout_id')
|
172
|
+
.should_encode(true))
|
173
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
174
|
+
.auth(Single.new('global')))
|
175
|
+
.response(new_response_handler
|
176
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
177
|
+
.is_api_response(true)
|
178
|
+
.convertor(ApiResponse.method(:create)))
|
179
|
+
.execute
|
292
180
|
end
|
293
181
|
|
294
182
|
# Creates a request to refund an Interac payment completed on a Square
|
@@ -301,32 +189,20 @@ module Square
|
|
301
189
|
# object definition for field details.
|
302
190
|
# @return [CreateTerminalRefundResponse Hash] response from the API call
|
303
191
|
def create_terminal_refund(body:)
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
headers: _headers,
|
319
|
-
parameters: body.to_json
|
320
|
-
)
|
321
|
-
OAuth2.apply(config, _request)
|
322
|
-
_response = execute_request(_request)
|
323
|
-
|
324
|
-
# Return appropriate response type.
|
325
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
326
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
327
|
-
ApiResponse.new(
|
328
|
-
_response, data: decoded, errors: _errors
|
329
|
-
)
|
192
|
+
new_api_call_builder
|
193
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
194
|
+
'/v2/terminals/refunds',
|
195
|
+
'default')
|
196
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
197
|
+
.body_param(new_parameter(body))
|
198
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
199
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
200
|
+
.auth(Single.new('global')))
|
201
|
+
.response(new_response_handler
|
202
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
203
|
+
.is_api_response(true)
|
204
|
+
.convertor(ApiResponse.method(:create)))
|
205
|
+
.execute
|
330
206
|
end
|
331
207
|
|
332
208
|
# Retrieves a filtered list of Interac Terminal refund requests created by
|
@@ -337,32 +213,20 @@ module Square
|
|
337
213
|
# object definition for field details.
|
338
214
|
# @return [SearchTerminalRefundsResponse Hash] response from the API call
|
339
215
|
def search_terminal_refunds(body:)
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
headers: _headers,
|
355
|
-
parameters: body.to_json
|
356
|
-
)
|
357
|
-
OAuth2.apply(config, _request)
|
358
|
-
_response = execute_request(_request)
|
359
|
-
|
360
|
-
# Return appropriate response type.
|
361
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
362
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
363
|
-
ApiResponse.new(
|
364
|
-
_response, data: decoded, errors: _errors
|
365
|
-
)
|
216
|
+
new_api_call_builder
|
217
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
218
|
+
'/v2/terminals/refunds/search',
|
219
|
+
'default')
|
220
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
221
|
+
.body_param(new_parameter(body))
|
222
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
223
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
224
|
+
.auth(Single.new('global')))
|
225
|
+
.response(new_response_handler
|
226
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
227
|
+
.is_api_response(true)
|
228
|
+
.convertor(ApiResponse.method(:create)))
|
229
|
+
.execute
|
366
230
|
end
|
367
231
|
|
368
232
|
# Retrieves an Interac Terminal refund object by ID. Terminal refund objects
|
@@ -371,34 +235,19 @@ module Square
|
|
371
235
|
# the desired `TerminalRefund`.
|
372
236
|
# @return [GetTerminalRefundResponse Hash] response from the API call
|
373
237
|
def get_terminal_refund(terminal_refund_id:)
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
# Prepare and execute HttpRequest.
|
389
|
-
_request = config.http_client.get(
|
390
|
-
_query_url,
|
391
|
-
headers: _headers
|
392
|
-
)
|
393
|
-
OAuth2.apply(config, _request)
|
394
|
-
_response = execute_request(_request)
|
395
|
-
|
396
|
-
# Return appropriate response type.
|
397
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
398
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
399
|
-
ApiResponse.new(
|
400
|
-
_response, data: decoded, errors: _errors
|
401
|
-
)
|
238
|
+
new_api_call_builder
|
239
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
240
|
+
'/v2/terminals/refunds/{terminal_refund_id}',
|
241
|
+
'default')
|
242
|
+
.template_param(new_parameter(terminal_refund_id, key: 'terminal_refund_id')
|
243
|
+
.should_encode(true))
|
244
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
245
|
+
.auth(Single.new('global')))
|
246
|
+
.response(new_response_handler
|
247
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
248
|
+
.is_api_response(true)
|
249
|
+
.convertor(ApiResponse.method(:create)))
|
250
|
+
.execute
|
402
251
|
end
|
403
252
|
|
404
253
|
# Cancels an Interac Terminal refund request by refund request ID if the
|
@@ -407,34 +256,19 @@ module Square
|
|
407
256
|
# the desired `TerminalRefund`.
|
408
257
|
# @return [CancelTerminalRefundResponse Hash] response from the API call
|
409
258
|
def cancel_terminal_refund(terminal_refund_id:)
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
# Prepare and execute HttpRequest.
|
425
|
-
_request = config.http_client.post(
|
426
|
-
_query_url,
|
427
|
-
headers: _headers
|
428
|
-
)
|
429
|
-
OAuth2.apply(config, _request)
|
430
|
-
_response = execute_request(_request)
|
431
|
-
|
432
|
-
# Return appropriate response type.
|
433
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
434
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
435
|
-
ApiResponse.new(
|
436
|
-
_response, data: decoded, errors: _errors
|
437
|
-
)
|
259
|
+
new_api_call_builder
|
260
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
261
|
+
'/v2/terminals/refunds/{terminal_refund_id}/cancel',
|
262
|
+
'default')
|
263
|
+
.template_param(new_parameter(terminal_refund_id, key: 'terminal_refund_id')
|
264
|
+
.should_encode(true))
|
265
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
266
|
+
.auth(Single.new('global')))
|
267
|
+
.response(new_response_handler
|
268
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
269
|
+
.is_api_response(true)
|
270
|
+
.convertor(ApiResponse.method(:create)))
|
271
|
+
.execute
|
438
272
|
end
|
439
273
|
end
|
440
274
|
end
|