square.rb 3.20190624.0 → 3.20190814.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +10 -28
  3. data/README.md +281 -17235
  4. data/lib/square/api/apple_pay_api.rb +55 -54
  5. data/lib/square/api/base_api.rb +45 -45
  6. data/lib/square/api/catalog_api.rb +461 -460
  7. data/lib/square/api/checkout_api.rb +54 -54
  8. data/lib/square/api/customers_api.rb +335 -334
  9. data/lib/square/api/employees_api.rb +91 -91
  10. data/lib/square/api/inventory_api.rb +300 -298
  11. data/lib/square/api/labor_api.rb +558 -558
  12. data/lib/square/api/locations_api.rb +45 -45
  13. data/lib/square/api/mobile_authorization_api.rb +56 -56
  14. data/lib/square/api/o_auth_api.rb +168 -164
  15. data/lib/square/api/orders_api.rb +269 -151
  16. data/lib/square/api/payments_api.rb +282 -0
  17. data/lib/square/api/refunds_api.rb +149 -0
  18. data/lib/square/api/reporting_api.rb +143 -139
  19. data/lib/square/api/transactions_api.rb +379 -360
  20. data/lib/square/api/v1_employees_api.rb +720 -720
  21. data/lib/square/api/v1_items_api.rb +1651 -1651
  22. data/lib/square/api/v1_locations_api.rb +67 -67
  23. data/lib/square/api/v1_locations_api.rbe +67 -0
  24. data/lib/square/api/v1_transactions_api.rb +574 -574
  25. data/lib/square/api_helper.rb +281 -277
  26. data/lib/square/client.rb +139 -127
  27. data/lib/square/configuration.rb +88 -85
  28. data/lib/square/exceptions/api_exception.rb +20 -20
  29. data/lib/square/http/api_response.rb +50 -50
  30. data/lib/square/http/auth/o_auth2.rb +17 -17
  31. data/lib/square/http/faraday_client.rb +64 -64
  32. data/lib/square/http/http_call_back.rb +24 -24
  33. data/lib/square/http/http_client.rb +104 -104
  34. data/lib/square/http/http_method_enum.rb +13 -13
  35. data/lib/square/http/http_request.rb +50 -50
  36. data/lib/square/http/http_response.rb +29 -29
  37. data/lib/square.rb +52 -50
  38. data/spec/user_journey_spec.rb +4 -1
  39. data/test/api/api_test_base.rb +2 -1
  40. data/test/api/test_catalog_api.rb +59 -0
  41. data/test/api/test_employees_api.rb +36 -0
  42. data/test/api/test_locations_api.rb +35 -0
  43. data/test/api/test_payments_api.rb +42 -0
  44. data/test/api/test_refunds_api.rb +41 -0
  45. metadata +19 -11
@@ -1,360 +1,379 @@
1
- # square
2
- #
3
- # This file was automatically generated by APIMATIC v2.0
4
- # ( https://apimatic.io ).
5
-
6
- module Square
7
- # TransactionsApi
8
- class TransactionsApi < BaseApi
9
- def initialize(config, http_call_back: nil)
10
- super(config, http_call_back: http_call_back)
11
- end
12
-
13
- # Lists refunds for one of a business's locations.
14
- # In addition to full or partial tender refunds processed through Square
15
- # APIs,
16
- # refunds may result from itemized returns or exchanges through Square's
17
- # Point of Sale applications.
18
- # Refunds with a `status` of `PENDING` are not currently included in this
19
- # endpoint's response.
20
- # Max results per [page](#paginatingresults): 50
21
- # @param [String] location_id Required parameter: The ID of the location to
22
- # list refunds for.
23
- # @param [String] begin_time Optional parameter: The beginning of the
24
- # requested reporting period, in RFC 3339 format. See [Date
25
- # ranges](#dateranges) for details on date inclusivity/exclusivity. Default
26
- # value: The current time minus one year.
27
- # @param [String] end_time Optional parameter: The end of the requested
28
- # reporting period, in RFC 3339 format. See [Date ranges](#dateranges) for
29
- # details on date inclusivity/exclusivity. Default value: The current
30
- # time.
31
- # @param [SortOrder] sort_order Optional parameter: The order in which
32
- # results are listed in the response (`ASC` for oldest first, `DESC` for
33
- # newest first). Default value: `DESC`
34
- # @param [String] cursor Optional parameter: A pagination cursor returned by
35
- # a previous call to this endpoint. Provide this to retrieve the next set of
36
- # results for your original query. See
37
- # [Pagination](/basics/api101/pagination) for more information.
38
- # @return [ListRefundsResponse Hash] response from the API call
39
- def list_refunds(location_id:,
40
- begin_time: nil,
41
- end_time: nil,
42
- sort_order: nil,
43
- cursor: nil)
44
- # Prepare query url.
45
- _query_builder = config.get_base_uri
46
- _query_builder << '/v2/locations/{location_id}/refunds'
47
- _query_builder = APIHelper.append_url_with_template_parameters(
48
- _query_builder,
49
- 'location_id' => location_id
50
- )
51
- _query_builder = APIHelper.append_url_with_query_parameters(
52
- _query_builder,
53
- 'begin_time' => begin_time,
54
- 'end_time' => end_time,
55
- 'sort_order' => sort_order,
56
- 'cursor' => cursor
57
- )
58
- _query_url = APIHelper.clean_url _query_builder
59
-
60
- # Prepare headers.
61
- _headers = {
62
- 'accept' => 'application/json'
63
- }
64
-
65
- # Prepare and execute HttpRequest.
66
- _request = config.http_client.get(
67
- _query_url,
68
- headers: _headers
69
- )
70
- OAuth2.apply(config, _request)
71
- _response = execute_request(_request)
72
-
73
- # Return appropriate response type.
74
- decoded = APIHelper.json_deserialize(_response.raw_body)
75
- _errors = APIHelper.map_response(decoded, ['errors'])
76
- ApiResponse.new(_response, data: decoded, errors: _errors)
77
- end
78
-
79
- # Lists transactions for a particular location.
80
- # Transactions include payment information from sales and exchanges and
81
- # refund
82
- # information from returns and exchanges.
83
- # Max results per [page](#paginatingresults): 50
84
- # @param [String] location_id Required parameter: The ID of the location to
85
- # list transactions for.
86
- # @param [String] begin_time Optional parameter: The beginning of the
87
- # requested reporting period, in RFC 3339 format. See [Date
88
- # ranges](#dateranges) for details on date inclusivity/exclusivity. Default
89
- # value: The current time minus one year.
90
- # @param [String] end_time Optional parameter: The end of the requested
91
- # reporting period, in RFC 3339 format. See [Date ranges](#dateranges) for
92
- # details on date inclusivity/exclusivity. Default value: The current
93
- # time.
94
- # @param [SortOrder] sort_order Optional parameter: The order in which
95
- # results are listed in the response (`ASC` for oldest first, `DESC` for
96
- # newest first). Default value: `DESC`
97
- # @param [String] cursor Optional parameter: A pagination cursor returned by
98
- # a previous call to this endpoint. Provide this to retrieve the next set of
99
- # results for your original query. See
100
- # [Pagination](/basics/api101/pagination) for more information.
101
- # @return [ListTransactionsResponse Hash] response from the API call
102
- def list_transactions(location_id:,
103
- begin_time: nil,
104
- end_time: nil,
105
- sort_order: nil,
106
- cursor: nil)
107
- # Prepare query url.
108
- _query_builder = config.get_base_uri
109
- _query_builder << '/v2/locations/{location_id}/transactions'
110
- _query_builder = APIHelper.append_url_with_template_parameters(
111
- _query_builder,
112
- 'location_id' => location_id
113
- )
114
- _query_builder = APIHelper.append_url_with_query_parameters(
115
- _query_builder,
116
- 'begin_time' => begin_time,
117
- 'end_time' => end_time,
118
- 'sort_order' => sort_order,
119
- 'cursor' => cursor
120
- )
121
- _query_url = APIHelper.clean_url _query_builder
122
-
123
- # Prepare headers.
124
- _headers = {
125
- 'accept' => 'application/json'
126
- }
127
-
128
- # Prepare and execute HttpRequest.
129
- _request = config.http_client.get(
130
- _query_url,
131
- headers: _headers
132
- )
133
- OAuth2.apply(config, _request)
134
- _response = execute_request(_request)
135
-
136
- # Return appropriate response type.
137
- decoded = APIHelper.json_deserialize(_response.raw_body)
138
- _errors = APIHelper.map_response(decoded, ['errors'])
139
- ApiResponse.new(_response, data: decoded, errors: _errors)
140
- end
141
-
142
- # Charges a card represented by a card nonce or a customer's card on file.
143
- # Your request to this endpoint must include _either_:
144
- # - A value for the `card_nonce` parameter (to charge a card nonce generated
145
- # with the `SqPaymentForm`)
146
- # - Values for the `customer_card_id` and `customer_id` parameters (to
147
- # charge
148
- # a customer's card on file)
149
- # When this response is returned, the amount of Square's processing fee
150
- # might not yet be
151
- # calculated. To obtain the processing fee, wait about ten seconds and call
152
- # [RetrieveTransaction](#endpoint-transactions-retrievetransaction). See the
153
- # `processing_fee_money`
154
- # field of each [Tender included](#type-tender) in the transaction.
155
- # @param [String] location_id Required parameter: The ID of the location to
156
- # associate the created transaction with.
157
- # @param [ChargeRequest] body Required parameter: An object containing the
158
- # fields to POST for the request. See the corresponding object definition
159
- # for field details.
160
- # @return [ChargeResponse Hash] response from the API call
161
- def charge(location_id:,
162
- body:)
163
- # Prepare query url.
164
- _query_builder = config.get_base_uri
165
- _query_builder << '/v2/locations/{location_id}/transactions'
166
- _query_builder = APIHelper.append_url_with_template_parameters(
167
- _query_builder,
168
- 'location_id' => location_id
169
- )
170
- _query_url = APIHelper.clean_url _query_builder
171
-
172
- # Prepare headers.
173
- _headers = {
174
- 'accept' => 'application/json',
175
- 'content-type' => 'application/json; charset=utf-8'
176
- }
177
-
178
- # Prepare and execute HttpRequest.
179
- _request = config.http_client.post(
180
- _query_url,
181
- headers: _headers,
182
- parameters: body.to_json
183
- )
184
- OAuth2.apply(config, _request)
185
- _response = execute_request(_request)
186
-
187
- # Return appropriate response type.
188
- decoded = APIHelper.json_deserialize(_response.raw_body)
189
- _errors = APIHelper.map_response(decoded, ['errors'])
190
- ApiResponse.new(_response, data: decoded, errors: _errors)
191
- end
192
-
193
- # Retrieves details for a single transaction.
194
- # @param [String] location_id Required parameter: The ID of the
195
- # transaction's associated location.
196
- # @param [String] transaction_id Required parameter: The ID of the
197
- # transaction to retrieve.
198
- # @return [RetrieveTransactionResponse Hash] response from the API call
199
- def retrieve_transaction(location_id:,
200
- transaction_id:)
201
- # Prepare query url.
202
- _query_builder = config.get_base_uri
203
- _query_builder << '/v2/locations/{location_id}/transactions/{transaction_id}'
204
- _query_builder = APIHelper.append_url_with_template_parameters(
205
- _query_builder,
206
- 'location_id' => location_id,
207
- 'transaction_id' => transaction_id
208
- )
209
- _query_url = APIHelper.clean_url _query_builder
210
-
211
- # Prepare headers.
212
- _headers = {
213
- 'accept' => 'application/json'
214
- }
215
-
216
- # Prepare and execute HttpRequest.
217
- _request = config.http_client.get(
218
- _query_url,
219
- headers: _headers
220
- )
221
- OAuth2.apply(config, _request)
222
- _response = execute_request(_request)
223
-
224
- # Return appropriate response type.
225
- decoded = APIHelper.json_deserialize(_response.raw_body)
226
- _errors = APIHelper.map_response(decoded, ['errors'])
227
- ApiResponse.new(_response, data: decoded, errors: _errors)
228
- end
229
-
230
- # Captures a transaction that was created with the
231
- # [Charge](#endpoint-transactions-charge)
232
- # endpoint with a `delay_capture` value of `true`.
233
- # See [Delayed capture
234
- # transactions](/payments/transactions/overview#delayed-capture)
235
- # for more information.
236
- # @param [String] location_id Required parameter: Example:
237
- # @param [String] transaction_id Required parameter: Example:
238
- # @return [CaptureTransactionResponse Hash] response from the API call
239
- def capture_transaction(location_id:,
240
- transaction_id:)
241
- # Prepare query url.
242
- _query_builder = config.get_base_uri
243
- _query_builder << '/v2/locations/{location_id}/transactions/{transaction_id}/capture'
244
- _query_builder = APIHelper.append_url_with_template_parameters(
245
- _query_builder,
246
- 'location_id' => location_id,
247
- 'transaction_id' => transaction_id
248
- )
249
- _query_url = APIHelper.clean_url _query_builder
250
-
251
- # Prepare headers.
252
- _headers = {
253
- 'accept' => 'application/json'
254
- }
255
-
256
- # Prepare and execute HttpRequest.
257
- _request = config.http_client.post(
258
- _query_url,
259
- headers: _headers
260
- )
261
- OAuth2.apply(config, _request)
262
- _response = execute_request(_request)
263
-
264
- # Return appropriate response type.
265
- decoded = APIHelper.json_deserialize(_response.raw_body)
266
- _errors = APIHelper.map_response(decoded, ['errors'])
267
- ApiResponse.new(_response, data: decoded, errors: _errors)
268
- end
269
-
270
- # Initiates a refund for a previously charged tender.
271
- # You must issue a refund within 120 days of the associated payment. See
272
- # [this article](https://squareup.com/help/us/en/article/5060) for more
273
- # information
274
- # on refund behavior.
275
- # NOTE: Card-present transactions with Interac credit cards **cannot be
276
- # refunded using the Connect API**. Interac transactions must refunded
277
- # in-person (e.g., dipping the card using POS app).
278
- # @param [String] location_id Required parameter: The ID of the original
279
- # transaction's associated location.
280
- # @param [String] transaction_id Required parameter: The ID of the original
281
- # transaction that includes the tender to refund.
282
- # @param [CreateRefundRequest] body Required parameter: An object containing
283
- # the fields to POST for the request. See the corresponding object
284
- # definition for field details.
285
- # @return [CreateRefundResponse Hash] response from the API call
286
- def create_refund(location_id:,
287
- transaction_id:,
288
- body:)
289
- # Prepare query url.
290
- _query_builder = config.get_base_uri
291
- _query_builder << '/v2/locations/{location_id}/transactions/{transaction_id}/refund'
292
- _query_builder = APIHelper.append_url_with_template_parameters(
293
- _query_builder,
294
- 'location_id' => location_id,
295
- 'transaction_id' => transaction_id
296
- )
297
- _query_url = APIHelper.clean_url _query_builder
298
-
299
- # Prepare headers.
300
- _headers = {
301
- 'accept' => 'application/json',
302
- 'content-type' => 'application/json; charset=utf-8'
303
- }
304
-
305
- # Prepare and execute HttpRequest.
306
- _request = config.http_client.post(
307
- _query_url,
308
- headers: _headers,
309
- parameters: body.to_json
310
- )
311
- OAuth2.apply(config, _request)
312
- _response = execute_request(_request)
313
-
314
- # Return appropriate response type.
315
- decoded = APIHelper.json_deserialize(_response.raw_body)
316
- _errors = APIHelper.map_response(decoded, ['errors'])
317
- ApiResponse.new(_response, data: decoded, errors: _errors)
318
- end
319
-
320
- # Cancels a transaction that was created with the
321
- # [Charge](#endpoint-transactions-charge)
322
- # endpoint with a `delay_capture` value of `true`.
323
- # See [Delayed capture
324
- # transactions](/payments/transactions/overview#delayed-capture)
325
- # for more information.
326
- # @param [String] location_id Required parameter: Example:
327
- # @param [String] transaction_id Required parameter: Example:
328
- # @return [VoidTransactionResponse Hash] response from the API call
329
- def void_transaction(location_id:,
330
- transaction_id:)
331
- # Prepare query url.
332
- _query_builder = config.get_base_uri
333
- _query_builder << '/v2/locations/{location_id}/transactions/{transaction_id}/void'
334
- _query_builder = APIHelper.append_url_with_template_parameters(
335
- _query_builder,
336
- 'location_id' => location_id,
337
- 'transaction_id' => transaction_id
338
- )
339
- _query_url = APIHelper.clean_url _query_builder
340
-
341
- # Prepare headers.
342
- _headers = {
343
- 'accept' => 'application/json'
344
- }
345
-
346
- # Prepare and execute HttpRequest.
347
- _request = config.http_client.post(
348
- _query_url,
349
- headers: _headers
350
- )
351
- OAuth2.apply(config, _request)
352
- _response = execute_request(_request)
353
-
354
- # Return appropriate response type.
355
- decoded = APIHelper.json_deserialize(_response.raw_body)
356
- _errors = APIHelper.map_response(decoded, ['errors'])
357
- ApiResponse.new(_response, data: decoded, errors: _errors)
358
- end
359
- end
360
- end
1
+ # square
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module Square
7
+ # TransactionsApi
8
+ class TransactionsApi < BaseApi
9
+ def initialize(config, http_call_back: nil)
10
+ super(config, http_call_back: http_call_back)
11
+ end
12
+
13
+ # Lists refunds for one of a business's locations.
14
+ # Deprecated - recommend using [SearchOrders](#endpoint-orders-searchorders)
15
+ # In addition to full or partial tender refunds processed through Square
16
+ # APIs,
17
+ # refunds may result from itemized returns or exchanges through Square's
18
+ # Point of Sale applications.
19
+ # Refunds with a `status` of `PENDING` are not currently included in this
20
+ # endpoint's response.
21
+ # Max results per [page](#paginatingresults): 50
22
+ # @param [String] location_id Required parameter: The ID of the location to
23
+ # list refunds for.
24
+ # @param [String] begin_time Optional parameter: The beginning of the
25
+ # requested reporting period, in RFC 3339 format. See [Date
26
+ # ranges](#dateranges) for details on date inclusivity/exclusivity. Default
27
+ # value: The current time minus one year.
28
+ # @param [String] end_time Optional parameter: The end of the requested
29
+ # reporting period, in RFC 3339 format. See [Date ranges](#dateranges) for
30
+ # details on date inclusivity/exclusivity. Default value: The current
31
+ # time.
32
+ # @param [SortOrder] sort_order Optional parameter: The order in which
33
+ # results are listed in the response (`ASC` for oldest first, `DESC` for
34
+ # newest first). Default value: `DESC`
35
+ # @param [String] cursor Optional parameter: A pagination cursor returned by
36
+ # a previous call to this endpoint. Provide this to retrieve the next set of
37
+ # results for your original query. See
38
+ # [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
39
+ # for more information.
40
+ # @return [ListRefundsResponse Hash] response from the API call
41
+ def list_refunds(location_id:,
42
+ begin_time: nil,
43
+ end_time: nil,
44
+ sort_order: nil,
45
+ cursor: nil)
46
+ warn 'Endpoint list_refunds in TransactionsApi is deprecated'
47
+ # Prepare query url.
48
+ _query_builder = config.get_base_uri
49
+ _query_builder << '/v2/locations/{location_id}/refunds'
50
+ _query_builder = APIHelper.append_url_with_template_parameters(
51
+ _query_builder,
52
+ 'location_id' => location_id
53
+ )
54
+ _query_builder = APIHelper.append_url_with_query_parameters(
55
+ _query_builder,
56
+ 'begin_time' => begin_time,
57
+ 'end_time' => end_time,
58
+ 'sort_order' => sort_order,
59
+ 'cursor' => cursor
60
+ )
61
+ _query_url = APIHelper.clean_url _query_builder
62
+
63
+ # Prepare headers.
64
+ _headers = {
65
+ 'accept' => 'application/json'
66
+ }
67
+
68
+ # Prepare and execute HttpRequest.
69
+ _request = config.http_client.get(
70
+ _query_url,
71
+ headers: _headers
72
+ )
73
+ OAuth2.apply(config, _request)
74
+ _response = execute_request(_request)
75
+
76
+ # Return appropriate response type.
77
+ decoded = APIHelper.json_deserialize(_response.raw_body)
78
+ _errors = APIHelper.map_response(decoded, ['errors'])
79
+ ApiResponse.new(_response, data: decoded, errors: _errors)
80
+ end
81
+
82
+ # Lists transactions for a particular location.
83
+ # Deprecated - recommend using [SearchOrders](#endpoint-orders-searchorders)
84
+ # Transactions include payment information from sales and exchanges and
85
+ # refund
86
+ # information from returns and exchanges.
87
+ # Max results per [page](#paginatingresults): 50
88
+ # @param [String] location_id Required parameter: The ID of the location to
89
+ # list transactions for.
90
+ # @param [String] begin_time Optional parameter: The beginning of the
91
+ # requested reporting period, in RFC 3339 format. See [Date
92
+ # ranges](#dateranges) for details on date inclusivity/exclusivity. Default
93
+ # value: The current time minus one year.
94
+ # @param [String] end_time Optional parameter: The end of the requested
95
+ # reporting period, in RFC 3339 format. See [Date ranges](#dateranges) for
96
+ # details on date inclusivity/exclusivity. Default value: The current
97
+ # time.
98
+ # @param [SortOrder] sort_order Optional parameter: The order in which
99
+ # results are listed in the response (`ASC` for oldest first, `DESC` for
100
+ # newest first). Default value: `DESC`
101
+ # @param [String] cursor Optional parameter: A pagination cursor returned by
102
+ # a previous call to this endpoint. Provide this to retrieve the next set of
103
+ # results for your original query. See
104
+ # [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
105
+ # for more information.
106
+ # @return [ListTransactionsResponse Hash] response from the API call
107
+ def list_transactions(location_id:,
108
+ begin_time: nil,
109
+ end_time: nil,
110
+ sort_order: nil,
111
+ cursor: nil)
112
+ warn 'Endpoint list_transactions in TransactionsApi is deprecated'
113
+ # Prepare query url.
114
+ _query_builder = config.get_base_uri
115
+ _query_builder << '/v2/locations/{location_id}/transactions'
116
+ _query_builder = APIHelper.append_url_with_template_parameters(
117
+ _query_builder,
118
+ 'location_id' => location_id
119
+ )
120
+ _query_builder = APIHelper.append_url_with_query_parameters(
121
+ _query_builder,
122
+ 'begin_time' => begin_time,
123
+ 'end_time' => end_time,
124
+ 'sort_order' => sort_order,
125
+ 'cursor' => cursor
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.get(
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(_response, data: decoded, errors: _errors)
146
+ end
147
+
148
+ # Charges a card represented by a card nonce or a customer's card on file.
149
+ # Deprecated - recommend using
150
+ # [CreatePayment](#endpoint-payments-createpayment)
151
+ # Your request to this endpoint must include _either_:
152
+ # - A value for the `card_nonce` parameter (to charge a card nonce generated
153
+ # with the `SqPaymentForm`)
154
+ # - Values for the `customer_card_id` and `customer_id` parameters (to
155
+ # charge
156
+ # a customer's card on file)
157
+ # When this response is returned, the amount of Square's processing fee
158
+ # might not yet be
159
+ # calculated. To obtain the processing fee, wait about ten seconds and call
160
+ # [RetrieveTransaction](#endpoint-transactions-retrievetransaction). See the
161
+ # `processing_fee_money`
162
+ # field of each [Tender included](#type-tender) in the transaction.
163
+ # @param [String] location_id Required parameter: The ID of the location to
164
+ # associate the created transaction with.
165
+ # @param [ChargeRequest] body Required parameter: An object containing the
166
+ # fields to POST for the request. See the corresponding object definition
167
+ # for field details.
168
+ # @return [ChargeResponse Hash] response from the API call
169
+ def charge(location_id:,
170
+ body:)
171
+ warn 'Endpoint charge in TransactionsApi is deprecated'
172
+ # Prepare query url.
173
+ _query_builder = config.get_base_uri
174
+ _query_builder << '/v2/locations/{location_id}/transactions'
175
+ _query_builder = APIHelper.append_url_with_template_parameters(
176
+ _query_builder,
177
+ 'location_id' => location_id
178
+ )
179
+ _query_url = APIHelper.clean_url _query_builder
180
+
181
+ # Prepare headers.
182
+ _headers = {
183
+ 'accept' => 'application/json',
184
+ 'content-type' => 'application/json; charset=utf-8'
185
+ }
186
+
187
+ # Prepare and execute HttpRequest.
188
+ _request = config.http_client.post(
189
+ _query_url,
190
+ headers: _headers,
191
+ parameters: body.to_json
192
+ )
193
+ OAuth2.apply(config, _request)
194
+ _response = execute_request(_request)
195
+
196
+ # Return appropriate response type.
197
+ decoded = APIHelper.json_deserialize(_response.raw_body)
198
+ _errors = APIHelper.map_response(decoded, ['errors'])
199
+ ApiResponse.new(_response, data: decoded, errors: _errors)
200
+ end
201
+
202
+ # Retrieves details for a single transaction.
203
+ # Deprecated - recommend using
204
+ # [BatchRetrieveOrders](#endpoint-batchretrieveorders)
205
+ # @param [String] location_id Required parameter: The ID of the
206
+ # transaction's associated location.
207
+ # @param [String] transaction_id Required parameter: The ID of the
208
+ # transaction to retrieve.
209
+ # @return [RetrieveTransactionResponse Hash] response from the API call
210
+ def retrieve_transaction(location_id:,
211
+ transaction_id:)
212
+ warn 'Endpoint retrieve_transaction in TransactionsApi is deprecated'
213
+ # Prepare query url.
214
+ _query_builder = config.get_base_uri
215
+ _query_builder << '/v2/locations/{location_id}/transactions/{transaction_id}'
216
+ _query_builder = APIHelper.append_url_with_template_parameters(
217
+ _query_builder,
218
+ 'location_id' => location_id,
219
+ 'transaction_id' => transaction_id
220
+ )
221
+ _query_url = APIHelper.clean_url _query_builder
222
+
223
+ # Prepare headers.
224
+ _headers = {
225
+ 'accept' => 'application/json'
226
+ }
227
+
228
+ # Prepare and execute HttpRequest.
229
+ _request = config.http_client.get(
230
+ _query_url,
231
+ headers: _headers
232
+ )
233
+ OAuth2.apply(config, _request)
234
+ _response = execute_request(_request)
235
+
236
+ # Return appropriate response type.
237
+ decoded = APIHelper.json_deserialize(_response.raw_body)
238
+ _errors = APIHelper.map_response(decoded, ['errors'])
239
+ ApiResponse.new(_response, data: decoded, errors: _errors)
240
+ end
241
+
242
+ # Captures a transaction that was created with the
243
+ # [Charge](#endpoint-transactions-charge)
244
+ # endpoint with a `delay_capture` value of `true`.
245
+ # See the [Delay Capture of
246
+ # Funds](https://developer.squareup.com/docs/transactions-api/cookbook/delay
247
+ # -capture)
248
+ # recipe for more information.
249
+ # @param [String] location_id Required parameter: Example:
250
+ # @param [String] transaction_id Required parameter: Example:
251
+ # @return [CaptureTransactionResponse Hash] response from the API call
252
+ def capture_transaction(location_id:,
253
+ transaction_id:)
254
+ warn 'Endpoint capture_transaction in TransactionsApi is deprecated'
255
+ # Prepare query url.
256
+ _query_builder = config.get_base_uri
257
+ _query_builder << '/v2/locations/{location_id}/transactions/{transaction_id}/capture'
258
+ _query_builder = APIHelper.append_url_with_template_parameters(
259
+ _query_builder,
260
+ 'location_id' => location_id,
261
+ 'transaction_id' => transaction_id
262
+ )
263
+ _query_url = APIHelper.clean_url _query_builder
264
+
265
+ # Prepare headers.
266
+ _headers = {
267
+ 'accept' => 'application/json'
268
+ }
269
+
270
+ # Prepare and execute HttpRequest.
271
+ _request = config.http_client.post(
272
+ _query_url,
273
+ headers: _headers
274
+ )
275
+ OAuth2.apply(config, _request)
276
+ _response = execute_request(_request)
277
+
278
+ # Return appropriate response type.
279
+ decoded = APIHelper.json_deserialize(_response.raw_body)
280
+ _errors = APIHelper.map_response(decoded, ['errors'])
281
+ ApiResponse.new(_response, data: decoded, errors: _errors)
282
+ end
283
+
284
+ # Initiates a refund for a previously charged tender.
285
+ # Deprecated - recommend using
286
+ # [RefundPayment](#endpoint-refunds-refundpayment)
287
+ # You must issue a refund within 120 days of the associated payment. See
288
+ # [this article](https://squareup.com/help/us/en/article/5060) for more
289
+ # information
290
+ # on refund behavior.
291
+ # NOTE: Card-present transactions with Interac credit cards **cannot be
292
+ # refunded using the Connect API**. Interac transactions must refunded
293
+ # in-person (e.g., dipping the card using POS app).
294
+ # @param [String] location_id Required parameter: The ID of the original
295
+ # transaction's associated location.
296
+ # @param [String] transaction_id Required parameter: The ID of the original
297
+ # transaction that includes the tender to refund.
298
+ # @param [CreateRefundRequest] body Required parameter: An object containing
299
+ # the fields to POST for the request. See the corresponding object
300
+ # definition for field details.
301
+ # @return [CreateRefundResponse Hash] response from the API call
302
+ def create_refund(location_id:,
303
+ transaction_id:,
304
+ body:)
305
+ warn 'Endpoint create_refund in TransactionsApi is deprecated'
306
+ # Prepare query url.
307
+ _query_builder = config.get_base_uri
308
+ _query_builder << '/v2/locations/{location_id}/transactions/{transaction_id}/refund'
309
+ _query_builder = APIHelper.append_url_with_template_parameters(
310
+ _query_builder,
311
+ 'location_id' => location_id,
312
+ 'transaction_id' => transaction_id
313
+ )
314
+ _query_url = APIHelper.clean_url _query_builder
315
+
316
+ # Prepare headers.
317
+ _headers = {
318
+ 'accept' => 'application/json',
319
+ 'content-type' => 'application/json; charset=utf-8'
320
+ }
321
+
322
+ # Prepare and execute HttpRequest.
323
+ _request = config.http_client.post(
324
+ _query_url,
325
+ headers: _headers,
326
+ parameters: body.to_json
327
+ )
328
+ OAuth2.apply(config, _request)
329
+ _response = execute_request(_request)
330
+
331
+ # Return appropriate response type.
332
+ decoded = APIHelper.json_deserialize(_response.raw_body)
333
+ _errors = APIHelper.map_response(decoded, ['errors'])
334
+ ApiResponse.new(_response, data: decoded, errors: _errors)
335
+ end
336
+
337
+ # Cancels a transaction that was created with the
338
+ # [Charge](#endpoint-transactions-charge)
339
+ # endpoint with a `delay_capture` value of `true`.
340
+ # See the [Delay Capture of
341
+ # Funds](https://developer.squareup.com/docs/transactions-api/cookbook/delay
342
+ # -capture)
343
+ # recipe for more information.
344
+ # @param [String] location_id Required parameter: Example:
345
+ # @param [String] transaction_id Required parameter: Example:
346
+ # @return [VoidTransactionResponse Hash] response from the API call
347
+ def void_transaction(location_id:,
348
+ transaction_id:)
349
+ warn 'Endpoint void_transaction in TransactionsApi is deprecated'
350
+ # Prepare query url.
351
+ _query_builder = config.get_base_uri
352
+ _query_builder << '/v2/locations/{location_id}/transactions/{transaction_id}/void'
353
+ _query_builder = APIHelper.append_url_with_template_parameters(
354
+ _query_builder,
355
+ 'location_id' => location_id,
356
+ 'transaction_id' => transaction_id
357
+ )
358
+ _query_url = APIHelper.clean_url _query_builder
359
+
360
+ # Prepare headers.
361
+ _headers = {
362
+ 'accept' => 'application/json'
363
+ }
364
+
365
+ # Prepare and execute HttpRequest.
366
+ _request = config.http_client.post(
367
+ _query_url,
368
+ headers: _headers
369
+ )
370
+ OAuth2.apply(config, _request)
371
+ _response = execute_request(_request)
372
+
373
+ # Return appropriate response type.
374
+ decoded = APIHelper.json_deserialize(_response.raw_body)
375
+ _errors = APIHelper.map_response(decoded, ['errors'])
376
+ ApiResponse.new(_response, data: decoded, errors: _errors)
377
+ end
378
+ end
379
+ end