fangkuai.rb 0.0.1
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 +7 -0
- data/LICENSE +10 -0
- data/README.md +1 -0
- data/lib/square.rb +61 -0
- data/lib/square/api/apple_pay_api.rb +50 -0
- data/lib/square/api/bank_accounts_api.rb +136 -0
- data/lib/square/api/base_api.rb +43 -0
- data/lib/square/api/cash_drawers_api.rb +150 -0
- data/lib/square/api/catalog_api.rb +572 -0
- data/lib/square/api/checkout_api.rb +49 -0
- data/lib/square/api/customer_groups_api.rb +182 -0
- data/lib/square/api/customer_segments_api.rb +78 -0
- data/lib/square/api/customers_api.rb +418 -0
- data/lib/square/api/devices_api.rb +120 -0
- data/lib/square/api/disputes_api.rb +398 -0
- data/lib/square/api/employees_api.rb +87 -0
- data/lib/square/api/inventory_api.rb +296 -0
- data/lib/square/api/invoices_api.rb +358 -0
- data/lib/square/api/labor_api.rb +630 -0
- data/lib/square/api/locations_api.rb +151 -0
- data/lib/square/api/loyalty_api.rb +543 -0
- data/lib/square/api/merchants_api.rb +83 -0
- data/lib/square/api/mobile_authorization_api.rb +52 -0
- data/lib/square/api/o_auth_api.rb +163 -0
- data/lib/square/api/orders_api.rb +280 -0
- data/lib/square/api/payments_api.rb +279 -0
- data/lib/square/api/refunds_api.rb +145 -0
- data/lib/square/api/subscriptions_api.rb +251 -0
- data/lib/square/api/team_api.rb +326 -0
- data/lib/square/api/terminal_api.rb +141 -0
- data/lib/square/api/transactions_api.rb +369 -0
- data/lib/square/api/v1_employees_api.rb +723 -0
- data/lib/square/api/v1_items_api.rb +1686 -0
- data/lib/square/api/v1_locations_api.rb +65 -0
- data/lib/square/api/v1_transactions_api.rb +572 -0
- data/lib/square/api_helper.rb +276 -0
- data/lib/square/client.rb +211 -0
- data/lib/square/configuration.rb +101 -0
- data/lib/square/exceptions/api_exception.rb +15 -0
- data/lib/square/http/api_response.rb +45 -0
- data/lib/square/http/auth/o_auth2.rb +12 -0
- data/lib/square/http/faraday_client.rb +55 -0
- data/lib/square/http/http_call_back.rb +19 -0
- data/lib/square/http/http_client.rb +99 -0
- data/lib/square/http/http_method_enum.rb +8 -0
- data/lib/square/http/http_request.rb +45 -0
- data/lib/square/http/http_response.rb +24 -0
- data/lib/square/utilities/file_wrapper.rb +12 -0
- data/spec/user_journey_spec.rb +148 -0
- data/test/api/api_test_base.rb +24 -0
- data/test/api/test_catalog_api.rb +59 -0
- data/test/api/test_customers_api.rb +45 -0
- data/test/api/test_employees_api.rb +36 -0
- data/test/api/test_labor_api.rb +74 -0
- data/test/api/test_locations_api.rb +35 -0
- data/test/api/test_merchants_api.rb +40 -0
- data/test/api/test_payments_api.rb +42 -0
- data/test/api/test_refunds_api.rb +41 -0
- data/test/http_response_catcher.rb +19 -0
- data/test/test_helper.rb +94 -0
- metadata +199 -0
@@ -0,0 +1,326 @@
|
|
1
|
+
module Square
|
2
|
+
# TeamApi
|
3
|
+
class TeamApi < BaseApi
|
4
|
+
def initialize(config, http_call_back: nil)
|
5
|
+
super(config, http_call_back: http_call_back)
|
6
|
+
end
|
7
|
+
|
8
|
+
# Creates a single `TeamMember` object. The `TeamMember` will be returned on
|
9
|
+
# successful creates.
|
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).
|
16
|
+
# @param [CreateTeamMemberRequest] body Required parameter: An object
|
17
|
+
# containing the fields to POST for the request. See the corresponding
|
18
|
+
# object definition for field details.
|
19
|
+
# @return [CreateTeamMemberResponse Hash] response from the API call
|
20
|
+
def create_team_member(body:)
|
21
|
+
# Prepare query url.
|
22
|
+
_query_builder = config.get_base_uri
|
23
|
+
_query_builder << '/v2/team-members'
|
24
|
+
_query_url = APIHelper.clean_url _query_builder
|
25
|
+
|
26
|
+
# Prepare headers.
|
27
|
+
_headers = {
|
28
|
+
'accept' => 'application/json',
|
29
|
+
'content-type' => 'application/json; charset=utf-8'
|
30
|
+
}
|
31
|
+
|
32
|
+
# Prepare and execute HttpRequest.
|
33
|
+
_request = config.http_client.post(
|
34
|
+
_query_url,
|
35
|
+
headers: _headers,
|
36
|
+
parameters: body.to_json
|
37
|
+
)
|
38
|
+
OAuth2.apply(config, _request)
|
39
|
+
_response = execute_request(_request)
|
40
|
+
|
41
|
+
# Return appropriate response type.
|
42
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
43
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
44
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
45
|
+
end
|
46
|
+
|
47
|
+
# 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).
|
57
|
+
# @param [BulkCreateTeamMembersRequest] body Required parameter: An object
|
58
|
+
# containing the fields to POST for the request. See the corresponding
|
59
|
+
# object definition for field details.
|
60
|
+
# @return [BulkCreateTeamMembersResponse Hash] response from the API call
|
61
|
+
def bulk_create_team_members(body:)
|
62
|
+
# Prepare query url.
|
63
|
+
_query_builder = config.get_base_uri
|
64
|
+
_query_builder << '/v2/team-members/bulk-create'
|
65
|
+
_query_url = APIHelper.clean_url _query_builder
|
66
|
+
|
67
|
+
# Prepare headers.
|
68
|
+
_headers = {
|
69
|
+
'accept' => 'application/json',
|
70
|
+
'content-type' => 'application/json; charset=utf-8'
|
71
|
+
}
|
72
|
+
|
73
|
+
# Prepare and execute HttpRequest.
|
74
|
+
_request = config.http_client.post(
|
75
|
+
_query_url,
|
76
|
+
headers: _headers,
|
77
|
+
parameters: body.to_json
|
78
|
+
)
|
79
|
+
OAuth2.apply(config, _request)
|
80
|
+
_response = execute_request(_request)
|
81
|
+
|
82
|
+
# Return appropriate response type.
|
83
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
84
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
85
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
86
|
+
end
|
87
|
+
|
88
|
+
# 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).
|
98
|
+
# @param [BulkUpdateTeamMembersRequest] body Required parameter: An object
|
99
|
+
# containing the fields to POST for the request. See the corresponding
|
100
|
+
# object definition for field details.
|
101
|
+
# @return [BulkUpdateTeamMembersResponse Hash] response from the API call
|
102
|
+
def bulk_update_team_members(body:)
|
103
|
+
# Prepare query url.
|
104
|
+
_query_builder = config.get_base_uri
|
105
|
+
_query_builder << '/v2/team-members/bulk-update'
|
106
|
+
_query_url = APIHelper.clean_url _query_builder
|
107
|
+
|
108
|
+
# Prepare headers.
|
109
|
+
_headers = {
|
110
|
+
'accept' => 'application/json',
|
111
|
+
'content-type' => 'application/json; charset=utf-8'
|
112
|
+
}
|
113
|
+
|
114
|
+
# Prepare and execute HttpRequest.
|
115
|
+
_request = config.http_client.post(
|
116
|
+
_query_url,
|
117
|
+
headers: _headers,
|
118
|
+
parameters: body.to_json
|
119
|
+
)
|
120
|
+
OAuth2.apply(config, _request)
|
121
|
+
_response = execute_request(_request)
|
122
|
+
|
123
|
+
# Return appropriate response type.
|
124
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
125
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
126
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
127
|
+
end
|
128
|
+
|
129
|
+
# 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`
|
133
|
+
# @param [SearchTeamMembersRequest] body Required parameter: An object
|
134
|
+
# containing the fields to POST for the request. See the corresponding
|
135
|
+
# object definition for field details.
|
136
|
+
# @return [SearchTeamMembersResponse Hash] response from the API call
|
137
|
+
def search_team_members(body:)
|
138
|
+
# Prepare query url.
|
139
|
+
_query_builder = config.get_base_uri
|
140
|
+
_query_builder << '/v2/team-members/search'
|
141
|
+
_query_url = APIHelper.clean_url _query_builder
|
142
|
+
|
143
|
+
# Prepare headers.
|
144
|
+
_headers = {
|
145
|
+
'accept' => 'application/json',
|
146
|
+
'content-type' => 'application/json; charset=utf-8'
|
147
|
+
}
|
148
|
+
|
149
|
+
# Prepare and execute HttpRequest.
|
150
|
+
_request = config.http_client.post(
|
151
|
+
_query_url,
|
152
|
+
headers: _headers,
|
153
|
+
parameters: body.to_json
|
154
|
+
)
|
155
|
+
OAuth2.apply(config, _request)
|
156
|
+
_response = execute_request(_request)
|
157
|
+
|
158
|
+
# Return appropriate response type.
|
159
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
160
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
161
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
162
|
+
end
|
163
|
+
|
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).
|
168
|
+
# @param [String] team_member_id Required parameter: The ID of the team
|
169
|
+
# member to retrieve.
|
170
|
+
# @return [RetrieveTeamMemberResponse Hash] response from the API call
|
171
|
+
def retrieve_team_member(team_member_id:)
|
172
|
+
# Prepare query url.
|
173
|
+
_query_builder = config.get_base_uri
|
174
|
+
_query_builder << '/v2/team-members/{team_member_id}'
|
175
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
176
|
+
_query_builder,
|
177
|
+
'team_member_id' => team_member_id
|
178
|
+
)
|
179
|
+
_query_url = APIHelper.clean_url _query_builder
|
180
|
+
|
181
|
+
# Prepare headers.
|
182
|
+
_headers = {
|
183
|
+
'accept' => 'application/json'
|
184
|
+
}
|
185
|
+
|
186
|
+
# Prepare and execute HttpRequest.
|
187
|
+
_request = config.http_client.get(
|
188
|
+
_query_url,
|
189
|
+
headers: _headers
|
190
|
+
)
|
191
|
+
OAuth2.apply(config, _request)
|
192
|
+
_response = execute_request(_request)
|
193
|
+
|
194
|
+
# Return appropriate response type.
|
195
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
196
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
197
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
198
|
+
end
|
199
|
+
|
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).
|
205
|
+
# @param [String] team_member_id Required parameter: The ID of the team
|
206
|
+
# member to update.
|
207
|
+
# @param [UpdateTeamMemberRequest] body Required parameter: An object
|
208
|
+
# containing the fields to POST for the request. See the corresponding
|
209
|
+
# object definition for field details.
|
210
|
+
# @return [UpdateTeamMemberResponse Hash] response from the API call
|
211
|
+
def update_team_member(team_member_id:,
|
212
|
+
body:)
|
213
|
+
# Prepare query url.
|
214
|
+
_query_builder = config.get_base_uri
|
215
|
+
_query_builder << '/v2/team-members/{team_member_id}'
|
216
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
217
|
+
_query_builder,
|
218
|
+
'team_member_id' => team_member_id
|
219
|
+
)
|
220
|
+
_query_url = APIHelper.clean_url _query_builder
|
221
|
+
|
222
|
+
# Prepare headers.
|
223
|
+
_headers = {
|
224
|
+
'accept' => 'application/json',
|
225
|
+
'content-type' => 'application/json; charset=utf-8'
|
226
|
+
}
|
227
|
+
|
228
|
+
# Prepare and execute HttpRequest.
|
229
|
+
_request = config.http_client.put(
|
230
|
+
_query_url,
|
231
|
+
headers: _headers,
|
232
|
+
parameters: body.to_json
|
233
|
+
)
|
234
|
+
OAuth2.apply(config, _request)
|
235
|
+
_response = execute_request(_request)
|
236
|
+
|
237
|
+
# Return appropriate response type.
|
238
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
239
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
240
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
241
|
+
end
|
242
|
+
|
243
|
+
# Retrieve a `WageSetting` object for a team member specified
|
244
|
+
# by `TeamMember.id`.
|
245
|
+
# Learn about [Troubleshooting the Teams
|
246
|
+
# API](https://developer.squareup.com/docs/docs/team/troubleshooting#retriev
|
247
|
+
# ewagesetting).
|
248
|
+
# @param [String] team_member_id Required parameter: The ID of the team
|
249
|
+
# member to retrieve wage setting for
|
250
|
+
# @return [RetrieveWageSettingResponse Hash] response from the API call
|
251
|
+
def retrieve_wage_setting(team_member_id:)
|
252
|
+
# Prepare query url.
|
253
|
+
_query_builder = config.get_base_uri
|
254
|
+
_query_builder << '/v2/team-members/{team_member_id}/wage-setting'
|
255
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
256
|
+
_query_builder,
|
257
|
+
'team_member_id' => team_member_id
|
258
|
+
)
|
259
|
+
_query_url = APIHelper.clean_url _query_builder
|
260
|
+
|
261
|
+
# Prepare headers.
|
262
|
+
_headers = {
|
263
|
+
'accept' => 'application/json'
|
264
|
+
}
|
265
|
+
|
266
|
+
# Prepare and execute HttpRequest.
|
267
|
+
_request = config.http_client.get(
|
268
|
+
_query_url,
|
269
|
+
headers: _headers
|
270
|
+
)
|
271
|
+
OAuth2.apply(config, _request)
|
272
|
+
_response = execute_request(_request)
|
273
|
+
|
274
|
+
# Return appropriate response type.
|
275
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
276
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
277
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
278
|
+
end
|
279
|
+
|
280
|
+
# Creates or updates a `WageSetting` object. The object is created if a
|
281
|
+
# `WageSetting` with the specified `team_member_id` does not exist.
|
282
|
+
# Otherwise,
|
283
|
+
# 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).
|
288
|
+
# @param [String] team_member_id Required parameter: The ID of the team
|
289
|
+
# member to update the `WageSetting` object for.
|
290
|
+
# @param [UpdateWageSettingRequest] body Required parameter: An object
|
291
|
+
# containing the fields to POST for the request. See the corresponding
|
292
|
+
# object definition for field details.
|
293
|
+
# @return [UpdateWageSettingResponse Hash] response from the API call
|
294
|
+
def update_wage_setting(team_member_id:,
|
295
|
+
body:)
|
296
|
+
# Prepare query url.
|
297
|
+
_query_builder = config.get_base_uri
|
298
|
+
_query_builder << '/v2/team-members/{team_member_id}/wage-setting'
|
299
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
300
|
+
_query_builder,
|
301
|
+
'team_member_id' => team_member_id
|
302
|
+
)
|
303
|
+
_query_url = APIHelper.clean_url _query_builder
|
304
|
+
|
305
|
+
# Prepare headers.
|
306
|
+
_headers = {
|
307
|
+
'accept' => 'application/json',
|
308
|
+
'content-type' => 'application/json; charset=utf-8'
|
309
|
+
}
|
310
|
+
|
311
|
+
# Prepare and execute HttpRequest.
|
312
|
+
_request = config.http_client.put(
|
313
|
+
_query_url,
|
314
|
+
headers: _headers,
|
315
|
+
parameters: body.to_json
|
316
|
+
)
|
317
|
+
OAuth2.apply(config, _request)
|
318
|
+
_response = execute_request(_request)
|
319
|
+
|
320
|
+
# Return appropriate response type.
|
321
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
322
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
323
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
324
|
+
end
|
325
|
+
end
|
326
|
+
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
module Square
|
2
|
+
# TerminalApi
|
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
|
+
# Creates a new Terminal checkout request and sends it to the specified
|
9
|
+
# device to take a payment for the requested amount.
|
10
|
+
# @param [CreateTerminalCheckoutRequest] body Required parameter: An object
|
11
|
+
# containing the fields to POST for the request. See the corresponding
|
12
|
+
# object definition for field details.
|
13
|
+
# @return [CreateTerminalCheckoutResponse Hash] response from the API call
|
14
|
+
def create_terminal_checkout(body:)
|
15
|
+
# Prepare query url.
|
16
|
+
_query_builder = config.get_base_uri
|
17
|
+
_query_builder << '/v2/terminals/checkouts'
|
18
|
+
_query_url = APIHelper.clean_url _query_builder
|
19
|
+
|
20
|
+
# Prepare headers.
|
21
|
+
_headers = {
|
22
|
+
'accept' => 'application/json',
|
23
|
+
'content-type' => 'application/json; charset=utf-8'
|
24
|
+
}
|
25
|
+
|
26
|
+
# Prepare and execute HttpRequest.
|
27
|
+
_request = config.http_client.post(
|
28
|
+
_query_url,
|
29
|
+
headers: _headers,
|
30
|
+
parameters: body.to_json
|
31
|
+
)
|
32
|
+
OAuth2.apply(config, _request)
|
33
|
+
_response = execute_request(_request)
|
34
|
+
|
35
|
+
# Return appropriate response type.
|
36
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
37
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
38
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
39
|
+
end
|
40
|
+
|
41
|
+
# Retrieves a filtered list of Terminal checkout requests created by the
|
42
|
+
# account making the request.
|
43
|
+
# @param [SearchTerminalCheckoutsRequest] body Required parameter: An object
|
44
|
+
# containing the fields to POST for the request. See the corresponding
|
45
|
+
# object definition for field details.
|
46
|
+
# @return [SearchTerminalCheckoutsResponse Hash] response from the API call
|
47
|
+
def search_terminal_checkouts(body:)
|
48
|
+
# Prepare query url.
|
49
|
+
_query_builder = config.get_base_uri
|
50
|
+
_query_builder << '/v2/terminals/checkouts/search'
|
51
|
+
_query_url = APIHelper.clean_url _query_builder
|
52
|
+
|
53
|
+
# Prepare headers.
|
54
|
+
_headers = {
|
55
|
+
'accept' => 'application/json',
|
56
|
+
'content-type' => 'application/json; charset=utf-8'
|
57
|
+
}
|
58
|
+
|
59
|
+
# Prepare and execute HttpRequest.
|
60
|
+
_request = config.http_client.post(
|
61
|
+
_query_url,
|
62
|
+
headers: _headers,
|
63
|
+
parameters: body.to_json
|
64
|
+
)
|
65
|
+
OAuth2.apply(config, _request)
|
66
|
+
_response = execute_request(_request)
|
67
|
+
|
68
|
+
# Return appropriate response type.
|
69
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
70
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
71
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
72
|
+
end
|
73
|
+
|
74
|
+
# Retrieves a Terminal checkout request by checkout_id.
|
75
|
+
# @param [String] checkout_id Required parameter: Unique ID for the desired
|
76
|
+
# `TerminalCheckout`
|
77
|
+
# @return [GetTerminalCheckoutResponse Hash] response from the API call
|
78
|
+
def get_terminal_checkout(checkout_id:)
|
79
|
+
# Prepare query url.
|
80
|
+
_query_builder = config.get_base_uri
|
81
|
+
_query_builder << '/v2/terminals/checkouts/{checkout_id}'
|
82
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
83
|
+
_query_builder,
|
84
|
+
'checkout_id' => checkout_id
|
85
|
+
)
|
86
|
+
_query_url = APIHelper.clean_url _query_builder
|
87
|
+
|
88
|
+
# Prepare headers.
|
89
|
+
_headers = {
|
90
|
+
'accept' => 'application/json'
|
91
|
+
}
|
92
|
+
|
93
|
+
# Prepare and execute HttpRequest.
|
94
|
+
_request = config.http_client.get(
|
95
|
+
_query_url,
|
96
|
+
headers: _headers
|
97
|
+
)
|
98
|
+
OAuth2.apply(config, _request)
|
99
|
+
_response = execute_request(_request)
|
100
|
+
|
101
|
+
# Return appropriate response type.
|
102
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
103
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
104
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
105
|
+
end
|
106
|
+
|
107
|
+
# Cancels a Terminal checkout request, if the status of the request permits
|
108
|
+
# it.
|
109
|
+
# @param [String] checkout_id Required parameter: Unique ID for the desired
|
110
|
+
# `TerminalCheckout`
|
111
|
+
# @return [CancelTerminalCheckoutResponse Hash] response from the API call
|
112
|
+
def cancel_terminal_checkout(checkout_id:)
|
113
|
+
# Prepare query url.
|
114
|
+
_query_builder = config.get_base_uri
|
115
|
+
_query_builder << '/v2/terminals/checkouts/{checkout_id}/cancel'
|
116
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
117
|
+
_query_builder,
|
118
|
+
'checkout_id' => checkout_id
|
119
|
+
)
|
120
|
+
_query_url = APIHelper.clean_url _query_builder
|
121
|
+
|
122
|
+
# Prepare headers.
|
123
|
+
_headers = {
|
124
|
+
'accept' => 'application/json'
|
125
|
+
}
|
126
|
+
|
127
|
+
# Prepare and execute HttpRequest.
|
128
|
+
_request = config.http_client.post(
|
129
|
+
_query_url,
|
130
|
+
headers: _headers
|
131
|
+
)
|
132
|
+
OAuth2.apply(config, _request)
|
133
|
+
_response = execute_request(_request)
|
134
|
+
|
135
|
+
# Return appropriate response type.
|
136
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
137
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
138
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|